@dxos/react-ui-canvas-compute 0.8.4-main.7ace549 → 0.8.4-main.8baae0fced
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +102 -5
- package/dist/lib/browser/index.mjs +903 -1144
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +903 -1144
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/DiagnosticOverlay.d.ts.map +1 -1
- package/dist/types/src/compute-layout.d.ts.map +1 -1
- package/dist/types/src/compute.stories.d.ts +22 -1
- package/dist/types/src/compute.stories.d.ts.map +1 -1
- package/dist/types/src/graph/controller.d.ts +48 -29
- package/dist/types/src/graph/controller.d.ts.map +1 -1
- package/dist/types/src/graph/node-defs.d.ts.map +1 -1
- package/dist/types/src/hooks/useComputeGraphController.d.ts.map +1 -1
- package/dist/types/src/hooks/useComputeNodeState.d.ts +2 -3
- package/dist/types/src/hooks/useComputeNodeState.d.ts.map +1 -1
- package/dist/types/src/hooks/useGraphMonitor.d.ts +2 -2
- package/dist/types/src/hooks/useGraphMonitor.d.ts.map +1 -1
- package/dist/types/src/shapes/Append.d.ts +1 -1
- package/dist/types/src/shapes/Append.d.ts.map +1 -1
- package/dist/types/src/shapes/Array.d.ts +1 -1
- package/dist/types/src/shapes/Array.d.ts.map +1 -1
- package/dist/types/src/shapes/Audio.d.ts +1 -1
- package/dist/types/src/shapes/Audio.d.ts.map +1 -1
- package/dist/types/src/shapes/Beacon.d.ts +1 -1
- package/dist/types/src/shapes/Beacon.d.ts.map +1 -1
- package/dist/types/src/shapes/Boolean.d.ts +7 -7
- package/dist/types/src/shapes/Boolean.d.ts.map +1 -1
- package/dist/types/src/shapes/Chat.d.ts +1 -1
- package/dist/types/src/shapes/Chat.d.ts.map +1 -1
- package/dist/types/src/shapes/Constant.d.ts +1 -1
- package/dist/types/src/shapes/Constant.d.ts.map +1 -1
- package/dist/types/src/shapes/Database.d.ts +1 -1
- package/dist/types/src/shapes/Database.d.ts.map +1 -1
- package/dist/types/src/shapes/{Queue.d.ts → Feed.d.ts} +9 -9
- package/dist/types/src/shapes/Feed.d.ts.map +1 -0
- package/dist/types/src/shapes/Function.d.ts +1 -1
- package/dist/types/src/shapes/Function.d.ts.map +1 -1
- package/dist/types/src/shapes/Gpt.d.ts +1 -1
- package/dist/types/src/shapes/Gpt.d.ts.map +1 -1
- package/dist/types/src/shapes/GptRealtime.d.ts +1 -1
- package/dist/types/src/shapes/GptRealtime.d.ts.map +1 -1
- package/dist/types/src/shapes/Json.d.ts +2 -2
- package/dist/types/src/shapes/Json.d.ts.map +1 -1
- package/dist/types/src/shapes/Logic.d.ts +2 -2
- package/dist/types/src/shapes/Logic.d.ts.map +1 -1
- package/dist/types/src/shapes/RNG.d.ts +2 -2
- package/dist/types/src/shapes/RNG.d.ts.map +1 -1
- package/dist/types/src/shapes/Scope.d.ts +1 -1
- package/dist/types/src/shapes/Scope.d.ts.map +1 -1
- package/dist/types/src/shapes/Surface.d.ts +1 -1
- package/dist/types/src/shapes/Surface.d.ts.map +1 -1
- package/dist/types/src/shapes/Switch.d.ts +1 -1
- package/dist/types/src/shapes/Switch.d.ts.map +1 -1
- package/dist/types/src/shapes/Table.d.ts +1 -1
- package/dist/types/src/shapes/Table.d.ts.map +1 -1
- package/dist/types/src/shapes/Template.d.ts +2 -2
- package/dist/types/src/shapes/Template.d.ts.map +1 -1
- package/dist/types/src/shapes/Text.d.ts +1 -1
- package/dist/types/src/shapes/Text.d.ts.map +1 -1
- package/dist/types/src/shapes/TextToImage.d.ts +1 -1
- package/dist/types/src/shapes/TextToImage.d.ts.map +1 -1
- package/dist/types/src/shapes/Thread.d.ts +1 -1
- package/dist/types/src/shapes/Thread.d.ts.map +1 -1
- package/dist/types/src/shapes/Trigger.d.ts +6 -4
- package/dist/types/src/shapes/Trigger.d.ts.map +1 -1
- package/dist/types/src/shapes/common/Box.d.ts +4 -4
- 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/common/TypeSelect.d.ts +1 -1
- package/dist/types/src/shapes/common/TypeSelect.d.ts.map +1 -1
- package/dist/types/src/shapes/defs.d.ts +1 -1
- package/dist/types/src/shapes/defs.d.ts.map +1 -1
- package/dist/types/src/shapes/index.d.ts +2 -2
- package/dist/types/src/shapes/index.d.ts.map +1 -1
- package/dist/types/src/testing/circuits.d.ts +18 -24
- package/dist/types/src/testing/circuits.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +62 -60
- package/src/README.md +0 -3
- package/src/compute.stories.tsx +91 -116
- package/src/graph/controller.ts +145 -75
- package/src/graph/node-defs.ts +28 -28
- package/src/hooks/useComputeNodeState.ts +3 -5
- package/src/hooks/useGraphMonitor.ts +9 -8
- package/src/json.test.ts +3 -3
- package/src/registry.ts +2 -2
- package/src/schema.test.ts +6 -6
- 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} +26 -21
- package/src/shapes/Function.tsx +12 -9
- package/src/shapes/Gpt.tsx +6 -2
- package/src/shapes/GptRealtime.tsx +1 -1
- package/src/shapes/Json.tsx +9 -3
- package/src/shapes/RNG.tsx +0 -1
- package/src/shapes/Scope.tsx +1 -2
- package/src/shapes/Surface.tsx +7 -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 +10 -8
- package/src/shapes/Trigger.tsx +20 -19
- package/src/shapes/common/Box.tsx +8 -11
- 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 +6 -14
- package/dist/types/src/shapes/Queue.d.ts.map +0 -1
|
@@ -6,31 +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
|
-
import { mx } from '@dxos/
|
|
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>({
|
|
31
|
+
type: 'queue',
|
|
32
|
+
size: { width: 256, height: 512 },
|
|
33
|
+
...props,
|
|
34
|
+
});
|
|
32
35
|
|
|
33
|
-
export const
|
|
36
|
+
export const FeedComponent = ({ shape }: ShapeComponentProps<FeedShape>) => {
|
|
34
37
|
const { runtime } = useComputeNodeState(shape);
|
|
35
38
|
const items = runtime.outputs[DEFAULT_OUTPUT]?.type === 'executed' ? runtime.outputs[DEFAULT_OUTPUT].value : [];
|
|
36
39
|
|
|
@@ -42,22 +45,24 @@ export const QueueComponent = ({ shape }: ShapeComponentProps<QueueShape>) => {
|
|
|
42
45
|
|
|
43
46
|
return (
|
|
44
47
|
<Box shape={shape} status={`${items.length} items`} onAction={handleAction}>
|
|
45
|
-
<
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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>
|
|
50
55
|
</Box>
|
|
51
56
|
);
|
|
52
57
|
};
|
|
53
58
|
|
|
54
|
-
export const
|
|
59
|
+
export const FeedItem = ({ classNames, item }: ThemedClassName<{ item: any }>) => {
|
|
55
60
|
if (typeof item !== 'object') {
|
|
56
61
|
return <div className={mx(classNames, 'whitespace-pre-wrap')}>{item}</div>;
|
|
57
62
|
}
|
|
58
63
|
|
|
59
64
|
return (
|
|
60
|
-
<div className={mx('grid grid-cols-[
|
|
65
|
+
<div className={mx('grid grid-cols-[80px_1fr]', classNames)}>
|
|
61
66
|
{Object.entries(item).map(([key, value]) => (
|
|
62
67
|
<Fragment key={key}>
|
|
63
68
|
<div className='p-1 text-xs text-subdued'>{key}</div>
|
|
@@ -68,12 +73,12 @@ export const QueueItem = ({ classNames, item }: ThemedClassName<{ item: any }>)
|
|
|
68
73
|
);
|
|
69
74
|
};
|
|
70
75
|
|
|
71
|
-
export const
|
|
72
|
-
type: '
|
|
73
|
-
name: '
|
|
76
|
+
export const feedShape: ShapeDef<FeedShape> = {
|
|
77
|
+
type: 'feed',
|
|
78
|
+
name: 'Feed',
|
|
74
79
|
icon: 'ph--queue--regular',
|
|
75
|
-
component:
|
|
76
|
-
createShape:
|
|
80
|
+
component: FeedComponent,
|
|
81
|
+
createShape: createFeed,
|
|
77
82
|
getAnchors: (shape) => createFunctionAnchors(shape, QueueInput, QueueOutput),
|
|
78
83
|
resizable: true,
|
|
79
84
|
};
|
package/src/shapes/Function.tsx
CHANGED
|
@@ -5,11 +5,13 @@
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
import React, { useCallback, useRef } from 'react';
|
|
7
7
|
|
|
8
|
+
import { Script } from '@dxos/compute';
|
|
9
|
+
import { Operation } from '@dxos/compute';
|
|
8
10
|
import { AnyOutput, FunctionInput } from '@dxos/conductor';
|
|
11
|
+
import { Filter } from '@dxos/echo';
|
|
9
12
|
import { Ref, getSnapshot, isInstanceOf } from '@dxos/echo/internal';
|
|
10
|
-
import {
|
|
13
|
+
import { parseId } from '@dxos/keys';
|
|
11
14
|
import { useClient } from '@dxos/react-client';
|
|
12
|
-
import { Filter, parseId } from '@dxos/react-client/echo';
|
|
13
15
|
import {
|
|
14
16
|
type ShapeComponentProps,
|
|
15
17
|
type ShapeDef,
|
|
@@ -19,7 +21,6 @@ import {
|
|
|
19
21
|
} from '@dxos/react-ui-canvas-editor';
|
|
20
22
|
|
|
21
23
|
import { useComputeNodeState } from '../hooks';
|
|
22
|
-
|
|
23
24
|
import { Box, createFunctionAnchors } from './common';
|
|
24
25
|
import { ComputeShape, type CreateShapeProps, createShape } from './defs';
|
|
25
26
|
|
|
@@ -35,7 +36,11 @@ export type FunctionShape = Schema.Schema.Type<typeof FunctionShape>;
|
|
|
35
36
|
export type CreateFunctionProps = CreateShapeProps<FunctionShape>;
|
|
36
37
|
|
|
37
38
|
export const createFunction = (props: CreateFunctionProps) =>
|
|
38
|
-
createShape<FunctionShape>({
|
|
39
|
+
createShape<FunctionShape>({
|
|
40
|
+
type: 'function',
|
|
41
|
+
size: { width: 256, height: 192 },
|
|
42
|
+
...props,
|
|
43
|
+
});
|
|
39
44
|
|
|
40
45
|
//
|
|
41
46
|
// Component
|
|
@@ -62,17 +67,15 @@ const TextInputComponent = ({ shape, title, ...props }: TextInputComponentProps)
|
|
|
62
67
|
return;
|
|
63
68
|
}
|
|
64
69
|
|
|
65
|
-
const {
|
|
66
|
-
objects: [fn],
|
|
67
|
-
} = await space.db.query(Filter.type(Function.Function, { source: Ref.make(object) })).run();
|
|
70
|
+
const [fn] = await space.db.query(Filter.type(Operation.PersistentOperation, { source: Ref.make(object) })).run();
|
|
68
71
|
if (!fn) {
|
|
69
72
|
return;
|
|
70
73
|
}
|
|
71
74
|
|
|
72
75
|
node.value = value;
|
|
73
76
|
node.function = Ref.make(fn);
|
|
74
|
-
node.inputSchema = getSnapshot(fn.inputSchema);
|
|
75
|
-
node.outputSchema = getSnapshot(fn.outputSchema);
|
|
77
|
+
node.inputSchema = fn.inputSchema ? getSnapshot(fn.inputSchema) : undefined;
|
|
78
|
+
node.outputSchema = fn.outputSchema ? getSnapshot(fn.outputSchema) : undefined;
|
|
76
79
|
},
|
|
77
80
|
[client, node],
|
|
78
81
|
);
|
package/src/shapes/Gpt.tsx
CHANGED
|
@@ -6,10 +6,10 @@ 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';
|
|
12
|
-
|
|
13
13
|
import { FunctionBody, createFunctionAnchors, getHeight } from './common';
|
|
14
14
|
import { ComputeShape, type CreateShapeProps, createShape } from './defs';
|
|
15
15
|
|
|
@@ -74,7 +74,11 @@ export const GptComponent = ({ shape }: ShapeComponentProps<GptShape>) => {
|
|
|
74
74
|
return (
|
|
75
75
|
<FunctionBody
|
|
76
76
|
shape={shape}
|
|
77
|
-
content={
|
|
77
|
+
content={
|
|
78
|
+
<ScrollArea.Root orientation='vertical' thin>
|
|
79
|
+
<ScrollArea.Viewport>{text}</ScrollArea.Viewport>
|
|
80
|
+
</ScrollArea.Root>
|
|
81
|
+
}
|
|
78
82
|
status={`${tokens} tokens`}
|
|
79
83
|
inputSchema={meta.input}
|
|
80
84
|
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,10 +8,9 @@ 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 { Syntax } from '@dxos/react-ui-syntax-highlighter';
|
|
12
12
|
|
|
13
13
|
import { useComputeNodeState } from '../hooks';
|
|
14
|
-
|
|
15
14
|
import { Box, createFunctionAnchors, getHeight } from './common';
|
|
16
15
|
import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
|
|
17
16
|
|
|
@@ -50,7 +49,14 @@ export const JsonComponent = ({ shape, ...props }: JsonComponentProps) => {
|
|
|
50
49
|
|
|
51
50
|
return (
|
|
52
51
|
<Box shape={shape}>
|
|
53
|
-
<
|
|
52
|
+
<Syntax.Root data={value}>
|
|
53
|
+
<Syntax.Content>
|
|
54
|
+
<Syntax.Filter />
|
|
55
|
+
<Syntax.Viewport>
|
|
56
|
+
<Syntax.Code classNames='text-xs' />
|
|
57
|
+
</Syntax.Viewport>
|
|
58
|
+
</Syntax.Content>
|
|
59
|
+
</Syntax.Root>
|
|
54
60
|
</Box>
|
|
55
61
|
);
|
|
56
62
|
};
|
package/src/shapes/RNG.tsx
CHANGED
|
@@ -10,7 +10,6 @@ import { Icon, type IconProps } 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 RandomShape = Schema.extend(
|
package/src/shapes/Scope.tsx
CHANGED
|
@@ -10,7 +10,6 @@ import { type ShapeComponentProps, type ShapeDef, createAnchorMap } from '@dxos/
|
|
|
10
10
|
import { Chaos, shaderPresets, useAudioStream } from '@dxos/react-ui-sfx';
|
|
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 ScopeShape = Schema.extend(
|
|
@@ -39,7 +38,7 @@ export const ScopeComponent = ({ shape }: ShapeComponentProps<ScopeShape>) => {
|
|
|
39
38
|
const { getAverage } = useAudioStream(active);
|
|
40
39
|
|
|
41
40
|
return (
|
|
42
|
-
<div className='flex
|
|
41
|
+
<div className='flex w-full justify-center items-center bg-black'>
|
|
43
42
|
<Chaos active={active} getValue={getAverage} options={{ ...shaderPresets.heptapod, zoom: 1.2 }} />
|
|
44
43
|
</div>
|
|
45
44
|
);
|
package/src/shapes/Surface.tsx
CHANGED
|
@@ -5,13 +5,14 @@
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
|
-
import { Surface } from '@dxos/app-framework/
|
|
8
|
+
import { Surface } from '@dxos/app-framework/ui';
|
|
9
|
+
import { AppSurface } from '@dxos/app-toolkit/ui';
|
|
9
10
|
import { DEFAULT_INPUT } from '@dxos/conductor';
|
|
11
|
+
import { Card } from '@dxos/react-ui';
|
|
10
12
|
import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
|
|
11
13
|
import { createAnchorMap } from '@dxos/react-ui-canvas-editor';
|
|
12
14
|
|
|
13
15
|
import { useComputeNodeState } from '../hooks';
|
|
14
|
-
|
|
15
16
|
import { Box, type BoxActionHandler } from './common';
|
|
16
17
|
import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
|
|
17
18
|
|
|
@@ -44,9 +45,12 @@ export const SurfaceComponent = ({ shape }: ShapeComponentProps<SurfaceShape>) =
|
|
|
44
45
|
}
|
|
45
46
|
};
|
|
46
47
|
|
|
48
|
+
// TODO(burdon): Subject property?
|
|
47
49
|
return (
|
|
48
50
|
<Box shape={shape} onAction={handleAction}>
|
|
49
|
-
|
|
51
|
+
<Card.Root>
|
|
52
|
+
{value !== null && <Surface.Surface type={AppSurface.Card} data={{ subject: value }} limit={1} />}
|
|
53
|
+
</Card.Root>
|
|
50
54
|
</Box>
|
|
51
55
|
);
|
|
52
56
|
};
|
package/src/shapes/Switch.tsx
CHANGED
|
@@ -10,7 +10,6 @@ import { Input } 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 SwitchShape = Schema.extend(
|
|
@@ -36,7 +35,7 @@ export const SwitchComponent = ({ shape }: ShapeComponentProps<SwitchShape>) =>
|
|
|
36
35
|
}, [value]);
|
|
37
36
|
|
|
38
37
|
return (
|
|
39
|
-
<div className='flex
|
|
38
|
+
<div className='flex w-full justify-center items-center' onClick={(ev) => ev.stopPropagation()}>
|
|
40
39
|
<Input.Root>
|
|
41
40
|
<Input.Switch checked={value} onCheckedChange={(value) => setValue(value)} />
|
|
42
41
|
</Input.Root>
|
package/src/shapes/Template.tsx
CHANGED
package/src/shapes/Text.tsx
CHANGED
|
@@ -10,7 +10,6 @@ import { type ShapeComponentProps, type ShapeDef, TextBox } from '@dxos/react-ui
|
|
|
10
10
|
import { createAnchorMap } from '@dxos/react-ui-canvas-editor';
|
|
11
11
|
|
|
12
12
|
import { useComputeNodeState } from '../hooks';
|
|
13
|
-
|
|
14
13
|
import { Box, type BoxActionHandler } from './common';
|
|
15
14
|
import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
|
|
16
15
|
|
package/src/shapes/Thread.tsx
CHANGED
|
@@ -6,10 +6,10 @@ import * as Schema from 'effect/Schema';
|
|
|
6
6
|
import React, { useEffect, useRef } from 'react';
|
|
7
7
|
|
|
8
8
|
import { createInputSchema, createOutputSchema } 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
|
-
import { mx } from '@dxos/react-ui-theme';
|
|
12
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';
|
|
@@ -42,11 +42,13 @@ export const ThreadComponent = ({ shape }: ShapeComponentProps<ThreadShape>) =>
|
|
|
42
42
|
|
|
43
43
|
return (
|
|
44
44
|
<Box shape={shape}>
|
|
45
|
-
<
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
<ScrollArea.Root orientation='vertical'>
|
|
46
|
+
<ScrollArea.Viewport classNames='gap-2 p-2' ref={scrollRef}>
|
|
47
|
+
{[...items].map((item, i) => (
|
|
48
|
+
<ThreadItem key={i} item={item} />
|
|
49
|
+
))}
|
|
50
|
+
</ScrollArea.Viewport>
|
|
51
|
+
</ScrollArea.Root>
|
|
50
52
|
</Box>
|
|
51
53
|
);
|
|
52
54
|
};
|
|
@@ -63,7 +65,7 @@ export const ThreadItem = ({ classNames, item }: ThemedClassName<{ item: any }>)
|
|
|
63
65
|
<div className={mx('flex', classNames, role === 'user' && 'justify-end')}>
|
|
64
66
|
<div
|
|
65
67
|
className={mx(
|
|
66
|
-
'block rounded-md p-1
|
|
68
|
+
'block rounded-md p-1 px-2 text-sm',
|
|
67
69
|
role === 'user'
|
|
68
70
|
? 'bg-blue-100 dark:bg-blue-800'
|
|
69
71
|
: role === 'system'
|
package/src/shapes/Trigger.tsx
CHANGED
|
@@ -5,11 +5,12 @@
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
import React, { useEffect } from 'react';
|
|
7
7
|
|
|
8
|
+
import { Trigger, TriggerEvent } from '@dxos/compute';
|
|
8
9
|
import { VoidInput } from '@dxos/conductor';
|
|
9
|
-
import { Filter, Obj, Query, Ref
|
|
10
|
-
import {
|
|
10
|
+
import { Filter, Obj, Query, Ref } from '@dxos/echo';
|
|
11
|
+
import { type Mutable } from '@dxos/echo/internal';
|
|
11
12
|
import { DXN, SpaceId } from '@dxos/keys';
|
|
12
|
-
import {
|
|
13
|
+
import { useSpaces } from '@dxos/react-client/echo';
|
|
13
14
|
import { Select, type SelectRootProps } from '@dxos/react-ui';
|
|
14
15
|
import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
|
|
15
16
|
|
|
@@ -20,10 +21,11 @@ export const TriggerShape = Schema.extend(
|
|
|
20
21
|
ComputeShape,
|
|
21
22
|
Schema.Struct({
|
|
22
23
|
type: Schema.Literal('trigger'),
|
|
23
|
-
functionTrigger: Schema.optional(
|
|
24
|
+
functionTrigger: Schema.optional(Ref.Ref(Trigger.Trigger)),
|
|
24
25
|
}),
|
|
25
26
|
);
|
|
26
|
-
|
|
27
|
+
|
|
28
|
+
export interface TriggerShape extends Schema.Schema.Type<typeof TriggerShape> {}
|
|
27
29
|
|
|
28
30
|
export type CreateTriggerProps = CreateShapeProps<Omit<TriggerShape, 'functionTrigger'>> & {
|
|
29
31
|
spaceId?: SpaceId;
|
|
@@ -46,12 +48,14 @@ export const createTrigger = (props: CreateTriggerProps): TriggerShape => {
|
|
|
46
48
|
export type TriggerComponentProps = ShapeComponentProps<TriggerShape>;
|
|
47
49
|
|
|
48
50
|
export const TriggerComponent = ({ shape }: TriggerComponentProps) => {
|
|
49
|
-
const space =
|
|
51
|
+
const [space] = useSpaces();
|
|
50
52
|
const functionTrigger = shape.functionTrigger?.target;
|
|
51
53
|
|
|
52
54
|
useEffect(() => {
|
|
53
55
|
if (functionTrigger && !functionTrigger.spec) {
|
|
54
|
-
|
|
56
|
+
Obj.update(functionTrigger, (functionTrigger) => {
|
|
57
|
+
functionTrigger.spec = createTriggerSpec({ triggerKind: 'email', spaceId: space?.id }) as Mutable<Trigger.Spec>;
|
|
58
|
+
});
|
|
55
59
|
}
|
|
56
60
|
}, [functionTrigger, functionTrigger?.spec]);
|
|
57
61
|
|
|
@@ -61,7 +65,9 @@ export const TriggerComponent = ({ shape }: TriggerComponentProps) => {
|
|
|
61
65
|
|
|
62
66
|
const setKind = (kind: Trigger.Kind) => {
|
|
63
67
|
if (functionTrigger?.spec?.kind !== kind) {
|
|
64
|
-
functionTrigger
|
|
68
|
+
Obj.update(functionTrigger!, (obj) => {
|
|
69
|
+
obj.spec = createTriggerSpec({ triggerKind: kind, spaceId: space?.id }) as Mutable<Trigger.Spec>;
|
|
70
|
+
});
|
|
65
71
|
}
|
|
66
72
|
};
|
|
67
73
|
|
|
@@ -85,7 +91,7 @@ export const TriggerComponent = ({ shape }: TriggerComponentProps) => {
|
|
|
85
91
|
const TriggerKindSelect = ({ value, onValueChange }: Pick<SelectRootProps, 'value' | 'onValueChange'>) => {
|
|
86
92
|
return (
|
|
87
93
|
<Select.Root value={value} onValueChange={onValueChange}>
|
|
88
|
-
<Select.TriggerButton variant='ghost' classNames='
|
|
94
|
+
<Select.TriggerButton variant='ghost' classNames='w-full px-0!' />
|
|
89
95
|
<Select.Portal>
|
|
90
96
|
<Select.Content>
|
|
91
97
|
<Select.ScrollUpButton />
|
|
@@ -108,21 +114,16 @@ const createTriggerSpec = (props: { triggerKind?: Trigger.Kind; spaceId?: SpaceI
|
|
|
108
114
|
const kind = props.triggerKind ?? 'email';
|
|
109
115
|
switch (kind) {
|
|
110
116
|
case 'timer':
|
|
111
|
-
return
|
|
117
|
+
return Trigger.specTimer('*/10 * * * * *');
|
|
112
118
|
case 'webhook':
|
|
113
|
-
return {
|
|
119
|
+
return Trigger.specWebhook({ method: 'POST' });
|
|
114
120
|
case 'subscription':
|
|
115
|
-
return
|
|
116
|
-
kind: 'subscription',
|
|
117
|
-
query: {
|
|
118
|
-
ast: Query.select(Filter.nothing()).ast,
|
|
119
|
-
},
|
|
120
|
-
} satisfies Trigger.SubscriptionSpec;
|
|
121
|
+
return Trigger.specSubscription(Query.select(Filter.nothing()));
|
|
121
122
|
case 'email':
|
|
122
|
-
return
|
|
123
|
+
return Trigger.specEmail();
|
|
123
124
|
case 'queue': {
|
|
124
125
|
const dxn = new DXN(DXN.kind.QUEUE, ['data', props.spaceId ?? SpaceId.random(), Obj.ID.random()]).toString();
|
|
125
|
-
return
|
|
126
|
+
return Trigger.specQueue(dxn);
|
|
126
127
|
}
|
|
127
128
|
}
|
|
128
129
|
};
|
|
@@ -6,9 +6,8 @@ import React, { type PropsWithChildren, type ReactNode, forwardRef } from 'react
|
|
|
6
6
|
|
|
7
7
|
import { invariant } from '@dxos/invariant';
|
|
8
8
|
import { Icon, IconButton, type ThemedClassName } from '@dxos/react-ui';
|
|
9
|
-
import { useEditorContext, useShapeDef } from '@dxos/react-ui-canvas-editor';
|
|
10
|
-
import {
|
|
11
|
-
import { mx } from '@dxos/react-ui-theme';
|
|
9
|
+
import { type CanvasBoard, useEditorContext, useShapeDef } from '@dxos/react-ui-canvas-editor';
|
|
10
|
+
import { mx } from '@dxos/ui-theme';
|
|
12
11
|
|
|
13
12
|
export const headerHeight = 32;
|
|
14
13
|
export const footerHeight = 32;
|
|
@@ -17,7 +16,7 @@ export type BoxActionHandler = (action: 'run' | 'open' | 'close') => void;
|
|
|
17
16
|
|
|
18
17
|
export type BoxProps = PropsWithChildren<
|
|
19
18
|
ThemedClassName<{
|
|
20
|
-
shape: Shape;
|
|
19
|
+
shape: CanvasBoard.Shape;
|
|
21
20
|
title?: string;
|
|
22
21
|
status?: string | ReactNode;
|
|
23
22
|
open?: boolean;
|
|
@@ -32,15 +31,14 @@ export const Box = forwardRef<HTMLDivElement, BoxProps>(
|
|
|
32
31
|
const { debug } = useEditorContext();
|
|
33
32
|
|
|
34
33
|
return (
|
|
35
|
-
<div ref={forwardedRef} className='flex flex-col
|
|
36
|
-
<div className='flex shrink-0
|
|
34
|
+
<div ref={forwardedRef} className='flex flex-col h-full w-full justify-between'>
|
|
35
|
+
<div className='flex shrink-0 w-full justify-between items-center h-[32px] bg-input-surface'>
|
|
37
36
|
<Icon icon={icon} classNames='mx-2' />
|
|
38
37
|
<div className='grow text-sm truncate'>{debug ? shape.type : (name ?? shape.text ?? title)}</div>
|
|
39
38
|
<IconButton
|
|
40
39
|
classNames='p-1 text-green-500'
|
|
41
40
|
variant='ghost'
|
|
42
41
|
icon='ph--play--regular'
|
|
43
|
-
size={4}
|
|
44
42
|
label='run'
|
|
45
43
|
iconOnly
|
|
46
44
|
onDoubleClick={(ev) => ev.stopPropagation()}
|
|
@@ -50,15 +48,14 @@ export const Box = forwardRef<HTMLDivElement, BoxProps>(
|
|
|
50
48
|
}}
|
|
51
49
|
/>
|
|
52
50
|
</div>
|
|
53
|
-
<div className={mx('flex flex-col
|
|
54
|
-
<div className='flex shrink-0
|
|
55
|
-
<div className='grow
|
|
51
|
+
<div className={mx('flex flex-col h-full grow overflow-hidden', classNames)}>{children}</div>
|
|
52
|
+
<div className='flex shrink-0 w-full justify-between items-center h-[32px] bg-input-surface'>
|
|
53
|
+
<div className='grow px-2 text-sm truncate'>{debug ? shape.id : status}</div>
|
|
56
54
|
{openable && (
|
|
57
55
|
<IconButton
|
|
58
56
|
classNames='p-1'
|
|
59
57
|
variant='ghost'
|
|
60
58
|
icon={open ? 'ph--caret-up--regular' : 'ph--caret-down--regular'}
|
|
61
|
-
size={4}
|
|
62
59
|
label={open ? 'close' : 'open'}
|
|
63
60
|
iconOnly
|
|
64
61
|
onClick={(ev) => {
|
|
@@ -8,7 +8,7 @@ import React, { type JSX, useRef, useState } from 'react';
|
|
|
8
8
|
|
|
9
9
|
import { VoidInput, VoidOutput } from '@dxos/conductor';
|
|
10
10
|
import { useCanvasContext } from '@dxos/react-ui-canvas';
|
|
11
|
-
import { type
|
|
11
|
+
import { type CanvasBoard, type Polygon } from '@dxos/react-ui-canvas-editor';
|
|
12
12
|
import { createAnchors, getParentShapeElement, rowHeight } from '@dxos/react-ui-canvas-editor';
|
|
13
13
|
|
|
14
14
|
import { Box, type BoxProps, footerHeight, headerHeight } from '../common';
|
|
@@ -18,7 +18,7 @@ const bodyPadding = 8;
|
|
|
18
18
|
const expandedHeight = 200;
|
|
19
19
|
|
|
20
20
|
export type FunctionBodyProps = {
|
|
21
|
-
shape: Shape;
|
|
21
|
+
shape: CanvasBoard.Shape;
|
|
22
22
|
name?: string;
|
|
23
23
|
content?: JSX.Element;
|
|
24
24
|
inputSchema?: Schema.Schema.Any;
|
|
@@ -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='px-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='px-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='w-full px-0!' />
|
|
15
15
|
<Select.Portal>
|
|
16
16
|
<Select.Content>
|
|
17
17
|
<Select.ScrollUpButton />
|
package/src/shapes/index.ts
CHANGED
|
@@ -13,11 +13,12 @@ export * from './Boolean';
|
|
|
13
13
|
export * from './Chat';
|
|
14
14
|
export * from './Constant';
|
|
15
15
|
export * from './Database';
|
|
16
|
+
export * from './Feed';
|
|
16
17
|
export * from './Function';
|
|
17
18
|
export * from './Gpt';
|
|
19
|
+
export * from './GptRealtime';
|
|
18
20
|
export * from './Json';
|
|
19
21
|
export * from './Logic';
|
|
20
|
-
export * from './Queue';
|
|
21
22
|
export * from './RNG';
|
|
22
23
|
export * from './Scope';
|
|
23
24
|
export * from './Surface';
|
|
@@ -28,4 +29,3 @@ export * from './Text';
|
|
|
28
29
|
export * from './Thread';
|
|
29
30
|
export * from './TextToImage';
|
|
30
31
|
export * from './Trigger';
|
|
31
|
-
export * from './GptRealtime';
|
package/src/testing/circuits.ts
CHANGED
|
@@ -3,13 +3,10 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { createSystemPrompt } from '@dxos/assistant';
|
|
6
|
-
import { type ServiceContainer } from '@dxos/functions-runtime';
|
|
7
6
|
import { DXN, ObjectId, SpaceId } from '@dxos/keys';
|
|
8
7
|
import { type Dimension, type Point } from '@dxos/react-ui-canvas';
|
|
9
8
|
import { CanvasGraphModel, createNote, pointMultiply, pointsToRect, rectToPoints } from '@dxos/react-ui-canvas-editor';
|
|
10
9
|
|
|
11
|
-
import { ComputeGraphController } from '../graph';
|
|
12
|
-
import { createComputeGraph } from '../hooks';
|
|
13
10
|
import {
|
|
14
11
|
type ComputeShape,
|
|
15
12
|
createAnd,
|
|
@@ -27,7 +24,7 @@ import {
|
|
|
27
24
|
createJsonTransform,
|
|
28
25
|
createNot,
|
|
29
26
|
createOr,
|
|
30
|
-
|
|
27
|
+
createFeed,
|
|
31
28
|
createRandom,
|
|
32
29
|
createScope,
|
|
33
30
|
createSurface,
|
|
@@ -37,19 +34,14 @@ import {
|
|
|
37
34
|
createTextToImage,
|
|
38
35
|
} from '../shapes';
|
|
39
36
|
|
|
40
|
-
export const createComputeGraphController = (
|
|
41
|
-
graph: CanvasGraphModel<ComputeShape>,
|
|
42
|
-
serviceContainer: ServiceContainer,
|
|
43
|
-
) => {
|
|
44
|
-
const computeGraph = createComputeGraph(graph);
|
|
45
|
-
const controller = new ComputeGraphController(serviceContainer, computeGraph);
|
|
46
|
-
return { controller, graph };
|
|
47
|
-
};
|
|
48
|
-
|
|
49
37
|
//
|
|
50
38
|
// Circuits
|
|
51
39
|
//
|
|
52
40
|
|
|
41
|
+
export const createEmptyCircuit = () => {
|
|
42
|
+
return CanvasGraphModel.create<ComputeShape>();
|
|
43
|
+
};
|
|
44
|
+
|
|
53
45
|
export const createBasicCircuit = () => {
|
|
54
46
|
const model = CanvasGraphModel.create<ComputeShape>();
|
|
55
47
|
model.builder.call(({ model }) => {
|
|
@@ -249,7 +241,7 @@ export const createGptCircuit = (options: {
|
|
|
249
241
|
}),
|
|
250
242
|
);
|
|
251
243
|
|
|
252
|
-
const thread = model.createNode(
|
|
244
|
+
const thread = model.createNode(createFeed(position({ x: -3, y: 3, width: 14, height: 10 })));
|
|
253
245
|
const append = model.createNode(createAppend(position({ x: 10, y: 6 })));
|
|
254
246
|
|
|
255
247
|
builder
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Queue.d.ts","sourceRoot":"","sources":["../../../../src/shapes/Queue.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAmB,MAAM,OAAO,CAAC;AAGxC,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,KAAK,mBAAmB,EAAE,KAAK,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAOvF,OAAO,EAAgB,KAAK,gBAAgB,EAAe,MAAM,QAAQ,CAAC;AAE1E,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;GAKtB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,UAAU,CAAC,CAAC;AAE/D,MAAM,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;AAE5D,eAAO,MAAM,WAAW,GAAI,OAAO,gBAAgB;;;;;;;;;;;;;;;;;;;CACsC,CAAC;AAE1F,eAAO,MAAM,cAAc,GAAI,WAAW,mBAAmB,CAAC,UAAU,CAAC,sBAmBxE,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,sBAAsB,eAAe,CAAC;IAAE,IAAI,EAAE,GAAG,CAAA;CAAE,CAAC,sBAe7E,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,UAAU,CAQ3C,CAAC"}
|