@dxos/react-ui-canvas-compute 0.13.0 → 0.14.0
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/chunk-types.mjs +142 -0
- package/dist/lib/chunk-types.mjs.map +1 -0
- package/dist/lib/index.mjs +526 -430
- package/dist/lib/index.mjs.map +1 -1
- package/dist/lib/types.mjs +2 -0
- package/dist/types/src/graph/controller.d.ts +1 -1
- package/dist/types/src/graph/controller.d.ts.map +1 -1
- package/dist/types/src/hooks/compute-context.d.ts +5 -4
- package/dist/types/src/hooks/compute-context.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +0 -1
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useGraphMonitor.d.ts +18 -1
- package/dist/types/src/hooks/useGraphMonitor.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/registry.d.ts +5 -8
- package/dist/types/src/registry.d.ts.map +1 -1
- package/dist/types/src/scene/compute.stories.d.ts.map +1 -1
- package/dist/types/src/scene/echo-store.d.ts +1 -1
- package/dist/types/src/scene/echo-store.d.ts.map +1 -1
- package/dist/types/src/scene/index.d.ts +0 -3
- package/dist/types/src/scene/index.d.ts.map +1 -1
- package/dist/types/src/scene/projection.d.ts.map +1 -1
- package/dist/types/src/scene/scene.d.ts +2 -2
- package/dist/types/src/scene/scene.d.ts.map +1 -1
- package/dist/types/src/shapes/Append.d.ts +2 -2
- package/dist/types/src/shapes/Append.d.ts.map +1 -1
- package/dist/types/src/shapes/Array.d.ts +3 -3
- package/dist/types/src/shapes/Array.d.ts.map +1 -1
- package/dist/types/src/shapes/Audio.d.ts +2 -2
- package/dist/types/src/shapes/Audio.d.ts.map +1 -1
- package/dist/types/src/shapes/Beacon.d.ts +2 -2
- package/dist/types/src/shapes/Beacon.d.ts.map +1 -1
- package/dist/types/src/shapes/Boolean.d.ts +4 -52
- package/dist/types/src/shapes/Boolean.d.ts.map +1 -1
- package/dist/types/src/shapes/Chat.d.ts +3 -3
- package/dist/types/src/shapes/Chat.d.ts.map +1 -1
- package/dist/types/src/shapes/Constant.d.ts +3 -4
- package/dist/types/src/shapes/Constant.d.ts.map +1 -1
- package/dist/types/src/shapes/Database.d.ts +2 -2
- package/dist/types/src/shapes/Database.d.ts.map +1 -1
- package/dist/types/src/shapes/Feed.d.ts +2 -2
- package/dist/types/src/shapes/Feed.d.ts.map +1 -1
- package/dist/types/src/shapes/Function.d.ts +3 -5
- package/dist/types/src/shapes/Function.d.ts.map +1 -1
- package/dist/types/src/shapes/Gpt.d.ts +2 -2
- package/dist/types/src/shapes/Gpt.d.ts.map +1 -1
- package/dist/types/src/shapes/GptRealtime.d.ts +2 -2
- package/dist/types/src/shapes/GptRealtime.d.ts.map +1 -1
- package/dist/types/src/shapes/Json.d.ts +5 -5
- package/dist/types/src/shapes/Json.d.ts.map +1 -1
- package/dist/types/src/shapes/Logic.d.ts +5 -5
- 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 +2 -2
- package/dist/types/src/shapes/Scope.d.ts.map +1 -1
- package/dist/types/src/shapes/Surface.d.ts +2 -2
- package/dist/types/src/shapes/Surface.d.ts.map +1 -1
- package/dist/types/src/shapes/Switch.d.ts +2 -2
- package/dist/types/src/shapes/Switch.d.ts.map +1 -1
- package/dist/types/src/shapes/Table.d.ts +2 -2
- 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 +2 -2
- package/dist/types/src/shapes/Text.d.ts.map +1 -1
- package/dist/types/src/shapes/TextToImage.d.ts +2 -2
- package/dist/types/src/shapes/TextToImage.d.ts.map +1 -1
- package/dist/types/src/shapes/Thread.d.ts +2 -2
- package/dist/types/src/shapes/Thread.d.ts.map +1 -1
- package/dist/types/src/shapes/Trigger.d.ts +3 -3
- package/dist/types/src/shapes/Trigger.d.ts.map +1 -1
- package/dist/types/src/shapes/append-def.d.ts +1 -2
- package/dist/types/src/shapes/append-def.d.ts.map +1 -1
- package/dist/types/src/shapes/array-def.d.ts +2 -3
- package/dist/types/src/shapes/array-def.d.ts.map +1 -1
- package/dist/types/src/shapes/audio-def.d.ts +1 -2
- package/dist/types/src/shapes/audio-def.d.ts.map +1 -1
- package/dist/types/src/shapes/beacon-def.d.ts +1 -2
- package/dist/types/src/shapes/beacon-def.d.ts.map +1 -1
- package/dist/types/src/shapes/chat-def.d.ts +1 -2
- package/dist/types/src/shapes/chat-def.d.ts.map +1 -1
- package/dist/types/src/shapes/common/Box.d.ts.map +1 -1
- package/dist/types/src/shapes/common/FunctionBody.d.ts.map +1 -1
- package/dist/types/src/shapes/common/TextBox.d.ts +26 -0
- package/dist/types/src/shapes/common/TextBox.d.ts.map +1 -0
- package/dist/types/src/shapes/common/index.d.ts +3 -1
- package/dist/types/src/shapes/common/index.d.ts.map +1 -1
- package/dist/types/src/shapes/common/node-def.d.ts +24 -0
- package/dist/types/src/shapes/common/node-def.d.ts.map +1 -0
- package/dist/types/src/shapes/common/ports.d.ts +33 -0
- package/dist/types/src/shapes/common/ports.d.ts.map +1 -0
- package/dist/types/src/shapes/constant-def.d.ts +1 -2
- package/dist/types/src/shapes/constant-def.d.ts.map +1 -1
- package/dist/types/src/shapes/database-def.d.ts +1 -2
- package/dist/types/src/shapes/database-def.d.ts.map +1 -1
- package/dist/types/src/shapes/defs.d.ts +7 -2
- package/dist/types/src/shapes/defs.d.ts.map +1 -1
- package/dist/types/src/shapes/feed-def.d.ts +1 -2
- package/dist/types/src/shapes/feed-def.d.ts.map +1 -1
- package/dist/types/src/shapes/function-def.d.ts +1 -2
- package/dist/types/src/shapes/function-def.d.ts.map +1 -1
- package/dist/types/src/shapes/gpt-def.d.ts +1 -2
- package/dist/types/src/shapes/gpt-def.d.ts.map +1 -1
- package/dist/types/src/shapes/gpt-realtime-def.d.ts +1 -2
- package/dist/types/src/shapes/gpt-realtime-def.d.ts.map +1 -1
- package/dist/types/src/shapes/json-def.d.ts +2 -3
- package/dist/types/src/shapes/json-def.d.ts.map +1 -1
- package/dist/types/src/shapes/logic-def.d.ts +2 -3
- package/dist/types/src/shapes/logic-def.d.ts.map +1 -1
- package/dist/types/src/shapes/ports.test.d.ts +2 -0
- package/dist/types/src/shapes/ports.test.d.ts.map +1 -0
- package/dist/types/src/shapes/rng-def.d.ts +1 -2
- package/dist/types/src/shapes/rng-def.d.ts.map +1 -1
- package/dist/types/src/shapes/scope-def.d.ts +1 -2
- package/dist/types/src/shapes/scope-def.d.ts.map +1 -1
- package/dist/types/src/shapes/surface-def.d.ts +1 -2
- package/dist/types/src/shapes/surface-def.d.ts.map +1 -1
- package/dist/types/src/shapes/switch-def.d.ts +1 -2
- package/dist/types/src/shapes/switch-def.d.ts.map +1 -1
- package/dist/types/src/shapes/table-def.d.ts +1 -2
- package/dist/types/src/shapes/table-def.d.ts.map +1 -1
- package/dist/types/src/shapes/template-def.d.ts +1 -2
- package/dist/types/src/shapes/template-def.d.ts.map +1 -1
- package/dist/types/src/shapes/text-def.d.ts +1 -2
- package/dist/types/src/shapes/text-def.d.ts.map +1 -1
- package/dist/types/src/shapes/text-to-image-def.d.ts +1 -2
- package/dist/types/src/shapes/text-to-image-def.d.ts.map +1 -1
- package/dist/types/src/shapes/thread-def.d.ts +1 -2
- package/dist/types/src/shapes/thread-def.d.ts.map +1 -1
- package/dist/types/src/shapes/trigger-def.d.ts +1 -2
- package/dist/types/src/shapes/trigger-def.d.ts.map +1 -1
- package/dist/types/src/testing/circuits.d.ts +1 -1
- package/dist/types/src/testing/circuits.d.ts.map +1 -1
- package/dist/types/src/types/canvas-board.test.d.ts +2 -0
- package/dist/types/src/types/canvas-board.test.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +4 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/src/types/model.d.ts +10 -0
- package/dist/types/src/types/model.d.ts.map +1 -0
- package/dist/types/src/types/schema.d.ts +66 -0
- package/dist/types/src/types/schema.d.ts.map +1 -0
- package/dist/types/src/types/shapes.d.ts +114 -0
- package/dist/types/src/types/shapes.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +43 -35
- package/src/graph/controller.ts +1 -1
- package/src/hooks/compute-context.ts +7 -4
- package/src/hooks/index.ts +0 -1
- package/src/hooks/useGraphMonitor.ts +10 -1
- package/src/index.ts +1 -1
- package/src/playwright/scene.spec.ts +3 -3
- package/src/registry.ts +63 -91
- package/src/scene/compute.stories.tsx +3 -6
- package/src/scene/echo-store.test.ts +18 -7
- package/src/scene/echo-store.ts +7 -10
- package/src/scene/index.ts +0 -3
- package/src/scene/projection.ts +2 -3
- package/src/scene/scene.test.ts +4 -4
- package/src/scene/scene.ts +6 -4
- package/src/schema.test.ts +7 -36
- package/src/shapes/Append.tsx +2 -3
- package/src/shapes/Array.tsx +3 -4
- package/src/shapes/Audio.tsx +2 -2
- package/src/shapes/Beacon.tsx +2 -2
- package/src/shapes/Boolean.tsx +32 -29
- package/src/shapes/Chat.tsx +5 -10
- package/src/shapes/Constant.tsx +19 -12
- package/src/shapes/Database.tsx +2 -4
- package/src/shapes/Feed.tsx +2 -3
- package/src/shapes/Function.tsx +4 -10
- package/src/shapes/Gpt.tsx +2 -3
- package/src/shapes/GptRealtime.tsx +2 -2
- package/src/shapes/Json.tsx +5 -6
- package/src/shapes/Logic.tsx +5 -6
- package/src/shapes/RNG.tsx +2 -2
- package/src/shapes/Scope.tsx +2 -2
- package/src/shapes/Surface.tsx +9 -6
- package/src/shapes/Switch.tsx +10 -12
- package/src/shapes/Table.tsx +2 -4
- package/src/shapes/Template.tsx +10 -9
- package/src/shapes/Text.tsx +2 -3
- package/src/shapes/TextToImage.tsx +2 -4
- package/src/shapes/Thread.tsx +2 -3
- package/src/shapes/Trigger.tsx +3 -4
- package/src/shapes/append-def.ts +8 -7
- package/src/shapes/array-def.ts +8 -8
- package/src/shapes/audio-def.ts +8 -7
- package/src/shapes/beacon-def.ts +9 -8
- package/src/shapes/chat-def.tsx +8 -8
- package/src/shapes/common/Box.tsx +7 -4
- package/src/shapes/common/FunctionBody.tsx +13 -26
- package/src/shapes/common/TextBox.tsx +137 -0
- package/src/shapes/common/index.ts +3 -1
- package/src/shapes/common/node-def.tsx +117 -0
- package/src/shapes/common/ports.ts +107 -0
- package/src/shapes/constant-def.tsx +8 -8
- package/src/shapes/database-def.ts +8 -8
- package/src/shapes/defs.ts +21 -6
- package/src/shapes/feed-def.ts +8 -7
- package/src/shapes/function-def.ts +8 -7
- package/src/shapes/gpt-def.ts +8 -7
- package/src/shapes/gpt-realtime-def.ts +10 -10
- package/src/shapes/json-def.ts +15 -13
- package/src/shapes/logic-def.ts +14 -11
- package/src/shapes/ports.test.ts +23 -0
- package/src/shapes/rng-def.ts +8 -7
- package/src/shapes/scope-def.ts +8 -7
- package/src/shapes/surface-def.ts +8 -8
- package/src/shapes/switch-def.ts +8 -7
- package/src/shapes/table-def.ts +7 -7
- package/src/shapes/template-def.ts +8 -7
- package/src/shapes/text-def.ts +8 -8
- package/src/shapes/text-to-image-def.ts +8 -8
- package/src/shapes/thread-def.ts +8 -7
- package/src/shapes/trigger-def.ts +11 -8
- package/src/testing/circuits.ts +21 -7
- package/src/types/canvas-board.test.ts +84 -0
- package/src/types/index.ts +7 -0
- package/src/types/model.ts +63 -0
- package/src/types/schema.ts +73 -0
- package/src/types/shapes.ts +73 -0
- package/dist/types/src/compute-layout.d.ts +0 -9
- package/dist/types/src/compute-layout.d.ts.map +0 -1
- package/dist/types/src/compute.stories.d.ts +0 -58
- package/dist/types/src/compute.stories.d.ts.map +0 -1
- package/dist/types/src/hooks/useComputeGraphController.d.ts +0 -10
- package/dist/types/src/hooks/useComputeGraphController.d.ts.map +0 -1
- package/dist/types/src/scene/NodeView.d.ts +0 -11
- package/dist/types/src/scene/NodeView.d.ts.map +0 -1
- package/dist/types/src/scene/defs.d.ts +0 -5
- package/dist/types/src/scene/defs.d.ts.map +0 -1
- package/dist/types/src/scene/ports.d.ts +0 -5
- package/dist/types/src/scene/ports.d.ts.map +0 -1
- package/dist/types/src/shapes/common/function-anchors.d.ts +0 -12
- package/dist/types/src/shapes/common/function-anchors.d.ts.map +0 -1
- package/src/compute-layout.ts +0 -37
- package/src/compute.stories.tsx +0 -302
- package/src/hooks/useComputeGraphController.ts +0 -65
- package/src/scene/NodeView.tsx +0 -42
- package/src/scene/defs.ts +0 -158
- package/src/scene/ports.ts +0 -30
- package/src/shapes/common/function-anchors.ts +0 -44
package/dist/lib/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/hooks/compute-context.ts","../../src/hooks/useComputeGraphController.ts","../../src/hooks/useComputeNodeState.ts","../../src/hooks/useGraphMonitor.ts","../../src/hooks/useControllerUpdates.ts","../../src/graph/node-defs.ts","../../src/graph/controller.ts","../../src/graph/sync.ts","../../src/shapes/common/box-defs.ts","../../src/shapes/defs.ts","../../src/shapes/common/function-anchors.ts","../../src/shapes/common/Box.tsx","../../src/shapes/common/FunctionBody.tsx","../../src/shapes/common/TypeSelect.tsx","../../src/shapes/Append.tsx","../../src/shapes/append-def.ts","../../src/shapes/Array.tsx","../../src/shapes/array-def.ts","../../src/shapes/Audio.tsx","../../src/shapes/audio-def.ts","../../src/shapes/Beacon.tsx","../../src/shapes/beacon-def.ts","../../src/shapes/Chat.tsx","../../src/shapes/chat-def.tsx","../../src/shapes/Constant.tsx","../../src/shapes/constant-def.tsx","../../src/shapes/Database.tsx","../../src/shapes/database-def.ts","../../src/shapes/Feed.tsx","../../src/shapes/feed-def.ts","../../src/shapes/Function.tsx","../../src/shapes/function-def.ts","../../src/shapes/Gpt.tsx","../../src/shapes/gpt-def.ts","../../src/shapes/GptRealtime.tsx","../../src/shapes/gpt-realtime-def.ts","../../src/shapes/Json.tsx","../../src/shapes/json-def.ts","../../src/shapes/Logic.tsx","../../src/shapes/logic-def.ts","../../src/shapes/RNG.tsx","../../src/shapes/rng-def.ts","../../src/shapes/Scope.tsx","../../src/shapes/scope-def.ts","../../src/shapes/Surface.tsx","../../src/shapes/surface-def.ts","../../src/shapes/Switch.tsx","../../src/shapes/switch-def.ts","../../src/shapes/Table.tsx","../../src/shapes/table-def.ts","../../src/shapes/Template.tsx","../../src/shapes/template-def.ts","../../src/shapes/Text.tsx","../../src/shapes/text-def.ts","../../src/shapes/TextToImage.tsx","../../src/shapes/text-to-image-def.ts","../../src/shapes/Thread.tsx","../../src/shapes/thread-def.ts","../../src/shapes/trigger-spec.ts","../../src/shapes/Trigger.tsx","../../src/shapes/trigger-def.ts","../../src/shapes/Boolean.tsx","../../src/registry.ts","../../src/scene/Bullets.tsx","../../src/scene/NodeView.tsx","../../src/scene/ports.ts","../../src/scene/defs.ts","../../src/scene/echo-store.ts","../../src/scene/projection.ts","../../src/scene/scene.ts","../../src/compute-layout.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport { createContext, useContext } from 'react';\n\nimport { raise } from '@dxos/debug';\nimport { type ShapeRegistry } from '@dxos/react-ui-canvas-editor';\n\nimport type { ComputeGraphController } from '../graph/index.ts';\n\nexport type ComputeContextType = {\n controller: ComputeGraphController;\n /** Shape definitions for the frame chrome (icon, name, openable); the editor's own registry is the fallback. */\n registry?: ShapeRegistry;\n debug?: boolean;\n /** Grows or shrinks a shape by `delta` px (a function body opening); absent, the frame's element is resized. */\n resize?: (id: string, delta: number) => void;\n};\n\nexport const ComputeContext = createContext<ComputeContextType | null>(null);\n\nexport const useComputeContext = () => {\n return useContext(ComputeContext) ?? raise(new Error('Missing ComputeContext'));\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport { type RefObject, useEffect, useState } from 'react';\n\nimport { type CleanupFn } from '@dxos/async';\nimport { type EditorController, type EditorRootProps } from '@dxos/react-ui-canvas-editor';\n\nimport { type ComputeGraphController } from '../graph/index.ts';\nimport { type ComputeShape } from '../shapes/index.ts';\n\n// TODO(burdon): Move to async/context?\nconst combine = (...cbs: CleanupFn[]) => {\n return () => {\n for (const cb of cbs) {\n cb();\n }\n };\n};\n\nexport type UseComputeGraphControllerOptions = Pick<EditorRootProps<ComputeShape>, 'graph'> & {\n controller: ComputeGraphController | null;\n editorRef: RefObject<EditorController | null>;\n};\n\nexport const useComputeGraphController = ({ controller, graph, editorRef }: UseComputeGraphControllerOptions) => {\n const [, forceUpdate] = useState({});\n\n useEffect(() => {\n if (!controller || !graph) {\n return;\n }\n\n void controller.open();\n const off = combine(\n controller.update.on(() => {\n void editorRef.current?.update();\n forceUpdate({});\n }),\n\n // TODO(burdon): Every node is called on every update.\n controller.output.on(({ nodeId, property, value }) => {\n if (value.type === 'not-executed') {\n // If the node didn't execute, don't trigger.\n return;\n }\n\n const edge = graph.edges.find((edge) => {\n const source = graph.getNode(edge.source);\n return (source as ComputeShape).node === nodeId && edge.output === property;\n });\n\n if (edge) {\n void editorRef.current?.action?.({ type: 'trigger', edges: [edge] });\n }\n }),\n );\n\n return () => {\n void controller.close();\n off();\n };\n }, [graph, controller]);\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport { useCallback, useEffect, useState } from 'react';\n\nimport type { ComputeNode, ComputeNodeMeta } from '@dxos/conductor';\nimport { invariant } from '@dxos/invariant';\n\nimport { type ComputeEvent, type RuntimeValue } from '../graph/index.ts';\nimport { type ComputeShape } from '../shapes/index.ts';\nimport { useComputeContext } from './compute-context.ts';\n\nexport type ComputeNodeState = {\n node: ComputeNode;\n meta: ComputeNodeMeta;\n runtime: {\n inputs: Record<string, RuntimeValue>;\n outputs: Record<string, RuntimeValue>;\n setOutput: (property: string, value: any) => void;\n evalNode: () => void;\n subscribeToEventLog: (cb: (event: ComputeEvent) => void) => () => void;\n };\n};\n\n/**\n * Runtime state of a compute node.\n */\nexport const useComputeNodeState = (shape: ComputeShape): ComputeNodeState => {\n const { controller } = useComputeContext();\n invariant(controller);\n\n const [meta, setMeta] = useState<ComputeNodeMeta>();\n useEffect(() => {\n let disposed = false;\n queueMicrotask(async () => {\n invariant(shape.node, 'Node not specified');\n const node = controller.getComputeNode(shape.node);\n const meta = await controller.getMeta(node);\n if (disposed) {\n return;\n }\n\n setMeta(meta);\n });\n\n return () => {\n disposed = true;\n };\n }, [shape.node]);\n\n const evalNode = useCallback(() => {\n return controller.evalNode(shape.node!);\n }, [shape.node]);\n\n const subscribeToEventLog = useCallback(\n (cb: (event: ComputeEvent) => void): (() => void) => {\n return controller.events.on((ev) => {\n if (ev.nodeId === shape.node) {\n cb(ev);\n }\n });\n },\n [shape.node],\n );\n\n return {\n node: controller.getComputeNode(shape.node!),\n meta: meta ?? {\n input: Schema.Struct({}),\n output: Schema.Struct({}),\n },\n runtime: {\n inputs: controller.getInputs(shape.node!),\n outputs: controller.getOutputs(shape.node!),\n setOutput: (property: string, value: any) => {\n controller.setOutput(shape.node!, property, value);\n },\n evalNode,\n subscribeToEventLog,\n },\n };\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport { useMemo } from 'react';\n\nimport { type ComputeEdge, ComputeGraphModel, DEFAULT_INPUT, DEFAULT_OUTPUT } from '@dxos/conductor';\nimport { invariant } from '@dxos/invariant';\nimport { type CanvasBoard, type CanvasGraphModel, type GraphMonitor } from '@dxos/react-ui-canvas-editor';\n\nimport { deleteTriggerObjects, syncCreate, syncDelete, syncLink } from '../graph/index.ts';\nimport { type ComputeShape } from '../shapes/index.ts';\n\n/**\n * Map canvas edge to compute edge.\n */\nexport const mapEdge = (\n graph: CanvasGraphModel,\n { source, target, output = DEFAULT_OUTPUT, input = DEFAULT_INPUT }: CanvasBoard.Connection,\n): Omit<ComputeEdge, 'id'> => {\n const sourceNode = graph.findNode(source) as ComputeShape;\n const targetNode = graph.findNode(target) as ComputeShape;\n invariant(sourceNode?.node);\n invariant(targetNode?.node);\n\n return {\n source: sourceNode.node,\n target: targetNode.node,\n output,\n input,\n };\n};\n\n/**\n * Listens for changes to the graph and updates the compute graph.\n * @param model Compute graph to update on change.\n */\n// TODO(burdon): Generalize into sync function.\nexport const useGraphMonitor = (model?: ComputeGraphModel): GraphMonitor<ComputeShape> => {\n return useMemo<GraphMonitor<ComputeShape>>(() => {\n return {\n onCreate: ({ node }) => {\n if (!model) {\n return;\n }\n\n // Ignore shapes that don't have a corresponding node factory.\n const computeNode = syncCreate(model, node);\n if (computeNode) {\n node.node = computeNode.id;\n }\n },\n\n onLink: ({ graph, edge }) => {\n if (model) {\n syncLink(model, mapEdge(graph, edge));\n }\n },\n\n onDelete: ({ graph, subgraph }) => {\n if (model) {\n const shapes = subgraph.nodes as ComputeShape[];\n const nodeIds = shapes.map((shape) => shape.node).filter((id): id is string => id !== undefined);\n // An edge's far end may survive the deletion, so it is looked up in the whole graph.\n const computeId = (id: string) =>\n ((subgraph.findNode(id) ?? graph.findNode(id)) as ComputeShape | undefined)?.node ?? '';\n const links = subgraph.edges.map(({ source, target, output, input }) => ({\n source: computeId(source),\n target: computeId(target),\n output,\n input,\n }));\n syncDelete(model, nodeIds, links);\n deleteTriggerObjects(model, shapes);\n }\n },\n };\n }, [model]);\n};\n\nexport const createComputeGraph = (graph?: CanvasGraphModel<ComputeShape>) => {\n const computeGraph = ComputeGraphModel.create();\n\n if (graph) {\n for (const shape of graph.nodes) {\n const node = syncCreate(computeGraph, shape);\n if (node) {\n shape.node = node.id;\n }\n }\n\n for (const edge of graph.edges) {\n syncLink(computeGraph, mapEdge(graph, edge));\n }\n }\n\n return computeGraph;\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport { useEffect, useReducer } from 'react';\n\nimport { type ComputeGraphController } from '../graph/index.ts';\n\n/** Re-renders the caller on every controller update, since the runtime state components read is not reactive. */\nexport const useControllerUpdates = (controller: ComputeGraphController): void => {\n const [, bump] = useReducer((count: number) => count + 1, 0);\n useEffect(() => controller.update.on(() => bump()), [controller]);\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport {\n type ComputeNode,\n type Executable,\n NODE_INPUT,\n NODE_OUTPUT,\n type NodeType,\n getTemplateInputSchema,\n registry,\n} from '@dxos/conductor';\nimport { raise } from '@dxos/debug';\nimport { JsonSchema, Obj } from '@dxos/echo';\nimport { invariant } from '@dxos/invariant';\n\nimport { type ComputeShape, type ConstantShape, type TemplateShape } from '../shapes/index.ts';\n\nexport const resolveComputeNode = async (node: ComputeNode): Promise<Executable> => {\n const impl = registry[node.type as NodeType];\n invariant(impl, `Unknown node type: ${node.type}`);\n return impl;\n};\n\nexport const isValidComputeNode = (type: string): boolean => {\n return nodeFactory[type as NodeType] !== undefined;\n};\n\nexport const createComputeNode = (shape: ComputeShape): ComputeNode => {\n const type = shape.type ?? raise(new Error('Type not specified'));\n const factory = nodeFactory[type as NodeType] ?? raise(new Error(`Unknown shape type: ${type}`));\n return factory(shape);\n};\n\nconst nodeFactory: Record<NodeType | 'trigger', (shape: ComputeShape) => ComputeNode> = {\n // System.\n [NODE_INPUT]: () => createNode(NODE_INPUT),\n [NODE_OUTPUT]: () => createNode(NODE_OUTPUT),\n\n // Extensions.\n 'text-to-image': () => createNode('text-to-image'), // TODO(burdon): Rename ai-impage-tool\n 'and': () => createNode('and'),\n 'append': () => createNode('append'),\n 'audio': () => createNode('audio'),\n 'beacon': () => createNode('beacon'),\n 'chat': () => createNode('chat'),\n 'constant': (shape) =>\n createNode('constant', {\n value: (shape as ConstantShape).value,\n }),\n 'make-queue': () => createNode('make-queue'),\n 'database': () => createNode('database'),\n 'gpt': () => createNode('gpt'),\n 'gpt-realtime': () => createNode('gpt-realtime'),\n 'if': () => createNode('if'),\n 'if-else': () => createNode('if-else'),\n 'function': () => createNode('function'),\n 'json': () => createNode('json'),\n 'json-transform': () => createNode('json-transform'),\n 'not': () => createNode('not'),\n 'or': () => createNode('or'),\n 'queue': () => createNode('queue'),\n 'rng': () => createNode('rng'),\n 'reducer': () => createNode('reducer'),\n 'scope': () => createNode('scope'),\n 'surface': () => createNode('surface'),\n 'switch': () => createNode('switch'),\n 'template': (shape) => {\n const node = createNode('template', { valueType: (shape as TemplateShape).valueType, value: shape.text });\n // `toJsonSchema` reuses cached fragments (e.g. the `Schema.Any` JSON form) across calls; deep-copy so each\n // ECHO node owns its own schema record rather than reassigning ownership of a shared one.\n node.inputSchema = structuredClone(JsonSchema.toJsonSchema(getTemplateInputSchema(node)));\n return node;\n },\n 'text': () => createNode('text'),\n 'thread': () => createNode('thread'),\n 'trigger': () => createNode(NODE_INPUT),\n};\n\nconst createNode = (type: string, props?: Partial<ComputeNode>): ComputeNode => ({\n id: Obj.ID.random(),\n type,\n ...props,\n});\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport * as Exit from 'effect/Exit';\nimport * as Layer from 'effect/Layer';\nimport * as Result from 'effect/Result';\nimport * as Scope from 'effect/Scope';\n\nimport type { AiService } from '@dxos/ai';\nimport { Event, synchronized } from '@dxos/async';\nimport type * as Credential from '@dxos/compute/Credential';\nimport type * as Operation from '@dxos/compute/Operation';\nimport * as Trace from '@dxos/compute/Trace';\nimport {\n ComputeBeginEvent,\n ComputeCustomEvent,\n type ComputeEdge,\n ComputeEndEvent,\n type ComputeGraphModel,\n ComputeInputEvent,\n type ComputeNode,\n type ComputeNodeMeta,\n ComputeOutputEvent,\n type GptInput,\n type GptOutput,\n type GraphDiagnostic,\n GraphExecutor,\n ValueBag,\n layerNoop as computeNodeContextLayerNoop,\n isNotExecuted,\n} from '@dxos/conductor';\nimport { Resource } from '@dxos/context';\nimport type { Database, Registry } from '@dxos/echo';\nimport * as EffectEx from '@dxos/effect/EffectEx';\nimport { log } from '@dxos/log';\nimport { type CanvasGraphModel } from '@dxos/react-ui-canvas-editor';\nimport { type ContentBlock } from '@dxos/types';\n\nimport { createComputeGraph } from '../hooks/index.ts';\nimport { type ComputeShape } from '../shapes/index.ts';\nimport { resolveComputeNode } from './node-defs.ts';\n\n// TODO(burdon): API package for conductor.\nexport const InvalidStateError = Error;\n\nexport type FunctionCallback<INPUT, OUTPUT> = (input: INPUT) => Promise<OUTPUT>;\n\n/**\n * Callback to notify the controller of a scheduled update.\n */\nexport type AsyncUpdate<T> = (value: T) => void;\n\nexport interface GptExecutor {\n invoke: FunctionCallback<GptInput, GptOutput>;\n\n // TODO(dmaretskyi): A hack to get image artifacts working. Rework into querying images from the ai-service store.\n imageCache: Map<string, ContentBlock.Image>;\n}\n\nexport type RuntimeValue =\n | {\n type: 'not-executed'; // TODO(burdon): Different from pending?\n }\n | {\n type: 'executed';\n value: any;\n }\n | {\n type: 'pending';\n }\n | {\n type: 'error';\n error: string;\n };\n\ntype ComputeOutputEvent = {\n nodeId: string;\n property: string;\n value: RuntimeValue;\n};\n\n/**\n * Event emitted by the compute graph during execution.\n */\nexport type ComputeEvent =\n | { type: 'begin-compute'; nodeId: string; inputs: ReadonlyArray<string> }\n | { type: 'end-compute'; nodeId: string; outputs: ReadonlyArray<string> }\n | { type: 'compute-input'; nodeId: string; property: string; value: any }\n | { type: 'compute-output'; nodeId: string; property: string; value: any }\n | { type: 'custom'; nodeId: string; event: any };\n\n// TODO(dmaretskyi): Re-use function servies definition.\nexport type ComputeServices =\n | AiService.AiService\n | Database.Service\n | Credential.CredentialsService\n | Operation.Service\n | Registry.Service;\n\n/**\n * Nodes that will automatically trigger the execution of the graph on startup.\n */\nconst AUTO_TRIGGER_NODES = ['chat', 'switch', 'constant'];\n\n/**\n * Minimal runtime interface required by the {@link ComputeGraphController}.\n *\n * Satisfied by both `effect/ManagedRuntime.ManagedRuntime` and ad-hoc adapters\n * built on top of the app-framework `ProcessManagerRuntime`.\n */\nexport interface ComputeGraphRuntime {\n runPromiseExit<A, E>(effect: Effect.Effect<A, E, ComputeServices>): Promise<Exit.Exit<A, E>>;\n}\n\nexport const createComputeGraphController = (\n graph: CanvasGraphModel<ComputeShape>,\n computeRuntime: ComputeGraphRuntime,\n) => {\n const computeGraph = createComputeGraph(graph);\n const controller = new ComputeGraphController(computeRuntime, computeGraph);\n return { controller, graph };\n};\n\n/**\n * Controller that manages compute graph state, execution, and service coordination.\n */\nexport class ComputeGraphController extends Resource {\n private readonly _executor = new GraphExecutor({\n computeNodeResolver: (node) => resolveComputeNode(node),\n });\n\n private _diagnostics: GraphDiagnostic[] = [];\n\n /**\n * Canvas force-sets outputs of those nodes.\n */\n private _forcedOutputs: Record<string, Record<string, unknown>> = {};\n\n /**\n * Runtime state of the execution graph.\n */\n private _runtimeStateInputs: Record<string, Record<string, RuntimeValue>> = {};\n\n private _runtimeStateOutputs: Record<string, Record<string, RuntimeValue>> = {};\n\n // TODO(burdon): Remove? Make state reactive?\n public readonly update = new Event();\n\n /** Computed result. */\n public readonly output = new Event<ComputeOutputEvent>();\n\n public readonly events = new Event<ComputeEvent>();\n\n constructor(\n private readonly _computeRuntime: ComputeGraphRuntime,\n /** Persistent compute graph. */\n private readonly _graph: ComputeGraphModel,\n ) {\n super();\n }\n\n /**\n * Runs the graph once so a circuit shows its state as soon as it is opened; without this the\n * trigger nodes only ever fire from {@link setOutput}, leaving a freshly loaded graph inert.\n */\n protected override async _open(): Promise<void> {\n try {\n await this.exec();\n } catch (err) {\n log.catch(err);\n }\n }\n\n toJSON() {\n return {\n graph: this._graph,\n state: {\n inputs: this._runtimeStateInputs,\n outputs: this._runtimeStateOutputs,\n },\n forcedOutputs: this._forcedOutputs,\n };\n }\n\n get graph() {\n return this._graph;\n }\n\n get diagnostics() {\n return this._diagnostics;\n }\n\n get userState() {\n return this._forcedOutputs;\n }\n\n get inputStates() {\n return this._runtimeStateInputs;\n }\n\n get outputStates() {\n return this._runtimeStateOutputs;\n }\n\n /**\n * Inputs and outputs for all nodes.\n */\n get state(): Record<\n string,\n {\n node: ComputeNode;\n input: Record<string, RuntimeValue>;\n output: Record<string, RuntimeValue>;\n }\n > {\n const ids = [...new Set([...Object.keys(this._runtimeStateInputs), ...Object.keys(this._runtimeStateOutputs)])];\n return Object.fromEntries(\n ids.map((id) => [\n id,\n {\n node: this._graph.getNode(id),\n input: this._runtimeStateInputs[id],\n output: this._runtimeStateOutputs[id],\n },\n ]),\n );\n }\n\n addNode(node: ComputeNode): void {\n this._graph.addNode(node);\n }\n\n addEdge(edge: ComputeEdge): void {\n this._graph.addEdge(edge);\n }\n\n getComputeNode(nodeId: string): ComputeNode {\n return this._graph.getNode(nodeId);\n }\n\n getInputs(nodeId: string): Record<string, RuntimeValue> {\n return this._runtimeStateInputs[nodeId] ?? {};\n }\n\n getOutputs(nodeId: string): Record<string, RuntimeValue> {\n return this._runtimeStateOutputs[nodeId] ?? {};\n }\n\n setOutput(nodeId: string, property: string, value: any): void {\n this._forcedOutputs[nodeId] ??= {};\n this._forcedOutputs[nodeId][property] = value;\n\n queueMicrotask(async () => {\n try {\n await this.exec(nodeId);\n } catch (err) {\n log.catch(err);\n }\n });\n }\n\n async getMeta(node: ComputeNode): Promise<ComputeNodeMeta> {\n const { meta } = await resolveComputeNode(node);\n return meta;\n }\n\n @synchronized\n async checkGraph(): Promise<void> {\n const executor = this._executor.clone();\n await executor.load(this._graph);\n this._diagnostics = executor.getDiagnostics();\n }\n\n async evalNode(nodeId: string): Promise<void> {\n const executor = this._executor.clone();\n await executor.load(this._graph);\n\n for (const [nodeId, outputs] of Object.entries(this._forcedOutputs)) {\n executor.setOutputs(nodeId, Effect.succeed(ValueBag.make(outputs)));\n }\n\n EffectEx.unwrapExit(\n await this._computeRuntime.runPromiseExit(\n Effect.gen({ self: this }, function* () {\n const scope = yield* Scope.make();\n\n // TODO(dmaretskyi): Code duplication.\n const executable = yield* Effect.promise(() => resolveComputeNode(this._graph.getNode(nodeId)));\n const computingOutputs = executable.exec != null;\n // TODO(dmaretskyi): Check if the node has a compute function and run computeOutputs if it does.\n const effect = (computingOutputs ? executor.computeOutputs(nodeId) : executor.computeInputs(nodeId)).pipe(\n Effect.withSpan('runGraph'),\n Scope.provide(scope),\n Effect.provide(\n Layer.mergeAll(Layer.succeed(Trace.TraceService, this._createTraceWriter()), computeNodeContextLayerNoop),\n ),\n Effect.flatMap(computeValueBag),\n Effect.withSpan('test'),\n // v4's `tap` requires the callback to return an `Effect`.\n Effect.tap((values) =>\n Effect.sync(() => {\n for (const [key, value] of Object.entries(values)) {\n if (computingOutputs) {\n this._onOutputComputed(nodeId, key, value);\n } else {\n this._onInputComputed(nodeId, key, value);\n }\n }\n }),\n ),\n );\n\n yield* effect;\n\n yield* Scope.close(scope, Exit.void);\n }),\n ),\n );\n\n this.update.emit();\n }\n\n /**\n * Executes the graph.\n * @param startFromNode - Node to start from, otherwise all {@link AUTO_TRIGGER_NODES} are executed.\n */\n @synchronized\n async exec(startFromNode?: string): Promise<void> {\n this._runtimeStateInputs = {};\n this._runtimeStateOutputs = {};\n const executor = this._executor.clone();\n await executor.load(this._graph);\n\n for (const [nodeId, outputs] of Object.entries(this._forcedOutputs)) {\n executor.setOutputs(nodeId, Effect.succeed(ValueBag.make(outputs)));\n }\n\n // TODO(dmaretskyi): Stop hardcoding.\n const triggerNodes =\n startFromNode != null\n ? [this._graph.getNode(startFromNode)]\n : this._graph.nodes.filter((node) => node.type != null && AUTO_TRIGGER_NODES.includes(node.type));\n const allAffectedNodes = [...new Set(triggerNodes.flatMap((node) => executor.getAllDependantNodes(node.id)))];\n\n EffectEx.unwrapExit(\n await this._computeRuntime.runPromiseExit(\n Effect.gen({ self: this }, function* () {\n const scope = yield* Scope.make();\n\n // TODO(burdon): Return map?\n const tasks: Effect.Effect<unknown, any, ComputeServices>[] = [];\n for (const node of allAffectedNodes) {\n // TODO(dmaretskyi): Code duplication.\n const executable = yield* Effect.promise(() => resolveComputeNode(this._graph.getNode(node)));\n const computingOutputs = executable.exec != null;\n\n // TODO(dmaretskyi): Check if the node has a compute function and run computeOutputs if it does.\n const effect = (computingOutputs ? executor.computeOutputs(node) : executor.computeInputs(node)).pipe(\n Effect.withSpan('runGraph'),\n Scope.provide(scope),\n Effect.flatMap(computeValueBag),\n Effect.provide(\n Layer.mergeAll(\n Layer.succeed(Trace.TraceService, this._createTraceWriter()),\n computeNodeContextLayerNoop,\n ),\n ),\n\n Effect.withSpan('test'),\n Effect.tap((values) =>\n Effect.sync(() => {\n for (const [key, value] of Object.entries(values)) {\n if (computingOutputs) {\n this._onOutputComputed(node, key, value);\n } else {\n this._onInputComputed(node, key, value);\n }\n }\n }),\n ),\n );\n\n tasks.push(effect);\n }\n\n //\n yield* Effect.all(tasks);\n\n //\n yield* Scope.close(scope, Exit.void);\n }),\n ),\n );\n\n this.update.emit();\n }\n\n private _createTraceWriter(): Trace.Writer {\n return {\n write: (eventType, payload) => {\n const event = traceEventToComputeEvent(eventType.key, payload);\n if (event) {\n this._handleEvent(event);\n }\n },\n };\n }\n\n private _handleEvent(event: ComputeEvent): void {\n log('handleEvent', { event });\n switch (event.type) {\n case 'compute-input': {\n this._onInputComputed(event.nodeId, event.property, { type: 'executed', value: event.value });\n break;\n }\n\n case 'compute-output': {\n this._onOutputComputed(event.nodeId, event.property, { type: 'executed', value: event.value });\n break;\n }\n }\n this.events.emit(event);\n }\n\n private _onInputComputed(nodeId: string, property: string, value: RuntimeValue): void {\n this._runtimeStateInputs[nodeId] ??= {};\n this._runtimeStateInputs[nodeId][property] = value;\n }\n\n private _onOutputComputed(nodeId: string, property: string, value: RuntimeValue): void {\n this._runtimeStateOutputs[nodeId] ??= {};\n this._runtimeStateOutputs[nodeId][property] = value;\n\n // TODO(burdon): Only fire if changed?\n this.output.emit({ nodeId, property, value });\n }\n}\n\nconst traceEventToComputeEvent = (key: string, payload: unknown): ComputeEvent | undefined => {\n switch (key) {\n case ComputeBeginEvent.key:\n return { type: 'begin-compute', ...(payload as { nodeId: string; inputs: ReadonlyArray<string> }) };\n case ComputeEndEvent.key:\n return { type: 'end-compute', ...(payload as { nodeId: string; outputs: ReadonlyArray<string> }) };\n case ComputeInputEvent.key:\n return { type: 'compute-input', ...(payload as { nodeId: string; property: string; value: any }) };\n case ComputeOutputEvent.key:\n return { type: 'compute-output', ...(payload as { nodeId: string; property: string; value: any }) };\n case ComputeCustomEvent.key:\n return { type: 'custom', ...(payload as { nodeId: string; event: any }) };\n default:\n return undefined;\n }\n};\n\n/**\n * Waits for all effects in the bag to complete and returns the `RuntimeValue` for each property.\n */\nconst computeValueBag = (bag: ValueBag<any>): Effect.Effect<Record<string, RuntimeValue>, never, never> => {\n return Effect.all(\n Object.entries(bag.values).map(([key, eff]) =>\n Effect.result(eff).pipe(\n Effect.map((value) => {\n if (Result.isFailure(value)) {\n if (isNotExecuted(value.failure)) {\n return [key, { type: 'not-executed' }] as const;\n } else {\n return [key, { type: 'error', error: value.failure }] as const;\n }\n } else {\n return [key, { type: 'executed', value: value.success }] as const;\n }\n }),\n ),\n ),\n ).pipe(Effect.map((entries) => Object.fromEntries(entries) as Record<string, RuntimeValue>));\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\n//\n// Mirrors canvas edits into the compute graph, shared by the editor's `GraphMonitor` and the scene\n// engine's compute projection so both surfaces keep one compute node per shape and one edge per link.\n//\n\nimport { type ComputeEdge, ComputeGraphModel, type ComputeNode, DEFAULT_INPUT, DEFAULT_OUTPUT } from '@dxos/conductor';\nimport { Obj, Ref } from '@dxos/echo';\nimport { invariant } from '@dxos/invariant';\n\nimport { type ComputeShape, type TriggerShape } from '../shapes/index.ts';\nimport { createComputeNode, isValidComputeNode } from './node-defs.ts';\n\n/**\n * A compute node for the shape, added to the model; the shape's `node` is what it returns. `id` keeps\n * a known compute id, so a shape restored by undo gets back the node its links name.\n */\nexport const syncCreate = (model: ComputeGraphModel, shape: ComputeShape, id?: string): ComputeNode | undefined => {\n invariant(shape.type);\n if (!isValidComputeNode(shape.type)) {\n return undefined;\n }\n const computeNode = { ...createComputeNode(shape), ...(id ? { id } : {}) };\n if (shape.type === 'trigger') {\n linkTriggerToCompute(model, computeNode, shape as TriggerShape);\n }\n model.addNode(computeNode);\n return computeNode;\n};\n\nexport type ComputeLink = {\n /** Compute node ids. */\n source: string;\n target: string;\n output?: string;\n input?: string;\n};\n\n/** The compute edge for a link between two compute nodes. */\nexport const syncLink = (\n model: ComputeGraphModel,\n { source, target, output = DEFAULT_OUTPUT, input = DEFAULT_INPUT }: ComputeLink,\n): ComputeEdge => {\n const edge: ComputeEdge = { id: Obj.ID.random(), source, target, output, input };\n model.addEdge(edge);\n return edge;\n};\n\n/**\n * The compute edge a link stands for, passing over `claimed` ids so parallel links with the same ends\n * and ports match distinct edges.\n */\nexport const findEdge = (\n model: ComputeGraphModel,\n { source, target, output = DEFAULT_OUTPUT, input = DEFAULT_INPUT }: ComputeLink,\n claimed: ReadonlySet<string> = new Set(),\n): ComputeEdge | undefined =>\n model.edges.find(\n (edge) =>\n !claimed.has(edge.id) &&\n edge.source === source &&\n edge.target === target &&\n edge.output === output &&\n edge.input === input,\n );\n\n/** The ids of the edges the links stand for, each edge claimed once. */\nexport const findEdges = (model: ComputeGraphModel, links: ComputeLink[]): string[] => {\n const claimed = new Set<string>();\n for (const link of links) {\n const edge = findEdge(model, link, claimed);\n if (edge) {\n claimed.add(edge.id);\n }\n }\n return [...claimed];\n};\n\n/** Removes the compute nodes and the compute edges that mirror the deleted shapes and links. */\nexport const syncDelete = (model: ComputeGraphModel, nodeIds: string[], links: ComputeLink[]): void => {\n const edgeIds = findEdges(model, links);\n model.removeNodes(nodeIds);\n model.removeEdges(edgeIds);\n};\n\nconst linkTriggerToCompute = (graph: ComputeGraphModel, computeNode: ComputeNode, triggerData: TriggerShape) => {\n const functionTrigger = triggerData.functionTrigger?.target;\n // A restored trigger whose object was removed with it keeps its node but cannot be wired.\n if (!functionTrigger) {\n return;\n }\n Obj.update(functionTrigger, (functionTrigger) => {\n // TODO(wittjosiah): Widen Runnable union to include ComputeGraph and remove cast.\n functionTrigger.runnable = Ref.make(graph.root) as any;\n functionTrigger.inputNodeId = computeNode.id;\n });\n};\n\n/** A deleted trigger shape takes its function trigger object with it. */\nexport const deleteTriggerObjects = (computeGraph: ComputeGraphModel, shapes: ComputeShape[]) => {\n const db = Obj.getDatabase(computeGraph.root);\n if (!db) {\n return;\n }\n for (const shape of shapes) {\n if (shape.type === 'trigger') {\n const trigger = shape as TriggerShape;\n if (trigger.functionTrigger?.target) {\n db.remove(trigger.functionTrigger.target);\n }\n }\n }\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport { DEFAULT_GRID } from '@dxos/react-ui-canvas/scene';\n\n// Kept out of `Box.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\n/**\n * The box's chrome, in whole grid cells rather than a pixel count of its own, so a shape sized from it\n * lands on the same lines the canvas draws and snaps to.\n */\nexport const headerHeight = 2 * DEFAULT_GRID;\n\nexport const footerHeight = 2 * DEFAULT_GRID;\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { DEFAULT_INPUT, DEFAULT_OUTPUT } from '@dxos/conductor';\nimport { Obj } from '@dxos/echo';\nimport * as SchemaAST from '@dxos/effect/SchemaAST';\nimport { Polygon } from '@dxos/react-ui-canvas-editor';\nimport { type MakeOptional } from '@dxos/util';\n\n//\n// Properties\n//\n\nexport type PropertyKind = 'input' | 'output';\n\nexport const getProperties = (ast: SchemaAST.AST) =>\n SchemaAST.getPropertySignatures(ast).map(({ name }) => ({ name: name.toString() }));\n\nexport const createAnchorId = (kind: PropertyKind, property = kind === 'input' ? DEFAULT_INPUT : DEFAULT_OUTPUT) =>\n [kind, property].join('.');\n\nexport const parseAnchorId = (id: string): [PropertyKind | undefined, string] => {\n const parts = id.match(/(input|output)\\.(.+)/);\n return parts ? (parts.slice(1) as any) : [undefined, id];\n};\n\n//\n// Shapes\n//\n\nexport type CreateShapeProps<S extends Polygon> = Omit<MakeOptional<S, 'id' | 'size'>, 'type' | 'node'>;\n\nexport const ComputeShape = Polygon.mapFields(\n Struct.assign({\n // TODO(burdon): Rename computeNode?\n node: Schema.mutableKey(Schema.optional(Obj.ID.annotate({ description: 'Compute node id' }))),\n }),\n);\n\nexport type ComputeShape = Schema.Schema.Type<typeof ComputeShape>;\n\nexport const createShape = <S extends ComputeShape>({ id, ...rest }: CreateShapeProps<S> & { type: string }): S => {\n return {\n id: id ?? Obj.ID.random(),\n ...rest,\n } as S;\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport type * as Schema from 'effect/Schema';\n\nimport { VoidInput, VoidOutput } from '@dxos/conductor';\nimport * as SchemaAST from '@dxos/effect/SchemaAST';\nimport { type Polygon } from '@dxos/react-ui-canvas-editor';\nimport { createAnchors, rowHeight } from '@dxos/react-ui-canvas-editor';\nimport { DEFAULT_GRID } from '@dxos/react-ui-canvas/scene';\n\nimport { footerHeight, headerHeight } from '../common/index.ts';\nimport { createAnchorId } from '../defs.ts';\n\n// Kept out of `FunctionBody.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\n/** Vertical padding inside the function body; the height maths below depends on it. */\nexport const bodyPadding = 8;\n\n/**\n * A function shape's height: the chrome plus a body grown to a whole number of grid cells. One row per\n * input is a floor on the body rather than its height, so the box lands on the grid whatever its schema\n * declares — the rows used to set it exactly, and `rowHeight` divides into no grid cell.\n */\nexport const getHeight = (input: Schema.Schema<any>, unit = DEFAULT_GRID) => {\n const properties = SchemaAST.getPropertySignatures(input.ast);\n const minBody = bodyPadding * 2 + properties.length * rowHeight + 2; // Incl. borders.\n return headerHeight + footerHeight + Math.ceil(minBody / unit) * unit;\n};\n\nexport const createFunctionAnchors = (\n shape: Polygon,\n input: Schema.Schema<any> = VoidInput,\n output: Schema.Schema<any> = VoidOutput,\n) => {\n // TODO(burdon): Set type.\n const inputs = SchemaAST.getPropertySignatures(input.ast).map(({ name }) => createAnchorId('input', name.toString()));\n const outputs = SchemaAST.getPropertySignatures(output.ast).map(({ name }) =>\n createAnchorId('output', name.toString()),\n );\n return createAnchors({ shape, inputs, outputs, center: { x: 0, y: (headerHeight - footerHeight) / 2 + 1 } });\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { type PropsWithChildren, type ReactNode, forwardRef } from 'react';\n\nimport { invariant } from '@dxos/invariant';\nimport { log } from '@dxos/log';\nimport * as Button from '@dxos/react-ui/Button';\nimport * as Icon from '@dxos/react-ui/Icon';\nimport type * as Util from '@dxos/react-ui/Util';\nimport { mx } from '@dxos/ui-theme';\n\nimport { useComputeContext } from '../../hooks/compute-context.ts';\nimport { type ComputeShape } from '../defs.ts';\n\nexport type BoxActionHandler = (action: 'open' | 'close') => void;\n\nexport type BoxProps = PropsWithChildren<\n Util.ThemedClassName<{\n shape: ComputeShape;\n title?: string;\n status?: string | ReactNode;\n open?: boolean;\n onAction?: BoxActionHandler;\n }>\n>;\n\nexport const Box = forwardRef<HTMLDivElement, BoxProps>(\n ({ children, classNames, shape, title, status, open, onAction }, forwardedRef) => {\n invariant(shape.type);\n // The chrome comes from the host's registry, whichever surface the shape is mounted in.\n const { controller, registry, debug = false } = useComputeContext();\n const { icon, name, openable } = registry?.getShapeDef(shape.type) ?? { icon: 'ph--circle-dashed--regular' };\n\n // Running a node propagates to everything downstream of it, which is what the button means; a shape\n // with no compute node behind it has nothing to run, so it does not get one.\n const nodeId = shape.node;\n const handleRun = () => {\n controller.exec(nodeId).catch((err) => log.catch(err));\n };\n\n return (\n <div ref={forwardedRef} className='flex flex-col dx-fill justify-between'>\n <div className='flex shrink-0 w-full justify-between items-center h-[32px] dx-input-surface'>\n <Icon.Icon icon={icon} classNames='mx-2' />\n <div className='grow text-sm truncate'>{debug ? shape.type : (name ?? shape.text ?? title)}</div>\n {nodeId && (\n <Button.Root\n classNames='p-1 text-green-500'\n variant='ghost'\n icon='ph--play--regular'\n label='run'\n iconOnly\n onPointerDown={(ev) => ev.stopPropagation()}\n onDoubleClick={(ev) => ev.stopPropagation()}\n onClick={(ev) => {\n ev.stopPropagation();\n handleRun();\n }}\n />\n )}\n </div>\n <div className={mx('flex flex-col h-full grow overflow-hidden', classNames)}>{children}</div>\n <div className='flex shrink-0 w-full justify-between items-center h-[32px] dx-input-surface'>\n <div className='grow px-2 text-sm truncate'>{debug ? shape.id : status}</div>\n {openable && (\n <Button.Root\n classNames='p-1'\n variant='ghost'\n icon={open ? 'ph--caret-up--regular' : 'ph--caret-down--regular'}\n label={open ? 'close' : 'open'}\n iconOnly\n onClick={(ev) => {\n ev.stopPropagation();\n onAction?.(open ? 'close' : 'open');\n }}\n />\n )}\n </div>\n </div>\n );\n },\n);\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport type * as Schema from 'effect/Schema';\nimport React, { type JSX, useRef, useState } from 'react';\n\nimport { VoidInput, VoidOutput } from '@dxos/conductor';\nimport { getParentShapeElement, rowHeight } from '@dxos/react-ui-canvas-editor';\n\nimport { useComputeContext } from '../../hooks/compute-context.ts';\nimport { Box, type BoxProps } from '../common/index.ts';\nimport { type ComputeShape, getProperties } from '../defs.ts';\nimport { bodyPadding } from './function-anchors.ts';\n\nconst expandedHeight = 200;\n\nexport type FunctionBodyProps = {\n shape: ComputeShape;\n name?: string;\n content?: JSX.Element;\n inputSchema?: Schema.Top;\n outputSchema?: Schema.Top;\n} & Pick<BoxProps, 'status'>;\n\n// TODO(wittjosiah): Rename, not used for functions.\nexport const FunctionBody = ({\n shape,\n name,\n content,\n inputSchema = VoidInput,\n outputSchema = VoidOutput,\n ...props\n}: FunctionBodyProps) => {\n // Opening grows the shape: through the host's `resize` when it offers one (the scene engine, where size\n // is model state), else by stretching the editor's frame element as the canvas editor always did.\n const { resize } = useComputeContext();\n const rootRef = useRef<HTMLDivElement>(null);\n const [open, setOpen] = useState(false);\n\n const handleAction: BoxProps['onAction'] = (action) => {\n const opening = action === 'open';\n if (resize) {\n resize(shape.id, opening ? expandedHeight : -expandedHeight);\n } else if (rootRef.current) {\n const element = getParentShapeElement(rootRef.current, shape.id);\n if (element) {\n // The layout height is already in canvas units, whatever the zoom.\n element.style.height = opening ? `${element.offsetHeight + expandedHeight}px` : '';\n }\n }\n setOpen(opening);\n };\n\n // TODO(burdon): Move labels to anchor?\n const inputs = getProperties(inputSchema.ast);\n const outputs = getProperties(outputSchema.ast);\n const columnCount = inputs.length && outputs.length ? 2 : 1;\n\n return (\n <Box\n ref={rootRef}\n shape={shape}\n title={name}\n classNames='divide-y divide-separator-subtle'\n open={open}\n onAction={handleAction}\n {...props}\n >\n <div\n className={`grid grid-cols-${columnCount} items-center`}\n style={{ paddingTop: bodyPadding, paddingBottom: bodyPadding }}\n >\n {(inputs?.length ?? 0) > 0 && (\n <div className='flex flex-col'>\n {inputs?.map(({ name }) => (\n <div key={name} className='px-2 truncate text-sm font-mono items-center' style={{ height: rowHeight }}>\n {name}\n </div>\n ))}\n </div>\n )}\n {(outputs?.length ?? 0) > 0 && (\n <div className='flex flex-col'>\n {outputs?.map(({ name }) => (\n <div\n key={name}\n className='px-2 truncate text-sm font-mono items-center text-right'\n style={{ height: rowHeight }}\n >\n {name}\n </div>\n ))}\n </div>\n )}\n </div>\n {open && <div className='flex flex-col grow overflow-hidden'>{content}</div>}\n </Box>\n );\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport React from 'react';\n\nimport { ComputeValueType } from '@dxos/conductor';\nimport * as Select from '@dxos/react-ui/Select';\n\n// TODO(burdon): Factor out.\nexport type TypeSelectProps = {\n value?: ComputeValueType;\n onValueChange: (value: ComputeValueType) => void;\n};\n\nexport const TypeSelect = ({ value, onValueChange }: TypeSelectProps) => {\n return (\n <Select.Root\n value={value === undefined ? [] : [value]}\n onValueChange={({ value: [next] }) => {\n const type = ComputeValueType.literals.find((literal) => literal === next);\n if (type) {\n onValueChange(type);\n }\n }}\n items={ComputeValueType.literals.map((type) => ({ value: type, label: type }))}\n >\n <Select.Trigger classNames='w-full px-0!' />\n <Select.Content>\n {ComputeValueType.literals.map((type) => (\n <Select.Item key={type} item={{ value: type, label: type }} />\n ))}\n </Select.Content>\n </Select.Root>\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport { AppendInput } from '@dxos/conductor';\nimport { type ShapeComponentProps } from '@dxos/react-ui-canvas-editor';\n\nimport { type AppendShape } from './append-def.ts';\nimport { FunctionBody } from './common/index.ts';\n\nexport const AppendComponent = ({ shape }: ShapeComponentProps<AppendShape>) => {\n return <FunctionBody shape={shape} inputSchema={AppendInput} />;\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { AppendInput } from '@dxos/conductor';\nimport { type ShapeDef } from '@dxos/react-ui-canvas-editor';\n\nimport { AppendComponent } from './Append.tsx';\nimport { createFunctionAnchors, getHeight } from './common/index.ts';\nimport { ComputeShape, type CreateShapeProps, createShape } from './defs.ts';\n\n// Kept out of `Append.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\nexport const AppendShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('append'),\n }),\n);\n\nexport type AppendShape = Schema.Schema.Type<typeof AppendShape>;\n\nexport type CreateAppendProps = CreateShapeProps<AppendShape>;\n\nexport const createAppend = (props: CreateAppendProps) =>\n createShape<AppendShape>({\n type: 'append',\n size: { width: 128, height: getHeight(AppendInput) },\n ...props,\n });\n\nexport const appendShape: ShapeDef<AppendShape> = {\n type: 'append',\n name: 'Append',\n icon: 'ph--list-plus--regular',\n component: AppendComponent,\n createShape: createAppend,\n getAnchors: (shape) => createFunctionAnchors(shape, AppendInput),\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport { ReducerInput, ReducerOutput } from '@dxos/conductor';\nimport { type ShapeComponentProps } from '@dxos/react-ui-canvas-editor';\n\nimport { type ReducerShape } from './array-def.ts';\nimport { FunctionBody } from './common/index.ts';\n\n//\n// Components\n//\n\nexport type ReducerComponentProps = ShapeComponentProps<ReducerShape>;\n\nexport const ReducerComponent = ({ shape }: ReducerComponentProps) => {\n return <FunctionBody shape={shape} inputSchema={ReducerInput} outputSchema={ReducerOutput} />;\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { ReducerInput, ReducerOutput } from '@dxos/conductor';\nimport { type ShapeDef } from '@dxos/react-ui-canvas-editor';\n\nimport { ReducerComponent } from './Array.tsx';\nimport { createFunctionAnchors, getHeight } from './common/index.ts';\nimport { ComputeShape, type CreateShapeProps, createShape } from './defs.ts';\n\n// Kept out of `Array.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\n//\n// Data\n//\n\nexport const ReducerShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('reducer'),\n }),\n);\n\nexport type ReducerShape = Schema.Schema.Type<typeof ReducerShape>;\n\n//\n// Defs\n//\n\nexport type CreateReduceProps = CreateShapeProps<ReducerShape> & { reduce?: string };\n\nexport const createReducer = ({\n id,\n size = { width: 192, height: getHeight(ReducerInput) },\n ...rest\n}: CreateReduceProps): ReducerShape =>\n createShape<ReducerShape>({\n type: 'reducer',\n size,\n ...rest,\n });\n\nexport const reducerShape: ShapeDef<ReducerShape> = {\n type: 'reducer',\n name: 'Reducer',\n icon: 'ph--repeat--regular',\n component: ReducerComponent,\n createShape: createReducer,\n getAnchors: (shape) => createFunctionAnchors(shape, ReducerInput, ReducerOutput),\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useEffect, useState } from 'react';\n\nimport { DEFAULT_OUTPUT } from '@dxos/conductor';\nimport { type ShapeComponentProps } from '@dxos/react-ui-canvas-editor';\nimport * as Icon from '@dxos/react-ui/Icon';\n\nimport { useComputeNodeState } from '../hooks/index.ts';\nimport { type AudioShape } from './audio-def.ts';\n\nexport const AudioComponent = ({ shape }: ShapeComponentProps<AudioShape>) => {\n const { runtime } = useComputeNodeState(shape);\n const [active, setActive] = useState(false);\n useEffect(() => {\n runtime.setOutput(DEFAULT_OUTPUT, active);\n }, [active]);\n\n // https://docs.pmnd.rs/react-three-fiber/api/canvas#render-props\n return (\n <div className='flex w-full justify-center items-center'>\n <Icon.Icon\n icon={active ? 'ph--microphone--regular' : 'ph--microphone-slash--regular'}\n classNames={['transition opacity-20 duration-1000', active && 'opacity-100 text-error-text']}\n size='xl'\n onPointerDown={(ev) => ev.stopPropagation()}\n onClick={() => setActive(!active)}\n />\n </div>\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { type ShapeDef, createAnchorMap } from '@dxos/react-ui-canvas-editor';\n\nimport { AudioComponent } from './Audio.tsx';\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs.ts';\n\n// Kept out of `Audio.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\nexport const AudioShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('audio'),\n }),\n);\n\nexport type AudioShape = Schema.Schema.Type<typeof AudioShape>;\n\nexport type CreateAudioProps = CreateShapeProps<AudioShape>;\n\nexport const createAudio = (props: CreateAudioProps) =>\n createShape<AudioShape>({ type: 'audio', size: { width: 64, height: 64 }, ...props });\n\nexport const audioShape: ShapeDef<AudioShape> = {\n type: 'audio',\n name: 'Audio',\n icon: 'ph--microphone--regular',\n component: AudioComponent,\n createShape: createAudio,\n getAnchors: (shape) => createAnchorMap(shape, { [createAnchorId('output')]: { x: 1, y: 0 } }),\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport { DEFAULT_INPUT, isTruthy } from '@dxos/conductor';\nimport { type ShapeComponentProps } from '@dxos/react-ui-canvas-editor';\nimport * as Icon from '@dxos/react-ui/Icon';\n\nimport { useComputeNodeState } from '../hooks/index.ts';\nimport { type BeaconShape } from './beacon-def.ts';\n\nexport const BeaconComponent = ({ shape }: ShapeComponentProps<BeaconShape>) => {\n const { runtime } = useComputeNodeState(shape);\n const input = runtime.inputs[DEFAULT_INPUT];\n const value = input?.type === 'executed' ? input.value : false;\n\n return (\n <div className='flex w-full justify-center items-center'>\n <Icon.Icon\n icon='ph--sun--regular'\n classNames={['transition opacity-20 duration-1000', isTruthy(value) && 'opacity-100 text-yellow-500']}\n size='xl'\n />\n </div>\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { type ShapeDef, createAnchorMap } from '@dxos/react-ui-canvas-editor';\n\nimport { BeaconComponent } from './Beacon.tsx';\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs.ts';\n\n// Kept out of `Beacon.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\nexport const BeaconShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('beacon'),\n }),\n);\n\nexport type BeaconShape = Schema.Schema.Type<typeof BeaconShape>;\n\nexport type CreateBeaconProps = CreateShapeProps<BeaconShape>;\n\nexport const createBeacon = (props: CreateBeaconProps) =>\n createShape<BeaconShape>({ type: 'beacon', size: { width: 64, height: 64 }, ...props });\n\nexport const beaconShape: ShapeDef<BeaconShape> = {\n type: 'beacon',\n name: 'Beacon',\n icon: 'ph--sun--regular',\n component: BeaconComponent,\n createShape: createBeacon,\n getAnchors: (shape) =>\n createAnchorMap(shape, {\n [createAnchorId('input')]: { x: -1, y: 0 },\n }),\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useRef } from 'react';\n\nimport { DEFAULT_OUTPUT } from '@dxos/conductor';\nimport {\n type ShapeComponentProps,\n TextBox,\n type TextBoxControl,\n type TextBoxProps,\n} from '@dxos/react-ui-canvas-editor';\n\nimport { useComputeNodeState } from '../hooks/index.ts';\nimport { type ChatShape } from './chat-def.tsx';\nimport { Box } from './common/index.ts';\n\n//\n// Component\n//\n\nexport type TextInputComponentProps = ShapeComponentProps<ChatShape> & TextBoxProps & { title?: string };\n\nexport const TextInputComponent = ({ shape, title, ...props }: TextInputComponentProps) => {\n const { runtime } = useComputeNodeState(shape);\n const inputRef = useRef<TextBoxControl>(null);\n\n const handleEnter: TextBoxProps['onEnter'] = (text) => {\n const value = text.trim();\n if (value.length) {\n runtime.setOutput(DEFAULT_OUTPUT, value);\n inputRef.current?.setText('');\n }\n };\n\n return (\n <Box shape={shape} title={title}>\n <TextBox ref={inputRef} onEnter={handleEnter} {...props} />\n </Box>\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\nimport React from 'react';\n\nimport { type ShapeDef } from '@dxos/react-ui-canvas-editor';\nimport { createAnchorMap } from '@dxos/react-ui-canvas-editor';\n\nimport { TextInputComponent } from './Chat.tsx';\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs.ts';\n\n// Kept out of `Chat.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\n//\n// Data\n//\n\nexport const ChatShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('chat'),\n }),\n);\n\nexport type ChatShape = Schema.Schema.Type<typeof ChatShape>;\n\n//\n// Defs\n//\n\nexport type CreateChatProps = CreateShapeProps<ChatShape>;\n\nexport const createChat = (props: CreateChatProps) =>\n createShape<ChatShape>({ type: 'chat', size: { width: 256, height: 128 }, ...props });\n\nexport const chatShape: ShapeDef<ChatShape> = {\n type: 'chat',\n name: 'Chat',\n icon: 'ph--textbox--regular',\n component: (props) => <TextInputComponent {...props} title={'Prompt'} placeholder={'Message'} />,\n createShape: createChat,\n getAnchors: (shape) => createAnchorMap(shape, { [createAnchorId('output')]: { x: 1, y: 0 } }),\n resizable: true,\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useCallback, useRef, useState } from 'react';\n\nimport { ComputeValueType } from '@dxos/conductor';\nimport {\n type ShapeComponentProps,\n TextBox,\n type TextBoxControl,\n type TextBoxProps,\n} from '@dxos/react-ui-canvas-editor';\nimport * as Field from '@dxos/react-ui/Field';\nimport * as Input from '@dxos/react-ui/Input';\nimport { safeParseJson } from '@dxos/util';\n\nimport { useComputeNodeState } from '../hooks/index.ts';\nimport { Box, TypeSelect } from './common/index.ts';\nimport { type ConstantShape } from './constant-def.tsx';\n\n//\n// Component\n//\n\nexport type ConstantComponentProps = ShapeComponentProps<ConstantShape> &\n TextBoxProps & { title?: string; chat?: boolean };\n\nconst inferType = (value: any): ComputeValueType | undefined => {\n if (typeof value === 'string') {\n return 'string';\n } else if (typeof value === 'number') {\n return 'number';\n } else if (typeof value === 'boolean') {\n return 'boolean';\n } else if (typeof value === 'object') {\n return 'object';\n }\n};\n\nexport const ConstantComponent = ({ shape, title, chat, ...props }: ConstantComponentProps) => {\n const { node } = useComputeNodeState(shape);\n const [type, setType] = useState(inferType(node.value) ?? ComputeValueType.literals[0]);\n const inputRef = useRef<TextBoxControl>(null);\n\n const handleEnter = useCallback<NonNullable<TextBoxProps['onEnter']>>(\n (text) => {\n const value = text.trim();\n if (value.length) {\n // TODO(burdon): Set text filter.\n if (type === 'number') {\n const floatValue = parseFloat(value);\n if (!isNaN(floatValue)) {\n node.value = floatValue;\n }\n } else if (type === 'object') {\n node.value = safeParseJson(value, {});\n } else {\n node.value = value;\n }\n\n inputRef.current?.focus();\n }\n },\n [type],\n );\n\n return (\n <Box shape={shape} title={title} status={<TypeSelect value={type} onValueChange={setType} />}>\n {(type === 'string' || type === 'number') && (\n <TextBox {...props} ref={inputRef} value={node.value} onEnter={handleEnter} />\n )}\n {type === 'object' && (\n <TextBox {...props} ref={inputRef} value={JSON.stringify(node.value, null, 2)} language={'json'} />\n )}\n {type === 'boolean' && (\n <div className='flex grow justify-center items-center'>\n <Field.Root>\n <Input.Switch\n checked={node.value}\n onCheckedChange={({ checked: value }) => {\n node.value = value;\n }}\n />\n </Field.Root>\n </div>\n )}\n </Box>\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\nimport React from 'react';\n\nimport { type ShapeDef } from '@dxos/react-ui-canvas-editor';\nimport { createAnchorMap } from '@dxos/react-ui-canvas-editor';\n\nimport { ConstantComponent } from './Constant.tsx';\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs.ts';\n\n// Kept out of `Constant.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\n//\n// Data\n//\n\nexport const ConstantShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('constant'),\n value: Schema.optional(Schema.Any),\n }),\n);\n\nexport type ConstantShape = Schema.Schema.Type<typeof ConstantShape>;\n\n//\n// Defs\n//\n\nexport type CreateConstantProps = CreateShapeProps<ConstantShape>;\n\nexport const createConstant = (props: CreateConstantProps) =>\n createShape<ConstantShape>({ type: 'constant', size: { width: 192, height: 128 }, ...props });\n\nexport const constantShape: ShapeDef<ConstantShape> = {\n type: 'constant',\n name: 'Value',\n icon: 'ph--dots-three-circle--regular',\n component: (props) => <ConstantComponent {...props} placeholder={'Constant'} />,\n createShape: createConstant,\n getAnchors: (shape) => createAnchorMap(shape, { [createAnchorId('output')]: { x: 1, y: 0 } }),\n resizable: true,\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport { type ShapeComponentProps } from '@dxos/react-ui-canvas-editor';\n\nimport { Box } from './common/index.ts';\nimport { type DatabaseShape } from './database-def.ts';\n\nexport const DatabaseComponent = ({ shape }: ShapeComponentProps<DatabaseShape>) => {\n return <Box shape={shape} />;\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { type ShapeDef } from '@dxos/react-ui-canvas-editor';\nimport { createAnchorMap } from '@dxos/react-ui-canvas-editor';\n\nimport { DatabaseComponent } from './Database.tsx';\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs.ts';\n\n// Kept out of `Database.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\nexport const DatabaseShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('database'),\n }),\n);\n\nexport type DatabaseShape = Schema.Schema.Type<typeof DatabaseShape>;\n\nexport type CreateDatabaseProps = CreateShapeProps<DatabaseShape>;\n\nexport const createDatabase = (props: CreateDatabaseProps) =>\n createShape<DatabaseShape>({ type: 'database', size: { width: 128, height: 64 }, ...props });\n\nexport const databaseShape: ShapeDef<DatabaseShape> = {\n type: 'database',\n name: 'ECHO',\n icon: 'ph--database--regular',\n component: DatabaseComponent,\n createShape: createDatabase,\n getAnchors: (shape) => createAnchorMap(shape, { [createAnchorId('output')]: { x: 1, y: 0 } }),\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { Fragment } from 'react';\n\nimport { DEFAULT_OUTPUT } from '@dxos/conductor';\nimport { type ShapeComponentProps } from '@dxos/react-ui-canvas-editor';\nimport * as ScrollArea from '@dxos/react-ui/ScrollArea';\nimport type * as Util from '@dxos/react-ui/Util';\nimport { mx } from '@dxos/ui-theme';\n\nimport { useComputeNodeState } from '../hooks/index.ts';\nimport { Box } from './common/index.ts';\nimport { type FeedShape } from './feed-def.ts';\n\nexport const FeedComponent = ({ shape }: ShapeComponentProps<FeedShape>) => {\n const { runtime } = useComputeNodeState(shape);\n const items = runtime.outputs[DEFAULT_OUTPUT]?.type === 'executed' ? runtime.outputs[DEFAULT_OUTPUT].value : [];\n\n return (\n <Box shape={shape} status={`${items.length} items`}>\n <ScrollArea.Root orientation='vertical'>\n <ScrollArea.Viewport classNames='divide-y divide-separator-subtle'>\n {[...items].map((item, i) => (\n <FeedItem key={i} classNames='p-1 px-2' item={item} />\n ))}\n </ScrollArea.Viewport>\n </ScrollArea.Root>\n </Box>\n );\n};\n\nexport const FeedItem = ({ classNames, item }: Util.ThemedClassName<{ item: any }>) => {\n if (typeof item !== 'object') {\n return <div className={mx(classNames, 'whitespace-pre-wrap')}>{item}</div>;\n }\n\n return (\n <div className={mx('grid grid-cols-[80px_1fr]', classNames)}>\n {Object.entries(item).map(([key, value]) => (\n <Fragment key={key}>\n <div className='p-1 text-xs text-fg-subtle'>{key}</div>\n <div>{typeof value === 'string' ? value : JSON.stringify(value)}</div>\n </Fragment>\n ))}\n </div>\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { QueueInput, QueueOutput } from '@dxos/conductor';\nimport { type ShapeDef } from '@dxos/react-ui-canvas-editor';\n\nimport { createFunctionAnchors } from './common/index.ts';\nimport { ComputeShape, type CreateShapeProps, createShape } from './defs.ts';\nimport { FeedComponent } from './Feed.tsx';\n\n// Kept out of `Feed.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\nexport const FeedShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('queue'),\n }),\n);\n\nexport type FeedShape = Schema.Schema.Type<typeof FeedShape>;\n\nexport type CreateFeedProps = CreateShapeProps<FeedShape>;\n\nexport const createFeed = (props: CreateFeedProps) =>\n createShape<FeedShape>({\n type: 'queue',\n size: { width: 256, height: 512 },\n ...props,\n });\n\nexport const feedShape: ShapeDef<FeedShape> = {\n // Must match the shape's `type` literal ('queue') so the registry resolves it; the registry is keyed by this.\n type: 'queue',\n name: 'Feed',\n icon: 'ph--queue--regular',\n component: FeedComponent,\n createShape: createFeed,\n getAnchors: (shape) => createFunctionAnchors(shape, QueueInput, QueueOutput),\n resizable: true,\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useCallback, useRef } from 'react';\n\nimport * as Operation from '@dxos/compute/Operation';\nimport * as Script from '@dxos/compute/Script';\nimport { Filter, Obj, Ref } from '@dxos/echo';\nimport { parseId } from '@dxos/keys';\nimport { useClient } from '@dxos/react-client';\nimport {\n type ShapeComponentProps,\n TextBox,\n type TextBoxControl,\n type TextBoxProps,\n} from '@dxos/react-ui-canvas-editor';\n\nimport { useComputeNodeState } from '../hooks/index.ts';\nimport { Box } from './common/index.ts';\nimport { type FunctionShape } from './function-def.ts';\n\n//\n// Component\n//\n\ntype FunctionShapeComponentProps = ShapeComponentProps<FunctionShape> & TextBoxProps & { title?: string };\n\nexport const FunctionShapeComponent = ({ shape, title, ...props }: FunctionShapeComponentProps) => {\n const client = useClient();\n const { node, runtime } = useComputeNodeState(shape);\n const inputRef = useRef<TextBoxControl>(null);\n\n const handleEnter = useCallback(\n async (text: string) => {\n const value = text.trim();\n const { spaceId, objectId } = parseId(value);\n if (!spaceId || !objectId) {\n return;\n }\n\n const space = client.spaces.get(spaceId);\n const object = space?.db.query(Filter.id(objectId)).runSync()[0];\n if (!space || !Obj.instanceOf(Script.Script, object)) {\n return;\n }\n\n const [fn] = await space.db.query(Filter.type(Operation.PersistentOperation, { source: Ref.make(object) })).run();\n if (!fn) {\n return;\n }\n\n node.value = value;\n node.function = Ref.make(fn);\n node.inputSchema = fn.inputSchema;\n node.outputSchema = fn.outputSchema;\n },\n [client, node],\n );\n\n const handleAction = useCallback(\n (action: 'run' | 'open' | 'close') => {\n if (action !== 'run') {\n return;\n }\n\n runtime.evalNode();\n },\n [runtime],\n );\n\n return (\n <Box shape={shape} title='Function' onAction={handleAction}>\n <TextBox\n {...props}\n ref={inputRef}\n value={node.value}\n language={node.valueType === 'object' ? 'json' : undefined}\n onBlur={handleEnter}\n onEnter={handleEnter}\n />\n </Box>\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { AnyOutput, FunctionInput } from '@dxos/conductor';\nimport { type ShapeDef } from '@dxos/react-ui-canvas-editor';\n\nimport { createFunctionAnchors } from './common/index.ts';\nimport { ComputeShape, type CreateShapeProps, createShape } from './defs.ts';\nimport { FunctionShapeComponent } from './Function.tsx';\n\n// Kept out of `Function.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\nexport const FunctionShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('function'),\n }),\n);\n\nexport type FunctionShape = Schema.Schema.Type<typeof FunctionShape>;\n\nexport type CreateFunctionProps = CreateShapeProps<FunctionShape>;\n\nexport const createFunction = (props: CreateFunctionProps) =>\n createShape<FunctionShape>({\n type: 'function',\n size: { width: 256, height: 192 },\n ...props,\n });\n\n//\n// Defs\n//\n\nexport const functionShape: ShapeDef<FunctionShape> = {\n type: 'function',\n name: 'Function',\n icon: 'ph--function--regular',\n component: FunctionShapeComponent,\n createShape: createFunction,\n getAnchors: (shape) => createFunctionAnchors(shape, FunctionInput, AnyOutput),\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useEffect, useState } from 'react';\n\nimport { type ShapeComponentProps } from '@dxos/react-ui-canvas-editor';\nimport * as ScrollArea from '@dxos/react-ui/ScrollArea';\n\nimport { useComputeNodeState } from '../hooks/index.ts';\nimport { FunctionBody } from './common/index.ts';\nimport { type GptShape } from './gpt-def.ts';\n\nexport const GptComponent = ({ shape }: ShapeComponentProps<GptShape>) => {\n const { meta, runtime } = useComputeNodeState(shape);\n const [text, setText] = useState('');\n const [tokens, setTokens] = useState(0);\n\n useEffect(() => {\n return runtime.subscribeToEventLog((ev) => {\n switch (ev.type) {\n case 'begin-compute': {\n setText('');\n break;\n }\n\n case 'custom': {\n // TODO(burdon): Any?\n const token = ev.event;\n switch (token.type) {\n case 'content_block_delta':\n switch (token.delta.type) {\n case 'text_delta': {\n const delta = token.delta.text;\n setText((prev) => {\n const text = prev + delta;\n // TODO(burdon): Get token count.\n setTokens(text.split(' ').length);\n return text;\n });\n break;\n }\n }\n break;\n\n // TODO(dmaretskyi): Handle other types of events.\n }\n break;\n }\n }\n });\n }, [runtime?.subscribeToEventLog]);\n\n return (\n <FunctionBody\n shape={shape}\n content={\n <ScrollArea.Root orientation='vertical'>\n <ScrollArea.Viewport>{text}</ScrollArea.Viewport>\n </ScrollArea.Root>\n }\n status={`${tokens} tokens`}\n inputSchema={meta.input}\n outputSchema={meta.output}\n />\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { GptInput, GptOutput } from '@dxos/conductor';\nimport { type ShapeDef } from '@dxos/react-ui-canvas-editor';\n\nimport { createFunctionAnchors, getHeight } from './common/index.ts';\nimport { ComputeShape, type CreateShapeProps, createShape } from './defs.ts';\nimport { GptComponent } from './Gpt.tsx';\n\n// Kept out of `Gpt.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\nexport const GptShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('gpt'),\n }),\n);\n\nexport type GptShape = Schema.Schema.Type<typeof GptShape>;\n\nexport type CreateGptProps = CreateShapeProps<GptShape>;\n\nexport const createGpt = (props: CreateGptProps) =>\n createShape<GptShape>({\n type: 'gpt',\n size: { width: 256, height: Math.max(getHeight(GptInput), getHeight(GptOutput)) },\n ...props,\n });\n\nexport const gptShape: ShapeDef<GptShape> = {\n type: 'gpt',\n name: 'GPT',\n icon: 'ph--brain--regular',\n component: GptComponent,\n createShape: createGpt,\n getAnchors: (shape) => createFunctionAnchors(shape, GptInput, GptOutput),\n openable: true,\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useState } from 'react';\n\nimport { log } from '@dxos/log';\nimport { useConfig } from '@dxos/react-client';\nimport { type ShapeComponentProps } from '@dxos/react-ui-canvas-editor';\nimport * as Icon from '@dxos/react-ui/Icon';\n\nimport { type GptRealtimeShape } from './gpt-realtime-def.ts';\n\nexport const GptRealtimeComponent = ({ shape }: ShapeComponentProps<GptRealtimeShape>) => {\n const [isLive, setIsLive] = useState(false);\n const [isReady, setIsReady] = useState(false);\n const config = useConfig();\n\n const start = async () => {\n const edgeUrl = config.values.runtime?.services?.edge?.url;\n if (!edgeUrl) {\n log.error('EDGE services are not configured (runtime.services.edge.url); realtime AI is unavailable.');\n return;\n }\n setIsLive(true);\n\n try {\n // Create WebRTC connection\n const peerConnection = new RTCPeerConnection();\n\n // Handle incoming audio\n peerConnection.ontrack = (event) => {\n const audioElement = document.createElement('audio');\n audioElement.srcObject = event.streams[0];\n audioElement.autoplay = true;\n audioElement.controls = false;\n audioElement.style.display = 'none';\n document.body.appendChild(audioElement);\n setIsReady(true);\n };\n\n // Get microphone stream\n const stream = await navigator.mediaDevices.getUserMedia({ audio: true });\n\n // Add microphone track to connection\n stream.getTracks().forEach((track) => peerConnection.addTransceiver(track, { direction: 'sendrecv' }));\n\n // Create offer\n const offer = await peerConnection.createOffer();\n await peerConnection.setLocalDescription(offer);\n\n // Send offer to backend and get answer. AI is served through edge's /ai/* proxy;\n // the configured edge URL uses a ws(s) scheme, so swap it for http(s).\n const aiServiceUrl = new URL('/ai/rtc-connect', edgeUrl);\n aiServiceUrl.protocol = aiServiceUrl.protocol.replace('ws', 'http');\n const response = await fetch(aiServiceUrl, {\n method: 'POST',\n body: offer.sdp,\n headers: {\n 'Content-Type': 'application/sdp',\n },\n });\n\n const answer = await response.text();\n\n // Set remote description with answer\n await peerConnection.setRemoteDescription({\n sdp: answer,\n type: 'answer',\n });\n\n const dataChannel = peerConnection.createDataChannel('response');\n\n const configureData = () => {\n log.info('Configuring data channel');\n const event = {\n type: 'session.update',\n session: {\n modalities: ['text', 'audio'],\n // Provide the tools. Note they match the keys in the `fns` object above\n tools: [],\n },\n };\n dataChannel.send(JSON.stringify(event));\n };\n\n dataChannel.addEventListener('open', (ev) => {\n log.info('Opening data channel', { ev });\n configureData();\n });\n\n // {\n // \"type\": \"response.function_call_arguments.done\",\n // \"event_id\": \"event_Ad2gt864G595umbCs2aF9\",\n // \"response_id\": \"resp_Ad2griUWUjsyeLyAVtTtt\",\n // \"item_id\": \"item_Ad2gsxA84w9GgEvFwW1Ex\",\n // \"output_index\": 1,\n // \"call_id\": \"call_PG12S5ER7l7HrvZz\",\n // \"name\": \"get_weather\",\n // \"arguments\": \"{\\\"location\\\":\\\"Portland, Oregon\\\"}\"\n // }\n\n dataChannel.addEventListener('message', async (ev) => {\n const msg = JSON.parse(ev.data);\n // console.log('realtime gpt event', msg);\n // Handle function calls\n if (msg.type === 'response.function_call_arguments.done') {\n // const fn = fns[msg.name];\n // if (fn !== undefined) {\n // console.log(`Calling local function ${msg.name} with ${msg.arguments}`);\n // const args = JSON.parse(msg.arguments);\n // const result = await fn(args);\n // console.log('result', result);\n // // Let OpenAI know that the function has been called and share it's output\n // const event = {\n // type: 'conversation.item.create',\n // item: {\n // type: 'function_call_output',\n // call_id: msg.call_id, // call_id from the function_call message\n // output: JSON.stringify(result), // result of the function\n // },\n // };\n // dataChannel.send(JSON.stringify(event));\n // }\n }\n });\n } catch (error) {\n log.error('Error in realtime session:', { error });\n throw error;\n }\n };\n\n return (\n <div className='flex w-full justify-center items-center'>\n <Icon.Icon\n icon={isReady ? 'ph--waveform--regular' : isLive ? 'ph--pulse--regular' : 'ph--play--regular'}\n size='xl'\n classNames={!isLive && 'cursor-pointer'}\n onPointerDown={(ev) => ev.stopPropagation()}\n onClick={start}\n />\n </div>\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { type ShapeDef } from '@dxos/react-ui-canvas-editor';\n\nimport { createFunctionAnchors } from './common/index.ts';\nimport { ComputeShape, type CreateShapeProps, createShape } from './defs.ts';\nimport { GptRealtimeComponent } from './GptRealtime.tsx';\n\n// Kept out of `GptRealtime.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\nexport const GptRealtimeShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('gpt-realtime'),\n }),\n);\n\nexport type GptRealtimeShape = Schema.Schema.Type<typeof GptRealtimeShape>;\n\nexport type CreateGptRealtimeProps = CreateShapeProps<GptRealtimeShape>;\n\nexport const createGptRealtime = (props: CreateGptRealtimeProps) =>\n createShape<GptRealtimeShape>({ type: 'gpt-realtime', size: { width: 256, height: 256 }, ...props });\n\nexport const gptRealtimeShape: ShapeDef<GptRealtimeShape> = {\n type: 'gpt-realtime',\n name: 'GPT Realtime',\n icon: 'ph--pulse--regular',\n component: GptRealtimeComponent,\n createShape: createGptRealtime,\n // TODO(dmaretskyi): Can we fetch the schema dynamically?\n getAnchors: (shape) =>\n createFunctionAnchors(\n shape,\n Schema.Struct({\n audio: Schema.Any,\n }),\n Schema.Struct({}),\n ),\n resizable: true,\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport { DEFAULT_INPUT } from '@dxos/conductor';\nimport { type ShapeComponentProps } from '@dxos/react-ui-canvas-editor';\nimport { Syntax } from '@dxos/react-ui-syntax-highlighter';\n\nimport { useComputeNodeState } from '../hooks/index.ts';\nimport { Box } from './common/index.ts';\nimport { type JsonShape, type JsonTransformShape } from './json-def.ts';\n\n//\n// Component\n//\n\nexport type JsonComponentProps = ShapeComponentProps<JsonShape>;\n\nexport const JsonComponent = ({ shape, ...props }: JsonComponentProps) => {\n const { runtime } = useComputeNodeState(shape);\n const input = runtime.inputs[DEFAULT_INPUT];\n const value = input?.type === 'executed' ? input.value : undefined;\n\n return (\n <Box shape={shape}>\n <Syntax.Root data={value}>\n <Syntax.Content>\n <Syntax.Filter />\n <Syntax.Viewport>\n <Syntax.Code classNames='text-xs' />\n </Syntax.Viewport>\n </Syntax.Content>\n </Syntax.Root>\n </Box>\n );\n};\n\nexport type JsonTransformComponentProps = ShapeComponentProps<JsonTransformShape>;\n\nexport const JsonTransformComponent = ({ shape, ...props }: JsonTransformComponentProps) => {\n return <Box shape={shape} />;\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { DefaultOutput, JsonTransformInput } from '@dxos/conductor';\nimport { type ShapeDef } from '@dxos/react-ui-canvas-editor';\nimport { createAnchorMap } from '@dxos/react-ui-canvas-editor';\n\nimport { createFunctionAnchors, getHeight } from './common/index.ts';\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs.ts';\nimport { JsonComponent, JsonTransformComponent } from './Json.tsx';\n\n// Kept out of `Json.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\n//\n// Data\n//\n\nexport const JsonShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('json'),\n }),\n);\n\nexport type JsonShape = Schema.Schema.Type<typeof JsonShape>;\n\nexport const JsonTransformShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('json-transform'),\n }),\n);\n\nexport type JsonTransformShape = Schema.Schema.Type<typeof JsonTransformShape>;\n\n//\n// Defs\n//\n\nexport type CreateJsonProps = CreateShapeProps<JsonShape>;\n\nexport const createJson = (props: CreateJsonProps) =>\n createShape<JsonShape>({ type: 'json', size: { width: 256, height: 256 }, ...props });\n\nexport const jsonShape: ShapeDef<JsonShape> = {\n type: 'json',\n name: 'JSON',\n icon: 'ph--code--regular',\n component: JsonComponent,\n createShape: createJson,\n getAnchors: (shape) =>\n createAnchorMap(shape, {\n [createAnchorId('input')]: { x: -1, y: 0 },\n [createAnchorId('output')]: { x: 1, y: 0 },\n }),\n resizable: true,\n};\n\nexport type CreateJsonTransformProps = CreateShapeProps<JsonTransformShape> & { expression?: string };\n\nexport const createJsonTransform = (props: CreateJsonTransformProps) =>\n createShape<JsonTransformShape>({\n type: 'json-transform',\n size: { width: 128, height: getHeight(JsonTransformInput) },\n ...props,\n });\n\nexport const jsonTransformShape: ShapeDef<JsonTransformShape> = {\n type: 'json-transform',\n name: 'Transform',\n icon: 'ph--shuffle-simple--regular',\n component: JsonTransformComponent,\n createShape: createJsonTransform,\n getAnchors: (shape) => createFunctionAnchors(shape, JsonTransformInput, DefaultOutput),\n resizable: true,\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport { IfElseInput, IfElseOutput, IfInput, IfOutput } from '@dxos/conductor';\nimport { type ShapeComponentProps } from '@dxos/react-ui-canvas-editor';\n\nimport { FunctionBody } from './common/index.ts';\nimport { type IfElseShape, type IfShape } from './logic-def.ts';\n\n//\n// Components\n//\n\nexport type IfComponentProps = ShapeComponentProps<IfShape>;\n\nexport const IfComponent = ({ shape, ...props }: IfComponentProps) => {\n return <FunctionBody shape={shape} inputSchema={IfInput} outputSchema={IfOutput} />;\n};\n\nexport type IfElseComponentProps = ShapeComponentProps<IfElseShape>;\n\nexport const IfElseComponent = ({ shape, ...props }: IfElseComponentProps) => {\n return <FunctionBody shape={shape} inputSchema={IfElseInput} outputSchema={IfElseOutput} />;\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { IfElseInput, IfElseOutput, IfInput, IfOutput } from '@dxos/conductor';\nimport { type ShapeDef } from '@dxos/react-ui-canvas-editor';\n\nimport { createFunctionAnchors, getHeight } from './common/index.ts';\nimport { ComputeShape, type CreateShapeProps, createShape } from './defs.ts';\nimport { IfComponent, IfElseComponent } from './Logic.tsx';\n\n// Kept out of `Logic.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\n//\n// Data\n//\n\nexport const IfShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('if'),\n }),\n);\n\nexport type IfShape = Schema.Schema.Type<typeof IfShape>;\n\nexport const IfElseShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('if-else'),\n }),\n);\n\nexport type IfElseShape = Schema.Schema.Type<typeof IfElseShape>;\n\n//\n// Defs\n//\n\nexport type CreateIfProps = CreateShapeProps<IfShape> & { if?: string };\n\nexport const createIf = (props: CreateIfProps) =>\n createShape<IfShape>({ type: 'if', size: { width: 192, height: getHeight(IfInput) }, ...props });\n\nexport const ifShape: ShapeDef<IfShape> = {\n type: 'if',\n name: 'IF',\n icon: 'ph--arrows-split--regular',\n component: IfComponent,\n createShape: createIf,\n getAnchors: (shape) => createFunctionAnchors(shape, IfInput, IfOutput),\n};\n\nexport type CreateIfElseProps = CreateShapeProps<IfShape> & { if?: string };\n\nexport const createIfElse = (props: CreateIfElseProps) =>\n createShape<IfElseShape>({ type: 'if-else', size: { width: 192, height: getHeight(IfElseInput) }, ...props });\n\nexport const ifElseShape: ShapeDef<IfElseShape> = {\n type: 'if-else',\n name: 'IF/ELSE',\n icon: 'ph--arrows-merge--regular',\n component: IfElseComponent,\n createShape: createIfElse,\n getAnchors: (shape) => createFunctionAnchors(shape, IfElseInput, IfElseOutput),\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useEffect, useState } from 'react';\n\nimport { DEFAULT_OUTPUT } from '@dxos/conductor';\nimport { type ShapeComponentProps } from '@dxos/react-ui-canvas-editor';\nimport * as Icon from '@dxos/react-ui/Icon';\n\nimport { useComputeNodeState } from '../hooks/index.ts';\nimport { type RandomShape } from './rng-def.ts';\n\nconst icons = [\n 'ph--dice-one--regular',\n 'ph--dice-two--regular',\n 'ph--dice-three--regular',\n 'ph--dice-four--regular',\n 'ph--dice-five--regular',\n 'ph--dice-six--regular',\n];\n\nconst pickIcon = () => icons[Math.floor(Math.random() * icons.length)];\n\n// TODO(burdon): Optional range.\nexport const RandomComponent = ({ shape }: ShapeComponentProps<RandomShape>) => {\n const { runtime } = useComputeNodeState(shape);\n\n const [spin, setSpin] = useState(false);\n const [icon, setIcon] = useState(pickIcon());\n useEffect(() => {\n if (!spin) {\n return;\n }\n\n const i = setInterval(() => setIcon(pickIcon()), 250);\n const t1 = setTimeout(() => clearInterval(i), 900);\n const t2 = setTimeout(() => setSpin(false), 1_100);\n return () => {\n clearInterval(i);\n clearTimeout(t1);\n clearTimeout(t2);\n };\n }, [spin]);\n\n // The node frame takes a pointer press as select-and-drag, capturing the pointer so the click never\n // reaches this control; the gesture has to stop here for the operation to fire.\n const stopGesture: Icon.IconProps['onPointerDown'] = (ev) => ev.stopPropagation();\n\n const handleClick: Icon.IconProps['onClick'] = (ev) => {\n ev.stopPropagation();\n runtime.setOutput(DEFAULT_OUTPUT, Math.random());\n setSpin(true);\n };\n\n return (\n <div className='flex grow items-center justify-center'>\n <Icon.Icon\n icon={icon}\n classNames={spin && 'animate-[spin_1s]'}\n size='xl'\n onPointerDown={stopGesture}\n onClick={handleClick}\n />\n </div>\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { type ShapeDef, createAnchorMap } from '@dxos/react-ui-canvas-editor';\n\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs.ts';\nimport { RandomComponent } from './RNG.tsx';\n\n// Kept out of `RNG.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\nexport const RandomShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('rng'),\n min: Schema.optional(Schema.Number),\n max: Schema.optional(Schema.Number),\n }),\n);\n\nexport type RandomShape = Schema.Schema.Type<typeof RandomShape>;\n\nexport type CreateRandomProps = CreateShapeProps<RandomShape>;\n\nexport const createRandom = (props: CreateRandomProps) =>\n createShape<RandomShape>({\n type: 'rng',\n size: { width: 64, height: 64 },\n ...props,\n });\n\nexport const randomShape: ShapeDef<RandomShape> = {\n type: 'rng',\n name: 'Random',\n icon: 'ph--dice-six--regular',\n component: RandomComponent,\n createShape: createRandom,\n getAnchors: (shape) => createAnchorMap(shape, { [createAnchorId('output')]: { x: 1, y: 0 } }),\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport { DEFAULT_INPUT } from '@dxos/conductor';\nimport { useAudioStream } from '@dxos/react-ui-audio';\nimport { type ShapeComponentProps } from '@dxos/react-ui-canvas-editor';\nimport { Chaos, shaderPresets } from '@dxos/react-ui-experimental';\n\nimport { useComputeNodeState } from '../hooks/index.ts';\nimport { type ScopeShape } from './scope-def.ts';\n\nexport const ScopeComponent = ({ shape }: ShapeComponentProps<ScopeShape>) => {\n const { runtime } = useComputeNodeState(shape);\n const input = runtime.inputs[DEFAULT_INPUT];\n const active = input?.type === 'executed' ? input.value : false;\n const { getAverage } = useAudioStream(active);\n\n return (\n <div className='flex w-full justify-center items-center bg-black'>\n <Chaos active={active} getValue={getAverage} options={{ ...shaderPresets.heptapod, zoom: 1.2 }} />\n </div>\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { type ShapeDef, createAnchorMap } from '@dxos/react-ui-canvas-editor';\n\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs.ts';\nimport { ScopeComponent } from './Scope.tsx';\n\n// Kept out of `Scope.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\nexport const ScopeShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('scope'),\n }),\n);\n\nexport type ScopeShape = Schema.Schema.Type<typeof ScopeShape>;\n\nexport type CreateScopeProps = CreateShapeProps<ScopeShape>;\n\nexport const createScope = (props: CreateScopeProps) =>\n createShape<ScopeShape>({\n type: 'scope',\n size: { width: 128, height: 128 },\n classNames: 'rounded-full border-primary-800',\n ...props,\n });\n\nexport const scopeShape: ShapeDef<ScopeShape> = {\n type: 'scope',\n name: 'Scope',\n icon: 'ph--waveform--regular',\n component: ScopeComponent,\n createShape: createScope,\n getAnchors: (shape) => createAnchorMap(shape, { [createAnchorId('input')]: { x: -1, y: 0 } }),\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport * as Surface from '@dxos/app-framework/Surface';\nimport * as AppSurface from '@dxos/app-toolkit/AppSurface';\nimport { DEFAULT_INPUT } from '@dxos/conductor';\nimport { type ShapeComponentProps } from '@dxos/react-ui-canvas-editor';\nimport * as Card from '@dxos/react-ui/Card';\n\nimport { useComputeNodeState } from '../hooks/index.ts';\nimport { Box } from './common/index.ts';\nimport { type SurfaceShape } from './surface-def.ts';\n\nexport const SurfaceComponent = ({ shape }: ShapeComponentProps<SurfaceShape>) => {\n const { runtime } = useComputeNodeState(shape);\n const input = runtime.inputs[DEFAULT_INPUT];\n const value = input?.type === 'executed' ? input.value : null;\n\n // TODO(burdon): Subject property?\n return (\n <Box shape={shape}>\n <Card.Root grid>\n {value !== null && <Surface.Surface type={AppSurface.CardContent} data={{ subject: value }} limit={1} />}\n </Card.Root>\n </Box>\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { type ShapeDef } from '@dxos/react-ui-canvas-editor';\nimport { createAnchorMap } from '@dxos/react-ui-canvas-editor';\n\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs.ts';\nimport { SurfaceComponent } from './Surface.tsx';\n\n// Kept out of `Surface.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\nexport const SurfaceShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('surface'),\n }),\n);\n\nexport type SurfaceShape = Schema.Schema.Type<typeof SurfaceShape>;\n\nexport type CreateSurfaceProps = CreateShapeProps<SurfaceShape>;\n\nexport const createSurface = (props: CreateSurfaceProps) =>\n createShape<SurfaceShape>({\n type: 'surface',\n size: { width: 384, height: 384 },\n ...props,\n });\n\nexport const surfaceShape: ShapeDef<SurfaceShape> = {\n type: 'surface',\n name: 'Surface',\n icon: 'ph--frame-corners--regular',\n component: SurfaceComponent,\n createShape: createSurface,\n getAnchors: (shape) => createAnchorMap(shape, { [createAnchorId('input')]: { x: -1, y: 0 } }),\n resizable: true,\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useEffect, useState } from 'react';\n\nimport { DEFAULT_OUTPUT } from '@dxos/conductor';\nimport { type ShapeComponentProps } from '@dxos/react-ui-canvas-editor';\nimport * as Field from '@dxos/react-ui/Field';\nimport * as Input from '@dxos/react-ui/Input';\n\nimport { useComputeNodeState } from '../hooks/index.ts';\nimport { type SwitchShape } from './switch-def.ts';\n\n// TODO(burdon): Should model as a constant.\nexport const SwitchComponent = ({ shape }: ShapeComponentProps<SwitchShape>) => {\n const { runtime } = useComputeNodeState(shape);\n const [value, setValue] = useState(false);\n useEffect(() => {\n runtime.setOutput(DEFAULT_OUTPUT, value);\n }, [value]);\n\n return (\n // The node frame would otherwise take the press as select-and-drag and capture the pointer, so the\n // switch never sees the click.\n <div\n className='flex w-full justify-center items-center'\n onPointerDown={(ev) => ev.stopPropagation()}\n onClick={(ev) => ev.stopPropagation()}\n >\n <Field.Root>\n <Input.Switch checked={value} onCheckedChange={({ checked: value }) => setValue(value)} />\n </Field.Root>\n </div>\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { type ShapeDef, createAnchorMap } from '@dxos/react-ui-canvas-editor';\n\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs.ts';\nimport { SwitchComponent } from './Switch.tsx';\n\n// Kept out of `Switch.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\nexport const SwitchShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('switch'),\n }),\n);\n\nexport type SwitchShape = Schema.Schema.Type<typeof SwitchShape>;\n\nexport type CreateSwitchProps = CreateShapeProps<SwitchShape>;\n\nexport const createSwitch = (props: CreateSwitchProps) =>\n createShape<SwitchShape>({ type: 'switch', size: { width: 64, height: 64 }, ...props });\n\nexport const switchShape: ShapeDef<SwitchShape> = {\n type: 'switch',\n name: 'Switch',\n icon: 'ph--toggle-left--regular',\n component: SwitchComponent,\n createShape: createSwitch,\n getAnchors: (shape) => createAnchorMap(shape, { [createAnchorId('output')]: { x: 1, y: 0 } }),\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport { type ShapeComponentProps } from '@dxos/react-ui-canvas-editor';\n\nimport { Box } from './common/index.ts';\nimport { type TableShape } from './table-def.ts';\n\nexport const TableComponent = ({ shape }: ShapeComponentProps<TableShape>) => {\n // const items = shape.node.items.value;\n\n return <Box shape={shape}></Box>;\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { createInputSchema, createOutputSchema } from '@dxos/conductor';\nimport { Type } from '@dxos/echo';\nimport { type ShapeDef } from '@dxos/react-ui-canvas-editor';\nimport { Message } from '@dxos/types';\n\nimport { createFunctionAnchors } from './common/index.ts';\nimport { ComputeShape, type CreateShapeProps, createShape } from './defs.ts';\nimport { TableComponent } from './Table.tsx';\n\n// Kept out of `Table.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\nconst InputSchema = createInputSchema(Type.getSchema(Message.Message));\n\nconst OutputSchema = createOutputSchema(Schema.mutable(Schema.Array(Type.getSchema(Message.Message))));\n\nexport const TableShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('table'),\n }),\n);\n\nexport type TableShape = Schema.Schema.Type<typeof TableShape>;\n\nexport type CreateTableProps = CreateShapeProps<TableShape>;\n\nexport const createTable = (props: CreateTableProps) =>\n createShape<TableShape>({ type: 'table', size: { width: 320, height: 512 }, ...props });\n\nexport const tableShape: ShapeDef<TableShape> = {\n type: 'table',\n name: 'Table',\n icon: 'ph--table--regular',\n component: TableComponent,\n createShape: createTable,\n getAnchors: (shape) => createFunctionAnchors(shape, InputSchema, OutputSchema),\n resizable: true,\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport React, { useRef } from 'react';\n\nimport { ComputeValueType, getTemplateInputSchema } from '@dxos/conductor';\nimport * as JsonSchema from '@dxos/echo/JsonSchema';\nimport { invariant } from '@dxos/invariant';\nimport {\n type ShapeComponentProps,\n TextBox,\n type TextBoxControl,\n type TextBoxProps,\n} from '@dxos/react-ui-canvas-editor';\n\nimport { useComputeNodeState } from '../hooks/index.ts';\nimport { Box, TypeSelect } from './common/index.ts';\nimport { type TemplateShape } from './template-def.ts';\n\n//\n// Component\n//\n\ntype TextInputComponentProps = ShapeComponentProps<TemplateShape> & TextBoxProps & { title?: string };\n\nconst TextInputComponent = ({ shape, title, ...props }: TextInputComponentProps) => {\n const { node } = useComputeNodeState(shape);\n const inputRef = useRef<TextBoxControl>(null);\n\n const handleEnter: TextBoxProps['onEnter'] = (text) => {\n const value = text.trim();\n if (value.length) {\n const schema = getTemplateInputSchema(node);\n\n node.value = value;\n node.inputSchema = JsonSchema.toJsonSchema(schema);\n }\n };\n\n const handleTypeChange = (newType: string) => {\n invariant(Schema.is(ComputeValueType)(newType), 'Invalid type');\n\n node.valueType = newType;\n node.inputSchema = JsonSchema.toJsonSchema(getTemplateInputSchema(node));\n };\n\n return (\n <Box\n shape={shape}\n title={'Template'}\n status={<TypeSelect value={node.valueType ?? 'string'} onValueChange={handleTypeChange} />}\n >\n <TextBox\n {...props}\n ref={inputRef}\n value={node.value}\n language={node.valueType === 'object' ? 'json' : undefined}\n onBlur={handleEnter}\n onEnter={handleEnter}\n />\n </Box>\n );\n};\n\nexport const TemplateComponent = (props: ShapeComponentProps<TemplateShape>) => (\n <TextInputComponent {...props} placeholder={'Prompt'} />\n);\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { ComputeValueType, TemplateOutput, VoidInput } from '@dxos/conductor';\nimport { type ShapeDef } from '@dxos/react-ui-canvas-editor';\n\nimport { createFunctionAnchors } from './common/index.ts';\nimport { ComputeShape, type CreateShapeProps, createShape } from './defs.ts';\nimport { TemplateComponent } from './Template.tsx';\n\n// Kept out of `Template.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\n//\n// Data\n//\n\nexport const TemplateShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('template'),\n valueType: Schema.optional(ComputeValueType),\n }),\n);\n\nexport type TemplateShape = Schema.Schema.Type<typeof TemplateShape>;\n\n//\n// Defs\n//\n\nexport type CreateTemplateProps = CreateShapeProps<TemplateShape> & { text?: string };\n\nexport const createTemplate = (props: CreateTemplateProps) =>\n createShape<TemplateShape>({ type: 'template', size: { width: 256, height: 384 }, ...props });\n\nexport const templateShape: ShapeDef<TemplateShape> = {\n type: 'template',\n name: 'Template',\n icon: 'ph--article--regular',\n component: TemplateComponent,\n createShape: createTemplate,\n getAnchors: (shape) => createFunctionAnchors(shape, VoidInput, TemplateOutput),\n resizable: true,\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport { DEFAULT_INPUT } from '@dxos/conductor';\nimport { type ShapeComponentProps, TextBox } from '@dxos/react-ui-canvas-editor';\n\nimport { useComputeNodeState } from '../hooks/index.ts';\nimport { Box } from './common/index.ts';\nimport { type TextShape } from './text-def.ts';\n\nexport const TextComponent = ({ shape }: ShapeComponentProps<TextShape>) => {\n const { runtime } = useComputeNodeState(shape);\n const input = runtime.inputs[DEFAULT_INPUT];\n const value = input?.type === 'executed' ? input.value : 0;\n\n return (\n <Box shape={shape}>\n <TextBox value={value} />\n </Box>\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { type ShapeDef } from '@dxos/react-ui-canvas-editor';\nimport { createAnchorMap } from '@dxos/react-ui-canvas-editor';\n\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs.ts';\nimport { TextComponent } from './Text.tsx';\n\n// Kept out of `Text.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\nexport const TextShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('text'),\n }),\n);\n\nexport type TextShape = Schema.Schema.Type<typeof TextShape>;\n\nexport type CreateTextProps = CreateShapeProps<TextShape>;\n\nexport const createText = (props: CreateTextProps) =>\n createShape<TextShape>({ type: 'text', size: { width: 384, height: 384 }, ...props });\n\nexport const textShape: ShapeDef<TextShape> = {\n type: 'text',\n name: 'Text',\n icon: 'ph--article--regular',\n component: TextComponent,\n createShape: createText,\n getAnchors: (shape) => createAnchorMap(shape, { [createAnchorId('input')]: { x: -1, y: 0 } }),\n resizable: true,\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport { type ShapeComponentProps } from '@dxos/react-ui-canvas-editor';\n\nimport { Box } from './common/index.ts';\nimport { type TextToImageShape } from './text-to-image-def.ts';\n\nexport const TextToImageComponent = ({ shape }: ShapeComponentProps<TextToImageShape>) => {\n return <Box shape={shape} />;\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { type ShapeDef } from '@dxos/react-ui-canvas-editor';\nimport { createAnchorMap } from '@dxos/react-ui-canvas-editor';\n\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs.ts';\nimport { TextToImageComponent } from './TextToImage.tsx';\n\n// Kept out of `TextToImage.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\nexport const TextToImageShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('text-to-image'),\n }),\n);\n\nexport type TextToImageShape = Schema.Schema.Type<typeof TextToImageShape>;\n\nexport type CreateTextToImageProps = CreateShapeProps<TextToImageShape>;\n\nexport const createTextToImage = (props: CreateTextToImageProps) =>\n createShape<TextToImageShape>({ type: 'text-to-image', size: { width: 128, height: 64 }, ...props });\n\nexport const textToImageShape: ShapeDef<TextToImageShape> = {\n type: 'text-to-image',\n name: 'Image',\n icon: 'ph--image--regular',\n component: TextToImageComponent,\n createShape: createTextToImage,\n getAnchors: (shape) => createAnchorMap(shape, { [createAnchorId('output')]: { x: 1, y: 0 } }),\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useEffect, useRef } from 'react';\n\nimport { type ShapeComponentProps } from '@dxos/react-ui-canvas-editor';\nimport * as ScrollArea from '@dxos/react-ui/ScrollArea';\nimport type * as Util from '@dxos/react-ui/Util';\nimport { mx } from '@dxos/ui-theme';\n\nimport { Box } from './common/index.ts';\nimport { type ThreadShape } from './thread-def.ts';\n\nexport const ThreadComponent = ({ shape }: ShapeComponentProps<ThreadShape>) => {\n const items: any[] = [];\n const scrollRef = useRef<HTMLDivElement>(null);\n useEffect(() => {\n if (scrollRef.current) {\n scrollRef.current.scrollTop = scrollRef.current.scrollHeight;\n }\n }, [items]);\n\n return (\n <Box shape={shape}>\n <ScrollArea.Root orientation='vertical'>\n <ScrollArea.Viewport classNames='gap-2 p-2' ref={scrollRef}>\n {[...items].map((item, i) => (\n <ThreadItem key={i} item={item} />\n ))}\n </ScrollArea.Viewport>\n </ScrollArea.Root>\n </Box>\n );\n};\n\nexport const ThreadItem = ({ classNames, item }: Util.ThemedClassName<{ item: any }>) => {\n if (typeof item !== 'object') {\n return <div className={mx(classNames)}>{item}</div>;\n }\n\n // TODO(burdon): Hack; introspect type.\n // TODO(burdon): Markdown parser.\n const { role, message } = item;\n return (\n <div className={mx('flex', classNames, role === 'user' && 'justify-end')}>\n <div\n className={mx(\n 'block rounded-md p-1 px-2 text-sm',\n role === 'user'\n ? 'bg-blue-100 dark:bg-blue-800'\n : role === 'system'\n ? 'bg-red-100, dark:bg-red-800'\n : 'whitespace-pre-wrap bg-neutral-50 dark:bg-neutral-800',\n )}\n >\n {message}\n </div>\n </div>\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { createInputSchema, createOutputSchema } from '@dxos/conductor';\nimport { Type } from '@dxos/echo';\nimport { type ShapeDef } from '@dxos/react-ui-canvas-editor';\nimport { Message } from '@dxos/types';\n\nimport { createFunctionAnchors } from './common/index.ts';\nimport { ComputeShape, type CreateShapeProps, createShape } from './defs.ts';\nimport { ThreadComponent } from './Thread.tsx';\n\n// Kept out of `Thread.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\nconst InputSchema = createInputSchema(Type.getSchema(Message.Message));\n\nconst OutputSchema = createOutputSchema(Schema.mutable(Schema.Array(Type.getSchema(Message.Message))));\n\nexport const ThreadShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('thread'),\n }),\n);\n\nexport type ThreadShape = Schema.Schema.Type<typeof ThreadShape>;\n\nexport type CreateThreadProps = CreateShapeProps<ThreadShape>;\n\nexport const createThread = (props: CreateThreadProps) =>\n createShape<ThreadShape>({ type: 'thread', size: { width: 384, height: 384 }, ...props });\n\nexport const threadShape: ShapeDef<ThreadShape> = {\n type: 'thread',\n name: 'Thread',\n icon: 'ph--chats-circle--regular',\n component: ThreadComponent,\n createShape: createThread,\n getAnchors: (shape) => createFunctionAnchors(shape, InputSchema, OutputSchema),\n resizable: true,\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport * as Trigger from '@dxos/compute/Trigger';\nimport * as TriggerEvent from '@dxos/compute/TriggerEvent';\nimport { Filter, Query } from '@dxos/echo';\nimport { type SpaceId } from '@dxos/keys';\n\n// Kept out of `Trigger.tsx` and shared with `trigger-def.ts`: react-refresh only fast-refreshes a\n// module whose exports are all components, and a value import back from the def module would close\n// a runtime cycle.\n\nexport const createTriggerSpec = (props: { triggerKind?: Trigger.Kind; spaceId?: SpaceId }): Trigger.Spec => {\n const kind = props.triggerKind ?? 'email';\n switch (kind) {\n case 'timer':\n return Trigger.specTimer('* * * * *');\n case 'webhook':\n return Trigger.specWebhook({ method: 'POST' });\n case 'subscription':\n return Trigger.specSubscription(Query.select(Filter.nothing()));\n case 'email':\n return Trigger.specEmail();\n case 'feed': {\n return { kind: 'feed' } satisfies Trigger.FeedSpec;\n }\n case 'direct':\n return Trigger.specDirect();\n }\n};\n\nexport const getOutputSchema = (kind: Trigger.Kind) => {\n const kindToSchema: Record<Trigger.Kind, Schema.Schema<any>> = {\n ['email']: TriggerEvent.EmailEvent,\n ['subscription']: TriggerEvent.SubscriptionEvent,\n ['timer']: TriggerEvent.TimerEvent,\n ['webhook']: TriggerEvent.WebhookEvent,\n ['feed']: TriggerEvent.FeedEvent,\n ['direct']: TriggerEvent.DirectEvent,\n };\n return kindToSchema[kind];\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useEffect } from 'react';\n\nimport * as Trigger from '@dxos/compute/Trigger';\nimport { VoidInput } from '@dxos/conductor';\nimport { Obj } from '@dxos/echo';\nimport { useResolveRef } from '@dxos/echo-react';\nimport { useSpaces } from '@dxos/react-client/echo';\nimport { type ShapeComponentProps } from '@dxos/react-ui-canvas-editor';\nimport * as Select from '@dxos/react-ui/Select';\n\nimport { FunctionBody, getHeight } from './common/index.ts';\nimport { type TriggerShape } from './trigger-def.ts';\nimport { createTriggerSpec, getOutputSchema } from './trigger-spec.ts';\n\nexport type TriggerComponentProps = ShapeComponentProps<TriggerShape>;\n\nexport const TriggerComponent = ({ shape }: TriggerComponentProps) => {\n const [space] = useSpaces();\n const functionTrigger = useResolveRef(shape.functionTrigger);\n\n useEffect(() => {\n if (functionTrigger && !functionTrigger.spec) {\n Obj.update(functionTrigger, (functionTrigger) => {\n functionTrigger.spec = createTriggerSpec({\n triggerKind: 'email',\n spaceId: space?.id,\n }) as Obj.Mutable<Trigger.Spec>;\n });\n }\n }, [functionTrigger, functionTrigger?.spec]);\n\n useEffect(() => {\n shape.size.height = getHeight(getOutputSchema(functionTrigger?.spec?.kind ?? 'email'));\n }, [functionTrigger?.spec?.kind]);\n\n const setKind = (kind: Trigger.Kind) => {\n if (functionTrigger?.spec?.kind !== kind) {\n Obj.update(functionTrigger!, (obj) => {\n obj.spec = createTriggerSpec({ triggerKind: kind, spaceId: space?.id }) as Obj.Mutable<Trigger.Spec>;\n });\n }\n };\n\n if (!functionTrigger?.spec) {\n return;\n }\n\n return (\n <FunctionBody\n shape={shape}\n status={<TriggerKindSelect value={functionTrigger.spec?.kind} onValueChange={setKind} />}\n inputSchema={VoidInput}\n outputSchema={getOutputSchema(functionTrigger.spec!.kind!)}\n />\n );\n};\n\n// TODO(burdon): Factor out.\ntype TriggerKindSelectProps = {\n value?: Trigger.Kind;\n onValueChange: (kind: Trigger.Kind) => void;\n};\n\nconst TriggerKindSelect = ({ value, onValueChange }: TriggerKindSelectProps) => {\n return (\n <Select.Root\n value={value === undefined ? [] : [value]}\n onValueChange={({ value: [next] }) => {\n const kind = Trigger.Kinds.find((kind) => kind === next);\n if (kind) {\n onValueChange(kind);\n }\n }}\n items={Trigger.Kinds.map((kind) => ({ value: kind, label: kind }))}\n >\n <Select.Trigger classNames='w-full px-0!' />\n <Select.Content>\n {Trigger.Kinds.map((kind) => (\n <Select.Item key={kind} item={{ value: kind, label: kind }} />\n ))}\n </Select.Content>\n </Select.Root>\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport * as Trigger from '@dxos/compute/Trigger';\nimport * as TriggerEvent from '@dxos/compute/TriggerEvent';\nimport { VoidInput } from '@dxos/conductor';\nimport { Ref } from '@dxos/echo';\nimport { type SpaceId } from '@dxos/keys';\nimport { type ShapeDef } from '@dxos/react-ui-canvas-editor';\n\nimport { createFunctionAnchors, getHeight } from './common/index.ts';\nimport { ComputeShape, type CreateShapeProps, createShape } from './defs.ts';\nimport { createTriggerSpec, getOutputSchema } from './trigger-spec.ts';\nimport { TriggerComponent } from './Trigger.tsx';\n\n// Kept out of `Trigger.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\n/** The struct behind `TriggerShape`, for hosts that compose their own union (the scene engine). */\nexport const TriggerShapeSchema = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('trigger'),\n functionTrigger: Schema.optional(Ref.Ref(Trigger.Trigger)),\n }),\n);\n\n// TODO(wittjosiah): Try to clean up this type inference.\nexport interface TriggerShape extends ComputeShape {\n type: 'trigger';\n functionTrigger?: Ref.Ref<Trigger.Trigger>;\n}\n\nexport const TriggerShape: Schema.Codec<TriggerShape> = TriggerShapeSchema as any;\n\nexport type CreateTriggerProps = CreateShapeProps<Omit<TriggerShape, 'functionTrigger'>> & {\n spaceId?: SpaceId;\n triggerKind?: Trigger.Kind;\n};\n\nexport const createTrigger = (props: CreateTriggerProps): TriggerShape => {\n const functionTrigger = Trigger.make({\n enabled: true,\n spec: createTriggerSpec(props),\n });\n return createShape<TriggerShape>({\n type: 'trigger',\n functionTrigger: Ref.make(functionTrigger),\n size: { width: 192, height: getHeight(TriggerEvent.EmailEvent) },\n ...props,\n });\n};\n\nexport const triggerShape: ShapeDef<TriggerShape> = {\n type: 'trigger',\n name: 'Trigger',\n icon: 'ph--lightning--regular',\n component: TriggerComponent,\n createShape: createTrigger,\n getAnchors: (shape) =>\n createFunctionAnchors(shape, VoidInput, getOutputSchema(shape.functionTrigger?.target?.spec?.kind ?? 'email')),\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\nimport React, { type FC } from 'react';\n\nimport { type ShapeDef, getAnchorPoints } from '@dxos/react-ui-canvas-editor';\nimport { createAnchors } from '@dxos/react-ui-canvas-editor';\n\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs.ts';\n\n//\n// Gate utils.\n// https://en.wikipedia.org/wiki/Logic_gate\n//\n\ntype GateType = 'and' | 'or' | 'not';\n\nconst GateShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.String,\n }),\n);\n\ntype GateShape = Schema.Schema.Type<typeof GateShape>;\n\ntype CreateGateProps = CreateShapeProps<GateShape> & { type: GateType };\n\nconst createGate = (props: CreateGateProps): GateShape =>\n createShape<GateShape>({\n size: { width: 64, height: 64 },\n ...props,\n });\n\n// TODO(burdon): Create custom icons.\nconst defineShape = <S extends GateShape>({\n type,\n name,\n icon,\n symbol: Symbol,\n createShape,\n inputs,\n outputs = [createAnchorId('output')],\n}: {\n type: GateType;\n symbol: FC<GateSymbolProps>;\n createShape: ShapeDef<S>['createShape'];\n inputs: string[];\n outputs?: string[];\n} & Pick<ShapeDef<GateShape>, 'name' | 'icon'>): ShapeDef<GateShape> => ({\n type,\n name,\n icon,\n // NOTE: Preact interprets captitalized properties as React components.\n // Be careful not to name component factories with a capital letter.\n component: () => {\n return (\n <div className='flex w-full justify-center items-center'>\n <Symbol />\n </div>\n );\n },\n createShape,\n getAnchors: (shape) => createAnchors({ shape, inputs, outputs }),\n});\n\n//\n// Symbols\n//\n\ntype PathConstructor = (props: { startX: number; endX: number; height: number }) => string[];\n\ntype GateSymbolProps = {\n width?: number;\n height?: number;\n className?: string;\n strokeWidth?: number;\n};\n\n// TODO(burdon): Note inputs should line up with anchors.\nconst createSymbol =\n (pathConstructor: PathConstructor, inputs: number): FC<GateSymbolProps> =>\n ({\n width = 64,\n height = 32,\n // TODO(burdon): Same as line color.\n className = 'fill-neutral-200 dark:fill-neutral-800 stroke-neutral-500',\n strokeWidth = 1,\n }) => {\n const startX = width * 0.25;\n const endX = width * 0.75;\n const centerY = height / 2;\n const paths = pathConstructor({ startX, endX, height });\n\n return (\n <svg viewBox={`0 0 ${width} ${height}`} className='dx-fill'>\n {/* Input line. */}\n {getAnchorPoints({ x: 0, y: centerY }, inputs).map(({ x, y }, i) => (\n <line key={i} x1={x} y1={y} x2={startX * 1.3} y2={y} strokeWidth={strokeWidth} className={className} />\n ))}\n\n {/* Output line. */}\n <line x1={endX} y1={centerY} x2={width} y2={centerY} strokeWidth={strokeWidth} className={className} />\n\n {/* And body. */}\n {paths.map((path, i) => (\n <path key={i} d={path} strokeWidth={strokeWidth} className={className} />\n ))}\n </svg>\n );\n };\n\n//\n// AND\n//\n\nconst AndSymbol = createSymbol(({ startX, endX, height }) => {\n const arcRadius = (endX - startX) / 2;\n return [\n `\n M ${startX},${height * 0.1}\n L ${endX - arcRadius},${height * 0.1}\n A ${arcRadius},${height * 0.4} 0 0 1 ${endX - arcRadius},${height * 0.9}\n L ${startX},${height * 0.9}\n Z\n `,\n ];\n}, 2);\n\nexport const AndShape = GateShape;\nexport type AndShape = GateShape;\n\nexport const createAnd = (props: Omit<CreateGateProps, 'type' | 'node'>) => {\n return createGate({ ...props, type: 'and' });\n};\nexport const andShape = defineShape({\n type: 'and',\n name: 'AND',\n icon: 'ph--intersection--regular',\n symbol: AndSymbol,\n createShape: createAnd,\n inputs: ['input.a', 'input.b'],\n});\n\n//\n// OR\n//\n\n// TODO(burdon): Should have sharper point.\nconst OrSymbol = createSymbol(({ startX, endX, height }) => {\n const arcRadius = (endX - startX) / 2;\n return [\n `\n M ${startX},${height * 0.1}\n L ${endX - arcRadius},${height * 0.1}\n A ${arcRadius},${height * 0.4} 0 0 1 ${endX - arcRadius},${height * 0.9}\n L ${startX},${height * 0.9}\n C ${startX * 1.4},${height * 0.5} ${startX * 1.4},${height * 0.5} ${startX},${height * 0.1}\n Z\n `,\n ];\n}, 2);\n\nexport const OrShape = GateShape;\nexport type OrShape = GateShape;\n\nexport const createOr = (props: Omit<CreateGateProps, 'type' | 'node'>) => {\n return createGate({ ...props, type: 'or' });\n};\nexport const orShape = defineShape({\n type: 'or',\n name: 'OR',\n icon: 'ph--union--regular',\n symbol: OrSymbol,\n createShape: createOr,\n inputs: ['input.a', 'input.b'],\n});\n\n//\n// NOT\n//\n\nconst NotSymbol = createSymbol(({ startX, endX, height }) => {\n return [\n `\n M ${startX},${height * 0.1}\n L ${endX * 0.9},${height * 0.5}\n L ${startX},${height * 0.9}\n Z\n `,\n `\n M ${endX - height * 0.2},${height * 0.5}\n A ${height * 0.1} ${height * 0.1} 0 0 1 ${endX},${height * 0.5}\n A ${height * 0.1} ${height * 0.1} 0 0 1 ${endX - height * 0.2},${height * 0.5}\n Z\n `,\n ];\n}, 1);\n\nexport const NotShape = GateShape;\nexport type NotShape = GateShape;\n\nexport const createNot = (props: Omit<CreateGateProps, 'type' | 'node'>) => {\n return createGate({ ...props, type: 'not' });\n};\nexport const notShape = defineShape({\n type: 'not',\n name: 'NOT',\n icon: 'ph--x--regular',\n symbol: NotSymbol,\n createShape: createNot,\n inputs: [createAnchorId('input')],\n});\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport type { ShapeDef } from '@dxos/react-ui-canvas-editor';\nimport { noteShape } from '@dxos/react-ui-canvas-editor';\n\nimport {\n andShape,\n appendShape,\n audioShape,\n beaconShape,\n chatShape,\n constantShape,\n databaseShape,\n feedShape,\n functionShape,\n gptRealtimeShape,\n gptShape,\n ifElseShape,\n ifShape,\n jsonShape,\n jsonTransformShape,\n notShape,\n orShape,\n randomShape,\n reducerShape,\n scopeShape,\n surfaceShape,\n switchShape,\n templateShape,\n textShape,\n textToImageShape,\n threadShape,\n triggerShape,\n} from './shapes/index.ts';\n\n/**\n * Order used by toolbar.\n */\nexport const computeShapes: { title: string; shapes: ShapeDef[] }[] = [\n {\n title: 'Inputs',\n shapes: [\n //\n constantShape,\n templateShape,\n chatShape,\n switchShape,\n audioShape,\n triggerShape,\n randomShape,\n ],\n },\n {\n title: 'Transform',\n shapes: [\n //\n gptShape,\n gptRealtimeShape,\n functionShape,\n databaseShape,\n textToImageShape,\n appendShape,\n ],\n },\n {\n title: 'Operations',\n shapes: [\n //\n ifShape,\n ifElseShape,\n andShape,\n orShape,\n notShape,\n reducerShape,\n jsonTransformShape,\n ],\n },\n {\n title: 'Outputs',\n shapes: [\n //\n jsonShape,\n feedShape,\n threadShape,\n textShape,\n surfaceShape,\n beaconShape,\n scopeShape,\n ],\n },\n {\n title: 'Misc',\n shapes: [\n //\n noteShape,\n ],\n },\n];\n","//\n// Copyright 2026 DXOS.org\n//\n\n//\n// The editor's bullets over the scene engine: a dot runs along a link's path when the compute node at\n// its source emits the property the link carries. Drawn as an overlay in scene coordinates; the paths\n// are found by the link id the layer stamps on them.\n//\n\nimport { useAtomValue } from '@effect/atom-react/Hooks';\nimport React, { useEffect, useRef } from 'react';\n\nimport { DEFAULT_OUTPUT } from '@dxos/conductor';\nimport { type Projection, type Scene, endpointNode } from '@dxos/react-ui-canvas/scene';\n\nimport { type ComputeGraphController } from '../graph/index.ts';\nimport { parseAnchorId } from '../shapes/index.ts';\n\nconst RADIUS = 3;\nconst DURATION_MS = 500;\nconst MAX_BULLETS = 32;\n\nexport type BulletsProps = {\n controller: ComputeGraphController;\n projection: Projection;\n};\n\n/** Links leaving the compute node `nodeId` through `property`. */\nconst outgoing = (scene: Scene, nodeId: string, property: string) =>\n Object.values(scene.links).filter((link) => {\n const source = endpointNode(link.source);\n const node = source ? scene.nodes[source] : undefined;\n if (!node || !('node' in node) || node.node !== nodeId) {\n return false;\n }\n const port = 'port' in link.source ? link.source.port : undefined;\n return (port ? parseAnchorId(port)[1] : DEFAULT_OUTPUT) === property;\n });\n\nexport const Bullets = ({ controller, projection }: BulletsProps) => {\n const scene = useAtomValue(projection.scene);\n const sceneRef = useRef(scene);\n sceneRef.current = scene;\n const layerRef = useRef<SVGGElement>(null);\n\n useEffect(\n () =>\n controller.output.on(({ nodeId, property, value }) => {\n const layer = layerRef.current;\n const root = layer?.closest('[data-testid=\"scene-view\"]');\n if (!layer || !root || value.type === 'not-executed') {\n return;\n }\n for (const link of outgoing(sceneRef.current, nodeId, property)) {\n const path = root.querySelector(`path[data-link-id=\"${link.id}\"]`);\n if (path instanceof SVGPathElement && layer.childElementCount < MAX_BULLETS) {\n fireBullet(layer, path);\n }\n }\n }),\n [controller],\n );\n\n return (\n <svg className='absolute overflow-visible pointer-events-none' width={1} height={1}>\n <g ref={layerRef} />\n </svg>\n );\n};\n\n/** One dot from the path's start to its end, removed when it arrives. */\nconst fireBullet = (layer: SVGGElement, path: SVGPathElement) => {\n const bullet = document.createElementNS('http://www.w3.org/2000/svg', 'circle');\n bullet.setAttribute('r', String(RADIUS));\n bullet.setAttribute('class', 'fill-orange-500');\n layer.append(bullet);\n const length = path.getTotalLength();\n const started = performance.now();\n const step = (now: number) => {\n const t = Math.min((now - started) / DURATION_MS, 1);\n const point = path.getPointAtLength(length * t);\n bullet.setAttribute('cx', String(point.x));\n bullet.setAttribute('cy', String(point.y));\n if (t < 1) {\n requestAnimationFrame(step);\n } else {\n bullet.remove();\n }\n };\n requestAnimationFrame(step);\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport React, { type ComponentType, type FC } from 'react';\n\nimport { type ShapeComponentProps } from '@dxos/react-ui-canvas-editor';\nimport { type NodeViewProps, UnknownNodeView } from '@dxos/react-ui-canvas/scene';\n\nimport { useComputeContext } from '../hooks/compute-context.ts';\nimport { useControllerUpdates } from '../hooks/useControllerUpdates.ts';\nimport { type ComputeShape } from '../shapes/index.ts';\n\n/**\n * The shape component under the engine's view props: the node is the shape (it carries the same fields\n * plus `z`), re-rendered on every controller update since the runtime state it reads is not reactive.\n */\nexport const computeNodeView = <S extends ComputeShape>(\n schema: Schema.Codec<S, unknown, never, never>,\n Component: FC<ShapeComponentProps<S>>,\n): ComponentType<NodeViewProps> => {\n const isShape = Schema.is(schema);\n const View = (props: NodeViewProps) => {\n const { node, selected } = props;\n const { controller } = useComputeContext();\n useControllerUpdates(controller);\n if (!isShape(node)) {\n return <UnknownNodeView {...props} />;\n }\n // The shape components were written against the editor's frame body, which is a full-size flex\n // container (`styles.frameContainer`); the engine's node frame is not, so their `grow` / `w-full`\n // centring collapsed to the top-left corner. The wrapper restores that contract for every shape.\n return (\n <div className='dx-cover flex'>\n <Component shape={node} selected={selected} />\n </div>\n );\n };\n View.displayName = `ComputeNodeView(${Component.displayName ?? Component.name})`;\n return View;\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\n//\n// Anchors as the scene engine's ports (MIGRATION.md §2.2): an anchor is a point relative to the shape's\n// centre, a port is a side and an offset along it; the anchor id says which way a link may run.\n//\n\nimport { type Anchor } from '@dxos/react-ui-canvas-editor';\nimport { type Port, type Size } from '@dxos/react-ui-canvas/scene';\n\nimport { parseAnchorId } from '../shapes/defs.ts';\n\n/** The ports of a shape from its anchors; a port's direction comes from the `input.` / `output.` prefix. */\nexport const anchorsToPorts = (anchors: Record<string, Anchor>, size: Size): Port[] =>\n Object.values(anchors).map(({ id, pos }) => {\n const [kind] = parseAnchorId(id);\n const half = { x: size.width / 2, y: size.height / 2 };\n // The anchor sits on whichever edge it is nearer to; ties go to the vertical edges (the input / output sides).\n const vertical = Math.abs(Math.abs(pos.x) - half.x) <= Math.abs(Math.abs(pos.y) - half.y);\n const side = vertical ? (pos.x < 0 ? 'w' : 'e') : pos.y < 0 ? 'n' : 's';\n const along = vertical ? (pos.y + half.y) / size.height : (pos.x + half.x) / size.width;\n return {\n id,\n side,\n offset: Math.min(Math.max(along, 0), 1),\n ...(kind === 'input' ? { accepts: 'in' as const } : kind === 'output' ? { accepts: 'out' as const } : {}),\n };\n });\n","//\n// Copyright 2026 DXOS.org\n//\n\n//\n// The compute shapes as scene-engine node definitions (MIGRATION.md M3): each `ShapeDef` becomes a\n// `NodeDef` whose schema is the shape's with the engine's `z`, whose view renders the shape component\n// unchanged, and whose ports come from the shape's anchors. The palette groups mirror the editor's.\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport * as TriggerEvent from '@dxos/compute/TriggerEvent';\nimport { type ShapeDef } from '@dxos/react-ui-canvas-editor';\nimport {\n type CreateProps,\n type NodeBase,\n type NodeDef,\n type NodeRegistry,\n type Size,\n defaultNodeRegistry,\n} from '@dxos/react-ui-canvas/scene';\n\nimport {\n AndShape,\n AppendShape,\n AudioShape,\n BeaconShape,\n ChatShape,\n type ComputeShape,\n ConstantShape,\n DatabaseShape,\n FeedShape,\n FunctionShape,\n GptRealtimeShape,\n GptShape,\n IfElseShape,\n IfShape,\n JsonShape,\n JsonTransformShape,\n NotShape,\n OrShape,\n RandomShape,\n ReducerShape,\n ScopeShape,\n SurfaceShape,\n SwitchShape,\n TemplateShape,\n TextShape,\n TextToImageShape,\n ThreadShape,\n TriggerShapeSchema,\n andShape,\n appendShape,\n audioShape,\n beaconShape,\n chatShape,\n constantShape,\n databaseShape,\n feedShape,\n functionShape,\n getHeight,\n gptRealtimeShape,\n gptShape,\n ifElseShape,\n ifShape,\n jsonShape,\n jsonTransformShape,\n notShape,\n orShape,\n randomShape,\n reducerShape,\n scopeShape,\n surfaceShape,\n switchShape,\n templateShape,\n textShape,\n textToImageShape,\n threadShape,\n triggerShape,\n} from '../shapes/index.ts';\nimport { computeNodeView } from './NodeView.tsx';\nimport { anchorsToPorts } from './ports.ts';\n\n/** The shape's schema with the engine's z-order key, so it is a node schema. */\nconst withZ = <Fields extends Schema.Struct.Fields>(shape: Schema.Struct<Fields>) =>\n shape.mapFields(Struct.assign({ z: Schema.String }));\n\ntype Entry = { group: string; def: NodeDef };\n\n/** `schema` is the shape's with `z` (`withZ`), applied at the call site so each stays a concrete struct. */\nconst entry = <S extends ComputeShape>(\n group: string,\n shape: ShapeDef<S>,\n schema: Schema.Codec<S & { z: string }, unknown, never, never>,\n defaultSize: Size = shape.createShape({ id: 'default', center: { x: 0, y: 0 } }).size,\n): Entry => ({\n group,\n def: {\n type: shape.type,\n name: shape.name,\n icon: shape.icon,\n group,\n schema,\n component: computeNodeView(schema, shape.component),\n create: ({ id, z, center, size }: CreateProps): NodeBase => ({ ...shape.createShape({ id, center }), z, size }),\n defaultSize,\n ports: (node) => (isShapeOf(schema, node) ? anchorsToPorts(shape.getAnchors?.(node) ?? {}, node.size) : []),\n resizable: shape.resizable,\n openable: shape.openable,\n },\n});\n\nconst isShapeOf = <S extends ComputeShape>(\n schema: Schema.Codec<S, unknown, never, never>,\n node: NodeBase,\n): node is NodeBase & S => Schema.is(schema)(node);\n\n/** Palette order, as the editor's `computeShapes`. */\nconst entries: Entry[] = [\n entry('Inputs', constantShape, withZ(ConstantShape)),\n entry('Inputs', templateShape, withZ(TemplateShape)),\n entry('Inputs', chatShape, withZ(ChatShape)),\n entry('Inputs', switchShape, withZ(SwitchShape)),\n entry('Inputs', audioShape, withZ(AudioShape)),\n // A trigger's `createShape` makes an ECHO object, so its default size is stated rather than sampled.\n entry('Inputs', triggerShape, withZ(TriggerShapeSchema), { width: 192, height: getHeight(TriggerEvent.EmailEvent) }),\n entry('Inputs', randomShape, withZ(RandomShape)),\n entry('Transform', gptShape, withZ(GptShape)),\n entry('Transform', gptRealtimeShape, withZ(GptRealtimeShape)),\n entry('Transform', functionShape, withZ(FunctionShape)),\n entry('Transform', databaseShape, withZ(DatabaseShape)),\n entry('Transform', textToImageShape, withZ(TextToImageShape)),\n entry('Transform', appendShape, withZ(AppendShape)),\n entry('Operations', ifShape, withZ(IfShape)),\n entry('Operations', ifElseShape, withZ(IfElseShape)),\n entry('Operations', andShape, withZ(AndShape)),\n entry('Operations', orShape, withZ(OrShape)),\n entry('Operations', notShape, withZ(NotShape)),\n entry('Operations', reducerShape, withZ(ReducerShape)),\n entry('Operations', jsonTransformShape, withZ(JsonTransformShape)),\n entry('Outputs', jsonShape, withZ(JsonShape)),\n entry('Outputs', feedShape, withZ(FeedShape)),\n entry('Outputs', threadShape, withZ(ThreadShape)),\n entry('Outputs', textShape, withZ(TextShape)),\n entry('Outputs', surfaceShape, withZ(SurfaceShape)),\n entry('Outputs', beaconShape, withZ(BeaconShape)),\n entry('Outputs', scopeShape, withZ(ScopeShape)),\n];\n\nexport const computeNodeDefs: NodeDef[] = entries.map(({ def }) => def);\n\n/** The compute types plus the engine's note under a `Misc` group. */\nexport const computeNodeRegistry: NodeRegistry = {\n ...Object.fromEntries(computeNodeDefs.map((def) => [def.type, def])),\n note: { ...defaultNodeRegistry.note, group: 'Misc' },\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\n//\n// The scene store over a `CanvasBoard` (MIGRATION.md M4): `layout.nodes` are the scene's nodes and\n// `layout.edges` its links, so a board written by the old editor opens on the engine unchanged. The\n// store is the only seam that changes — `SceneView` takes this exactly as it takes the memory store.\n//\n// The two representations differ in three places, and each is translated rather than migrated:\n// z-order (an array in the layout, a fractional key in the scene), style (`guide` / `classNames` at the\n// top of a shape, a `style` object on a node) and link ends (an edge's `input` / `output` property\n// names, a link endpoint's anchor-id port).\n//\n\nimport * as Equal from 'effect/Equal';\nimport * as Atom from 'effect/reactivity/Atom';\n\nimport { DEFAULT_INPUT, DEFAULT_OUTPUT } from '@dxos/conductor';\nimport { Obj } from '@dxos/echo';\nimport { CanvasBoard } from '@dxos/react-ui-canvas-editor';\nimport {\n type Link,\n LINK_TYPES,\n type LinkType,\n type Node,\n type NodeStyle,\n type Scene,\n type SceneId,\n type SceneMap,\n type SceneStore,\n initialKeys,\n sortByZ,\n} from '@dxos/react-ui-canvas/scene';\n\nimport { createAnchorId, parseAnchorId } from '../shapes/defs.ts';\n\n/** A board's layout as both representations see it: the arrays, whether live (ECHO) or plain. */\ntype Layout = { nodes: CanvasBoard.Shape[]; edges: CanvasBoard.Connection[] };\n\n/** The scene id a board's own layout takes; a board holds one scene, so it is the board's id. */\nexport const boardSceneId = (board: CanvasBoard.CanvasBoard): SceneId => board.id;\n\n/** An edge naming a type the engine does not have is drawn as a curve, which is what the editor drew. */\nconst DEFAULT_LINK_TYPE: LinkType = 'curve';\nconst linkType = (type: string | undefined): LinkType =>\n LINK_TYPES.find((candidate) => candidate === type) ?? DEFAULT_LINK_TYPE;\n\n//\n// Read\n//\n\n/**\n * The scene a layout stands for. `z` comes from array order — the order the editor painted in — so the\n * first read of an existing board reproduces its stacking exactly; every later read uses the key the\n * write path put the node's position in the array for.\n */\nexport const sceneFromLayout = (id: SceneId, layout: Partial<Layout> | undefined, name?: string): Scene => {\n const shapes = layout?.nodes ?? [];\n const edges = layout?.edges ?? [];\n const nodeKeys = initialKeys(shapes.length);\n const linkKeys = initialKeys(edges.length);\n const nodes: Record<string, Node> = {};\n shapes.forEach((shape, index) => {\n nodes[shape.id] = nodeFromShape(shape, nodeKeys[index]);\n });\n const links: Record<string, Link> = {};\n edges.forEach((edge, index) => {\n links[edge.id] = linkFromEdge(edge, linkKeys[index]);\n });\n return { id, ...(name ? { name } : {}), nodes, links };\n};\n\nconst nodeFromShape = (shape: CanvasBoard.Shape, z: string): Node => {\n const { guide: _guide, classNames: _classNames, ...rest } = shape as CanvasBoard.Shape & { style?: NodeStyle };\n const style = styleFromShape(shape);\n return {\n ...(rest as unknown as Node),\n z,\n ...(style ? { style } : {}),\n };\n};\n\n/** A shape's look: its own `style` when the engine wrote one, else the editor's two top-level fields. */\nconst styleFromShape = (shape: CanvasBoard.Shape): NodeStyle | undefined => {\n const { style, guide, classNames } = shape as CanvasBoard.Shape & { style?: NodeStyle };\n const legacy: NodeStyle = {\n ...(guide !== undefined ? { guide } : {}),\n ...(classNames !== undefined ? { className: classNames } : {}),\n };\n const merged = { ...legacy, ...style };\n return Object.keys(merged).length > 0 ? merged : undefined;\n};\n\n/**\n * The link an edge stands for. Both ends are node ends: the editor has no free endpoints, and the\n * property names it stores become the anchor ids the compute node definitions draw ports for.\n */\nconst linkFromEdge = (edge: CanvasBoard.Connection, z: string): Link => {\n const { id, source, target, input, output, type } = edge;\n return {\n id,\n type: linkType(type),\n z,\n source: { node: source, port: createAnchorId('output', output ?? DEFAULT_OUTPUT) },\n target: { node: target, port: createAnchorId('input', input ?? DEFAULT_INPUT) },\n } as Link;\n};\n\n//\n// Write\n//\n\n/**\n * The scene applied to a layout in place: each element updated, added or removed on its own, and the\n * arrays left in z order. A wholesale rebuild would be one Automerge delta per drag frame covering the\n * whole board, so every change here touches only what changed.\n */\nexport const applySceneToLayout = (layout: Layout, scene: Scene): void => {\n applyElements(layout.nodes, sortByZ(Object.values(scene.nodes)).map(shapeFromNode));\n applyElements(layout.edges, sortByZ(Object.values(scene.links)).map(edgeFromLink));\n};\n\n/** One array reconciled against the elements it should hold, in that order. */\nconst applyElements = <T extends { id: string }>(current: T[], next: readonly T[]): void => {\n const wanted = new Map(next.map((element) => [element.id, element]));\n for (let index = current.length - 1; index >= 0; index--) {\n const element = current[index];\n const update = wanted.get(element.id);\n if (update) {\n assignFields(element as Record<string, unknown>, update as Record<string, unknown>);\n } else {\n current.splice(index, 1);\n }\n }\n const present = new Set(current.map(({ id }) => id));\n for (const element of next) {\n if (!present.has(element.id)) {\n current.push(element);\n }\n }\n reorder(current, next);\n};\n\n/** The array put in `next`'s order, moving only the elements that are out of place. */\nconst reorder = <T extends { id: string }>(current: T[], next: readonly T[]): void => {\n const order = new Map(next.map((element, index) => [element.id, index]));\n for (let index = 1; index < current.length; index++) {\n const element = current[index];\n const rank = order.get(element.id) ?? 0;\n let target = index;\n while (target > 0 && (order.get(current[target - 1].id) ?? 0) > rank) {\n target--;\n }\n if (target !== index) {\n current.splice(index, 1);\n current.splice(target, 0, element);\n }\n }\n};\n\n/** The shape a node is stored as: the node's own fields, the style kept and also mirrored for the editor. */\nconst shapeFromNode = (node: Node): CanvasBoard.Shape => {\n const { z: _z, style, ...rest } = node as Node & { style?: NodeStyle };\n return {\n ...(rest as unknown as CanvasBoard.Shape),\n ...(style ? { style } : {}),\n // The old editor reads these two, so a board stays readable by it (M5 retires them with the package).\n ...(style?.guide !== undefined ? { guide: style.guide } : {}),\n ...(style?.className !== undefined ? { classNames: style.className } : {}),\n } as CanvasBoard.Shape;\n};\n\nconst edgeFromLink = (link: Link): CanvasBoard.Connection => {\n const source = 'node' in link.source ? link.source : undefined;\n const target = 'node' in link.target ? link.target : undefined;\n return {\n id: link.id,\n type: link.type,\n source: source?.node ?? '',\n target: target?.node ?? '',\n output: parseAnchorId(source?.port ?? '')[1] || DEFAULT_OUTPUT,\n input: parseAnchorId(target?.port ?? '')[1] || DEFAULT_INPUT,\n } as CanvasBoard.Connection;\n};\n\n/** Fields written one by one, so an unchanged field produces no Automerge change. */\nconst assignFields = (element: Record<string, unknown>, next: Record<string, unknown>): void => {\n for (const [key, value] of Object.entries(next)) {\n // Structural, so a node whose geometry object was rebuilt but holds the same numbers writes nothing.\n if (key !== 'id' && !Equal.equals(element[key], value)) {\n element[key] = value;\n }\n }\n for (const key of Object.keys(element)) {\n if (key !== 'id' && !(key in next)) {\n delete element[key];\n }\n }\n};\n\n//\n// Store\n//\n\nexport type EchoStoreOptions = {\n /** The scene the board's own layout is; defaults to the board's id. */\n sceneId?: SceneId;\n};\n\n/**\n * A `SceneStore` over a board's layout: reads derive the scene from the object (re-deriving whenever\n * ECHO announces a change, including a peer's edit), writes go back through `Obj.update`. Only the\n * board's own scene lives here — a nested scene needs another object and is not part of M4.\n */\nexport const createEchoStore = (board: CanvasBoard.CanvasBoard, options: EchoStoreOptions = {}): SceneStore => {\n const sceneId = options.sceneId ?? boardSceneId(board);\n const scenes = Atom.keepAlive(\n Atom.writable<SceneMap, SceneMap>(\n (get) => {\n const snapshot = get(Obj.atom(board));\n return { [sceneId]: sceneFromLayout(sceneId, snapshot.layout as Partial<Layout>, snapshot.name) };\n },\n (ctx, next) => {\n const scene = next[sceneId];\n if (scene) {\n Obj.update(board, (board) => applySceneToLayout(board.layout as Layout, scene));\n }\n ctx.refreshSelf();\n },\n ),\n );\n\n const derived = new Map<SceneId, Atom.Atom<Scene | undefined>>();\n return {\n scenes,\n scene: (id) => {\n let atom = derived.get(id);\n if (!atom) {\n atom = Atom.keepAlive(Atom.make((get) => get(scenes)[id]));\n derived.set(id, atom);\n }\n return atom;\n },\n };\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\n//\n// The compute projection (MIGRATION.md M3, DESIGN.md §3): freehand semantics over the scene store, and\n// every structural intent mirrored into the compute graph, which is what the editor's `GraphMonitor`\n// did from the outside. The positioned scene it emits carries each node's runtime ports: a node whose\n// compute node declares input / output schemas gets one port per property.\n//\n\nimport * as Atom from 'effect/reactivity/Atom';\n\nimport { DefaultInput, DefaultOutput } from '@dxos/conductor';\nimport * as JsonSchema from '@dxos/echo/JsonSchema';\nimport {\n type FreehandProjectionOptions,\n type Intent,\n type Link,\n type Node,\n type Projection,\n type Scene,\n createFreehandProjection,\n endpointNode,\n reduceIntent,\n} from '@dxos/react-ui-canvas/scene';\n\nimport {\n type ComputeGraphController,\n type ComputeLink,\n deleteTriggerObjects,\n findEdge,\n syncCreate,\n syncDelete,\n syncLink,\n} from '../graph/index.ts';\nimport { type ComputeShape, createFunctionAnchors, parseAnchorId } from '../shapes/index.ts';\nimport { anchorsToPorts } from './ports.ts';\n\n/** What the projection needs of the controller: the graph it mirrors into and the runtime's change event. */\nexport type ComputeGraphSource = Pick<ComputeGraphController, 'graph' | 'update'>;\n\nexport type ComputeProjectionOptions = FreehandProjectionOptions & {\n controller: ComputeGraphSource;\n};\n\n/** The compute node id a scene node carries, when it is a compute shape. */\nconst computeId = (node: Node | undefined): string | undefined =>\n node && 'node' in node && typeof node.node === 'string' ? node.node : undefined;\n\n/** The compute edge a link stands for: both ends on compute nodes, the ports naming the properties. */\nconst computeLink = (scene: Scene, link: Link | undefined): ComputeLink | undefined => {\n if (!link) {\n return undefined;\n }\n const sourceNode = endpointNode(link.source);\n const targetNode = endpointNode(link.target);\n const source = computeId(sourceNode ? scene.nodes[sourceNode] : undefined);\n const target = computeId(targetNode ? scene.nodes[targetNode] : undefined);\n if (!source || !target) {\n return undefined;\n }\n const output = 'port' in link.source ? parseAnchorId(link.source.port ?? '')[1] : undefined;\n const input = 'port' in link.target ? parseAnchorId(link.target.port ?? '')[1] : undefined;\n return { source, target, ...(output ? { output } : {}), ...(input ? { input } : {}) };\n};\n\nconst sameLink = (left: ComputeLink | undefined, right: ComputeLink | undefined): boolean =>\n left?.source === right?.source &&\n left?.target === right?.target &&\n left?.output === right?.output &&\n left?.input === right?.input;\n\n/**\n * Freehand over the store plus the compute graph kept in step: `create` makes the compute node and writes\n * its id into the shape, `link` adds the edge, `delete` removes both, an end dragged to another node moves\n * the edge, and a restored scene (undo / redo) gets its nodes and edges back. The scene atom re-emits on\n * every controller update so runtime ports (and the components reading runtime state) follow.\n */\nexport const createComputeProjection = ({\n registry,\n store,\n sceneId,\n controller,\n}: ComputeProjectionOptions): Projection => {\n const freehand = createFreehandProjection({ registry, store, sceneId });\n const model = controller.graph;\n // Compute nodes this projection made or removed: the ones a restore may take away again.\n const mirrored = new Set<string>();\n\n // The compute graph is not an atom: the scene re-derives on every controller update instead.\n const scene = Atom.keepAlive(\n Atom.make((get) => {\n const current = get(freehand.scene);\n const nodes = Object.fromEntries(\n Object.values(current.nodes).map((node) => [node.id, withRuntimePorts(controller, node)]),\n );\n return { ...current, nodes };\n }),\n );\n controller.update.on(() => registry.refresh(scene));\n\n const apply = (intent: Intent): void => {\n switch (intent.kind) {\n case 'create': {\n const computeNode = syncCreate(model, intent.node);\n if (computeNode) {\n mirrored.add(computeNode.id);\n }\n const node = computeNode ? { ...intent.node, node: computeNode.id } : intent.node;\n freehand.apply({ kind: 'create', node });\n break;\n }\n case 'link': {\n const current = registry.get(freehand.scene);\n // The reducer decides first, so a link the scene refuses (a self-link, a missing end) has no edge.\n if (reduceIntent(current, intent) === current) {\n break;\n }\n const edge = computeLink(current, intent.link);\n if (edge) {\n syncLink(model, edge);\n }\n freehand.apply(intent);\n break;\n }\n case 'update': {\n const current = registry.get(freehand.scene);\n const link = current.links[intent.id];\n if (link && ('source' in intent.values || 'target' in intent.values)) {\n const after = reduceIntent(current, intent);\n const before = computeLink(current, link);\n const next = computeLink(after, after.links[intent.id]);\n if (!sameLink(before, next)) {\n if (before) {\n syncDelete(model, [], [before]);\n }\n if (next) {\n syncLink(model, next);\n }\n }\n }\n freehand.apply(intent);\n break;\n }\n case 'delete': {\n const current = registry.get(freehand.scene);\n const after = reduceIntent(current, intent);\n const nodes = Object.values(current.nodes).filter((node) => after.nodes[node.id] === undefined);\n const links = Object.values(current.links).filter((link) => after.links[link.id] === undefined);\n const nodeIds = nodes.map(computeId).filter((id): id is string => id !== undefined);\n const edges = links.map((link) => computeLink(current, link)).filter((edge) => edge !== undefined);\n nodeIds.forEach((id) => mirrored.add(id));\n syncDelete(model, nodeIds, edges);\n deleteTriggerObjects(model, nodes.filter(isComputeShape));\n freehand.apply(intent);\n break;\n }\n case 'batch':\n // Applied one by one so each create / link / delete reaches the compute graph.\n intent.intents.forEach(apply);\n break;\n default:\n freehand.apply(intent);\n }\n };\n\n /**\n * The compute graph brought in line with the restored scene: a shape whose node is gone gets it back\n * under the same id, a node this projection mirrored whose shape is gone goes, and the edges between\n * shape-backed nodes are exactly the scene's links.\n */\n const reconcile = (restored: Scene): void => {\n const shapes = new Map<string, Node>();\n for (const node of Object.values(restored.nodes)) {\n const id = computeId(node);\n if (id) {\n shapes.set(id, node);\n }\n }\n model.removeNodes(model.nodes.filter((node) => mirrored.has(node.id) && !shapes.has(node.id)).map(({ id }) => id));\n for (const [id, shape] of shapes) {\n if (!model.findNode(id) && isComputeShape(shape)) {\n syncCreate(model, shape, id);\n }\n }\n const claimed = new Set<string>();\n const missing: ComputeLink[] = [];\n for (const link of Object.values(restored.links)) {\n const wanted = computeLink(restored, link);\n if (!wanted) {\n continue;\n }\n const edge = findEdge(model, wanted, claimed);\n if (edge) {\n claimed.add(edge.id);\n } else {\n missing.push(wanted);\n }\n }\n model.removeEdges(\n model.edges\n .filter((edge) => !claimed.has(edge.id) && shapes.has(edge.source) && shapes.has(edge.target))\n .map(({ id }) => id),\n );\n missing.forEach((link) => syncLink(model, link));\n };\n\n return {\n scene,\n apply,\n capabilities: freehand.capabilities,\n snapshot: freehand.snapshot,\n restore: (snapshot) => {\n freehand.restore(snapshot);\n reconcile(registry.get(freehand.scene));\n },\n };\n};\n\nconst isComputeShape = (node: Node): node is Node & ComputeShape => typeof node.type === 'string';\n\n/**\n * The node with the ports its compute node's runtime schemas define, one per property; a node without\n * schemas keeps its definition's ports (the registry supplies them when `ports` is absent).\n */\nconst withRuntimePorts = (controller: ComputeGraphSource, node: Node): Node => {\n const id = computeId(node);\n if (!id) {\n return node;\n }\n const computeNode = model(controller).getNode(id);\n if (!computeNode?.inputSchema && !computeNode?.outputSchema) {\n return node;\n }\n const inputSchema = computeNode.inputSchema ? JsonSchema.toEffectSchema(computeNode.inputSchema) : DefaultInput;\n const outputSchema = computeNode.outputSchema ? JsonSchema.toEffectSchema(computeNode.outputSchema) : DefaultOutput;\n return { ...node, ports: anchorsToPorts(createFunctionAnchors(node, inputSchema, outputSchema), node.size) };\n};\n\nconst model = (controller: ComputeGraphSource) => controller.graph;\n","//\n// Copyright 2026 DXOS.org\n//\n\n//\n// A canvas-editor circuit as a scene: shapes become nodes with a z key (a note becomes the engine's\n// note node), connections become curves pinned to the ports the properties name. The circuit factories\n// and `createComputeGraph` stay as they are; this is the seam the M4 store migration builds on.\n//\n\nimport { DEFAULT_INPUT, DEFAULT_OUTPUT } from '@dxos/conductor';\nimport { type CanvasGraphModel, isPolygon } from '@dxos/react-ui-canvas-editor';\nimport { type Link, type Node, type Scene, initialKeys } from '@dxos/react-ui-canvas/scene';\n\nimport { type ComputeShape, createAnchorId } from '../shapes/index.ts';\n\nexport const sceneFromCircuit = (model: CanvasGraphModel<ComputeShape>, id = 'circuit', name?: string): Scene => {\n const shapes = model.nodes.filter(isPolygon);\n const keys = initialKeys(shapes.length + model.edges.length);\n const nodes: Record<string, Node> = {};\n shapes.forEach((shape, index) => {\n const z = keys[index];\n nodes[shape.id] =\n shape.type === 'note'\n ? { type: 'note', id: shape.id, z, center: shape.center, size: shape.size, text: shape.text ?? '' }\n : { ...shape, z };\n });\n const links: Record<string, Link> = {};\n model.edges.forEach((edge, index) => {\n links[edge.id] = {\n type: 'curve',\n id: edge.id,\n z: keys[shapes.length + index],\n source: { node: edge.source, port: createAnchorId('output', edge.output ?? DEFAULT_OUTPUT) },\n target: { node: edge.target, port: createAnchorId('input', edge.input ?? DEFAULT_INPUT) },\n directed: true,\n };\n });\n return { id, ...(name ? { name } : {}), nodes, links };\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport { DefaultInput, DefaultOutput } from '@dxos/conductor';\nimport * as JsonSchema from '@dxos/echo/JsonSchema';\nimport { type Anchor, ShapeLayout, type ShapeRegistry } from '@dxos/react-ui-canvas-editor';\n\nimport { type ComputeGraphController } from './graph/index.ts';\nimport { type ComputeShape, createFunctionAnchors } from './shapes/index.ts';\n\n// TODO(burdon): Customize layout. Specialize ComputeShapeDef and registry.\nexport class ComputeShapeLayout extends ShapeLayout {\n constructor(\n private _controller: ComputeGraphController,\n registry: ShapeRegistry,\n ) {\n super(registry);\n }\n\n // TODO(burdon): Doesn't update.\n override getAnchors(shape: ComputeShape): Record<string, Anchor> {\n const shapeDef = this._registry.getShapeDef(shape.type);\n let anchors = shapeDef?.getAnchors?.(shape) ?? {};\n if (shape.node) {\n const node = this._controller.graph.getNode(shape.node);\n if (node.inputSchema || node.outputSchema) {\n // TODO(burdon): Requires that component defined input and output types.\n const inputSchema = node.inputSchema ? JsonSchema.toEffectSchema(node.inputSchema) : DefaultInput;\n const outputSchema = node.outputSchema ? JsonSchema.toEffectSchema(node.outputSchema) : DefaultOutput;\n anchors = createFunctionAnchors(shape, inputSchema, outputSchema);\n }\n }\n\n return anchors;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,IAAa,iBAAiB,cAAyC,IAAI;AAE3E,IAAa,0BAA0B;CACrC,OAAO,WAAW,cAAc,KAAK,sBAAM,IAAI,MAAM,wBAAwB,CAAC;AAChF;;;ACXA,IAAM,WAAW,GAAG,QAAqB;CACvC,aAAa;EACX,KAAK,MAAM,MAAM,KACf,GAAG;CAEP;AACF;AAOA,IAAa,6BAA6B,EAAE,YAAY,OAAO,gBAAkD;CAC/G,MAAM,GAAG,eAAe,SAAS,CAAC,CAAC;CAEnC,gBAAgB;EACd,IAAI,CAAC,cAAc,CAAC,OAClB;EAGF,WAAgB,KAAK;EACrB,MAAM,MAAM,QACV,WAAW,OAAO,SAAS;GACzB,UAAe,SAAS,OAAO;GAC/B,YAAY,CAAC,CAAC;EAChB,CAAC,GAGD,WAAW,OAAO,IAAI,EAA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ks/useGraphMonitor.ts","../../src/hooks/useControllerUpdates.ts","../../src/graph/node-defs.ts","../../src/graph/controller.ts","../../src/graph/sync.ts","../../src/shapes/common/box-defs.ts","../../src/shapes/common/node-def.tsx","../../src/shapes/defs.ts","../../src/shapes/common/ports.ts","../../src/shapes/common/Box.tsx","../../src/shapes/common/FunctionBody.tsx","../../src/shapes/common/TextBox.tsx","../../src/shapes/common/TypeSelect.tsx","../../src/shapes/Append.tsx","../../src/shapes/append-def.ts","../../src/shapes/Array.tsx","../../src/shapes/array-def.ts","../../src/shapes/Audio.tsx","../../src/shapes/audio-def.ts","../../src/shapes/Beacon.tsx","../../src/shapes/beacon-def.ts","../../src/shapes/Chat.tsx","../../src/shapes/chat-def.tsx","../../src/shapes/Constant.tsx","../../src/shapes/constant-def.tsx","../../src/shapes/Database.tsx","../../src/shapes/database-def.ts","../../src/shapes/Feed.tsx","../../src/shapes/feed-def.ts","../../src/shapes/Function.tsx","../../src/shapes/function-def.ts","../../src/shapes/Gpt.tsx","../../src/shapes/gpt-def.ts","../../src/shapes/GptRealtime.tsx","../../src/shapes/gpt-realtime-def.ts","../../src/shapes/Json.tsx","../../src/shapes/json-def.ts","../../src/shapes/Logic.tsx","../../src/shapes/logic-def.ts","../../src/shapes/RNG.tsx","../../src/shapes/rng-def.ts","../../src/shapes/Scope.tsx","../../src/shapes/scope-def.ts","../../src/shapes/Surface.tsx","../../src/shapes/surface-def.ts","../../src/shapes/Switch.tsx","../../src/shapes/switch-def.ts","../../src/shapes/Table.tsx","../../src/shapes/table-def.ts","../../src/shapes/Template.tsx","../../src/shapes/template-def.ts","../../src/shapes/Text.tsx","../../src/shapes/text-def.ts","../../src/shapes/TextToImage.tsx","../../src/shapes/text-to-image-def.ts","../../src/shapes/Thread.tsx","../../src/shapes/thread-def.ts","../../src/shapes/trigger-spec.ts","../../src/shapes/Trigger.tsx","../../src/shapes/trigger-def.ts","../../src/shapes/Boolean.tsx","../../src/registry.ts","../../src/scene/Bullets.tsx","../../src/scene/echo-store.ts","../../src/scene/projection.ts","../../src/scene/scene.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport { createContext, useContext } from 'react';\n\nimport { raise } from '@dxos/debug';\nimport { type NodeDef } from '@dxos/react-ui-canvas/scene';\n\nimport type { ComputeGraphController } from '../graph/index.ts';\n\nexport type ComputeContextType = {\n controller: ComputeGraphController;\n debug?: boolean;\n /** Grows or shrinks a shape by `delta` px (a function body opening); absent, the body opens in place. */\n resize?: (id: string, delta: number) => void;\n};\n\nexport const ComputeContext = createContext<ComputeContextType | null>(null);\n\nexport const useComputeContext = () => {\n return useContext(ComputeContext) ?? raise(new Error('Missing ComputeContext'));\n};\n\n/** The definition of the node being rendered, from the registry the scene renders with, for the frame chrome. */\nexport const ComputeNodeDefContext = createContext<NodeDef | undefined>(undefined);\n\nexport const useComputeNodeDef = () => useContext(ComputeNodeDefContext);\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport { useCallback, useEffect, useState } from 'react';\n\nimport type { ComputeNode, ComputeNodeMeta } from '@dxos/conductor';\nimport { invariant } from '@dxos/invariant';\n\nimport { type ComputeEvent, type RuntimeValue } from '../graph/index.ts';\nimport { type ComputeShape } from '../shapes/index.ts';\nimport { useComputeContext } from './compute-context.ts';\n\nexport type ComputeNodeState = {\n node: ComputeNode;\n meta: ComputeNodeMeta;\n runtime: {\n inputs: Record<string, RuntimeValue>;\n outputs: Record<string, RuntimeValue>;\n setOutput: (property: string, value: any) => void;\n evalNode: () => void;\n subscribeToEventLog: (cb: (event: ComputeEvent) => void) => () => void;\n };\n};\n\n/**\n * Runtime state of a compute node.\n */\nexport const useComputeNodeState = (shape: ComputeShape): ComputeNodeState => {\n const { controller } = useComputeContext();\n invariant(controller);\n\n const [meta, setMeta] = useState<ComputeNodeMeta>();\n useEffect(() => {\n let disposed = false;\n queueMicrotask(async () => {\n invariant(shape.node, 'Node not specified');\n const node = controller.getComputeNode(shape.node);\n const meta = await controller.getMeta(node);\n if (disposed) {\n return;\n }\n\n setMeta(meta);\n });\n\n return () => {\n disposed = true;\n };\n }, [shape.node]);\n\n const evalNode = useCallback(() => {\n return controller.evalNode(shape.node!);\n }, [shape.node]);\n\n const subscribeToEventLog = useCallback(\n (cb: (event: ComputeEvent) => void): (() => void) => {\n return controller.events.on((ev) => {\n if (ev.nodeId === shape.node) {\n cb(ev);\n }\n });\n },\n [shape.node],\n );\n\n return {\n node: controller.getComputeNode(shape.node!),\n meta: meta ?? {\n input: Schema.Struct({}),\n output: Schema.Struct({}),\n },\n runtime: {\n inputs: controller.getInputs(shape.node!),\n outputs: controller.getOutputs(shape.node!),\n setOutput: (property: string, value: any) => {\n controller.setOutput(shape.node!, property, value);\n },\n evalNode,\n subscribeToEventLog,\n },\n };\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport { useMemo } from 'react';\n\nimport { type ComputeEdge, ComputeGraphModel, DEFAULT_INPUT, DEFAULT_OUTPUT } from '@dxos/conductor';\nimport { invariant } from '@dxos/invariant';\n\nimport { deleteTriggerObjects, syncCreate, syncDelete, syncLink } from '../graph/index.ts';\nimport { type ComputeShape } from '../shapes/index.ts';\nimport { type CanvasBoard, type CanvasGraphModel } from '../types/index.ts';\n\n/**\n * Model callback.\n */\nexport interface GraphMonitor<S extends CanvasBoard.Shape = CanvasBoard.Shape> {\n onCreate: (props: { graph: CanvasGraphModel<S>; node: S }) => void;\n onLink: (props: { graph: CanvasGraphModel<S>; edge: CanvasBoard.Connection }) => void;\n onDelete: (props: { graph: CanvasGraphModel<S>; subgraph: CanvasGraphModel<S> }) => void;\n}\n\n/**\n * Map canvas edge to compute edge.\n */\nexport const mapEdge = (\n graph: CanvasGraphModel,\n { source, target, output = DEFAULT_OUTPUT, input = DEFAULT_INPUT }: CanvasBoard.Connection,\n): Omit<ComputeEdge, 'id'> => {\n const sourceNode = graph.findNode(source) as ComputeShape;\n const targetNode = graph.findNode(target) as ComputeShape;\n invariant(sourceNode?.node);\n invariant(targetNode?.node);\n\n return {\n source: sourceNode.node,\n target: targetNode.node,\n output,\n input,\n };\n};\n\n/**\n * Listens for changes to the graph and updates the compute graph.\n * @param model Compute graph to update on change.\n */\n// TODO(burdon): Generalize into sync function.\nexport const useGraphMonitor = (model?: ComputeGraphModel): GraphMonitor<ComputeShape> => {\n return useMemo<GraphMonitor<ComputeShape>>(() => {\n return {\n onCreate: ({ node }) => {\n if (!model) {\n return;\n }\n\n // Ignore shapes that don't have a corresponding node factory.\n const computeNode = syncCreate(model, node);\n if (computeNode) {\n node.node = computeNode.id;\n }\n },\n\n onLink: ({ graph, edge }) => {\n if (model) {\n syncLink(model, mapEdge(graph, edge));\n }\n },\n\n onDelete: ({ graph, subgraph }) => {\n if (model) {\n const shapes = subgraph.nodes as ComputeShape[];\n const nodeIds = shapes.map((shape) => shape.node).filter((id): id is string => id !== undefined);\n // An edge's far end may survive the deletion, so it is looked up in the whole graph.\n const computeId = (id: string) =>\n ((subgraph.findNode(id) ?? graph.findNode(id)) as ComputeShape | undefined)?.node ?? '';\n const links = subgraph.edges.map(({ source, target, output, input }) => ({\n source: computeId(source),\n target: computeId(target),\n output,\n input,\n }));\n syncDelete(model, nodeIds, links);\n deleteTriggerObjects(model, shapes);\n }\n },\n };\n }, [model]);\n};\n\nexport const createComputeGraph = (graph?: CanvasGraphModel<ComputeShape>) => {\n const computeGraph = ComputeGraphModel.create();\n\n if (graph) {\n for (const shape of graph.nodes) {\n const node = syncCreate(computeGraph, shape);\n if (node) {\n shape.node = node.id;\n }\n }\n\n for (const edge of graph.edges) {\n syncLink(computeGraph, mapEdge(graph, edge));\n }\n }\n\n return computeGraph;\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport { useEffect, useReducer } from 'react';\n\nimport { type ComputeGraphController } from '../graph/index.ts';\n\n/** Re-renders the caller on every controller update, since the runtime state components read is not reactive. */\nexport const useControllerUpdates = (controller: ComputeGraphController): void => {\n const [, bump] = useReducer((count: number) => count + 1, 0);\n useEffect(() => controller.update.on(() => bump()), [controller]);\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport {\n type ComputeNode,\n type Executable,\n NODE_INPUT,\n NODE_OUTPUT,\n type NodeType,\n getTemplateInputSchema,\n registry,\n} from '@dxos/conductor';\nimport { raise } from '@dxos/debug';\nimport { JsonSchema, Obj } from '@dxos/echo';\nimport { invariant } from '@dxos/invariant';\n\nimport { type ComputeShape, type ConstantShape, type TemplateShape } from '../shapes/index.ts';\n\nexport const resolveComputeNode = async (node: ComputeNode): Promise<Executable> => {\n const impl = registry[node.type as NodeType];\n invariant(impl, `Unknown node type: ${node.type}`);\n return impl;\n};\n\nexport const isValidComputeNode = (type: string): boolean => {\n return nodeFactory[type as NodeType] !== undefined;\n};\n\nexport const createComputeNode = (shape: ComputeShape): ComputeNode => {\n const type = shape.type ?? raise(new Error('Type not specified'));\n const factory = nodeFactory[type as NodeType] ?? raise(new Error(`Unknown shape type: ${type}`));\n return factory(shape);\n};\n\nconst nodeFactory: Record<NodeType | 'trigger', (shape: ComputeShape) => ComputeNode> = {\n // System.\n [NODE_INPUT]: () => createNode(NODE_INPUT),\n [NODE_OUTPUT]: () => createNode(NODE_OUTPUT),\n\n // Extensions.\n 'text-to-image': () => createNode('text-to-image'), // TODO(burdon): Rename ai-impage-tool\n 'and': () => createNode('and'),\n 'append': () => createNode('append'),\n 'audio': () => createNode('audio'),\n 'beacon': () => createNode('beacon'),\n 'chat': () => createNode('chat'),\n 'constant': (shape) =>\n createNode('constant', {\n value: (shape as ConstantShape).value,\n }),\n 'make-queue': () => createNode('make-queue'),\n 'database': () => createNode('database'),\n 'gpt': () => createNode('gpt'),\n 'gpt-realtime': () => createNode('gpt-realtime'),\n 'if': () => createNode('if'),\n 'if-else': () => createNode('if-else'),\n 'function': () => createNode('function'),\n 'json': () => createNode('json'),\n 'json-transform': () => createNode('json-transform'),\n 'not': () => createNode('not'),\n 'or': () => createNode('or'),\n 'queue': () => createNode('queue'),\n 'rng': () => createNode('rng'),\n 'reducer': () => createNode('reducer'),\n 'scope': () => createNode('scope'),\n 'surface': () => createNode('surface'),\n 'switch': () => createNode('switch'),\n 'template': (shape) => {\n const node = createNode('template', { valueType: (shape as TemplateShape).valueType, value: shape.text });\n // `toJsonSchema` reuses cached fragments (e.g. the `Schema.Any` JSON form) across calls; deep-copy so each\n // ECHO node owns its own schema record rather than reassigning ownership of a shared one.\n node.inputSchema = structuredClone(JsonSchema.toJsonSchema(getTemplateInputSchema(node)));\n return node;\n },\n 'text': () => createNode('text'),\n 'thread': () => createNode('thread'),\n 'trigger': () => createNode(NODE_INPUT),\n};\n\nconst createNode = (type: string, props?: Partial<ComputeNode>): ComputeNode => ({\n id: Obj.ID.random(),\n type,\n ...props,\n});\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport * as Exit from 'effect/Exit';\nimport * as Layer from 'effect/Layer';\nimport * as Result from 'effect/Result';\nimport * as Scope from 'effect/Scope';\n\nimport type { AiService } from '@dxos/ai';\nimport { Event, synchronized } from '@dxos/async';\nimport type * as Credential from '@dxos/compute/Credential';\nimport type * as Operation from '@dxos/compute/Operation';\nimport * as Trace from '@dxos/compute/Trace';\nimport {\n ComputeBeginEvent,\n ComputeCustomEvent,\n type ComputeEdge,\n ComputeEndEvent,\n type ComputeGraphModel,\n ComputeInputEvent,\n type ComputeNode,\n type ComputeNodeMeta,\n ComputeOutputEvent,\n type GptInput,\n type GptOutput,\n type GraphDiagnostic,\n GraphExecutor,\n ValueBag,\n layerNoop as computeNodeContextLayerNoop,\n isNotExecuted,\n} from '@dxos/conductor';\nimport { Resource } from '@dxos/context';\nimport type { Database, Registry } from '@dxos/echo';\nimport * as EffectEx from '@dxos/effect/EffectEx';\nimport { log } from '@dxos/log';\nimport { type ContentBlock } from '@dxos/types';\n\nimport { createComputeGraph } from '../hooks/index.ts';\nimport { type ComputeShape } from '../shapes/index.ts';\nimport { type CanvasGraphModel } from '../types/index.ts';\nimport { resolveComputeNode } from './node-defs.ts';\n\n// TODO(burdon): API package for conductor.\nexport const InvalidStateError = Error;\n\nexport type FunctionCallback<INPUT, OUTPUT> = (input: INPUT) => Promise<OUTPUT>;\n\n/**\n * Callback to notify the controller of a scheduled update.\n */\nexport type AsyncUpdate<T> = (value: T) => void;\n\nexport interface GptExecutor {\n invoke: FunctionCallback<GptInput, GptOutput>;\n\n // TODO(dmaretskyi): A hack to get image artifacts working. Rework into querying images from the ai-service store.\n imageCache: Map<string, ContentBlock.Image>;\n}\n\nexport type RuntimeValue =\n | {\n type: 'not-executed'; // TODO(burdon): Different from pending?\n }\n | {\n type: 'executed';\n value: any;\n }\n | {\n type: 'pending';\n }\n | {\n type: 'error';\n error: string;\n };\n\ntype ComputeOutputEvent = {\n nodeId: string;\n property: string;\n value: RuntimeValue;\n};\n\n/**\n * Event emitted by the compute graph during execution.\n */\nexport type ComputeEvent =\n | { type: 'begin-compute'; nodeId: string; inputs: ReadonlyArray<string> }\n | { type: 'end-compute'; nodeId: string; outputs: ReadonlyArray<string> }\n | { type: 'compute-input'; nodeId: string; property: string; value: any }\n | { type: 'compute-output'; nodeId: string; property: string; value: any }\n | { type: 'custom'; nodeId: string; event: any };\n\n// TODO(dmaretskyi): Re-use function servies definition.\nexport type ComputeServices =\n | AiService.AiService\n | Database.Service\n | Credential.CredentialsService\n | Operation.Service\n | Registry.Service;\n\n/**\n * Nodes that will automatically trigger the execution of the graph on startup.\n */\nconst AUTO_TRIGGER_NODES = ['chat', 'switch', 'constant'];\n\n/**\n * Minimal runtime interface required by the {@link ComputeGraphController}.\n *\n * Satisfied by both `effect/ManagedRuntime.ManagedRuntime` and ad-hoc adapters\n * built on top of the app-framework `ProcessManagerRuntime`.\n */\nexport interface ComputeGraphRuntime {\n runPromiseExit<A, E>(effect: Effect.Effect<A, E, ComputeServices>): Promise<Exit.Exit<A, E>>;\n}\n\nexport const createComputeGraphController = (\n graph: CanvasGraphModel<ComputeShape>,\n computeRuntime: ComputeGraphRuntime,\n) => {\n const computeGraph = createComputeGraph(graph);\n const controller = new ComputeGraphController(computeRuntime, computeGraph);\n return { controller, graph };\n};\n\n/**\n * Controller that manages compute graph state, execution, and service coordination.\n */\nexport class ComputeGraphController extends Resource {\n private readonly _executor = new GraphExecutor({\n computeNodeResolver: (node) => resolveComputeNode(node),\n });\n\n private _diagnostics: GraphDiagnostic[] = [];\n\n /**\n * Canvas force-sets outputs of those nodes.\n */\n private _forcedOutputs: Record<string, Record<string, unknown>> = {};\n\n /**\n * Runtime state of the execution graph.\n */\n private _runtimeStateInputs: Record<string, Record<string, RuntimeValue>> = {};\n\n private _runtimeStateOutputs: Record<string, Record<string, RuntimeValue>> = {};\n\n // TODO(burdon): Remove? Make state reactive?\n public readonly update = new Event();\n\n /** Computed result. */\n public readonly output = new Event<ComputeOutputEvent>();\n\n public readonly events = new Event<ComputeEvent>();\n\n constructor(\n private readonly _computeRuntime: ComputeGraphRuntime,\n /** Persistent compute graph. */\n private readonly _graph: ComputeGraphModel,\n ) {\n super();\n }\n\n /**\n * Runs the graph once so a circuit shows its state as soon as it is opened; without this the\n * trigger nodes only ever fire from {@link setOutput}, leaving a freshly loaded graph inert.\n */\n protected override async _open(): Promise<void> {\n try {\n await this.exec();\n } catch (err) {\n log.catch(err);\n }\n }\n\n toJSON() {\n return {\n graph: this._graph,\n state: {\n inputs: this._runtimeStateInputs,\n outputs: this._runtimeStateOutputs,\n },\n forcedOutputs: this._forcedOutputs,\n };\n }\n\n get graph() {\n return this._graph;\n }\n\n get diagnostics() {\n return this._diagnostics;\n }\n\n get userState() {\n return this._forcedOutputs;\n }\n\n get inputStates() {\n return this._runtimeStateInputs;\n }\n\n get outputStates() {\n return this._runtimeStateOutputs;\n }\n\n /**\n * Inputs and outputs for all nodes.\n */\n get state(): Record<\n string,\n {\n node: ComputeNode;\n input: Record<string, RuntimeValue>;\n output: Record<string, RuntimeValue>;\n }\n > {\n const ids = [...new Set([...Object.keys(this._runtimeStateInputs), ...Object.keys(this._runtimeStateOutputs)])];\n return Object.fromEntries(\n ids.map((id) => [\n id,\n {\n node: this._graph.getNode(id),\n input: this._runtimeStateInputs[id],\n output: this._runtimeStateOutputs[id],\n },\n ]),\n );\n }\n\n addNode(node: ComputeNode): void {\n this._graph.addNode(node);\n }\n\n addEdge(edge: ComputeEdge): void {\n this._graph.addEdge(edge);\n }\n\n getComputeNode(nodeId: string): ComputeNode {\n return this._graph.getNode(nodeId);\n }\n\n getInputs(nodeId: string): Record<string, RuntimeValue> {\n return this._runtimeStateInputs[nodeId] ?? {};\n }\n\n getOutputs(nodeId: string): Record<string, RuntimeValue> {\n return this._runtimeStateOutputs[nodeId] ?? {};\n }\n\n setOutput(nodeId: string, property: string, value: any): void {\n this._forcedOutputs[nodeId] ??= {};\n this._forcedOutputs[nodeId][property] = value;\n\n queueMicrotask(async () => {\n try {\n await this.exec(nodeId);\n } catch (err) {\n log.catch(err);\n }\n });\n }\n\n async getMeta(node: ComputeNode): Promise<ComputeNodeMeta> {\n const { meta } = await resolveComputeNode(node);\n return meta;\n }\n\n @synchronized\n async checkGraph(): Promise<void> {\n const executor = this._executor.clone();\n await executor.load(this._graph);\n this._diagnostics = executor.getDiagnostics();\n }\n\n async evalNode(nodeId: string): Promise<void> {\n const executor = this._executor.clone();\n await executor.load(this._graph);\n\n for (const [nodeId, outputs] of Object.entries(this._forcedOutputs)) {\n executor.setOutputs(nodeId, Effect.succeed(ValueBag.make(outputs)));\n }\n\n EffectEx.unwrapExit(\n await this._computeRuntime.runPromiseExit(\n Effect.gen({ self: this }, function* () {\n const scope = yield* Scope.make();\n\n // TODO(dmaretskyi): Code duplication.\n const executable = yield* Effect.promise(() => resolveComputeNode(this._graph.getNode(nodeId)));\n const computingOutputs = executable.exec != null;\n // TODO(dmaretskyi): Check if the node has a compute function and run computeOutputs if it does.\n const effect = (computingOutputs ? executor.computeOutputs(nodeId) : executor.computeInputs(nodeId)).pipe(\n Effect.withSpan('runGraph'),\n Scope.provide(scope),\n Effect.provide(\n Layer.mergeAll(Layer.succeed(Trace.TraceService, this._createTraceWriter()), computeNodeContextLayerNoop),\n ),\n Effect.flatMap(computeValueBag),\n Effect.withSpan('test'),\n // v4's `tap` requires the callback to return an `Effect`.\n Effect.tap((values) =>\n Effect.sync(() => {\n for (const [key, value] of Object.entries(values)) {\n if (computingOutputs) {\n this._onOutputComputed(nodeId, key, value);\n } else {\n this._onInputComputed(nodeId, key, value);\n }\n }\n }),\n ),\n );\n\n yield* effect;\n\n yield* Scope.close(scope, Exit.void);\n }),\n ),\n );\n\n this.update.emit();\n }\n\n /**\n * Executes the graph.\n * @param startFromNode - Node to start from, otherwise all {@link AUTO_TRIGGER_NODES} are executed.\n */\n @synchronized\n async exec(startFromNode?: string): Promise<void> {\n this._runtimeStateInputs = {};\n this._runtimeStateOutputs = {};\n const executor = this._executor.clone();\n await executor.load(this._graph);\n\n for (const [nodeId, outputs] of Object.entries(this._forcedOutputs)) {\n executor.setOutputs(nodeId, Effect.succeed(ValueBag.make(outputs)));\n }\n\n // TODO(dmaretskyi): Stop hardcoding.\n const triggerNodes =\n startFromNode != null\n ? [this._graph.getNode(startFromNode)]\n : this._graph.nodes.filter((node) => node.type != null && AUTO_TRIGGER_NODES.includes(node.type));\n const allAffectedNodes = [...new Set(triggerNodes.flatMap((node) => executor.getAllDependantNodes(node.id)))];\n\n EffectEx.unwrapExit(\n await this._computeRuntime.runPromiseExit(\n Effect.gen({ self: this }, function* () {\n const scope = yield* Scope.make();\n\n // TODO(burdon): Return map?\n const tasks: Effect.Effect<unknown, any, ComputeServices>[] = [];\n for (const node of allAffectedNodes) {\n // TODO(dmaretskyi): Code duplication.\n const executable = yield* Effect.promise(() => resolveComputeNode(this._graph.getNode(node)));\n const computingOutputs = executable.exec != null;\n\n // TODO(dmaretskyi): Check if the node has a compute function and run computeOutputs if it does.\n const effect = (computingOutputs ? executor.computeOutputs(node) : executor.computeInputs(node)).pipe(\n Effect.withSpan('runGraph'),\n Scope.provide(scope),\n Effect.flatMap(computeValueBag),\n Effect.provide(\n Layer.mergeAll(\n Layer.succeed(Trace.TraceService, this._createTraceWriter()),\n computeNodeContextLayerNoop,\n ),\n ),\n\n Effect.withSpan('test'),\n Effect.tap((values) =>\n Effect.sync(() => {\n for (const [key, value] of Object.entries(values)) {\n if (computingOutputs) {\n this._onOutputComputed(node, key, value);\n } else {\n this._onInputComputed(node, key, value);\n }\n }\n }),\n ),\n );\n\n tasks.push(effect);\n }\n\n //\n yield* Effect.all(tasks);\n\n //\n yield* Scope.close(scope, Exit.void);\n }),\n ),\n );\n\n this.update.emit();\n }\n\n private _createTraceWriter(): Trace.Writer {\n return {\n write: (eventType, payload) => {\n const event = traceEventToComputeEvent(eventType.key, payload);\n if (event) {\n this._handleEvent(event);\n }\n },\n };\n }\n\n private _handleEvent(event: ComputeEvent): void {\n log('handleEvent', { event });\n switch (event.type) {\n case 'compute-input': {\n this._onInputComputed(event.nodeId, event.property, { type: 'executed', value: event.value });\n break;\n }\n\n case 'compute-output': {\n this._onOutputComputed(event.nodeId, event.property, { type: 'executed', value: event.value });\n break;\n }\n }\n this.events.emit(event);\n }\n\n private _onInputComputed(nodeId: string, property: string, value: RuntimeValue): void {\n this._runtimeStateInputs[nodeId] ??= {};\n this._runtimeStateInputs[nodeId][property] = value;\n }\n\n private _onOutputComputed(nodeId: string, property: string, value: RuntimeValue): void {\n this._runtimeStateOutputs[nodeId] ??= {};\n this._runtimeStateOutputs[nodeId][property] = value;\n\n // TODO(burdon): Only fire if changed?\n this.output.emit({ nodeId, property, value });\n }\n}\n\nconst traceEventToComputeEvent = (key: string, payload: unknown): ComputeEvent | undefined => {\n switch (key) {\n case ComputeBeginEvent.key:\n return { type: 'begin-compute', ...(payload as { nodeId: string; inputs: ReadonlyArray<string> }) };\n case ComputeEndEvent.key:\n return { type: 'end-compute', ...(payload as { nodeId: string; outputs: ReadonlyArray<string> }) };\n case ComputeInputEvent.key:\n return { type: 'compute-input', ...(payload as { nodeId: string; property: string; value: any }) };\n case ComputeOutputEvent.key:\n return { type: 'compute-output', ...(payload as { nodeId: string; property: string; value: any }) };\n case ComputeCustomEvent.key:\n return { type: 'custom', ...(payload as { nodeId: string; event: any }) };\n default:\n return undefined;\n }\n};\n\n/**\n * Waits for all effects in the bag to complete and returns the `RuntimeValue` for each property.\n */\nconst computeValueBag = (bag: ValueBag<any>): Effect.Effect<Record<string, RuntimeValue>, never, never> => {\n return Effect.all(\n Object.entries(bag.values).map(([key, eff]) =>\n Effect.result(eff).pipe(\n Effect.map((value) => {\n if (Result.isFailure(value)) {\n if (isNotExecuted(value.failure)) {\n return [key, { type: 'not-executed' }] as const;\n } else {\n return [key, { type: 'error', error: value.failure }] as const;\n }\n } else {\n return [key, { type: 'executed', value: value.success }] as const;\n }\n }),\n ),\n ),\n ).pipe(Effect.map((entries) => Object.fromEntries(entries) as Record<string, RuntimeValue>));\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\n//\n// Mirrors canvas edits into the compute graph, shared by the editor's `GraphMonitor` and the scene\n// engine's compute projection so both surfaces keep one compute node per shape and one edge per link.\n//\n\nimport { type ComputeEdge, ComputeGraphModel, type ComputeNode, DEFAULT_INPUT, DEFAULT_OUTPUT } from '@dxos/conductor';\nimport { Obj, Ref } from '@dxos/echo';\nimport { invariant } from '@dxos/invariant';\n\nimport { type ComputeShape, type TriggerShape } from '../shapes/index.ts';\nimport { createComputeNode, isValidComputeNode } from './node-defs.ts';\n\n/**\n * A compute node for the shape, added to the model; the shape's `node` is what it returns. `id` keeps\n * a known compute id, so a shape restored by undo gets back the node its links name.\n */\nexport const syncCreate = (model: ComputeGraphModel, shape: ComputeShape, id?: string): ComputeNode | undefined => {\n invariant(shape.type);\n if (!isValidComputeNode(shape.type)) {\n return undefined;\n }\n const computeNode = { ...createComputeNode(shape), ...(id ? { id } : {}) };\n if (shape.type === 'trigger') {\n linkTriggerToCompute(model, computeNode, shape as TriggerShape);\n }\n model.addNode(computeNode);\n return computeNode;\n};\n\nexport type ComputeLink = {\n /** Compute node ids. */\n source: string;\n target: string;\n output?: string;\n input?: string;\n};\n\n/** The compute edge for a link between two compute nodes. */\nexport const syncLink = (\n model: ComputeGraphModel,\n { source, target, output = DEFAULT_OUTPUT, input = DEFAULT_INPUT }: ComputeLink,\n): ComputeEdge => {\n const edge: ComputeEdge = { id: Obj.ID.random(), source, target, output, input };\n model.addEdge(edge);\n return edge;\n};\n\n/**\n * The compute edge a link stands for, passing over `claimed` ids so parallel links with the same ends\n * and ports match distinct edges.\n */\nexport const findEdge = (\n model: ComputeGraphModel,\n { source, target, output = DEFAULT_OUTPUT, input = DEFAULT_INPUT }: ComputeLink,\n claimed: ReadonlySet<string> = new Set(),\n): ComputeEdge | undefined =>\n model.edges.find(\n (edge) =>\n !claimed.has(edge.id) &&\n edge.source === source &&\n edge.target === target &&\n edge.output === output &&\n edge.input === input,\n );\n\n/** The ids of the edges the links stand for, each edge claimed once. */\nexport const findEdges = (model: ComputeGraphModel, links: ComputeLink[]): string[] => {\n const claimed = new Set<string>();\n for (const link of links) {\n const edge = findEdge(model, link, claimed);\n if (edge) {\n claimed.add(edge.id);\n }\n }\n return [...claimed];\n};\n\n/** Removes the compute nodes and the compute edges that mirror the deleted shapes and links. */\nexport const syncDelete = (model: ComputeGraphModel, nodeIds: string[], links: ComputeLink[]): void => {\n const edgeIds = findEdges(model, links);\n model.removeNodes(nodeIds);\n model.removeEdges(edgeIds);\n};\n\nconst linkTriggerToCompute = (graph: ComputeGraphModel, computeNode: ComputeNode, triggerData: TriggerShape) => {\n const functionTrigger = triggerData.functionTrigger?.target;\n // A restored trigger whose object was removed with it keeps its node but cannot be wired.\n if (!functionTrigger) {\n return;\n }\n Obj.update(functionTrigger, (functionTrigger) => {\n // TODO(wittjosiah): Widen Runnable union to include ComputeGraph and remove cast.\n functionTrigger.runnable = Ref.make(graph.root) as any;\n functionTrigger.inputNodeId = computeNode.id;\n });\n};\n\n/** A deleted trigger shape takes its function trigger object with it. */\nexport const deleteTriggerObjects = (computeGraph: ComputeGraphModel, shapes: ComputeShape[]) => {\n const db = Obj.getDatabase(computeGraph.root);\n if (!db) {\n return;\n }\n for (const shape of shapes) {\n if (shape.type === 'trigger') {\n const trigger = shape as TriggerShape;\n if (trigger.functionTrigger?.target) {\n db.remove(trigger.functionTrigger.target);\n }\n }\n }\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport { DEFAULT_GRID } from '@dxos/react-ui-canvas/scene';\n\n// Kept out of `Box.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\n/**\n * The box's chrome, in whole grid cells rather than a pixel count of its own, so a shape sized from it\n * lands on the same lines the canvas draws and snaps to.\n */\nexport const headerHeight = 2 * DEFAULT_GRID;\n\nexport const footerHeight = 2 * DEFAULT_GRID;\n","//\n// Copyright 2026 DXOS.org\n//\n\n//\n// The compute shapes as scene-engine node types: the schema is the shape's with the engine's `z`, the view\n// renders the shape's component under the engine's view props, and the ports come from the shape.\n//\n\nimport * as Schema from 'effect/Schema';\nimport React, { type ComponentType, type FC } from 'react';\n\nimport {\n type CreateProps,\n DEFAULT_CELL,\n type Node,\n type NodeDef,\n type NodeViewProps,\n type Port,\n type Size,\n UnknownNodeView,\n nodeDef,\n} from '@dxos/react-ui-canvas/scene';\nimport * as Icon from '@dxos/react-ui/Icon';\n\nimport { ComputeNodeDefContext, useComputeContext } from '../../hooks/compute-context.ts';\nimport { useControllerUpdates } from '../../hooks/useControllerUpdates.ts';\nimport { type ComputeShape } from '../defs.ts';\n\n/** The engine's view props with the node narrowed to the shape. */\nexport type ComputeNodeViewProps<S extends ComputeShape> = Omit<NodeViewProps, 'node'> & { node: S };\n\nexport type ComputeNodeSpec<S extends ComputeShape> = Pick<\n NodeDef,\n 'name' | 'icon' | 'group' | 'resizable' | 'openable'\n> & {\n type: S['type'];\n /** The shape's schema with `z` (`withZ`), so the node is checked as the shape before its view or ports read it. */\n schema: Schema.Codec<S & { z: string }, unknown, never, never>;\n component: FC<ComputeNodeViewProps<S>>;\n /** The shape's factory; the engine's id, centre, size and z are applied over what it makes. */\n create: (props: Pick<ComputeShape, 'id' | 'center'>) => S;\n /** In scene px, as the shapes were designed; defaults to the size the factory gives a new shape. */\n defaultSize?: Size;\n ports: (shape: S) => readonly Port[];\n};\n\n/**\n * A size in scene px as nominal units (major cells) to the nearest half cell, so a new node lands close to that px\n * size and its edges on the grid.\n */\nconst toNominal = ({ width, height }: Size): Size => ({\n width: Math.round((width / DEFAULT_CELL) * 2) / 2,\n height: Math.round((height / DEFAULT_CELL) * 2) / 2,\n});\n\n/** A compute shape's node definition. */\nexport const defineComputeNode = <S extends ComputeShape>({\n schema,\n component,\n create,\n defaultSize,\n ports,\n ...rest\n}: ComputeNodeSpec<S>): NodeDef => {\n const isShape = Schema.is(schema);\n return {\n ...rest,\n schema,\n component: computeNodeView(isShape, component),\n create: ({ id, z, center, size }: CreateProps): Node => ({ ...create({ id, center }), z, size }),\n // The engine sizes a new node in nominal units (major grid cells), so the px size is stated in cells.\n defaultSize: toNominal(defaultSize ?? create({ id: 'default', center: { x: 0, y: 0 } }).size),\n ports: (node) => (isShape(node) ? ports(node) : []),\n };\n};\n\n/**\n * The shape's component under the engine's view props, re-rendered on every controller update since the\n * runtime state it reads is not reactive; a node that is not the shape renders as an unknown node.\n */\nconst computeNodeView = <S extends ComputeShape>(\n isShape: (node: Node) => node is Node & S & { z: string },\n Component: FC<ComputeNodeViewProps<S>>,\n): ComponentType<NodeViewProps> => {\n const View = (props: NodeViewProps) => {\n const { node, registry } = props;\n const { controller } = useComputeContext();\n useControllerUpdates(controller);\n if (!isShape(node)) {\n return <UnknownNodeView {...props} />;\n }\n // A shape with no compute node behind it yet (the ghost of a create or palette drag) has no runtime state to\n // read, so it shows what it will be rather than mounting the live component.\n if (!node.node) {\n const def = nodeDef(registry, node);\n return (\n <div className='dx-cover flex flex-col items-center justify-center gap-1 text-fg-muted'>\n {def?.icon && <Icon.Icon icon={def.icon} size='lg' />}\n <span className='text-sm truncate'>{def?.name ?? node.type}</span>\n </div>\n );\n }\n\n // The components lay out as a full-size flex container (centring with `grow` / `w-full`); the engine's\n // node frame is not one, so the wrapper provides it.\n return (\n <ComputeNodeDefContext.Provider value={nodeDef(registry, node)}>\n <div className='dx-cover flex'>\n <Component {...props} node={node} />\n </div>\n </ComputeNodeDefContext.Provider>\n );\n };\n View.displayName = `ComputeNodeView(${Component.displayName ?? Component.name})`;\n return View;\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { DEFAULT_INPUT, DEFAULT_OUTPUT } from '@dxos/conductor';\nimport { Obj } from '@dxos/echo';\nimport * as SchemaAST from '@dxos/effect/SchemaAST';\nimport { Point, Size } from '@dxos/react-ui-canvas/scene';\nimport { type MakeOptional } from '@dxos/util';\n\nimport { CanvasBoard } from '../types/index.ts';\n\n//\n// Properties\n//\n\nexport type PropertyKind = 'input' | 'output';\n\nexport const getProperties = (ast: SchemaAST.AST) =>\n SchemaAST.getPropertySignatures(ast).map(({ name }) => ({ name: name.toString() }));\n\nexport const createAnchorId = (kind: PropertyKind, property = kind === 'input' ? DEFAULT_INPUT : DEFAULT_OUTPUT) =>\n [kind, property].join('.');\n\nexport const parseAnchorId = (id: string): [PropertyKind | undefined, string] => {\n const parts = id.match(/(input|output)\\.(.+)/);\n return parts ? (parts.slice(1) as any) : [undefined, id];\n};\n\n//\n// Shapes\n//\n\nexport type CreateShapeProps<S extends ComputeShape> = Omit<MakeOptional<S, 'id' | 'size'>, 'type' | 'node'>;\n\n// The board's stored shape (a closed shape with a centre and size, every key mutable), so boards the editor wrote\n// still decode.\nexport const ComputeShape = CanvasBoard.Shape.mapFields(\n Struct.assign({\n center: Point,\n size: Size.mapFields(Struct.map(Schema.mutableKey)),\n }),\n)\n .mapFields(Struct.map(Schema.mutableKey))\n .mapFields(\n Struct.assign({\n // TODO(burdon): Rename computeNode?\n node: Schema.mutableKey(Schema.optional(Obj.ID.annotate({ description: 'Compute node id' }))),\n }),\n );\n\nexport type ComputeShape = Schema.Schema.Type<typeof ComputeShape>;\n\n/** The shape's schema with the engine's z-order key, so it is a node schema. */\nexport const withZ = <Fields extends Schema.Struct.Fields>(shape: Schema.Struct<Fields>) =>\n shape.mapFields(Struct.assign({ z: Schema.String }));\n\nexport const createShape = <S extends ComputeShape>({ id, ...rest }: CreateShapeProps<S> & { type: string }): S => {\n return {\n id: id ?? Obj.ID.random(),\n ...rest,\n } as S;\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport type * as Schema from 'effect/Schema';\n\nimport { VoidInput, VoidOutput } from '@dxos/conductor';\nimport * as SchemaAST from '@dxos/effect/SchemaAST';\nimport { DEFAULT_GRID, type Point, type Port, type Size } from '@dxos/react-ui-canvas/scene';\n\nimport { createAnchorId, parseAnchorId } from '../defs.ts';\nimport { footerHeight, headerHeight } from './box-defs.ts';\n\n// Kept out of `FunctionBody.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\n/**\n * Height of one property row, two minor grid cells: with the rows centred in a body that is a whole number of rows,\n * every row's centre, and so every port, lands on a minor grid line.\n */\nexport const rowHeight = 2 * DEFAULT_GRID;\n\n/** A function shape's height: the chrome plus one row per input (at least one), each a whole number of rows. */\nexport const getHeight = (input: Schema.Schema<any>) => {\n const properties = SchemaAST.getPropertySignatures(input.ast);\n return headerHeight + footerHeight + Math.max(properties.length, 1) * rowHeight;\n};\n\n/** `n` points one row apart, centred on `center`. */\nexport const getRowPoints = (center: Point, n: number): Point[] => {\n const span = (n - 1) * rowHeight;\n return [...Array(n)].map((_, index) => ({ x: center.x, y: center.y - span / 2 + index * rowHeight }));\n};\n\n/** A port at a point relative to the node's centre, in px. */\nexport type PortPoint = { id: string; pos: Point };\n\n/**\n * The ports at the given points: each sits on whichever edge it is nearer to, at its offset along it; the\n * id's `input.` / `output.` prefix says which way a link may run.\n */\nexport const pointsToPorts = (points: readonly PortPoint[], size: Size): Port[] =>\n points.map(({ id, pos }) => {\n const [kind] = parseAnchorId(id);\n const half = { x: size.width / 2, y: size.height / 2 };\n // Ties go to the vertical edges (the input / output sides).\n const vertical = Math.abs(Math.abs(pos.x) - half.x) <= Math.abs(Math.abs(pos.y) - half.y);\n const side = vertical ? (pos.x < 0 ? 'w' : 'e') : pos.y < 0 ? 'n' : 's';\n const along = vertical ? (pos.y + half.y) / size.height : (pos.x + half.x) / size.width;\n return {\n id,\n side,\n offset: Math.min(Math.max(along, 0), 1),\n ...(kind === 'input' ? { accepts: 'in' as const } : kind === 'output' ? { accepts: 'out' as const } : {}),\n };\n });\n\n/** Ports at points given in half-sizes from the centre (`{ x: 1, y: 0 }` is the middle of the east side). */\nexport const createPorts = (size: Size, points: Record<string, Point>): Port[] =>\n pointsToPorts(\n Object.entries(points).map(([id, { x, y }]) => ({\n id,\n pos: { x: (x * size.width) / 2, y: (y * size.height) / 2 },\n })),\n size,\n );\n\n/** Inputs stacked one row apart down the west side and outputs down the east, centred on `center`. */\nexport const createRowPorts = ({\n size,\n inputs,\n outputs,\n center = { x: 0, y: 0 },\n}: {\n size: Size;\n inputs: readonly string[];\n outputs: readonly string[];\n center?: Point;\n}): Port[] =>\n pointsToPorts(\n [\n ...getRowPoints({ x: center.x - size.width / 2, y: center.y }, inputs.length).map((pos, index) => ({\n id: inputs[index],\n pos,\n })),\n ...getRowPoints({ x: center.x + size.width / 2, y: center.y }, outputs.length).map((pos, index) => ({\n id: outputs[index],\n pos,\n })),\n ],\n size,\n );\n\n/** A function shape's ports: one per property of its input and output schemas, level with the body's rows. */\nexport const createFunctionPorts = (\n size: Size,\n input: Schema.Schema<any> = VoidInput,\n output: Schema.Schema<any> = VoidOutput,\n): Port[] => {\n // TODO(burdon): Set type.\n const inputs = SchemaAST.getPropertySignatures(input.ast).map(({ name }) => createAnchorId('input', name.toString()));\n const outputs = SchemaAST.getPropertySignatures(output.ast).map(({ name }) =>\n createAnchorId('output', name.toString()),\n );\n // The rows are centred in the body, between the header and the footer.\n return createRowPorts({ size, inputs, outputs, center: { x: 0, y: (headerHeight - footerHeight) / 2 } });\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { type PropsWithChildren, type ReactNode, forwardRef } from 'react';\n\nimport { invariant } from '@dxos/invariant';\nimport { log } from '@dxos/log';\nimport * as Button from '@dxos/react-ui/Button';\nimport * as Icon from '@dxos/react-ui/Icon';\nimport type * as Util from '@dxos/react-ui/Util';\nimport { mx } from '@dxos/ui-theme';\n\nimport { useComputeContext, useComputeNodeDef } from '../../hooks/compute-context.ts';\nimport { type ComputeShape } from '../defs.ts';\n\nexport type BoxActionHandler = (action: 'open' | 'close') => void;\n\nexport type BoxProps = PropsWithChildren<\n Util.ThemedClassName<{\n shape: ComputeShape;\n title?: string;\n status?: string | ReactNode;\n open?: boolean;\n onAction?: BoxActionHandler;\n }>\n>;\n\nexport const Box = forwardRef<HTMLDivElement, BoxProps>(\n ({ children, classNames, shape, title, status, open, onAction }, forwardedRef) => {\n invariant(shape.type);\n // The chrome comes from the node registry the scene renders with.\n const { controller, debug = false } = useComputeContext();\n const def = useComputeNodeDef();\n const icon = def?.icon ?? 'ph--circle-dashed--regular';\n const name = def?.name;\n const openable = def?.openable;\n\n // Running a node propagates to everything downstream of it, which is what the button means; a shape\n // with no compute node behind it has nothing to run, so it does not get one.\n const nodeId = shape.node;\n const handleRun = () => {\n controller.exec(nodeId).catch((err) => log.catch(err));\n };\n\n return (\n <div ref={forwardedRef} className='flex flex-col dx-fill justify-between'>\n <div className='flex shrink-0 w-full justify-between items-center h-[32px] dx-input-surface'>\n <Icon.Icon icon={icon} classNames='mx-2' />\n <div className='grow text-sm truncate'>{debug ? shape.type : (name ?? shape.text ?? title)}</div>\n {nodeId && (\n <Button.Root\n classNames='p-1 text-green-500'\n variant='ghost'\n icon='ph--play--regular'\n label='run'\n iconOnly\n onPointerDown={(ev) => ev.stopPropagation()}\n onDoubleClick={(ev) => ev.stopPropagation()}\n onClick={(ev) => {\n ev.stopPropagation();\n handleRun();\n }}\n />\n )}\n </div>\n <div className={mx('flex flex-col h-full grow overflow-hidden', classNames)}>{children}</div>\n <div className='flex shrink-0 w-full justify-between items-center h-[32px] dx-input-surface'>\n <div className='grow px-2 text-sm truncate'>{debug ? shape.id : status}</div>\n {openable && (\n <Button.Root\n classNames='p-1'\n variant='ghost'\n icon={open ? 'ph--caret-up--regular' : 'ph--caret-down--regular'}\n label={open ? 'close' : 'open'}\n iconOnly\n onClick={(ev) => {\n ev.stopPropagation();\n onAction?.(open ? 'close' : 'open');\n }}\n />\n )}\n </div>\n </div>\n );\n },\n);\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport type * as Schema from 'effect/Schema';\nimport React, { type JSX, useState } from 'react';\n\nimport { VoidInput, VoidOutput } from '@dxos/conductor';\nimport { mx } from '@dxos/ui-theme';\n\nimport { useComputeContext } from '../../hooks/compute-context.ts';\nimport { Box, type BoxProps } from '../common/index.ts';\nimport { type ComputeShape, getProperties } from '../defs.ts';\nimport { rowHeight } from './ports.ts';\n\nconst expandedHeight = 200;\n\nexport type FunctionBodyProps = {\n shape: ComputeShape;\n name?: string;\n content?: JSX.Element;\n inputSchema?: Schema.Top;\n outputSchema?: Schema.Top;\n} & Pick<BoxProps, 'status'>;\n\n// TODO(wittjosiah): Rename, not used for functions.\nexport const FunctionBody = ({\n shape,\n name,\n content,\n inputSchema = VoidInput,\n outputSchema = VoidOutput,\n ...props\n}: FunctionBodyProps) => {\n // Opening grows the shape through the host's `resize`, since its size is model state.\n const { resize } = useComputeContext();\n const [open, setOpen] = useState(false);\n\n const handleAction: BoxProps['onAction'] = (action) => {\n const opening = action === 'open';\n resize?.(shape.id, opening ? expandedHeight : -expandedHeight);\n setOpen(opening);\n };\n\n // TODO(burdon): Move labels to anchor?\n const inputs = getProperties(inputSchema.ast);\n const outputs = getProperties(outputSchema.ast);\n const columnCount = inputs.length && outputs.length ? 2 : 1;\n\n return (\n <Box\n shape={shape}\n title={name}\n classNames='divide-y divide-separator-subtle'\n open={open}\n onAction={handleAction}\n {...props}\n >\n {/* Each column's rows are centred in the body, as the ports beside them are (`createFunctionPorts`). */}\n <div className={mx(`grid grid-cols-${columnCount}`, !open && 'grow')}>\n {(inputs?.length ?? 0) > 0 && (\n <div className='flex flex-col justify-center'>\n {inputs?.map(({ name }) => (\n <div key={name} className='flex items-center px-2 text-sm font-mono' style={{ height: rowHeight }}>\n <span className='truncate'>{name}</span>\n </div>\n ))}\n </div>\n )}\n {(outputs?.length ?? 0) > 0 && (\n <div className='flex flex-col justify-center'>\n {outputs?.map(({ name }) => (\n <div\n key={name}\n className='flex items-center justify-end px-2 text-sm font-mono'\n style={{ height: rowHeight }}\n >\n <span className='truncate'>{name}</span>\n </div>\n ))}\n </div>\n )}\n </div>\n {open && <div className='flex flex-col grow overflow-hidden'>{content}</div>}\n </Box>\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport { json } from '@codemirror/lang-json';\nimport { Prec } from '@codemirror/state';\nimport { EditorView, keymap } from '@codemirror/view';\nimport React, { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';\n\nimport { useTextEditor } from '@dxos/react-ui-editor';\nimport * as Hooks from '@dxos/react-ui/Hooks';\nimport type * as Util from '@dxos/react-ui/Util';\nimport {\n type BasicExtensionsOptions,\n createBasicExtensions,\n createMarkdownExtensions,\n createThemeExtensions,\n decorateMarkdown,\n} from '@dxos/ui-editor';\nimport { mx } from '@dxos/ui-theme';\n\n// An always-editable field, since the engine's `TextPart` edits only an opened part and focuses on mount.\n\nexport interface TextBoxControl {\n setText(text: string): void;\n focus(): void;\n}\n\nexport type TextBoxProps = Util.ThemedClassName<\n {\n value?: string;\n centered?: boolean;\n onBlur?: (value: string) => void;\n onEnter?: (value: string) => void;\n onCancel?: () => void;\n language?: 'json' | 'markdown';\n } & Pick<BasicExtensionsOptions, 'placeholder'>\n>;\n\nexport const TextBox = forwardRef<TextBoxControl, TextBoxProps>(\n ({ classNames, value = '', centered, onEnter, onCancel, language, ...rest }, forwardedRef) => {\n const themeMode = Hooks.useThemeMode();\n const modified = useRef(false);\n const doc = useRef(value);\n useEffect(() => {\n modified.current = false;\n doc.current = value;\n }, [value]);\n\n const { parentRef, view, focusAttributes } = useTextEditor(() => {\n return {\n id: 'text',\n initialValue: value,\n extensions: [\n createBasicExtensions({ lineWrapping: !centered, ...rest }),\n ...(language === 'json'\n ? [json()]\n : language === 'markdown'\n ? [createMarkdownExtensions(), decorateMarkdown()]\n : []),\n createThemeExtensions({\n themeMode,\n syntaxHighlighting: !!language,\n slots: {\n editor: { className: 'h-full w-full [&>.cm-scroller]:scrollbar-none p-2' },\n content: { className: mx(centered && 'text-center') },\n },\n }),\n // Detect changes.\n EditorView.updateListener.of((update) => {\n if (update.docChanged) {\n modified.current = doc.current !== update.state.doc.toString();\n }\n }),\n // TODO(burdon): Only fire if modified.\n EditorView.focusChangeEffect.of((state, focusing) => {\n if (!focusing && modified.current) {\n onEnter?.(state.doc.toString());\n }\n\n return null;\n }),\n Prec.highest(\n keymap.of([\n {\n key: 'Enter',\n preventDefault: true,\n run: (view) => {\n onEnter?.(view.state.doc.toString());\n modified.current = false;\n return true;\n },\n },\n {\n key: 'Shift-Enter',\n run: (view) => {\n // The new line is an edit like any other, so leaving the field still commits it.\n view.dispatch(view.state.replaceSelection('\\n'));\n return true;\n },\n },\n {\n key: 'Escape',\n run: () => {\n onCancel?.();\n modified.current = false;\n return true;\n },\n },\n ]),\n ),\n ],\n };\n }, [value, language]);\n\n // External control.\n useImperativeHandle(\n forwardedRef,\n () => ({\n setText: (text: string) => {\n view?.dispatch({ changes: { from: 0, to: view.state.doc.length, insert: text } });\n },\n focus: () => {\n view?.focus();\n },\n }),\n [view],\n );\n\n // Scroll to bottom.\n useEffect(() => {\n view?.dispatch({ selection: { anchor: view.state.doc.length } });\n }, [view]);\n\n return <div ref={parentRef} {...focusAttributes} className={mx('dx-fill overflow-hidden', classNames)} />;\n },\n);\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport React from 'react';\n\nimport { ComputeValueType } from '@dxos/conductor';\nimport * as Select from '@dxos/react-ui/Select';\n\n// TODO(burdon): Factor out.\nexport type TypeSelectProps = {\n value?: ComputeValueType;\n onValueChange: (value: ComputeValueType) => void;\n};\n\nexport const TypeSelect = ({ value, onValueChange }: TypeSelectProps) => {\n return (\n <Select.Root\n value={value === undefined ? [] : [value]}\n onValueChange={({ value: [next] }) => {\n const type = ComputeValueType.literals.find((literal) => literal === next);\n if (type) {\n onValueChange(type);\n }\n }}\n items={ComputeValueType.literals.map((type) => ({ value: type, label: type }))}\n >\n <Select.Trigger classNames='w-full px-0!' />\n <Select.Content>\n {ComputeValueType.literals.map((type) => (\n <Select.Item key={type} item={{ value: type, label: type }} />\n ))}\n </Select.Content>\n </Select.Root>\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport { AppendInput } from '@dxos/conductor';\n\nimport { type AppendShape } from './append-def.ts';\nimport { type ComputeNodeViewProps, FunctionBody } from './common/index.ts';\n\nexport const AppendComponent = ({ node: shape }: ComputeNodeViewProps<AppendShape>) => {\n return <FunctionBody shape={shape} inputSchema={AppendInput} />;\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { AppendInput } from '@dxos/conductor';\n\nimport { AppendComponent } from './Append.tsx';\nimport { createFunctionPorts, defineComputeNode, getHeight } from './common/index.ts';\nimport { ComputeShape, type CreateShapeProps, createShape, withZ } from './defs.ts';\n\n// Kept out of `Append.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\nexport const AppendShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('append'),\n }),\n);\n\nexport type AppendShape = Schema.Schema.Type<typeof AppendShape>;\n\nexport type CreateAppendProps = CreateShapeProps<AppendShape>;\n\nexport const createAppend = (props: CreateAppendProps) =>\n createShape<AppendShape>({\n type: 'append',\n size: { width: 128, height: getHeight(AppendInput) },\n ...props,\n });\n\nexport const appendNodeDef = defineComputeNode<AppendShape>({\n type: 'append',\n name: 'Append',\n icon: 'ph--list-plus--regular',\n group: 'Transform',\n schema: withZ(AppendShape),\n component: AppendComponent,\n create: createAppend,\n ports: (shape) => createFunctionPorts(shape.size, AppendInput),\n});\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport { ReducerInput, ReducerOutput } from '@dxos/conductor';\n\nimport { type ReducerShape } from './array-def.ts';\nimport { type ComputeNodeViewProps, FunctionBody } from './common/index.ts';\n\n//\n// Components\n//\n\nexport type ReducerComponentProps = ComputeNodeViewProps<ReducerShape>;\n\nexport const ReducerComponent = ({ node: shape }: ReducerComponentProps) => {\n return <FunctionBody shape={shape} inputSchema={ReducerInput} outputSchema={ReducerOutput} />;\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { ReducerInput, ReducerOutput } from '@dxos/conductor';\n\nimport { ReducerComponent } from './Array.tsx';\nimport { createFunctionPorts, defineComputeNode, getHeight } from './common/index.ts';\nimport { ComputeShape, type CreateShapeProps, createShape, withZ } from './defs.ts';\n\n// Kept out of `Array.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\n//\n// Data\n//\n\nexport const ReducerShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('reducer'),\n }),\n);\n\nexport type ReducerShape = Schema.Schema.Type<typeof ReducerShape>;\n\n//\n// Defs\n//\n\nexport type CreateReduceProps = CreateShapeProps<ReducerShape> & { reduce?: string };\n\nexport const createReducer = ({\n size = { width: 192, height: getHeight(ReducerInput) },\n ...rest\n}: CreateReduceProps): ReducerShape =>\n createShape<ReducerShape>({\n type: 'reducer',\n size,\n ...rest,\n });\n\nexport const reducerNodeDef = defineComputeNode<ReducerShape>({\n type: 'reducer',\n name: 'Reducer',\n icon: 'ph--repeat--regular',\n group: 'Operations',\n schema: withZ(ReducerShape),\n component: ReducerComponent,\n create: createReducer,\n ports: (shape) => createFunctionPorts(shape.size, ReducerInput, ReducerOutput),\n});\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useEffect, useState } from 'react';\n\nimport { DEFAULT_OUTPUT } from '@dxos/conductor';\nimport * as Icon from '@dxos/react-ui/Icon';\n\nimport { useComputeNodeState } from '../hooks/index.ts';\nimport { type AudioShape } from './audio-def.ts';\nimport { type ComputeNodeViewProps } from './common/index.ts';\n\nexport const AudioComponent = ({ node: shape }: ComputeNodeViewProps<AudioShape>) => {\n const { runtime } = useComputeNodeState(shape);\n const [active, setActive] = useState(false);\n useEffect(() => {\n runtime.setOutput(DEFAULT_OUTPUT, active);\n }, [active]);\n\n // https://docs.pmnd.rs/react-three-fiber/api/canvas#render-props\n return (\n <div className='flex w-full justify-center items-center'>\n <Icon.Icon\n icon={active ? 'ph--microphone--regular' : 'ph--microphone-slash--regular'}\n classNames={['transition opacity-20 duration-1000', active && 'opacity-100 text-error-text']}\n size='xl'\n onPointerDown={(ev) => ev.stopPropagation()}\n onClick={() => setActive(!active)}\n />\n </div>\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { AudioComponent } from './Audio.tsx';\nimport { createPorts, defineComputeNode } from './common/index.ts';\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape, withZ } from './defs.ts';\n\n// Kept out of `Audio.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\nexport const AudioShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('audio'),\n }),\n);\n\nexport type AudioShape = Schema.Schema.Type<typeof AudioShape>;\n\nexport type CreateAudioProps = CreateShapeProps<AudioShape>;\n\nexport const createAudio = (props: CreateAudioProps) =>\n createShape<AudioShape>({ type: 'audio', size: { width: 64, height: 64 }, ...props });\n\nexport const audioNodeDef = defineComputeNode<AudioShape>({\n type: 'audio',\n name: 'Audio',\n icon: 'ph--microphone--regular',\n group: 'Inputs',\n schema: withZ(AudioShape),\n component: AudioComponent,\n create: createAudio,\n ports: (shape) => createPorts(shape.size, { [createAnchorId('output')]: { x: 1, y: 0 } }),\n});\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport { DEFAULT_INPUT, isTruthy } from '@dxos/conductor';\nimport * as Icon from '@dxos/react-ui/Icon';\n\nimport { useComputeNodeState } from '../hooks/index.ts';\nimport { type BeaconShape } from './beacon-def.ts';\nimport { type ComputeNodeViewProps } from './common/index.ts';\n\nexport const BeaconComponent = ({ node: shape }: ComputeNodeViewProps<BeaconShape>) => {\n const { runtime } = useComputeNodeState(shape);\n const input = runtime.inputs[DEFAULT_INPUT];\n const value = input?.type === 'executed' ? input.value : false;\n\n return (\n <div className='flex w-full justify-center items-center'>\n <Icon.Icon\n icon='ph--sun--regular'\n classNames={['transition opacity-20 duration-1000', isTruthy(value) && 'opacity-100 text-yellow-500']}\n size='xl'\n />\n </div>\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { BeaconComponent } from './Beacon.tsx';\nimport { createPorts, defineComputeNode } from './common/index.ts';\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape, withZ } from './defs.ts';\n\n// Kept out of `Beacon.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\nexport const BeaconShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('beacon'),\n }),\n);\n\nexport type BeaconShape = Schema.Schema.Type<typeof BeaconShape>;\n\nexport type CreateBeaconProps = CreateShapeProps<BeaconShape>;\n\nexport const createBeacon = (props: CreateBeaconProps) =>\n createShape<BeaconShape>({ type: 'beacon', size: { width: 64, height: 64 }, ...props });\n\nexport const beaconNodeDef = defineComputeNode<BeaconShape>({\n type: 'beacon',\n name: 'Beacon',\n icon: 'ph--sun--regular',\n group: 'Outputs',\n schema: withZ(BeaconShape),\n component: BeaconComponent,\n create: createBeacon,\n ports: (shape) =>\n createPorts(shape.size, {\n [createAnchorId('input')]: { x: -1, y: 0 },\n }),\n});\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useRef } from 'react';\n\nimport { DEFAULT_OUTPUT } from '@dxos/conductor';\n\nimport { useComputeNodeState } from '../hooks/index.ts';\nimport { type ChatShape } from './chat-def.tsx';\nimport { Box, type ComputeNodeViewProps, TextBox, type TextBoxControl, type TextBoxProps } from './common/index.ts';\n\n//\n// Component\n//\n\nexport type TextInputComponentProps = ComputeNodeViewProps<ChatShape> &\n Pick<TextBoxProps, 'placeholder'> & { title?: string };\n\nexport const TextInputComponent = ({ node: shape, title, placeholder }: TextInputComponentProps) => {\n const { runtime } = useComputeNodeState(shape);\n const inputRef = useRef<TextBoxControl>(null);\n\n const handleEnter: TextBoxProps['onEnter'] = (text) => {\n const value = text.trim();\n if (value.length) {\n runtime.setOutput(DEFAULT_OUTPUT, value);\n inputRef.current?.setText('');\n }\n };\n\n return (\n <Box shape={shape} title={title}>\n <TextBox ref={inputRef} onEnter={handleEnter} placeholder={placeholder} />\n </Box>\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\nimport React from 'react';\n\nimport { TextInputComponent } from './Chat.tsx';\nimport { createPorts, defineComputeNode } from './common/index.ts';\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape, withZ } from './defs.ts';\n\n// Kept out of `Chat.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\n//\n// Data\n//\n\nexport const ChatShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('chat'),\n }),\n);\n\nexport type ChatShape = Schema.Schema.Type<typeof ChatShape>;\n\n//\n// Defs\n//\n\nexport type CreateChatProps = CreateShapeProps<ChatShape>;\n\nexport const createChat = (props: CreateChatProps) =>\n createShape<ChatShape>({ type: 'chat', size: { width: 256, height: 128 }, ...props });\n\nexport const chatNodeDef = defineComputeNode<ChatShape>({\n type: 'chat',\n name: 'Chat',\n icon: 'ph--textbox--regular',\n group: 'Inputs',\n schema: withZ(ChatShape),\n component: (props) => <TextInputComponent {...props} title={'Prompt'} placeholder={'Message'} />,\n create: createChat,\n ports: (shape) => createPorts(shape.size, { [createAnchorId('output')]: { x: 1, y: 0 } }),\n resizable: true,\n});\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useCallback, useRef, useState } from 'react';\n\nimport { ComputeValueType } from '@dxos/conductor';\nimport * as Field from '@dxos/react-ui/Field';\nimport * as Input from '@dxos/react-ui/Input';\nimport { safeParseJson } from '@dxos/util';\n\nimport { useComputeNodeState } from '../hooks/index.ts';\nimport {\n Box,\n type ComputeNodeViewProps,\n TextBox,\n type TextBoxControl,\n type TextBoxProps,\n TypeSelect,\n} from './common/index.ts';\nimport { type ConstantShape } from './constant-def.tsx';\n\n//\n// Component\n//\n\nexport type ConstantComponentProps = ComputeNodeViewProps<ConstantShape> &\n Pick<TextBoxProps, 'placeholder'> & { title?: string };\n\nconst inferType = (value: any): ComputeValueType | undefined => {\n if (typeof value === 'string') {\n return 'string';\n } else if (typeof value === 'number') {\n return 'number';\n } else if (typeof value === 'boolean') {\n return 'boolean';\n } else if (typeof value === 'object') {\n return 'object';\n }\n};\n\nexport const ConstantComponent = ({ node: shape, title, placeholder }: ConstantComponentProps) => {\n const { node } = useComputeNodeState(shape);\n const [type, setType] = useState(inferType(node.value) ?? ComputeValueType.literals[0]);\n const inputRef = useRef<TextBoxControl>(null);\n\n const handleEnter = useCallback<NonNullable<TextBoxProps['onEnter']>>(\n (text) => {\n const value = text.trim();\n if (value.length) {\n // TODO(burdon): Set text filter.\n if (type === 'number') {\n const floatValue = parseFloat(value);\n if (!isNaN(floatValue)) {\n node.value = floatValue;\n }\n } else if (type === 'object') {\n node.value = safeParseJson(value, {});\n } else {\n node.value = value;\n }\n\n inputRef.current?.focus();\n }\n },\n [type],\n );\n\n return (\n <Box shape={shape} title={title} status={<TypeSelect value={type} onValueChange={setType} />}>\n {(type === 'string' || type === 'number') && (\n <TextBox placeholder={placeholder} ref={inputRef} value={node.value} onEnter={handleEnter} />\n )}\n {type === 'object' && (\n <TextBox\n placeholder={placeholder}\n ref={inputRef}\n value={JSON.stringify(node.value, null, 2)}\n language={'json'}\n onEnter={handleEnter}\n />\n )}\n {type === 'boolean' && (\n <div className='flex grow justify-center items-center'>\n <Field.Root>\n <Input.Switch\n checked={node.value}\n onCheckedChange={({ checked: value }) => {\n node.value = value;\n }}\n />\n </Field.Root>\n </div>\n )}\n </Box>\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\nimport React from 'react';\n\nimport { createPorts, defineComputeNode } from './common/index.ts';\nimport { ConstantComponent } from './Constant.tsx';\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape, withZ } from './defs.ts';\n\n// Kept out of `Constant.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\n//\n// Data\n//\n\nexport const ConstantShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('constant'),\n value: Schema.optional(Schema.Any),\n }),\n);\n\nexport type ConstantShape = Schema.Schema.Type<typeof ConstantShape>;\n\n//\n// Defs\n//\n\nexport type CreateConstantProps = CreateShapeProps<ConstantShape>;\n\nexport const createConstant = (props: CreateConstantProps) =>\n createShape<ConstantShape>({ type: 'constant', size: { width: 192, height: 128 }, ...props });\n\nexport const constantNodeDef = defineComputeNode<ConstantShape>({\n type: 'constant',\n name: 'Value',\n icon: 'ph--dots-three-circle--regular',\n group: 'Inputs',\n schema: withZ(ConstantShape),\n component: (props) => <ConstantComponent {...props} placeholder={'Constant'} />,\n create: createConstant,\n ports: (shape) => createPorts(shape.size, { [createAnchorId('output')]: { x: 1, y: 0 } }),\n resizable: true,\n});\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport { Box, type ComputeNodeViewProps } from './common/index.ts';\nimport { type DatabaseShape } from './database-def.ts';\n\nexport const DatabaseComponent = ({ node: shape }: ComputeNodeViewProps<DatabaseShape>) => {\n return <Box shape={shape} />;\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { createPorts, defineComputeNode } from './common/index.ts';\nimport { DatabaseComponent } from './Database.tsx';\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape, withZ } from './defs.ts';\n\n// Kept out of `Database.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\nexport const DatabaseShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('database'),\n }),\n);\n\nexport type DatabaseShape = Schema.Schema.Type<typeof DatabaseShape>;\n\nexport type CreateDatabaseProps = CreateShapeProps<DatabaseShape>;\n\nexport const createDatabase = (props: CreateDatabaseProps) =>\n createShape<DatabaseShape>({ type: 'database', size: { width: 128, height: 64 }, ...props });\n\nexport const databaseNodeDef = defineComputeNode<DatabaseShape>({\n type: 'database',\n name: 'ECHO',\n icon: 'ph--database--regular',\n group: 'Transform',\n schema: withZ(DatabaseShape),\n component: DatabaseComponent,\n create: createDatabase,\n ports: (shape) => createPorts(shape.size, { [createAnchorId('output')]: { x: 1, y: 0 } }),\n});\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { Fragment } from 'react';\n\nimport { DEFAULT_OUTPUT } from '@dxos/conductor';\nimport * as ScrollArea from '@dxos/react-ui/ScrollArea';\nimport type * as Util from '@dxos/react-ui/Util';\nimport { mx } from '@dxos/ui-theme';\n\nimport { useComputeNodeState } from '../hooks/index.ts';\nimport { Box, type ComputeNodeViewProps } from './common/index.ts';\nimport { type FeedShape } from './feed-def.ts';\n\nexport const FeedComponent = ({ node: shape }: ComputeNodeViewProps<FeedShape>) => {\n const { runtime } = useComputeNodeState(shape);\n const items = runtime.outputs[DEFAULT_OUTPUT]?.type === 'executed' ? runtime.outputs[DEFAULT_OUTPUT].value : [];\n\n return (\n <Box shape={shape} status={`${items.length} items`}>\n <ScrollArea.Root orientation='vertical'>\n <ScrollArea.Viewport classNames='divide-y divide-separator-subtle'>\n {[...items].map((item, i) => (\n <FeedItem key={i} classNames='p-1 px-2' item={item} />\n ))}\n </ScrollArea.Viewport>\n </ScrollArea.Root>\n </Box>\n );\n};\n\nexport const FeedItem = ({ classNames, item }: Util.ThemedClassName<{ item: any }>) => {\n if (typeof item !== 'object') {\n return <div className={mx(classNames, 'whitespace-pre-wrap')}>{item}</div>;\n }\n\n return (\n <div className={mx('grid grid-cols-[80px_1fr]', classNames)}>\n {Object.entries(item).map(([key, value]) => (\n <Fragment key={key}>\n <div className='p-1 text-xs text-fg-subtle'>{key}</div>\n <div>{typeof value === 'string' ? value : JSON.stringify(value)}</div>\n </Fragment>\n ))}\n </div>\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { QueueInput, QueueOutput } from '@dxos/conductor';\n\nimport { createFunctionPorts, defineComputeNode } from './common/index.ts';\nimport { ComputeShape, type CreateShapeProps, createShape, withZ } from './defs.ts';\nimport { FeedComponent } from './Feed.tsx';\n\n// Kept out of `Feed.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\nexport const FeedShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('queue'),\n }),\n);\n\nexport type FeedShape = Schema.Schema.Type<typeof FeedShape>;\n\nexport type CreateFeedProps = CreateShapeProps<FeedShape>;\n\nexport const createFeed = (props: CreateFeedProps) =>\n createShape<FeedShape>({\n type: 'queue',\n size: { width: 256, height: 512 },\n ...props,\n });\n\nexport const feedNodeDef = defineComputeNode<FeedShape>({\n // Must match the shape's `type` literal ('queue') so the registry resolves it; the registry is keyed by this.\n type: 'queue',\n name: 'Feed',\n icon: 'ph--queue--regular',\n group: 'Outputs',\n schema: withZ(FeedShape),\n component: FeedComponent,\n create: createFeed,\n ports: (shape) => createFunctionPorts(shape.size, QueueInput, QueueOutput),\n resizable: true,\n});\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useCallback, useRef } from 'react';\n\nimport * as Operation from '@dxos/compute/Operation';\nimport * as Script from '@dxos/compute/Script';\nimport { Filter, Obj, Ref } from '@dxos/echo';\nimport { parseId } from '@dxos/keys';\nimport { useClient } from '@dxos/react-client';\n\nimport { useComputeNodeState } from '../hooks/index.ts';\nimport { Box, type ComputeNodeViewProps, TextBox, type TextBoxControl, type TextBoxProps } from './common/index.ts';\nimport { type FunctionShape } from './function-def.ts';\n\n//\n// Component\n//\n\ntype FunctionShapeComponentProps = ComputeNodeViewProps<FunctionShape> & Pick<TextBoxProps, 'placeholder'>;\n\nexport const FunctionShapeComponent = ({ node: shape, placeholder }: FunctionShapeComponentProps) => {\n const client = useClient();\n const { node, runtime } = useComputeNodeState(shape);\n const inputRef = useRef<TextBoxControl>(null);\n\n const handleEnter = useCallback(\n async (text: string) => {\n const value = text.trim();\n const { spaceId, objectId } = parseId(value);\n if (!spaceId || !objectId) {\n return;\n }\n\n const space = client.spaces.get(spaceId);\n const object = space?.db.query(Filter.id(objectId)).runSync()[0];\n if (!space || !Obj.instanceOf(Script.Script, object)) {\n return;\n }\n\n const [fn] = await space.db.query(Filter.type(Operation.PersistentOperation, { source: Ref.make(object) })).run();\n if (!fn) {\n return;\n }\n\n node.value = value;\n node.function = Ref.make(fn);\n node.inputSchema = fn.inputSchema;\n node.outputSchema = fn.outputSchema;\n },\n [client, node],\n );\n\n const handleAction = useCallback(\n (action: 'run' | 'open' | 'close') => {\n if (action !== 'run') {\n return;\n }\n\n runtime.evalNode();\n },\n [runtime],\n );\n\n return (\n <Box shape={shape} title='Function' onAction={handleAction}>\n <TextBox\n placeholder={placeholder}\n ref={inputRef}\n value={node.value}\n language={node.valueType === 'object' ? 'json' : undefined}\n onBlur={handleEnter}\n onEnter={handleEnter}\n />\n </Box>\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { AnyOutput, FunctionInput } from '@dxos/conductor';\n\nimport { createFunctionPorts, defineComputeNode } from './common/index.ts';\nimport { ComputeShape, type CreateShapeProps, createShape, withZ } from './defs.ts';\nimport { FunctionShapeComponent } from './Function.tsx';\n\n// Kept out of `Function.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\nexport const FunctionShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('function'),\n }),\n);\n\nexport type FunctionShape = Schema.Schema.Type<typeof FunctionShape>;\n\nexport type CreateFunctionProps = CreateShapeProps<FunctionShape>;\n\nexport const createFunction = (props: CreateFunctionProps) =>\n createShape<FunctionShape>({\n type: 'function',\n size: { width: 256, height: 192 },\n ...props,\n });\n\n//\n// Defs\n//\n\nexport const functionNodeDef = defineComputeNode<FunctionShape>({\n type: 'function',\n name: 'Function',\n icon: 'ph--function--regular',\n group: 'Transform',\n schema: withZ(FunctionShape),\n component: FunctionShapeComponent,\n create: createFunction,\n ports: (shape) => createFunctionPorts(shape.size, FunctionInput, AnyOutput),\n});\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useEffect, useState } from 'react';\n\nimport * as ScrollArea from '@dxos/react-ui/ScrollArea';\n\nimport { useComputeNodeState } from '../hooks/index.ts';\nimport { type ComputeNodeViewProps, FunctionBody } from './common/index.ts';\nimport { type GptShape } from './gpt-def.ts';\n\nexport const GptComponent = ({ node: shape }: ComputeNodeViewProps<GptShape>) => {\n const { meta, runtime } = useComputeNodeState(shape);\n const [text, setText] = useState('');\n const [tokens, setTokens] = useState(0);\n\n useEffect(() => {\n return runtime.subscribeToEventLog((ev) => {\n switch (ev.type) {\n case 'begin-compute': {\n setText('');\n break;\n }\n\n case 'custom': {\n // TODO(burdon): Any?\n const token = ev.event;\n switch (token.type) {\n case 'content_block_delta':\n switch (token.delta.type) {\n case 'text_delta': {\n const delta = token.delta.text;\n setText((prev) => {\n const text = prev + delta;\n // TODO(burdon): Get token count.\n setTokens(text.split(' ').length);\n return text;\n });\n break;\n }\n }\n break;\n\n // TODO(dmaretskyi): Handle other types of events.\n }\n break;\n }\n }\n });\n }, [runtime?.subscribeToEventLog]);\n\n return (\n <FunctionBody\n shape={shape}\n content={\n <ScrollArea.Root orientation='vertical'>\n <ScrollArea.Viewport>{text}</ScrollArea.Viewport>\n </ScrollArea.Root>\n }\n status={`${tokens} tokens`}\n inputSchema={meta.input}\n outputSchema={meta.output}\n />\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { GptInput, GptOutput } from '@dxos/conductor';\n\nimport { createFunctionPorts, defineComputeNode, getHeight } from './common/index.ts';\nimport { ComputeShape, type CreateShapeProps, createShape, withZ } from './defs.ts';\nimport { GptComponent } from './Gpt.tsx';\n\n// Kept out of `Gpt.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\nexport const GptShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('gpt'),\n }),\n);\n\nexport type GptShape = Schema.Schema.Type<typeof GptShape>;\n\nexport type CreateGptProps = CreateShapeProps<GptShape>;\n\nexport const createGpt = (props: CreateGptProps) =>\n createShape<GptShape>({\n type: 'gpt',\n size: { width: 256, height: Math.max(getHeight(GptInput), getHeight(GptOutput)) },\n ...props,\n });\n\nexport const gptNodeDef = defineComputeNode<GptShape>({\n type: 'gpt',\n name: 'GPT',\n icon: 'ph--brain--regular',\n group: 'Transform',\n schema: withZ(GptShape),\n component: GptComponent,\n create: createGpt,\n ports: (shape) => createFunctionPorts(shape.size, GptInput, GptOutput),\n openable: true,\n});\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useState } from 'react';\n\nimport { log } from '@dxos/log';\nimport { useConfig } from '@dxos/react-client';\nimport * as Icon from '@dxos/react-ui/Icon';\n\nimport { type ComputeNodeViewProps } from './common/index.ts';\nimport { type GptRealtimeShape } from './gpt-realtime-def.ts';\n\nexport const GptRealtimeComponent = ({ node: shape }: ComputeNodeViewProps<GptRealtimeShape>) => {\n const [isLive, setIsLive] = useState(false);\n const [isReady, setIsReady] = useState(false);\n const config = useConfig();\n\n const start = async () => {\n const edgeUrl = config.values.runtime?.services?.edge?.url;\n if (!edgeUrl) {\n log.error('EDGE services are not configured (runtime.services.edge.url); realtime AI is unavailable.');\n return;\n }\n setIsLive(true);\n\n try {\n // Create WebRTC connection\n const peerConnection = new RTCPeerConnection();\n\n // Handle incoming audio\n peerConnection.ontrack = (event) => {\n const audioElement = document.createElement('audio');\n audioElement.srcObject = event.streams[0];\n audioElement.autoplay = true;\n audioElement.controls = false;\n audioElement.style.display = 'none';\n document.body.appendChild(audioElement);\n setIsReady(true);\n };\n\n // Get microphone stream\n const stream = await navigator.mediaDevices.getUserMedia({ audio: true });\n\n // Add microphone track to connection\n stream.getTracks().forEach((track) => peerConnection.addTransceiver(track, { direction: 'sendrecv' }));\n\n // Create offer\n const offer = await peerConnection.createOffer();\n await peerConnection.setLocalDescription(offer);\n\n // Send offer to backend and get answer. AI is served through edge's /ai/* proxy;\n // the configured edge URL uses a ws(s) scheme, so swap it for http(s).\n const aiServiceUrl = new URL('/ai/rtc-connect', edgeUrl);\n aiServiceUrl.protocol = aiServiceUrl.protocol.replace('ws', 'http');\n const response = await fetch(aiServiceUrl, {\n method: 'POST',\n body: offer.sdp,\n headers: {\n 'Content-Type': 'application/sdp',\n },\n });\n\n const answer = await response.text();\n\n // Set remote description with answer\n await peerConnection.setRemoteDescription({\n sdp: answer,\n type: 'answer',\n });\n\n const dataChannel = peerConnection.createDataChannel('response');\n\n const configureData = () => {\n log.info('Configuring data channel');\n const event = {\n type: 'session.update',\n session: {\n modalities: ['text', 'audio'],\n // Provide the tools. Note they match the keys in the `fns` object above\n tools: [],\n },\n };\n dataChannel.send(JSON.stringify(event));\n };\n\n dataChannel.addEventListener('open', (ev) => {\n log.info('Opening data channel', { ev });\n configureData();\n });\n\n // {\n // \"type\": \"response.function_call_arguments.done\",\n // \"event_id\": \"event_Ad2gt864G595umbCs2aF9\",\n // \"response_id\": \"resp_Ad2griUWUjsyeLyAVtTtt\",\n // \"item_id\": \"item_Ad2gsxA84w9GgEvFwW1Ex\",\n // \"output_index\": 1,\n // \"call_id\": \"call_PG12S5ER7l7HrvZz\",\n // \"name\": \"get_weather\",\n // \"arguments\": \"{\\\"location\\\":\\\"Portland, Oregon\\\"}\"\n // }\n\n dataChannel.addEventListener('message', async (ev) => {\n const msg = JSON.parse(ev.data);\n // console.log('realtime gpt event', msg);\n // Handle function calls\n if (msg.type === 'response.function_call_arguments.done') {\n // const fn = fns[msg.name];\n // if (fn !== undefined) {\n // console.log(`Calling local function ${msg.name} with ${msg.arguments}`);\n // const args = JSON.parse(msg.arguments);\n // const result = await fn(args);\n // console.log('result', result);\n // // Let OpenAI know that the function has been called and share it's output\n // const event = {\n // type: 'conversation.item.create',\n // item: {\n // type: 'function_call_output',\n // call_id: msg.call_id, // call_id from the function_call message\n // output: JSON.stringify(result), // result of the function\n // },\n // };\n // dataChannel.send(JSON.stringify(event));\n // }\n }\n });\n } catch (error) {\n log.error('Error in realtime session:', { error });\n throw error;\n }\n };\n\n return (\n <div className='flex w-full justify-center items-center'>\n <Icon.Icon\n icon={isReady ? 'ph--waveform--regular' : isLive ? 'ph--pulse--regular' : 'ph--play--regular'}\n size='xl'\n classNames={!isLive && 'cursor-pointer'}\n onPointerDown={(ev) => ev.stopPropagation()}\n onClick={start}\n />\n </div>\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { createFunctionPorts, defineComputeNode } from './common/index.ts';\nimport { ComputeShape, type CreateShapeProps, createShape, withZ } from './defs.ts';\nimport { GptRealtimeComponent } from './GptRealtime.tsx';\n\n// Kept out of `GptRealtime.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\nexport const GptRealtimeShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('gpt-realtime'),\n }),\n);\n\nexport type GptRealtimeShape = Schema.Schema.Type<typeof GptRealtimeShape>;\n\nexport type CreateGptRealtimeProps = CreateShapeProps<GptRealtimeShape>;\n\nexport const createGptRealtime = (props: CreateGptRealtimeProps) =>\n createShape<GptRealtimeShape>({ type: 'gpt-realtime', size: { width: 256, height: 256 }, ...props });\n\nexport const gptRealtimeNodeDef = defineComputeNode<GptRealtimeShape>({\n type: 'gpt-realtime',\n name: 'GPT Realtime',\n icon: 'ph--pulse--regular',\n group: 'Transform',\n schema: withZ(GptRealtimeShape),\n component: GptRealtimeComponent,\n create: createGptRealtime,\n // TODO(dmaretskyi): Can we fetch the schema dynamically?\n ports: (shape) =>\n createFunctionPorts(\n shape.size,\n Schema.Struct({\n audio: Schema.Any,\n }),\n Schema.Struct({}),\n ),\n resizable: true,\n});\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport { DEFAULT_INPUT } from '@dxos/conductor';\nimport { Syntax } from '@dxos/react-ui-syntax-highlighter';\n\nimport { useComputeNodeState } from '../hooks/index.ts';\nimport { Box, type ComputeNodeViewProps } from './common/index.ts';\nimport { type JsonShape, type JsonTransformShape } from './json-def.ts';\n\n//\n// Component\n//\n\nexport type JsonComponentProps = ComputeNodeViewProps<JsonShape>;\n\nexport const JsonComponent = ({ node: shape }: JsonComponentProps) => {\n const { runtime } = useComputeNodeState(shape);\n const input = runtime.inputs[DEFAULT_INPUT];\n const value = input?.type === 'executed' ? input.value : undefined;\n\n return (\n <Box shape={shape}>\n <Syntax.Root data={value}>\n <Syntax.Content>\n <Syntax.Filter />\n <Syntax.Viewport>\n <Syntax.Code classNames='text-xs' />\n </Syntax.Viewport>\n </Syntax.Content>\n </Syntax.Root>\n </Box>\n );\n};\n\nexport type JsonTransformComponentProps = ComputeNodeViewProps<JsonTransformShape>;\n\nexport const JsonTransformComponent = ({ node: shape }: JsonTransformComponentProps) => {\n return <Box shape={shape} />;\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { DefaultOutput, JsonTransformInput } from '@dxos/conductor';\n\nimport { createFunctionPorts, createPorts, defineComputeNode, getHeight } from './common/index.ts';\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape, withZ } from './defs.ts';\nimport { JsonComponent, JsonTransformComponent } from './Json.tsx';\n\n// Kept out of `Json.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\n//\n// Data\n//\n\nexport const JsonShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('json'),\n }),\n);\n\nexport type JsonShape = Schema.Schema.Type<typeof JsonShape>;\n\nexport const JsonTransformShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('json-transform'),\n }),\n);\n\nexport type JsonTransformShape = Schema.Schema.Type<typeof JsonTransformShape>;\n\n//\n// Defs\n//\n\nexport type CreateJsonProps = CreateShapeProps<JsonShape>;\n\nexport const createJson = (props: CreateJsonProps) =>\n createShape<JsonShape>({ type: 'json', size: { width: 256, height: 256 }, ...props });\n\nexport const jsonNodeDef = defineComputeNode<JsonShape>({\n type: 'json',\n name: 'JSON',\n icon: 'ph--code--regular',\n group: 'Outputs',\n schema: withZ(JsonShape),\n component: JsonComponent,\n create: createJson,\n ports: (shape) =>\n createPorts(shape.size, {\n [createAnchorId('input')]: { x: -1, y: 0 },\n [createAnchorId('output')]: { x: 1, y: 0 },\n }),\n resizable: true,\n});\n\nexport type CreateJsonTransformProps = CreateShapeProps<JsonTransformShape> & { expression?: string };\n\nexport const createJsonTransform = (props: CreateJsonTransformProps) =>\n createShape<JsonTransformShape>({\n type: 'json-transform',\n size: { width: 128, height: getHeight(JsonTransformInput) },\n ...props,\n });\n\nexport const jsonTransformNodeDef = defineComputeNode<JsonTransformShape>({\n type: 'json-transform',\n name: 'Transform',\n icon: 'ph--shuffle-simple--regular',\n group: 'Operations',\n schema: withZ(JsonTransformShape),\n component: JsonTransformComponent,\n create: createJsonTransform,\n ports: (shape) => createFunctionPorts(shape.size, JsonTransformInput, DefaultOutput),\n resizable: true,\n});\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport { IfElseInput, IfElseOutput, IfInput, IfOutput } from '@dxos/conductor';\n\nimport { type ComputeNodeViewProps, FunctionBody } from './common/index.ts';\nimport { type IfElseShape, type IfShape } from './logic-def.ts';\n\n//\n// Components\n//\n\nexport type IfComponentProps = ComputeNodeViewProps<IfShape>;\n\nexport const IfComponent = ({ node: shape }: IfComponentProps) => {\n return <FunctionBody shape={shape} inputSchema={IfInput} outputSchema={IfOutput} />;\n};\n\nexport type IfElseComponentProps = ComputeNodeViewProps<IfElseShape>;\n\nexport const IfElseComponent = ({ node: shape }: IfElseComponentProps) => {\n return <FunctionBody shape={shape} inputSchema={IfElseInput} outputSchema={IfElseOutput} />;\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { IfElseInput, IfElseOutput, IfInput, IfOutput } from '@dxos/conductor';\n\nimport { createFunctionPorts, defineComputeNode, getHeight } from './common/index.ts';\nimport { ComputeShape, type CreateShapeProps, createShape, withZ } from './defs.ts';\nimport { IfComponent, IfElseComponent } from './Logic.tsx';\n\n// Kept out of `Logic.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\n//\n// Data\n//\n\nexport const IfShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('if'),\n }),\n);\n\nexport type IfShape = Schema.Schema.Type<typeof IfShape>;\n\nexport const IfElseShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('if-else'),\n }),\n);\n\nexport type IfElseShape = Schema.Schema.Type<typeof IfElseShape>;\n\n//\n// Defs\n//\n\nexport type CreateIfProps = CreateShapeProps<IfShape> & { if?: string };\n\nexport const createIf = (props: CreateIfProps) =>\n createShape<IfShape>({ type: 'if', size: { width: 192, height: getHeight(IfInput) }, ...props });\n\nexport const ifNodeDef = defineComputeNode<IfShape>({\n type: 'if',\n name: 'IF',\n icon: 'ph--arrows-split--regular',\n group: 'Operations',\n schema: withZ(IfShape),\n component: IfComponent,\n create: createIf,\n ports: (shape) => createFunctionPorts(shape.size, IfInput, IfOutput),\n});\n\nexport type CreateIfElseProps = CreateShapeProps<IfShape> & { if?: string };\n\nexport const createIfElse = (props: CreateIfElseProps) =>\n createShape<IfElseShape>({ type: 'if-else', size: { width: 192, height: getHeight(IfElseInput) }, ...props });\n\nexport const ifElseNodeDef = defineComputeNode<IfElseShape>({\n type: 'if-else',\n name: 'IF/ELSE',\n icon: 'ph--arrows-merge--regular',\n group: 'Operations',\n schema: withZ(IfElseShape),\n component: IfElseComponent,\n create: createIfElse,\n ports: (shape) => createFunctionPorts(shape.size, IfElseInput, IfElseOutput),\n});\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useEffect, useState } from 'react';\n\nimport { DEFAULT_OUTPUT } from '@dxos/conductor';\nimport * as Icon from '@dxos/react-ui/Icon';\n\nimport { useComputeNodeState } from '../hooks/index.ts';\nimport { type ComputeNodeViewProps } from './common/index.ts';\nimport { type RandomShape } from './rng-def.ts';\n\nconst icons = [\n 'ph--dice-one--regular',\n 'ph--dice-two--regular',\n 'ph--dice-three--regular',\n 'ph--dice-four--regular',\n 'ph--dice-five--regular',\n 'ph--dice-six--regular',\n];\n\nconst pickIcon = () => icons[Math.floor(Math.random() * icons.length)];\n\n// TODO(burdon): Optional range.\nexport const RandomComponent = ({ node: shape }: ComputeNodeViewProps<RandomShape>) => {\n const { runtime } = useComputeNodeState(shape);\n\n const [spin, setSpin] = useState(false);\n const [icon, setIcon] = useState(pickIcon());\n useEffect(() => {\n if (!spin) {\n return;\n }\n\n const i = setInterval(() => setIcon(pickIcon()), 250);\n const t1 = setTimeout(() => clearInterval(i), 900);\n const t2 = setTimeout(() => setSpin(false), 1_100);\n return () => {\n clearInterval(i);\n clearTimeout(t1);\n clearTimeout(t2);\n };\n }, [spin]);\n\n // The node frame takes a pointer press as select-and-drag, capturing the pointer so the click never\n // reaches this control; the gesture has to stop here for the operation to fire.\n const stopGesture: Icon.IconProps['onPointerDown'] = (ev) => ev.stopPropagation();\n\n const handleClick: Icon.IconProps['onClick'] = (ev) => {\n ev.stopPropagation();\n runtime.setOutput(DEFAULT_OUTPUT, Math.random());\n setSpin(true);\n };\n\n return (\n <div className='flex grow items-center justify-center'>\n <Icon.Icon\n icon={icon}\n classNames={spin && 'animate-[spin_1s]'}\n size='xl'\n onPointerDown={stopGesture}\n onClick={handleClick}\n />\n </div>\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { createPorts, defineComputeNode } from './common/index.ts';\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape, withZ } from './defs.ts';\nimport { RandomComponent } from './RNG.tsx';\n\n// Kept out of `RNG.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\nexport const RandomShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('rng'),\n min: Schema.optional(Schema.Number),\n max: Schema.optional(Schema.Number),\n }),\n);\n\nexport type RandomShape = Schema.Schema.Type<typeof RandomShape>;\n\nexport type CreateRandomProps = CreateShapeProps<RandomShape>;\n\nexport const createRandom = (props: CreateRandomProps) =>\n createShape<RandomShape>({\n type: 'rng',\n size: { width: 64, height: 64 },\n ...props,\n });\n\nexport const randomNodeDef = defineComputeNode<RandomShape>({\n type: 'rng',\n name: 'Random',\n icon: 'ph--dice-six--regular',\n group: 'Inputs',\n schema: withZ(RandomShape),\n component: RandomComponent,\n create: createRandom,\n ports: (shape) => createPorts(shape.size, { [createAnchorId('output')]: { x: 1, y: 0 } }),\n});\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport { DEFAULT_INPUT } from '@dxos/conductor';\nimport { useAudioStream } from '@dxos/react-ui-audio';\nimport { Chaos, shaderPresets } from '@dxos/react-ui-experimental';\n\nimport { useComputeNodeState } from '../hooks/index.ts';\nimport { type ComputeNodeViewProps } from './common/index.ts';\nimport { type ScopeShape } from './scope-def.ts';\n\nexport const ScopeComponent = ({ node: shape }: ComputeNodeViewProps<ScopeShape>) => {\n const { runtime } = useComputeNodeState(shape);\n const input = runtime.inputs[DEFAULT_INPUT];\n const active = input?.type === 'executed' ? input.value : false;\n const { getAverage } = useAudioStream(active);\n\n return (\n <div className='flex w-full justify-center items-center bg-black'>\n <Chaos active={active} getValue={getAverage} options={{ ...shaderPresets.heptapod, zoom: 1.2 }} />\n </div>\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { createPorts, defineComputeNode } from './common/index.ts';\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape, withZ } from './defs.ts';\nimport { ScopeComponent } from './Scope.tsx';\n\n// Kept out of `Scope.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\nexport const ScopeShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('scope'),\n }),\n);\n\nexport type ScopeShape = Schema.Schema.Type<typeof ScopeShape>;\n\nexport type CreateScopeProps = CreateShapeProps<ScopeShape>;\n\nexport const createScope = (props: CreateScopeProps) =>\n createShape<ScopeShape>({\n type: 'scope',\n size: { width: 128, height: 128 },\n classNames: 'rounded-full border-primary-800',\n ...props,\n });\n\nexport const scopeNodeDef = defineComputeNode<ScopeShape>({\n type: 'scope',\n name: 'Scope',\n icon: 'ph--waveform--regular',\n group: 'Outputs',\n schema: withZ(ScopeShape),\n component: ScopeComponent,\n create: createScope,\n ports: (shape) => createPorts(shape.size, { [createAnchorId('input')]: { x: -1, y: 0 } }),\n});\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport * as Surface from '@dxos/app-framework/Surface';\nimport * as AppSurface from '@dxos/app-toolkit/AppSurface';\nimport { DEFAULT_INPUT } from '@dxos/conductor';\nimport * as Card from '@dxos/react-ui/Card';\n\nimport { useComputeNodeState } from '../hooks/index.ts';\nimport { Box, type ComputeNodeViewProps } from './common/index.ts';\nimport { type SurfaceShape } from './surface-def.ts';\n\nexport const SurfaceComponent = ({ node: shape }: ComputeNodeViewProps<SurfaceShape>) => {\n const { runtime } = useComputeNodeState(shape);\n const input = runtime.inputs[DEFAULT_INPUT];\n const value = input?.type === 'executed' ? input.value : null;\n\n // TODO(burdon): Subject property?\n return (\n <Box shape={shape}>\n {/* No card until the input has a value: an empty one is a bare frame with nothing in it. */}\n {value !== null && (\n // The shape's frame already frames it, so the card fills the body without a border of its own.\n <Card.Root grid border={false} classNames='dx-grow'>\n <Surface.Surface type={AppSurface.CardContent} data={{ subject: value }} limit={1} />\n </Card.Root>\n )}\n </Box>\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { createPorts, defineComputeNode } from './common/index.ts';\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape, withZ } from './defs.ts';\nimport { SurfaceComponent } from './Surface.tsx';\n\n// Kept out of `Surface.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\nexport const SurfaceShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('surface'),\n }),\n);\n\nexport type SurfaceShape = Schema.Schema.Type<typeof SurfaceShape>;\n\nexport type CreateSurfaceProps = CreateShapeProps<SurfaceShape>;\n\nexport const createSurface = (props: CreateSurfaceProps) =>\n createShape<SurfaceShape>({\n type: 'surface',\n size: { width: 384, height: 384 },\n ...props,\n });\n\nexport const surfaceNodeDef = defineComputeNode<SurfaceShape>({\n type: 'surface',\n name: 'Surface',\n icon: 'ph--frame-corners--regular',\n group: 'Outputs',\n schema: withZ(SurfaceShape),\n component: SurfaceComponent,\n create: createSurface,\n ports: (shape) => createPorts(shape.size, { [createAnchorId('input')]: { x: -1, y: 0 } }),\n resizable: true,\n});\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useEffect, useState } from 'react';\n\nimport { DEFAULT_OUTPUT } from '@dxos/conductor';\nimport * as Field from '@dxos/react-ui/Field';\nimport * as Input from '@dxos/react-ui/Input';\n\nimport { useComputeNodeState } from '../hooks/index.ts';\nimport { type ComputeNodeViewProps } from './common/index.ts';\nimport { type SwitchShape } from './switch-def.ts';\n\n// TODO(burdon): Should model as a constant.\nexport const SwitchComponent = ({ node: shape }: ComputeNodeViewProps<SwitchShape>) => {\n const { runtime } = useComputeNodeState(shape);\n const [value, setValue] = useState(false);\n useEffect(() => {\n runtime.setOutput(DEFAULT_OUTPUT, value);\n }, [value]);\n\n return (\n <div className='flex w-full justify-center items-center'>\n {/* Only the switch keeps the press from the node frame (which would take it as select-and-drag and capture\n the pointer, so the switch never saw the click); the rest of the shape drags as any node does. */}\n <div className='inline-flex' onPointerDown={(ev) => ev.stopPropagation()} onClick={(ev) => ev.stopPropagation()}>\n <Field.Root>\n <Input.Switch checked={value} onCheckedChange={({ checked: value }) => setValue(value)} />\n </Field.Root>\n </div>\n </div>\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { createPorts, defineComputeNode } from './common/index.ts';\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape, withZ } from './defs.ts';\nimport { SwitchComponent } from './Switch.tsx';\n\n// Kept out of `Switch.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\nexport const SwitchShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('switch'),\n }),\n);\n\nexport type SwitchShape = Schema.Schema.Type<typeof SwitchShape>;\n\nexport type CreateSwitchProps = CreateShapeProps<SwitchShape>;\n\nexport const createSwitch = (props: CreateSwitchProps) =>\n createShape<SwitchShape>({ type: 'switch', size: { width: 64, height: 64 }, ...props });\n\nexport const switchNodeDef = defineComputeNode<SwitchShape>({\n type: 'switch',\n name: 'Switch',\n icon: 'ph--toggle-left--regular',\n group: 'Inputs',\n schema: withZ(SwitchShape),\n component: SwitchComponent,\n create: createSwitch,\n ports: (shape) => createPorts(shape.size, { [createAnchorId('output')]: { x: 1, y: 0 } }),\n});\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport { Box, type ComputeNodeViewProps } from './common/index.ts';\nimport { type TableShape } from './table-def.ts';\n\nexport const TableComponent = ({ node: shape }: ComputeNodeViewProps<TableShape>) => {\n // const items = shape.node.items.value;\n\n return <Box shape={shape}></Box>;\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { createInputSchema, createOutputSchema } from '@dxos/conductor';\nimport { Type } from '@dxos/echo';\nimport { Message } from '@dxos/types';\n\nimport { createFunctionPorts, defineComputeNode } from './common/index.ts';\nimport { ComputeShape, type CreateShapeProps, createShape, withZ } from './defs.ts';\nimport { TableComponent } from './Table.tsx';\n\n// Kept out of `Table.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\nconst InputSchema = createInputSchema(Type.getSchema(Message.Message));\n\nconst OutputSchema = createOutputSchema(Schema.mutable(Schema.Array(Type.getSchema(Message.Message))));\n\nexport const TableShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('table'),\n }),\n);\n\nexport type TableShape = Schema.Schema.Type<typeof TableShape>;\n\nexport type CreateTableProps = CreateShapeProps<TableShape>;\n\nexport const createTable = (props: CreateTableProps) =>\n createShape<TableShape>({ type: 'table', size: { width: 320, height: 512 }, ...props });\n\nexport const tableNodeDef = defineComputeNode<TableShape>({\n type: 'table',\n name: 'Table',\n icon: 'ph--table--regular',\n schema: withZ(TableShape),\n component: TableComponent,\n create: createTable,\n ports: (shape) => createFunctionPorts(shape.size, InputSchema, OutputSchema),\n resizable: true,\n});\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport React, { useRef } from 'react';\n\nimport { ComputeValueType, getTemplateInputSchema } from '@dxos/conductor';\nimport * as JsonSchema from '@dxos/echo/JsonSchema';\nimport { invariant } from '@dxos/invariant';\n\nimport { useComputeNodeState } from '../hooks/index.ts';\nimport {\n Box,\n type ComputeNodeViewProps,\n TextBox,\n type TextBoxControl,\n type TextBoxProps,\n TypeSelect,\n} from './common/index.ts';\nimport { type TemplateShape } from './template-def.ts';\n\n//\n// Component\n//\n\ntype TextInputComponentProps = ComputeNodeViewProps<TemplateShape> & Pick<TextBoxProps, 'placeholder'>;\n\nconst TextInputComponent = ({ node: shape, placeholder }: TextInputComponentProps) => {\n const { node } = useComputeNodeState(shape);\n const inputRef = useRef<TextBoxControl>(null);\n\n const handleEnter: TextBoxProps['onEnter'] = (text) => {\n const value = text.trim();\n if (value.length) {\n const schema = getTemplateInputSchema(node);\n\n node.value = value;\n node.inputSchema = JsonSchema.toJsonSchema(schema);\n }\n };\n\n const handleTypeChange = (newType: string) => {\n invariant(Schema.is(ComputeValueType)(newType), 'Invalid type');\n\n node.valueType = newType;\n node.inputSchema = JsonSchema.toJsonSchema(getTemplateInputSchema(node));\n };\n\n return (\n <Box\n shape={shape}\n title={'Template'}\n status={<TypeSelect value={node.valueType ?? 'string'} onValueChange={handleTypeChange} />}\n >\n <TextBox\n placeholder={placeholder}\n ref={inputRef}\n value={node.value}\n language={node.valueType === 'object' ? 'json' : undefined}\n onBlur={handleEnter}\n onEnter={handleEnter}\n />\n </Box>\n );\n};\n\nexport const TemplateComponent = (props: ComputeNodeViewProps<TemplateShape>) => (\n <TextInputComponent {...props} placeholder={'Prompt'} />\n);\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { ComputeValueType, TemplateOutput, VoidInput } from '@dxos/conductor';\n\nimport { createFunctionPorts, defineComputeNode } from './common/index.ts';\nimport { ComputeShape, type CreateShapeProps, createShape, withZ } from './defs.ts';\nimport { TemplateComponent } from './Template.tsx';\n\n// Kept out of `Template.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\n//\n// Data\n//\n\nexport const TemplateShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('template'),\n valueType: Schema.optional(ComputeValueType),\n }),\n);\n\nexport type TemplateShape = Schema.Schema.Type<typeof TemplateShape>;\n\n//\n// Defs\n//\n\nexport type CreateTemplateProps = CreateShapeProps<TemplateShape> & { text?: string };\n\nexport const createTemplate = (props: CreateTemplateProps) =>\n createShape<TemplateShape>({ type: 'template', size: { width: 256, height: 384 }, ...props });\n\nexport const templateNodeDef = defineComputeNode<TemplateShape>({\n type: 'template',\n name: 'Template',\n icon: 'ph--article--regular',\n group: 'Inputs',\n schema: withZ(TemplateShape),\n component: TemplateComponent,\n create: createTemplate,\n ports: (shape) => createFunctionPorts(shape.size, VoidInput, TemplateOutput),\n resizable: true,\n});\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport { DEFAULT_INPUT } from '@dxos/conductor';\n\nimport { useComputeNodeState } from '../hooks/index.ts';\nimport { Box, type ComputeNodeViewProps, TextBox } from './common/index.ts';\nimport { type TextShape } from './text-def.ts';\n\nexport const TextComponent = ({ node: shape }: ComputeNodeViewProps<TextShape>) => {\n const { runtime } = useComputeNodeState(shape);\n const input = runtime.inputs[DEFAULT_INPUT];\n const value = input?.type === 'executed' ? input.value : 0;\n\n return (\n <Box shape={shape}>\n <TextBox value={value} />\n </Box>\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { createPorts, defineComputeNode } from './common/index.ts';\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape, withZ } from './defs.ts';\nimport { TextComponent } from './Text.tsx';\n\n// Kept out of `Text.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\nexport const TextShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('text'),\n }),\n);\n\nexport type TextShape = Schema.Schema.Type<typeof TextShape>;\n\nexport type CreateTextProps = CreateShapeProps<TextShape>;\n\nexport const createText = (props: CreateTextProps) =>\n createShape<TextShape>({ type: 'text', size: { width: 384, height: 384 }, ...props });\n\nexport const textNodeDef = defineComputeNode<TextShape>({\n type: 'text',\n name: 'Text',\n icon: 'ph--article--regular',\n group: 'Outputs',\n schema: withZ(TextShape),\n component: TextComponent,\n create: createText,\n ports: (shape) => createPorts(shape.size, { [createAnchorId('input')]: { x: -1, y: 0 } }),\n resizable: true,\n});\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport { Box, type ComputeNodeViewProps } from './common/index.ts';\nimport { type TextToImageShape } from './text-to-image-def.ts';\n\nexport const TextToImageComponent = ({ node: shape }: ComputeNodeViewProps<TextToImageShape>) => {\n return <Box shape={shape} />;\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { createPorts, defineComputeNode } from './common/index.ts';\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape, withZ } from './defs.ts';\nimport { TextToImageComponent } from './TextToImage.tsx';\n\n// Kept out of `TextToImage.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\nexport const TextToImageShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('text-to-image'),\n }),\n);\n\nexport type TextToImageShape = Schema.Schema.Type<typeof TextToImageShape>;\n\nexport type CreateTextToImageProps = CreateShapeProps<TextToImageShape>;\n\nexport const createTextToImage = (props: CreateTextToImageProps) =>\n createShape<TextToImageShape>({ type: 'text-to-image', size: { width: 128, height: 64 }, ...props });\n\nexport const textToImageNodeDef = defineComputeNode<TextToImageShape>({\n type: 'text-to-image',\n name: 'Image',\n icon: 'ph--image--regular',\n group: 'Transform',\n schema: withZ(TextToImageShape),\n component: TextToImageComponent,\n create: createTextToImage,\n ports: (shape) => createPorts(shape.size, { [createAnchorId('output')]: { x: 1, y: 0 } }),\n});\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useEffect, useRef } from 'react';\n\nimport * as ScrollArea from '@dxos/react-ui/ScrollArea';\nimport type * as Util from '@dxos/react-ui/Util';\nimport { mx } from '@dxos/ui-theme';\n\nimport { Box, type ComputeNodeViewProps } from './common/index.ts';\nimport { type ThreadShape } from './thread-def.ts';\n\nexport const ThreadComponent = ({ node: shape }: ComputeNodeViewProps<ThreadShape>) => {\n const items: any[] = [];\n const scrollRef = useRef<HTMLDivElement>(null);\n useEffect(() => {\n if (scrollRef.current) {\n scrollRef.current.scrollTop = scrollRef.current.scrollHeight;\n }\n }, [items]);\n\n return (\n <Box shape={shape}>\n <ScrollArea.Root orientation='vertical'>\n <ScrollArea.Viewport classNames='gap-2 p-2' ref={scrollRef}>\n {[...items].map((item, i) => (\n <ThreadItem key={i} item={item} />\n ))}\n </ScrollArea.Viewport>\n </ScrollArea.Root>\n </Box>\n );\n};\n\nexport const ThreadItem = ({ classNames, item }: Util.ThemedClassName<{ item: any }>) => {\n if (typeof item !== 'object') {\n return <div className={mx(classNames)}>{item}</div>;\n }\n\n // TODO(burdon): Hack; introspect type.\n // TODO(burdon): Markdown parser.\n const { role, message } = item;\n return (\n <div className={mx('flex', classNames, role === 'user' && 'justify-end')}>\n <div\n className={mx(\n 'block rounded-md p-1 px-2 text-sm',\n role === 'user'\n ? 'bg-blue-100 dark:bg-blue-800'\n : role === 'system'\n ? 'bg-red-100, dark:bg-red-800'\n : 'whitespace-pre-wrap bg-neutral-50 dark:bg-neutral-800',\n )}\n >\n {message}\n </div>\n </div>\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport { createInputSchema, createOutputSchema } from '@dxos/conductor';\nimport { Type } from '@dxos/echo';\nimport { Message } from '@dxos/types';\n\nimport { createFunctionPorts, defineComputeNode } from './common/index.ts';\nimport { ComputeShape, type CreateShapeProps, createShape, withZ } from './defs.ts';\nimport { ThreadComponent } from './Thread.tsx';\n\n// Kept out of `Thread.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\nconst InputSchema = createInputSchema(Type.getSchema(Message.Message));\n\nconst OutputSchema = createOutputSchema(Schema.mutable(Schema.Array(Type.getSchema(Message.Message))));\n\nexport const ThreadShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('thread'),\n }),\n);\n\nexport type ThreadShape = Schema.Schema.Type<typeof ThreadShape>;\n\nexport type CreateThreadProps = CreateShapeProps<ThreadShape>;\n\nexport const createThread = (props: CreateThreadProps) =>\n createShape<ThreadShape>({ type: 'thread', size: { width: 384, height: 384 }, ...props });\n\nexport const threadNodeDef = defineComputeNode<ThreadShape>({\n type: 'thread',\n name: 'Thread',\n icon: 'ph--chats-circle--regular',\n group: 'Outputs',\n schema: withZ(ThreadShape),\n component: ThreadComponent,\n create: createThread,\n ports: (shape) => createFunctionPorts(shape.size, InputSchema, OutputSchema),\n resizable: true,\n});\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport * as Trigger from '@dxos/compute/Trigger';\nimport * as TriggerEvent from '@dxos/compute/TriggerEvent';\nimport { Filter, Query } from '@dxos/echo';\nimport { type SpaceId } from '@dxos/keys';\n\n// Kept out of `Trigger.tsx` and shared with `trigger-def.ts`: react-refresh only fast-refreshes a\n// module whose exports are all components, and a value import back from the def module would close\n// a runtime cycle.\n\nexport const createTriggerSpec = (props: { triggerKind?: Trigger.Kind; spaceId?: SpaceId }): Trigger.Spec => {\n const kind = props.triggerKind ?? 'email';\n switch (kind) {\n case 'timer':\n return Trigger.specTimer('* * * * *');\n case 'webhook':\n return Trigger.specWebhook({ method: 'POST' });\n case 'subscription':\n return Trigger.specSubscription(Query.select(Filter.nothing()));\n case 'email':\n return Trigger.specEmail();\n case 'feed': {\n return { kind: 'feed' } satisfies Trigger.FeedSpec;\n }\n case 'direct':\n return Trigger.specDirect();\n }\n};\n\nexport const getOutputSchema = (kind: Trigger.Kind) => {\n const kindToSchema: Record<Trigger.Kind, Schema.Schema<any>> = {\n ['email']: TriggerEvent.EmailEvent,\n ['subscription']: TriggerEvent.SubscriptionEvent,\n ['timer']: TriggerEvent.TimerEvent,\n ['webhook']: TriggerEvent.WebhookEvent,\n ['feed']: TriggerEvent.FeedEvent,\n ['direct']: TriggerEvent.DirectEvent,\n };\n return kindToSchema[kind];\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useEffect } from 'react';\n\nimport * as Trigger from '@dxos/compute/Trigger';\nimport { VoidInput } from '@dxos/conductor';\nimport { Obj } from '@dxos/echo';\nimport { useResolveRef } from '@dxos/echo-react';\nimport { useSpaces } from '@dxos/react-client/echo';\nimport * as Select from '@dxos/react-ui/Select';\n\nimport { type ComputeNodeViewProps, FunctionBody, getHeight } from './common/index.ts';\nimport { type TriggerShape } from './trigger-def.ts';\nimport { createTriggerSpec, getOutputSchema } from './trigger-spec.ts';\n\nexport type TriggerComponentProps = ComputeNodeViewProps<TriggerShape>;\n\nexport const TriggerComponent = ({ node: shape }: TriggerComponentProps) => {\n const [space] = useSpaces();\n const functionTrigger = useResolveRef(shape.functionTrigger);\n\n useEffect(() => {\n if (functionTrigger && !functionTrigger.spec) {\n Obj.update(functionTrigger, (functionTrigger) => {\n functionTrigger.spec = createTriggerSpec({\n triggerKind: 'email',\n spaceId: space?.id,\n }) as Obj.Mutable<Trigger.Spec>;\n });\n }\n }, [functionTrigger, functionTrigger?.spec]);\n\n useEffect(() => {\n shape.size.height = getHeight(getOutputSchema(functionTrigger?.spec?.kind ?? 'email'));\n }, [functionTrigger?.spec?.kind]);\n\n const setKind = (kind: Trigger.Kind) => {\n if (functionTrigger?.spec?.kind !== kind) {\n Obj.update(functionTrigger!, (obj) => {\n obj.spec = createTriggerSpec({ triggerKind: kind, spaceId: space?.id }) as Obj.Mutable<Trigger.Spec>;\n });\n }\n };\n\n if (!functionTrigger?.spec) {\n return;\n }\n\n return (\n <FunctionBody\n shape={shape}\n status={<TriggerKindSelect value={functionTrigger.spec?.kind} onValueChange={setKind} />}\n inputSchema={VoidInput}\n outputSchema={getOutputSchema(functionTrigger.spec!.kind!)}\n />\n );\n};\n\n// TODO(burdon): Factor out.\ntype TriggerKindSelectProps = {\n value?: Trigger.Kind;\n onValueChange: (kind: Trigger.Kind) => void;\n};\n\nconst TriggerKindSelect = ({ value, onValueChange }: TriggerKindSelectProps) => {\n return (\n <Select.Root\n value={value === undefined ? [] : [value]}\n onValueChange={({ value: [next] }) => {\n const kind = Trigger.Kinds.find((kind) => kind === next);\n if (kind) {\n onValueChange(kind);\n }\n }}\n items={Trigger.Kinds.map((kind) => ({ value: kind, label: kind }))}\n >\n <Select.Trigger classNames='w-full px-0!' />\n <Select.Content>\n {Trigger.Kinds.map((kind) => (\n <Select.Item key={kind} item={{ value: kind, label: kind }} />\n ))}\n </Select.Content>\n </Select.Root>\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\n\nimport * as Trigger from '@dxos/compute/Trigger';\nimport * as TriggerEvent from '@dxos/compute/TriggerEvent';\nimport { VoidInput } from '@dxos/conductor';\nimport { Ref } from '@dxos/echo';\nimport { type SpaceId } from '@dxos/keys';\n\nimport { createFunctionPorts, defineComputeNode, getHeight } from './common/index.ts';\nimport { ComputeShape, type CreateShapeProps, createShape, withZ } from './defs.ts';\nimport { createTriggerSpec, getOutputSchema } from './trigger-spec.ts';\nimport { TriggerComponent } from './Trigger.tsx';\n\n// Kept out of `Trigger.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\n/** The struct behind `TriggerShape`, for hosts that compose their own union (the scene engine). */\nexport const TriggerShapeSchema = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.Literal('trigger'),\n functionTrigger: Schema.optional(Ref.Ref(Trigger.Trigger)),\n }),\n);\n\n// TODO(wittjosiah): Try to clean up this type inference.\nexport interface TriggerShape extends ComputeShape {\n type: 'trigger';\n functionTrigger?: Ref.Ref<Trigger.Trigger>;\n}\n\nexport const TriggerShape: Schema.Codec<TriggerShape> = TriggerShapeSchema as any;\n\nexport type CreateTriggerProps = CreateShapeProps<Omit<TriggerShape, 'functionTrigger'>> & {\n spaceId?: SpaceId;\n triggerKind?: Trigger.Kind;\n};\n\nexport const createTrigger = (props: CreateTriggerProps): TriggerShape => {\n const functionTrigger = Trigger.make({\n enabled: true,\n spec: createTriggerSpec(props),\n });\n return createShape<TriggerShape>({\n type: 'trigger',\n functionTrigger: Ref.make(functionTrigger),\n size: { width: 192, height: getHeight(TriggerEvent.EmailEvent) },\n ...props,\n });\n};\n\nexport const triggerNodeDef = defineComputeNode<TriggerShape>({\n type: 'trigger',\n name: 'Trigger',\n icon: 'ph--lightning--regular',\n group: 'Inputs',\n schema: withZ(TriggerShapeSchema),\n component: TriggerComponent,\n create: createTrigger,\n // The factory makes an ECHO object, so the default size is stated rather than sampled.\n defaultSize: { width: 192, height: getHeight(TriggerEvent.EmailEvent) },\n ports: (shape) =>\n createFunctionPorts(shape.size, VoidInput, getOutputSchema(shape.functionTrigger?.target?.spec?.kind ?? 'email')),\n});\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as Struct from 'effect/Struct';\nimport React, { type FC } from 'react';\n\nimport { type NodeDef } from '@dxos/react-ui-canvas/scene';\n\nimport { createRowPorts, defineComputeNode, getRowPoints } from './common/index.ts';\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape, withZ } from './defs.ts';\n\n//\n// Gate utils.\n// https://en.wikipedia.org/wiki/Logic_gate\n//\n\ntype GateType = 'and' | 'or' | 'not';\n\nconst GateShape = ComputeShape.mapFields(\n Struct.assign({\n type: Schema.String,\n }),\n);\n\ntype GateShape = Schema.Schema.Type<typeof GateShape>;\n\ntype CreateGateProps = CreateShapeProps<GateShape> & { type: GateType };\n\nconst createGate = (props: CreateGateProps): GateShape =>\n createShape<GateShape>({\n size: { width: 64, height: 64 },\n ...props,\n });\n\n// TODO(burdon): Create custom icons.\nconst defineGate = ({\n type,\n name,\n icon,\n symbol: Symbol,\n create,\n inputs,\n outputs = [createAnchorId('output')],\n}: {\n type: GateType;\n symbol: FC<GateSymbolProps>;\n create: (props: Pick<GateShape, 'id' | 'center'>) => GateShape;\n inputs: string[];\n outputs?: string[];\n} & Pick<NodeDef, 'name' | 'icon'>): NodeDef =>\n defineComputeNode<GateShape>({\n type,\n name,\n icon,\n group: 'Operations',\n schema: withZ(GateShape),\n // NOTE: Preact interprets captitalized properties as React components.\n // Be careful not to name component factories with a capital letter.\n component: () => {\n return (\n <div className='flex w-full justify-center items-center'>\n <Symbol />\n </div>\n );\n },\n create,\n ports: (shape) => createRowPorts({ size: shape.size, inputs, outputs }),\n });\n\n//\n// Symbols\n//\n\ntype PathConstructor = (props: { startX: number; endX: number; height: number }) => string[];\n\ntype GateSymbolProps = {\n width?: number;\n height?: number;\n className?: string;\n strokeWidth?: number;\n};\n\n// TODO(burdon): Note inputs should line up with anchors.\nconst createSymbol =\n (pathConstructor: PathConstructor, inputs: number): FC<GateSymbolProps> =>\n ({\n width = 64,\n height = 32,\n // TODO(burdon): Same as line color.\n className = 'fill-neutral-200 dark:fill-neutral-800 stroke-neutral-500',\n strokeWidth = 1,\n }) => {\n const startX = width * 0.25;\n const endX = width * 0.75;\n const centerY = height / 2;\n const paths = pathConstructor({ startX, endX, height });\n\n return (\n <svg viewBox={`0 0 ${width} ${height}`} className='dx-fill'>\n {/* Input line. */}\n {getRowPoints({ x: 0, y: centerY }, inputs).map(({ x, y }, i) => (\n <line key={i} x1={x} y1={y} x2={startX * 1.3} y2={y} strokeWidth={strokeWidth} className={className} />\n ))}\n\n {/* Output line. */}\n <line x1={endX} y1={centerY} x2={width} y2={centerY} strokeWidth={strokeWidth} className={className} />\n\n {/* And body. */}\n {paths.map((path, i) => (\n <path key={i} d={path} strokeWidth={strokeWidth} className={className} />\n ))}\n </svg>\n );\n };\n\n//\n// AND\n//\n\nconst AndSymbol = createSymbol(({ startX, endX, height }) => {\n const arcRadius = (endX - startX) / 2;\n return [\n `\n M ${startX},${height * 0.1}\n L ${endX - arcRadius},${height * 0.1}\n A ${arcRadius},${height * 0.4} 0 0 1 ${endX - arcRadius},${height * 0.9}\n L ${startX},${height * 0.9}\n Z\n `,\n ];\n}, 2);\n\nexport const AndShape = GateShape;\nexport type AndShape = GateShape;\n\nexport const createAnd = (props: Omit<CreateGateProps, 'type' | 'node'>) => {\n return createGate({ ...props, type: 'and' });\n};\nexport const andNodeDef = defineGate({\n type: 'and',\n name: 'AND',\n icon: 'ph--intersection--regular',\n symbol: AndSymbol,\n create: createAnd,\n inputs: ['input.a', 'input.b'],\n});\n\n//\n// OR\n//\n\n// TODO(burdon): Should have sharper point.\nconst OrSymbol = createSymbol(({ startX, endX, height }) => {\n const arcRadius = (endX - startX) / 2;\n return [\n `\n M ${startX},${height * 0.1}\n L ${endX - arcRadius},${height * 0.1}\n A ${arcRadius},${height * 0.4} 0 0 1 ${endX - arcRadius},${height * 0.9}\n L ${startX},${height * 0.9}\n C ${startX * 1.4},${height * 0.5} ${startX * 1.4},${height * 0.5} ${startX},${height * 0.1}\n Z\n `,\n ];\n}, 2);\n\nexport const OrShape = GateShape;\nexport type OrShape = GateShape;\n\nexport const createOr = (props: Omit<CreateGateProps, 'type' | 'node'>) => {\n return createGate({ ...props, type: 'or' });\n};\nexport const orNodeDef = defineGate({\n type: 'or',\n name: 'OR',\n icon: 'ph--union--regular',\n symbol: OrSymbol,\n create: createOr,\n inputs: ['input.a', 'input.b'],\n});\n\n//\n// NOT\n//\n\nconst NotSymbol = createSymbol(({ startX, endX, height }) => {\n return [\n `\n M ${startX},${height * 0.1}\n L ${endX * 0.9},${height * 0.5}\n L ${startX},${height * 0.9}\n Z\n `,\n `\n M ${endX - height * 0.2},${height * 0.5}\n A ${height * 0.1} ${height * 0.1} 0 0 1 ${endX},${height * 0.5}\n A ${height * 0.1} ${height * 0.1} 0 0 1 ${endX - height * 0.2},${height * 0.5}\n Z\n `,\n ];\n}, 1);\n\nexport const NotShape = GateShape;\nexport type NotShape = GateShape;\n\nexport const createNot = (props: Omit<CreateGateProps, 'type' | 'node'>) => {\n return createGate({ ...props, type: 'not' });\n};\nexport const notNodeDef = defineGate({\n type: 'not',\n name: 'NOT',\n icon: 'ph--x--regular',\n symbol: NotSymbol,\n create: createNot,\n inputs: [createAnchorId('input')],\n});\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport { type NodeDef, type NodeRegistry, defaultNodeRegistry } from '@dxos/react-ui-canvas/scene';\n\nimport {\n andNodeDef,\n appendNodeDef,\n audioNodeDef,\n beaconNodeDef,\n chatNodeDef,\n constantNodeDef,\n databaseNodeDef,\n feedNodeDef,\n functionNodeDef,\n gptNodeDef,\n gptRealtimeNodeDef,\n ifElseNodeDef,\n ifNodeDef,\n jsonNodeDef,\n jsonTransformNodeDef,\n notNodeDef,\n orNodeDef,\n randomNodeDef,\n reducerNodeDef,\n scopeNodeDef,\n surfaceNodeDef,\n switchNodeDef,\n templateNodeDef,\n textNodeDef,\n textToImageNodeDef,\n threadNodeDef,\n triggerNodeDef,\n} from './shapes/index.ts';\n\n/** The compute types in palette order, each under its group (Inputs, Transform, Operations, Outputs). */\nexport const computeNodeDefs: NodeDef[] = [\n constantNodeDef,\n templateNodeDef,\n chatNodeDef,\n switchNodeDef,\n audioNodeDef,\n triggerNodeDef,\n randomNodeDef,\n gptNodeDef,\n gptRealtimeNodeDef,\n functionNodeDef,\n databaseNodeDef,\n textToImageNodeDef,\n appendNodeDef,\n ifNodeDef,\n ifElseNodeDef,\n andNodeDef,\n orNodeDef,\n notNodeDef,\n reducerNodeDef,\n jsonTransformNodeDef,\n jsonNodeDef,\n feedNodeDef,\n threadNodeDef,\n textNodeDef,\n surfaceNodeDef,\n beaconNodeDef,\n scopeNodeDef,\n];\n\n/** The compute types plus the engine's note under a `Misc` group. */\nexport const computeNodeRegistry: NodeRegistry = {\n ...Object.fromEntries(computeNodeDefs.map((def) => [def.type, def])),\n note: { ...defaultNodeRegistry.note, group: 'Misc' },\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\n//\n// The editor's bullets over the scene engine: a dot runs along a link's path when the compute node at\n// its source emits the property the link carries. Drawn as an overlay in scene coordinates; the paths\n// are found by the link id the layer stamps on them.\n//\n\nimport { useAtomValue } from '@effect/atom-react/Hooks';\nimport React, { useEffect, useRef } from 'react';\n\nimport { DEFAULT_OUTPUT } from '@dxos/conductor';\nimport { type Projection, type Scene, endpointNode } from '@dxos/react-ui-canvas/scene';\n\nimport { type ComputeGraphController } from '../graph/index.ts';\nimport { parseAnchorId } from '../shapes/index.ts';\n\nconst RADIUS = 3;\nconst DURATION_MS = 500;\nconst MAX_BULLETS = 32;\n\nexport type BulletsProps = {\n controller: ComputeGraphController;\n projection: Projection;\n};\n\n/** Links leaving the compute node `nodeId` through `property`. */\nconst outgoing = (scene: Scene, nodeId: string, property: string) =>\n Object.values(scene.links).filter((link) => {\n const source = endpointNode(link.source);\n const node = source ? scene.nodes[source] : undefined;\n if (!node || !('node' in node) || node.node !== nodeId) {\n return false;\n }\n const port = 'port' in link.source ? link.source.port : undefined;\n return (port ? parseAnchorId(port)[1] : DEFAULT_OUTPUT) === property;\n });\n\nexport const Bullets = ({ controller, projection }: BulletsProps) => {\n const scene = useAtomValue(projection.scene);\n const sceneRef = useRef(scene);\n sceneRef.current = scene;\n const layerRef = useRef<SVGGElement>(null);\n\n useEffect(\n () =>\n controller.output.on(({ nodeId, property, value }) => {\n const layer = layerRef.current;\n const root = layer?.closest('[data-testid=\"scene-view\"]');\n if (!layer || !root || value.type === 'not-executed') {\n return;\n }\n for (const link of outgoing(sceneRef.current, nodeId, property)) {\n const path = root.querySelector(`path[data-link-id=\"${link.id}\"]`);\n if (path instanceof SVGPathElement && layer.childElementCount < MAX_BULLETS) {\n fireBullet(layer, path);\n }\n }\n }),\n [controller],\n );\n\n return (\n <svg className='absolute overflow-visible pointer-events-none' width={1} height={1}>\n <g ref={layerRef} />\n </svg>\n );\n};\n\n/** One dot from the path's start to its end, removed when it arrives. */\nconst fireBullet = (layer: SVGGElement, path: SVGPathElement) => {\n const bullet = document.createElementNS('http://www.w3.org/2000/svg', 'circle');\n bullet.setAttribute('r', String(RADIUS));\n bullet.setAttribute('class', 'fill-orange-500');\n layer.append(bullet);\n const length = path.getTotalLength();\n const started = performance.now();\n const step = (now: number) => {\n const t = Math.min((now - started) / DURATION_MS, 1);\n const point = path.getPointAtLength(length * t);\n bullet.setAttribute('cx', String(point.x));\n bullet.setAttribute('cy', String(point.y));\n if (t < 1) {\n requestAnimationFrame(step);\n } else {\n bullet.remove();\n }\n };\n requestAnimationFrame(step);\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\n//\n// The scene store over a `CanvasBoard` (MIGRATION.md M4): `layout.nodes` are the scene's nodes and\n// `layout.edges` its links, so a board written by the old editor opens on the engine unchanged. The\n// store is the only seam that changes — `SceneView` takes this exactly as it takes the memory store.\n//\n// The two representations differ in three places, and each is translated rather than migrated:\n// z-order (an array in the layout, a fractional key in the scene), style (`guide` / `classNames` at the\n// top of a shape, a `style` object on a node) and link ends (an edge's `input` / `output` property\n// names, a link endpoint's anchor-id port).\n//\n\nimport * as Equal from 'effect/Equal';\nimport * as Atom from 'effect/reactivity/Atom';\n\nimport { DEFAULT_INPUT, DEFAULT_OUTPUT } from '@dxos/conductor';\nimport { Obj } from '@dxos/echo';\nimport {\n type Link,\n LINK_TYPES,\n type LinkType,\n type Node,\n type NodeStyle,\n type Scene,\n type SceneId,\n type SceneMap,\n type SceneStore,\n initialKeys,\n sortByZ,\n} from '@dxos/react-ui-canvas/scene';\n\nimport { createAnchorId, parseAnchorId } from '../shapes/defs.ts';\nimport { type CanvasBoard } from '../types/index.ts';\n\n/** A board's layout as both representations see it: the arrays, whether live (ECHO) or plain. */\ntype Layout = { nodes: CanvasBoard.Shape[]; edges: CanvasBoard.Connection[] };\n\n/** The scene id a board's own layout takes; a board holds one scene, so it is the board's id. */\nexport const boardSceneId = (board: CanvasBoard.CanvasBoard): SceneId => board.id;\n\n/** An edge naming a type the engine does not have is drawn as a curve, which is what the editor drew. */\nconst DEFAULT_LINK_TYPE: LinkType = 'curve';\nconst linkType = (type: string | undefined): LinkType =>\n LINK_TYPES.find((candidate) => candidate === type) ?? DEFAULT_LINK_TYPE;\n\n//\n// Read\n//\n\n/**\n * The scene a layout stands for. `z` comes from array order — the order the editor painted in — so the\n * first read of an existing board reproduces its stacking exactly; every later read uses the key the\n * write path put the node's position in the array for.\n */\nexport const sceneFromLayout = (id: SceneId, layout: Partial<Layout> | undefined, name?: string): Scene => {\n const shapes = layout?.nodes ?? [];\n const edges = layout?.edges ?? [];\n const nodeKeys = initialKeys(shapes.length);\n const linkKeys = initialKeys(edges.length);\n const nodes: Record<string, Node> = {};\n shapes.forEach((shape, index) => {\n nodes[shape.id] = nodeFromShape(shape, nodeKeys[index]);\n });\n const links: Record<string, Link> = {};\n edges.forEach((edge, index) => {\n links[edge.id] = linkFromEdge(edge, linkKeys[index]);\n });\n return { id, ...(name ? { name } : {}), nodes, links };\n};\n\nconst nodeFromShape = (shape: CanvasBoard.Shape, z: string): Node => {\n // `classNames` rides through on the node untouched: the old editor reads it, the engine draws no host classes.\n const { guide: _guide, ...rest } = shape as CanvasBoard.Shape & { style?: NodeStyle };\n const style = styleFromShape(shape);\n return {\n ...(rest as unknown as Node),\n z,\n ...(style ? { style } : {}),\n };\n};\n\n/** A shape's look: its own `style` when the engine wrote one, else the editor's top-level `guide`. */\nconst styleFromShape = (shape: CanvasBoard.Shape): NodeStyle | undefined => {\n const { style, guide } = shape as CanvasBoard.Shape & { style?: NodeStyle };\n const legacy: NodeStyle = guide !== undefined ? { guide } : {};\n const merged = { ...legacy, ...style };\n return Object.keys(merged).length > 0 ? merged : undefined;\n};\n\n/**\n * The link an edge stands for. Both ends are node ends: the editor has no free endpoints, and the\n * property names it stores become the anchor ids the compute node definitions draw ports for.\n */\nconst linkFromEdge = (edge: CanvasBoard.Connection, z: string): Link => {\n const { id, source, target, input, output, type } = edge;\n return {\n id,\n type: linkType(type),\n z,\n source: { node: source, port: createAnchorId('output', output ?? DEFAULT_OUTPUT) },\n target: { node: target, port: createAnchorId('input', input ?? DEFAULT_INPUT) },\n } as Link;\n};\n\n//\n// Write\n//\n\n/**\n * The scene applied to a layout in place: each element updated, added or removed on its own, and the\n * arrays left in z order. A wholesale rebuild would be one Automerge delta per drag frame covering the\n * whole board, so every change here touches only what changed.\n */\nexport const applySceneToLayout = (layout: Layout, scene: Scene): void => {\n applyElements(layout.nodes, sortByZ(Object.values(scene.nodes)).map(shapeFromNode));\n applyElements(layout.edges, sortByZ(Object.values(scene.links)).map(edgeFromLink));\n};\n\n/** One array reconciled against the elements it should hold, in that order. */\nconst applyElements = <T extends { id: string }>(current: T[], next: readonly T[]): void => {\n const wanted = new Map(next.map((element) => [element.id, element]));\n for (let index = current.length - 1; index >= 0; index--) {\n const element = current[index];\n const update = wanted.get(element.id);\n if (update) {\n assignFields(element as Record<string, unknown>, update as Record<string, unknown>);\n } else {\n current.splice(index, 1);\n }\n }\n const present = new Set(current.map(({ id }) => id));\n for (const element of next) {\n if (!present.has(element.id)) {\n current.push(element);\n }\n }\n reorder(current, next);\n};\n\n/** The array put in `next`'s order, moving only the elements that are out of place. */\nconst reorder = <T extends { id: string }>(current: T[], next: readonly T[]): void => {\n const order = new Map(next.map((element, index) => [element.id, index]));\n for (let index = 1; index < current.length; index++) {\n const element = current[index];\n const rank = order.get(element.id) ?? 0;\n let target = index;\n while (target > 0 && (order.get(current[target - 1].id) ?? 0) > rank) {\n target--;\n }\n if (target !== index) {\n current.splice(index, 1);\n current.splice(target, 0, element);\n }\n }\n};\n\n/** The shape a node is stored as: the node's own fields, the style kept and also mirrored for the editor. */\nconst shapeFromNode = (node: Node): CanvasBoard.Shape => {\n const { z: _z, style, ...rest } = node as Node & { style?: NodeStyle };\n return {\n ...(rest as unknown as CanvasBoard.Shape),\n ...(style ? { style } : {}),\n // The old editor reads `guide`, so a board stays readable by it (M5 retires it with the package).\n ...(style?.guide !== undefined ? { guide: style.guide } : {}),\n } as CanvasBoard.Shape;\n};\n\nconst edgeFromLink = (link: Link): CanvasBoard.Connection => {\n const source = 'node' in link.source ? link.source : undefined;\n const target = 'node' in link.target ? link.target : undefined;\n return {\n id: link.id,\n type: link.type,\n source: source?.node ?? '',\n target: target?.node ?? '',\n output: parseAnchorId(source?.port ?? '')[1] || DEFAULT_OUTPUT,\n input: parseAnchorId(target?.port ?? '')[1] || DEFAULT_INPUT,\n } as CanvasBoard.Connection;\n};\n\n/** Fields written one by one, so an unchanged field produces no Automerge change. */\nconst assignFields = (element: Record<string, unknown>, next: Record<string, unknown>): void => {\n for (const [key, value] of Object.entries(next)) {\n // Structural, so a node whose geometry object was rebuilt but holds the same numbers writes nothing.\n if (key !== 'id' && !Equal.equals(element[key], value)) {\n element[key] = value;\n }\n }\n for (const key of Object.keys(element)) {\n if (key !== 'id' && !(key in next)) {\n delete element[key];\n }\n }\n};\n\n//\n// Store\n//\n\nexport type EchoStoreOptions = {\n /** The scene the board's own layout is; defaults to the board's id. */\n sceneId?: SceneId;\n};\n\n/**\n * A `SceneStore` over a board's layout: reads derive the scene from the object (re-deriving whenever\n * ECHO announces a change, including a peer's edit), writes go back through `Obj.update`. Only the\n * board's own scene lives here — a nested scene needs another object and is not part of M4.\n */\nexport const createEchoStore = (board: CanvasBoard.CanvasBoard, options: EchoStoreOptions = {}): SceneStore => {\n const sceneId = options.sceneId ?? boardSceneId(board);\n const scenes = Atom.keepAlive(\n Atom.writable<SceneMap, SceneMap>(\n (get) => {\n const snapshot = get(Obj.atom(board));\n return { [sceneId]: sceneFromLayout(sceneId, snapshot.layout as Partial<Layout>, snapshot.name) };\n },\n (ctx, next) => {\n const scene = next[sceneId];\n if (scene) {\n Obj.update(board, (board) => applySceneToLayout(board.layout as Layout, scene));\n }\n ctx.refreshSelf();\n },\n ),\n );\n\n const derived = new Map<SceneId, Atom.Atom<Scene | undefined>>();\n return {\n scenes,\n scene: (id) => {\n let atom = derived.get(id);\n if (!atom) {\n atom = Atom.keepAlive(Atom.make((get) => get(scenes)[id]));\n derived.set(id, atom);\n }\n return atom;\n },\n };\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\n//\n// The compute projection (MIGRATION.md M3, DESIGN.md §3): freehand semantics over the scene store, and\n// every structural intent mirrored into the compute graph, which is what the editor's `GraphMonitor`\n// did from the outside. The positioned scene it emits carries each node's runtime ports: a node whose\n// compute node declares input / output schemas gets one port per property.\n//\n\nimport * as Atom from 'effect/reactivity/Atom';\n\nimport { DefaultInput, DefaultOutput } from '@dxos/conductor';\nimport * as JsonSchema from '@dxos/echo/JsonSchema';\nimport {\n type FreehandProjectionOptions,\n type Intent,\n type Link,\n type Node,\n type Projection,\n type Scene,\n createFreehandProjection,\n endpointNode,\n reduceIntent,\n} from '@dxos/react-ui-canvas/scene';\n\nimport {\n type ComputeGraphController,\n type ComputeLink,\n deleteTriggerObjects,\n findEdge,\n syncCreate,\n syncDelete,\n syncLink,\n} from '../graph/index.ts';\nimport { type ComputeShape, createFunctionPorts, parseAnchorId } from '../shapes/index.ts';\n\n/** What the projection needs of the controller: the graph it mirrors into and the runtime's change event. */\nexport type ComputeGraphSource = Pick<ComputeGraphController, 'graph' | 'update'>;\n\nexport type ComputeProjectionOptions = FreehandProjectionOptions & {\n controller: ComputeGraphSource;\n};\n\n/** The compute node id a scene node carries, when it is a compute shape. */\nconst computeId = (node: Node | undefined): string | undefined =>\n node && 'node' in node && typeof node.node === 'string' ? node.node : undefined;\n\n/** The compute edge a link stands for: both ends on compute nodes, the ports naming the properties. */\nconst computeLink = (scene: Scene, link: Link | undefined): ComputeLink | undefined => {\n if (!link) {\n return undefined;\n }\n const sourceNode = endpointNode(link.source);\n const targetNode = endpointNode(link.target);\n const source = computeId(sourceNode ? scene.nodes[sourceNode] : undefined);\n const target = computeId(targetNode ? scene.nodes[targetNode] : undefined);\n if (!source || !target) {\n return undefined;\n }\n const output = 'port' in link.source ? parseAnchorId(link.source.port ?? '')[1] : undefined;\n const input = 'port' in link.target ? parseAnchorId(link.target.port ?? '')[1] : undefined;\n return { source, target, ...(output ? { output } : {}), ...(input ? { input } : {}) };\n};\n\nconst sameLink = (left: ComputeLink | undefined, right: ComputeLink | undefined): boolean =>\n left?.source === right?.source &&\n left?.target === right?.target &&\n left?.output === right?.output &&\n left?.input === right?.input;\n\n/**\n * Freehand over the store plus the compute graph kept in step: `create` makes the compute node and writes\n * its id into the shape, `link` adds the edge, `delete` removes both, an end dragged to another node moves\n * the edge, and a restored scene (undo / redo) gets its nodes and edges back. The scene atom re-emits on\n * every controller update so runtime ports (and the components reading runtime state) follow.\n */\nexport const createComputeProjection = ({\n registry,\n store,\n sceneId,\n controller,\n}: ComputeProjectionOptions): Projection => {\n const freehand = createFreehandProjection({ registry, store, sceneId });\n const model = controller.graph;\n // Compute nodes this projection made or removed: the ones a restore may take away again.\n const mirrored = new Set<string>();\n\n // The compute graph is not an atom: the scene re-derives on every controller update instead.\n const scene = Atom.keepAlive(\n Atom.make((get) => {\n const current = get(freehand.scene);\n const nodes = Object.fromEntries(\n Object.values(current.nodes).map((node) => [node.id, withRuntimePorts(controller, node)]),\n );\n return { ...current, nodes };\n }),\n );\n controller.update.on(() => registry.refresh(scene));\n\n const apply = (intent: Intent): void => {\n switch (intent.kind) {\n case 'create': {\n const computeNode = syncCreate(model, intent.node);\n if (computeNode) {\n mirrored.add(computeNode.id);\n }\n const node = computeNode ? { ...intent.node, node: computeNode.id } : intent.node;\n freehand.apply({ kind: 'create', node });\n break;\n }\n case 'link': {\n const current = registry.get(freehand.scene);\n // The reducer decides first, so a link the scene refuses (a self-link, a missing end) has no edge.\n if (reduceIntent(current, intent) === current) {\n break;\n }\n const edge = computeLink(current, intent.link);\n if (edge) {\n syncLink(model, edge);\n }\n freehand.apply(intent);\n break;\n }\n case 'update': {\n const current = registry.get(freehand.scene);\n const link = current.links[intent.id];\n if (link && ('source' in intent.values || 'target' in intent.values)) {\n const after = reduceIntent(current, intent);\n const before = computeLink(current, link);\n const next = computeLink(after, after.links[intent.id]);\n if (!sameLink(before, next)) {\n if (before) {\n syncDelete(model, [], [before]);\n }\n if (next) {\n syncLink(model, next);\n }\n }\n }\n freehand.apply(intent);\n break;\n }\n case 'delete': {\n const current = registry.get(freehand.scene);\n const after = reduceIntent(current, intent);\n const nodes = Object.values(current.nodes).filter((node) => after.nodes[node.id] === undefined);\n const links = Object.values(current.links).filter((link) => after.links[link.id] === undefined);\n const nodeIds = nodes.map(computeId).filter((id): id is string => id !== undefined);\n const edges = links.map((link) => computeLink(current, link)).filter((edge) => edge !== undefined);\n nodeIds.forEach((id) => mirrored.add(id));\n syncDelete(model, nodeIds, edges);\n deleteTriggerObjects(model, nodes.filter(isComputeShape));\n freehand.apply(intent);\n break;\n }\n case 'batch':\n // Applied one by one so each create / link / delete reaches the compute graph.\n intent.intents.forEach(apply);\n break;\n default:\n freehand.apply(intent);\n }\n };\n\n /**\n * The compute graph brought in line with the restored scene: a shape whose node is gone gets it back\n * under the same id, a node this projection mirrored whose shape is gone goes, and the edges between\n * shape-backed nodes are exactly the scene's links.\n */\n const reconcile = (restored: Scene): void => {\n const shapes = new Map<string, Node>();\n for (const node of Object.values(restored.nodes)) {\n const id = computeId(node);\n if (id) {\n shapes.set(id, node);\n }\n }\n model.removeNodes(model.nodes.filter((node) => mirrored.has(node.id) && !shapes.has(node.id)).map(({ id }) => id));\n for (const [id, shape] of shapes) {\n if (!model.findNode(id) && isComputeShape(shape)) {\n syncCreate(model, shape, id);\n }\n }\n const claimed = new Set<string>();\n const missing: ComputeLink[] = [];\n for (const link of Object.values(restored.links)) {\n const wanted = computeLink(restored, link);\n if (!wanted) {\n continue;\n }\n const edge = findEdge(model, wanted, claimed);\n if (edge) {\n claimed.add(edge.id);\n } else {\n missing.push(wanted);\n }\n }\n model.removeEdges(\n model.edges\n .filter((edge) => !claimed.has(edge.id) && shapes.has(edge.source) && shapes.has(edge.target))\n .map(({ id }) => id),\n );\n missing.forEach((link) => syncLink(model, link));\n };\n\n return {\n scene,\n apply,\n capabilities: freehand.capabilities,\n snapshot: freehand.snapshot,\n restore: (snapshot) => {\n freehand.restore(snapshot);\n reconcile(registry.get(freehand.scene));\n },\n };\n};\n\nconst isComputeShape = (node: Node): node is Node & ComputeShape => typeof node.type === 'string';\n\n/**\n * The node with the ports its compute node's runtime schemas define, one per property; a node without\n * schemas keeps its definition's ports (the registry supplies them when `ports` is absent).\n */\nconst withRuntimePorts = (controller: ComputeGraphSource, node: Node): Node => {\n const id = computeId(node);\n if (!id) {\n return node;\n }\n const computeNode = model(controller).getNode(id);\n if (!computeNode?.inputSchema && !computeNode?.outputSchema) {\n return node;\n }\n const inputSchema = computeNode.inputSchema ? JsonSchema.toEffectSchema(computeNode.inputSchema) : DefaultInput;\n const outputSchema = computeNode.outputSchema ? JsonSchema.toEffectSchema(computeNode.outputSchema) : DefaultOutput;\n return { ...node, ports: createFunctionPorts(node.size, inputSchema, outputSchema) };\n};\n\nconst model = (controller: ComputeGraphSource) => controller.graph;\n","//\n// Copyright 2026 DXOS.org\n//\n\n//\n// A canvas-editor circuit as a scene: shapes become nodes with a z key (a note becomes the engine's\n// note node), connections become curves pinned to the ports the properties name. The circuit factories\n// and `createComputeGraph` stay as they are; this is the seam the M4 store migration builds on.\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { DEFAULT_INPUT, DEFAULT_OUTPUT } from '@dxos/conductor';\nimport { type Link, type Node, type Scene, initialKeys } from '@dxos/react-ui-canvas/scene';\n\nimport { ComputeShape, createAnchorId } from '../shapes/index.ts';\nimport { type CanvasGraphModel } from '../types/index.ts';\n\nexport const sceneFromCircuit = (model: CanvasGraphModel<ComputeShape>, id = 'circuit', name?: string): Scene => {\n const shapes = model.nodes.filter(Schema.is(ComputeShape));\n const keys = initialKeys(shapes.length + model.edges.length);\n const nodes: Record<string, Node> = {};\n shapes.forEach((shape, index) => {\n const z = keys[index];\n nodes[shape.id] =\n shape.type === 'note'\n ? { type: 'note', id: shape.id, z, center: shape.center, size: shape.size, text: shape.text ?? '' }\n : { ...shape, z };\n });\n const links: Record<string, Link> = {};\n model.edges.forEach((edge, index) => {\n links[edge.id] = {\n type: 'curve',\n id: edge.id,\n z: keys[shapes.length + index],\n source: { node: edge.source, port: createAnchorId('output', edge.output ?? DEFAULT_OUTPUT) },\n target: { node: edge.target, port: createAnchorId('input', edge.input ?? DEFAULT_INPUT) },\n ends: { end: 'arrow' },\n };\n });\n return { id, ...(name ? { name } : {}), nodes, links };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,IAAa,iBAAiB,cAAyC,IAAI;AAE3E,IAAa,0BAA0B;CACrC,OAAO,WAAW,cAAc,KAAK,sBAAM,IAAI,MAAM,wBAAwB,CAAC;AAChF;;AAGA,IAAa,wBAAwB,cAAmC,KAAA,CAAS;AAEjF,IAAa,0BAA0B,WAAW,qBAAqB;;;;;;;ACEvE,IAAa,uBAAuB,UAA0C;CAC5E,MAAM,EAAE,eAAe,kBAAkB;CACzC,UAAU,YAAS,KAAA,GAAA;EAAA,YAAA;EAAA,G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