@dxos/react-ui-canvas-compute 0.8.4-main.ae835ea → 0.8.4-main.bc674ce
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 +706 -881
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +706 -881
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/compute.stories.d.ts +22 -1
- package/dist/types/src/compute.stories.d.ts.map +1 -1
- package/dist/types/src/graph/controller.d.ts +13 -13
- package/dist/types/src/graph/controller.d.ts.map +1 -1
- package/dist/types/src/hooks/useComputeNodeState.d.ts +2 -2
- package/dist/types/src/hooks/useComputeNodeState.d.ts.map +1 -1
- package/dist/types/src/hooks/useGraphMonitor.d.ts.map +1 -1
- package/dist/types/src/shapes/Function.d.ts.map +1 -1
- package/dist/types/src/shapes/Queue.d.ts.map +1 -1
- package/dist/types/src/shapes/RNG.d.ts.map +1 -1
- package/dist/types/src/shapes/Surface.d.ts.map +1 -1
- package/dist/types/src/shapes/Trigger.d.ts +3 -2
- package/dist/types/src/shapes/Trigger.d.ts.map +1 -1
- package/dist/types/src/shapes/common/Box.d.ts +1 -1
- package/dist/types/src/testing/circuits.d.ts +18 -24
- package/dist/types/src/testing/circuits.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +55 -51
- package/src/compute.stories.tsx +66 -110
- package/src/graph/controller.ts +100 -70
- package/src/graph/node-defs.ts +3 -3
- package/src/hooks/useComputeNodeState.ts +4 -3
- package/src/hooks/useGraphMonitor.ts +9 -8
- package/src/json.test.ts +3 -3
- package/src/schema.test.ts +8 -8
- package/src/shapes/Audio.tsx +1 -1
- package/src/shapes/Beacon.tsx +1 -1
- package/src/shapes/Boolean.tsx +2 -2
- package/src/shapes/Function.tsx +8 -6
- package/src/shapes/Gpt.tsx +1 -1
- package/src/shapes/GptRealtime.tsx +1 -1
- package/src/shapes/Queue.tsx +8 -4
- package/src/shapes/RNG.tsx +5 -1
- package/src/shapes/Scope.tsx +1 -1
- package/src/shapes/Surface.tsx +6 -2
- package/src/shapes/Switch.tsx +1 -1
- package/src/shapes/Table.tsx +3 -3
- package/src/shapes/Thread.tsx +6 -6
- package/src/shapes/Trigger.tsx +13 -8
- package/src/shapes/common/Box.tsx +6 -6
- package/src/shapes/common/FunctionBody.tsx +2 -2
- package/src/shapes/common/TypeSelect.tsx +1 -1
- package/src/shapes/defs.ts +3 -3
- package/src/testing/circuits.ts +5 -14
package/src/shapes/Thread.tsx
CHANGED
|
@@ -8,14 +8,14 @@ import React, { useEffect, useRef } from 'react';
|
|
|
8
8
|
import { createInputSchema, createOutputSchema } from '@dxos/conductor';
|
|
9
9
|
import { type ThemedClassName } from '@dxos/react-ui';
|
|
10
10
|
import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import { Message } from '@dxos/types';
|
|
12
|
+
import { mx } from '@dxos/ui-theme';
|
|
13
13
|
|
|
14
14
|
import { Box, createFunctionAnchors } from './common';
|
|
15
15
|
import { ComputeShape, type CreateShapeProps, createShape } from './defs';
|
|
16
16
|
|
|
17
|
-
const InputSchema = createInputSchema(
|
|
18
|
-
const OutputSchema = createOutputSchema(Schema.mutable(Schema.Array(
|
|
17
|
+
const InputSchema = createInputSchema(Message.Message);
|
|
18
|
+
const OutputSchema = createOutputSchema(Schema.mutable(Schema.Array(Message.Message)));
|
|
19
19
|
|
|
20
20
|
export const ThreadShape = Schema.extend(
|
|
21
21
|
ComputeShape,
|
|
@@ -42,7 +42,7 @@ export const ThreadComponent = ({ shape }: ShapeComponentProps<ThreadShape>) =>
|
|
|
42
42
|
|
|
43
43
|
return (
|
|
44
44
|
<Box shape={shape}>
|
|
45
|
-
<div ref={scrollRef} className='flex flex-col
|
|
45
|
+
<div ref={scrollRef} className='flex flex-col is-full overflow-y-auto gap-2 p-2'>
|
|
46
46
|
{[...items].map((item, i) => (
|
|
47
47
|
<ThreadItem key={i} item={item} />
|
|
48
48
|
))}
|
|
@@ -63,7 +63,7 @@ export const ThreadItem = ({ classNames, item }: ThemedClassName<{ item: any }>)
|
|
|
63
63
|
<div className={mx('flex', classNames, role === 'user' && 'justify-end')}>
|
|
64
64
|
<div
|
|
65
65
|
className={mx(
|
|
66
|
-
'block rounded-md p-1
|
|
66
|
+
'block rounded-md p-1 pli-2 text-sm',
|
|
67
67
|
role === 'user'
|
|
68
68
|
? 'bg-blue-100 dark:bg-blue-800'
|
|
69
69
|
: role === 'system'
|
package/src/shapes/Trigger.tsx
CHANGED
|
@@ -6,8 +6,8 @@ import * as Schema from 'effect/Schema';
|
|
|
6
6
|
import React, { useEffect } from 'react';
|
|
7
7
|
|
|
8
8
|
import { VoidInput } from '@dxos/conductor';
|
|
9
|
-
import { Filter, Query } from '@dxos/echo';
|
|
10
|
-
import {
|
|
9
|
+
import { Filter, Obj, Query, Ref, Type } from '@dxos/echo';
|
|
10
|
+
import { type Mutable } from '@dxos/echo/internal';
|
|
11
11
|
import { Trigger, TriggerEvent } from '@dxos/functions';
|
|
12
12
|
import { DXN, SpaceId } from '@dxos/keys';
|
|
13
13
|
import { useSpace } from '@dxos/react-client/echo';
|
|
@@ -21,10 +21,11 @@ export const TriggerShape = Schema.extend(
|
|
|
21
21
|
ComputeShape,
|
|
22
22
|
Schema.Struct({
|
|
23
23
|
type: Schema.Literal('trigger'),
|
|
24
|
-
functionTrigger: Schema.optional(Ref(Trigger.Trigger)),
|
|
24
|
+
functionTrigger: Schema.optional(Type.Ref(Trigger.Trigger)),
|
|
25
25
|
}),
|
|
26
26
|
);
|
|
27
|
-
|
|
27
|
+
|
|
28
|
+
export interface TriggerShape extends Schema.Schema.Type<typeof TriggerShape> {}
|
|
28
29
|
|
|
29
30
|
export type CreateTriggerProps = CreateShapeProps<Omit<TriggerShape, 'functionTrigger'>> & {
|
|
30
31
|
spaceId?: SpaceId;
|
|
@@ -52,7 +53,9 @@ export const TriggerComponent = ({ shape }: TriggerComponentProps) => {
|
|
|
52
53
|
|
|
53
54
|
useEffect(() => {
|
|
54
55
|
if (functionTrigger && !functionTrigger.spec) {
|
|
55
|
-
|
|
56
|
+
Obj.change(functionTrigger, (t) => {
|
|
57
|
+
t.spec = createTriggerSpec({ triggerKind: 'email', spaceId: space?.id }) as Mutable<Trigger.Spec>;
|
|
58
|
+
});
|
|
56
59
|
}
|
|
57
60
|
}, [functionTrigger, functionTrigger?.spec]);
|
|
58
61
|
|
|
@@ -62,7 +65,9 @@ export const TriggerComponent = ({ shape }: TriggerComponentProps) => {
|
|
|
62
65
|
|
|
63
66
|
const setKind = (kind: Trigger.Kind) => {
|
|
64
67
|
if (functionTrigger?.spec?.kind !== kind) {
|
|
65
|
-
functionTrigger
|
|
68
|
+
Obj.change(functionTrigger!, (t) => {
|
|
69
|
+
t.spec = createTriggerSpec({ triggerKind: kind, spaceId: space?.id }) as Mutable<Trigger.Spec>;
|
|
70
|
+
});
|
|
66
71
|
}
|
|
67
72
|
};
|
|
68
73
|
|
|
@@ -86,7 +91,7 @@ export const TriggerComponent = ({ shape }: TriggerComponentProps) => {
|
|
|
86
91
|
const TriggerKindSelect = ({ value, onValueChange }: Pick<SelectRootProps, 'value' | 'onValueChange'>) => {
|
|
87
92
|
return (
|
|
88
93
|
<Select.Root value={value} onValueChange={onValueChange}>
|
|
89
|
-
<Select.TriggerButton variant='ghost' classNames='
|
|
94
|
+
<Select.TriggerButton variant='ghost' classNames='is-full !pli-0' />
|
|
90
95
|
<Select.Portal>
|
|
91
96
|
<Select.Content>
|
|
92
97
|
<Select.ScrollUpButton />
|
|
@@ -122,7 +127,7 @@ const createTriggerSpec = (props: { triggerKind?: Trigger.Kind; spaceId?: SpaceI
|
|
|
122
127
|
case 'email':
|
|
123
128
|
return { kind: 'email' } satisfies Trigger.EmailSpec;
|
|
124
129
|
case 'queue': {
|
|
125
|
-
const dxn = new DXN(DXN.kind.QUEUE, ['data', props.spaceId ?? SpaceId.random(),
|
|
130
|
+
const dxn = new DXN(DXN.kind.QUEUE, ['data', props.spaceId ?? SpaceId.random(), Obj.ID.random()]).toString();
|
|
126
131
|
return { kind: 'queue', queue: dxn } satisfies Trigger.QueueSpec;
|
|
127
132
|
}
|
|
128
133
|
}
|
|
@@ -8,7 +8,7 @@ import { invariant } from '@dxos/invariant';
|
|
|
8
8
|
import { Icon, IconButton, type ThemedClassName } from '@dxos/react-ui';
|
|
9
9
|
import { useEditorContext, useShapeDef } from '@dxos/react-ui-canvas-editor';
|
|
10
10
|
import { type Shape } from '@dxos/react-ui-canvas-editor';
|
|
11
|
-
import { mx } from '@dxos/
|
|
11
|
+
import { mx } from '@dxos/ui-theme';
|
|
12
12
|
|
|
13
13
|
export const headerHeight = 32;
|
|
14
14
|
export const footerHeight = 32;
|
|
@@ -32,8 +32,8 @@ export const Box = forwardRef<HTMLDivElement, BoxProps>(
|
|
|
32
32
|
const { debug } = useEditorContext();
|
|
33
33
|
|
|
34
34
|
return (
|
|
35
|
-
<div ref={forwardedRef} className='flex flex-col
|
|
36
|
-
<div className='flex shrink-0
|
|
35
|
+
<div ref={forwardedRef} className='flex flex-col bs-full is-full justify-between'>
|
|
36
|
+
<div className='flex shrink-0 is-full justify-between items-center bs-[32px] bg-hoverSurface'>
|
|
37
37
|
<Icon icon={icon} classNames='mx-2' />
|
|
38
38
|
<div className='grow text-sm truncate'>{debug ? shape.type : (name ?? shape.text ?? title)}</div>
|
|
39
39
|
<IconButton
|
|
@@ -50,9 +50,9 @@ export const Box = forwardRef<HTMLDivElement, BoxProps>(
|
|
|
50
50
|
}}
|
|
51
51
|
/>
|
|
52
52
|
</div>
|
|
53
|
-
<div className={mx('flex flex-col
|
|
54
|
-
<div className='flex shrink-0
|
|
55
|
-
<div className='grow
|
|
53
|
+
<div className={mx('flex flex-col bs-full grow overflow-hidden', classNames)}>{children}</div>
|
|
54
|
+
<div className='flex shrink-0 is-full justify-between items-center bs-[32px] bg-hoverSurface'>
|
|
55
|
+
<div className='grow pli-2 text-sm truncate'>{debug ? shape.id : status}</div>
|
|
56
56
|
{openable && (
|
|
57
57
|
<IconButton
|
|
58
58
|
classNames='p-1'
|
|
@@ -82,7 +82,7 @@ export const FunctionBody = ({
|
|
|
82
82
|
{(inputs?.length ?? 0) > 0 && (
|
|
83
83
|
<div className='flex flex-col'>
|
|
84
84
|
{inputs?.map(({ name }) => (
|
|
85
|
-
<div key={name} className='
|
|
85
|
+
<div key={name} className='pli-2 truncate text-sm font-mono items-center' style={{ height: rowHeight }}>
|
|
86
86
|
{name}
|
|
87
87
|
</div>
|
|
88
88
|
))}
|
|
@@ -93,7 +93,7 @@ export const FunctionBody = ({
|
|
|
93
93
|
{outputs?.map(({ name }) => (
|
|
94
94
|
<div
|
|
95
95
|
key={name}
|
|
96
|
-
className='
|
|
96
|
+
className='pli-2 truncate text-sm font-mono items-center text-right'
|
|
97
97
|
style={{ height: rowHeight }}
|
|
98
98
|
>
|
|
99
99
|
{name}
|
|
@@ -11,7 +11,7 @@ import { Select, type SelectRootProps } from '@dxos/react-ui';
|
|
|
11
11
|
export const TypeSelect = ({ value, onValueChange }: Pick<SelectRootProps, 'value' | 'onValueChange'>) => {
|
|
12
12
|
return (
|
|
13
13
|
<Select.Root value={value} onValueChange={onValueChange}>
|
|
14
|
-
<Select.TriggerButton variant='ghost' classNames='
|
|
14
|
+
<Select.TriggerButton variant='ghost' classNames='is-full !pli-0' />
|
|
15
15
|
<Select.Portal>
|
|
16
16
|
<Select.Content>
|
|
17
17
|
<Select.ScrollUpButton />
|
package/src/shapes/defs.ts
CHANGED
|
@@ -6,7 +6,7 @@ import * as Schema from 'effect/Schema';
|
|
|
6
6
|
import * as SchemaAST from 'effect/SchemaAST';
|
|
7
7
|
|
|
8
8
|
import { DEFAULT_INPUT, DEFAULT_OUTPUT } from '@dxos/conductor';
|
|
9
|
-
import {
|
|
9
|
+
import { Obj } from '@dxos/echo';
|
|
10
10
|
import { Polygon } from '@dxos/react-ui-canvas-editor';
|
|
11
11
|
import { type MakeOptional } from '@dxos/util';
|
|
12
12
|
|
|
@@ -37,7 +37,7 @@ export const ComputeShape = Schema.extend(
|
|
|
37
37
|
Polygon,
|
|
38
38
|
Schema.Struct({
|
|
39
39
|
// TODO(burdon): Rename computeNode?
|
|
40
|
-
node: Schema.optional(
|
|
40
|
+
node: Schema.optional(Obj.ID.annotations({ description: 'Compute node id' })),
|
|
41
41
|
}).pipe(Schema.mutable),
|
|
42
42
|
);
|
|
43
43
|
|
|
@@ -45,7 +45,7 @@ export type ComputeShape = Schema.Schema.Type<typeof ComputeShape>;
|
|
|
45
45
|
|
|
46
46
|
export const createShape = <S extends ComputeShape>({ id, ...rest }: CreateShapeProps<S> & { type: string }): S => {
|
|
47
47
|
return {
|
|
48
|
-
id: id ??
|
|
48
|
+
id: id ?? Obj.ID.random(),
|
|
49
49
|
...rest,
|
|
50
50
|
} as S;
|
|
51
51
|
};
|
package/src/testing/circuits.ts
CHANGED
|
@@ -3,14 +3,10 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { createSystemPrompt } from '@dxos/assistant';
|
|
6
|
-
import { ObjectId } from '@dxos/
|
|
7
|
-
import { type ServiceContainer } from '@dxos/functions';
|
|
8
|
-
import { DXN, SpaceId } from '@dxos/keys';
|
|
6
|
+
import { DXN, ObjectId, SpaceId } from '@dxos/keys';
|
|
9
7
|
import { type Dimension, type Point } from '@dxos/react-ui-canvas';
|
|
10
8
|
import { CanvasGraphModel, createNote, pointMultiply, pointsToRect, rectToPoints } from '@dxos/react-ui-canvas-editor';
|
|
11
9
|
|
|
12
|
-
import { ComputeGraphController } from '../graph';
|
|
13
|
-
import { createComputeGraph } from '../hooks';
|
|
14
10
|
import {
|
|
15
11
|
type ComputeShape,
|
|
16
12
|
createAnd,
|
|
@@ -38,19 +34,14 @@ import {
|
|
|
38
34
|
createTextToImage,
|
|
39
35
|
} from '../shapes';
|
|
40
36
|
|
|
41
|
-
export const createComputeGraphController = (
|
|
42
|
-
graph: CanvasGraphModel<ComputeShape>,
|
|
43
|
-
serviceContainer: ServiceContainer,
|
|
44
|
-
) => {
|
|
45
|
-
const computeGraph = createComputeGraph(graph);
|
|
46
|
-
const controller = new ComputeGraphController(serviceContainer, computeGraph);
|
|
47
|
-
return { controller, graph };
|
|
48
|
-
};
|
|
49
|
-
|
|
50
37
|
//
|
|
51
38
|
// Circuits
|
|
52
39
|
//
|
|
53
40
|
|
|
41
|
+
export const createEmptyCircuit = () => {
|
|
42
|
+
return CanvasGraphModel.create<ComputeShape>();
|
|
43
|
+
};
|
|
44
|
+
|
|
54
45
|
export const createBasicCircuit = () => {
|
|
55
46
|
const model = CanvasGraphModel.create<ComputeShape>();
|
|
56
47
|
model.builder.call(({ model }) => {
|