@dxos/react-ui-canvas-compute 0.8.4-main.ae835ea → 0.8.4-main.bc674ce

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/lib/browser/index.mjs +706 -881
  2. package/dist/lib/browser/index.mjs.map +3 -3
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node-esm/index.mjs +706 -881
  5. package/dist/lib/node-esm/index.mjs.map +3 -3
  6. package/dist/lib/node-esm/meta.json +1 -1
  7. package/dist/types/src/compute.stories.d.ts +22 -1
  8. package/dist/types/src/compute.stories.d.ts.map +1 -1
  9. package/dist/types/src/graph/controller.d.ts +13 -13
  10. package/dist/types/src/graph/controller.d.ts.map +1 -1
  11. package/dist/types/src/hooks/useComputeNodeState.d.ts +2 -2
  12. package/dist/types/src/hooks/useComputeNodeState.d.ts.map +1 -1
  13. package/dist/types/src/hooks/useGraphMonitor.d.ts.map +1 -1
  14. package/dist/types/src/shapes/Function.d.ts.map +1 -1
  15. package/dist/types/src/shapes/Queue.d.ts.map +1 -1
  16. package/dist/types/src/shapes/RNG.d.ts.map +1 -1
  17. package/dist/types/src/shapes/Surface.d.ts.map +1 -1
  18. package/dist/types/src/shapes/Trigger.d.ts +3 -2
  19. package/dist/types/src/shapes/Trigger.d.ts.map +1 -1
  20. package/dist/types/src/shapes/common/Box.d.ts +1 -1
  21. package/dist/types/src/testing/circuits.d.ts +18 -24
  22. package/dist/types/src/testing/circuits.d.ts.map +1 -1
  23. package/dist/types/tsconfig.tsbuildinfo +1 -1
  24. package/package.json +55 -51
  25. package/src/compute.stories.tsx +66 -110
  26. package/src/graph/controller.ts +100 -70
  27. package/src/graph/node-defs.ts +3 -3
  28. package/src/hooks/useComputeNodeState.ts +4 -3
  29. package/src/hooks/useGraphMonitor.ts +9 -8
  30. package/src/json.test.ts +3 -3
  31. package/src/schema.test.ts +8 -8
  32. package/src/shapes/Audio.tsx +1 -1
  33. package/src/shapes/Beacon.tsx +1 -1
  34. package/src/shapes/Boolean.tsx +2 -2
  35. package/src/shapes/Function.tsx +8 -6
  36. package/src/shapes/Gpt.tsx +1 -1
  37. package/src/shapes/GptRealtime.tsx +1 -1
  38. package/src/shapes/Queue.tsx +8 -4
  39. package/src/shapes/RNG.tsx +5 -1
  40. package/src/shapes/Scope.tsx +1 -1
  41. package/src/shapes/Surface.tsx +6 -2
  42. package/src/shapes/Switch.tsx +1 -1
  43. package/src/shapes/Table.tsx +3 -3
  44. package/src/shapes/Thread.tsx +6 -6
  45. package/src/shapes/Trigger.tsx +13 -8
  46. package/src/shapes/common/Box.tsx +6 -6
  47. package/src/shapes/common/FunctionBody.tsx +2 -2
  48. package/src/shapes/common/TypeSelect.tsx +1 -1
  49. package/src/shapes/defs.ts +3 -3
  50. package/src/testing/circuits.ts +5 -14
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/graph/controller.ts", "../../../src/hooks/compute-context.ts", "../../../src/hooks/useComputeGraphController.ts", "../../../src/hooks/useComputeNodeState.ts", "../../../src/hooks/useGraphMonitor.ts", "../../../src/graph/node-defs.ts", "../../../src/registry.ts", "../../../src/shapes/common/Box.tsx", "../../../src/shapes/common/FunctionBody.tsx", "../../../src/shapes/defs.ts", "../../../src/shapes/common/TypeSelect.tsx", "../../../src/shapes/Array.tsx", "../../../src/shapes/Append.tsx", "../../../src/shapes/Audio.tsx", "../../../src/shapes/Beacon.tsx", "../../../src/shapes/Boolean.tsx", "../../../src/shapes/Chat.tsx", "../../../src/shapes/Constant.tsx", "../../../src/shapes/Database.tsx", "../../../src/shapes/Function.tsx", "../../../src/shapes/Gpt.tsx", "../../../src/shapes/Json.tsx", "../../../src/shapes/Logic.tsx", "../../../src/shapes/Queue.tsx", "../../../src/shapes/RNG.tsx", "../../../src/shapes/Scope.tsx", "../../../src/shapes/Surface.tsx", "../../../src/shapes/Switch.tsx", "../../../src/shapes/Table.tsx", "../../../src/shapes/Template.tsx", "../../../src/shapes/Text.tsx", "../../../src/shapes/Thread.tsx", "../../../src/shapes/TextToImage.tsx", "../../../src/shapes/Trigger.tsx", "../../../src/shapes/GptRealtime.tsx", "../../../src/compute-layout.ts"],
4
- "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport type * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Either from 'effect/Either';\nimport * as Exit from 'effect/Exit';\nimport * as Scope from 'effect/Scope';\n\nimport { Event, synchronized } from '@dxos/async';\nimport {\n type ComputeEdge,\n type ComputeGraphModel,\n type ComputeMeta,\n type ComputeNode,\n type GptInput,\n type GptOutput,\n type GraphDiagnostic,\n GraphExecutor,\n ValueBag,\n isNotExecuted,\n} from '@dxos/conductor';\nimport { Resource } from '@dxos/context';\nimport { type ComputeEventLogger, type ComputeEventPayload } from '@dxos/functions';\nimport { type ServiceContainer } from '@dxos/functions';\nimport { log } from '@dxos/log';\nimport { type CanvasGraphModel } from '@dxos/react-ui-canvas-editor';\nimport { type ContentBlock } from '@dxos/schema';\n\nimport { createComputeGraph } from '../hooks';\nimport { type ComputeShape } from '../shapes';\n\nimport { resolveComputeNode } from './node-defs';\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 * Nodes that will automatically trigger the execution of the graph on startup.\n */\nconst AUTO_TRIGGER_NODES = ['chat', 'switch', 'constant'];\n\nexport const createComputeGraphController = (\n graph: CanvasGraphModel<ComputeShape>,\n serviceContainer: ServiceContainer,\n) => {\n const computeGraph = createComputeGraph(graph);\n const controller = new ComputeGraphController(serviceContainer, 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<ComputeEventPayload>();\n\n constructor(\n private readonly _serviceContainer: ServiceContainer,\n /** Persistent compute graph. */\n private readonly _graph: ComputeGraphModel,\n ) {\n super();\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<ComputeMeta> {\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 const serviceLayer = this._serviceContainer.createLayer();\n await Effect.runPromise(\n Effect.gen(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.extend(scope),\n\n Effect.flatMap(computeValueBag),\n Effect.provide(serviceLayer),\n Effect.withSpan('test'),\n Effect.tap((values) => {\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 yield* effect;\n\n yield* Scope.close(scope, Exit.void);\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 await Effect.runPromise(\n Effect.gen(this, function* () {\n const scope = yield* Scope.make();\n\n // TODO(burdon): Return map?\n const tasks: Effect.Effect<unknown, any, never>[] = [];\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.extend(scope),\n Effect.flatMap(computeValueBag),\n Effect.provide(this._serviceContainer.createLayer()),\n Effect.withSpan('test'),\n Effect.tap((values) => {\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 tasks.push(effect);\n }\n\n //\n yield* Effect.all(tasks);\n\n //\n yield* Scope.close(scope, Exit.void);\n }),\n );\n\n this.update.emit();\n }\n\n private _createLogger(): Context.Tag.Service<ComputeEventLogger> {\n return {\n log: (event) => {\n this._handleEvent(event);\n },\n nodeId: undefined, // Not in a context of a specific node.\n };\n }\n\n private _handleEvent(event: ComputeEventPayload): 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\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.either(eff).pipe(\n Effect.map((value) => {\n if (Either.isLeft(value)) {\n if (isNotExecuted(value.left)) {\n return [key, { type: 'not-executed' }] as const;\n } else {\n return [key, { type: 'error', error: value.left }] as const;\n }\n } else {\n return [key, { type: 'executed', value: value.right }] as const;\n }\n }),\n ),\n ),\n ).pipe(Effect.map((entries) => Object.fromEntries(entries) as Record<string, RuntimeValue>));\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { createContext, useContext } from 'react';\n\nimport { raise } from '@dxos/debug';\n\nimport type { ComputeGraphController } from '../graph';\n\nexport type ComputeContextType = {\n controller: ComputeGraphController;\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';\nimport { type ComputeShape } from '../shapes';\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 { ComputeMeta, ComputeNode } from '@dxos/conductor';\nimport type { ComputeEventPayload } from '@dxos/functions';\nimport { invariant } from '@dxos/invariant';\n\nimport { type RuntimeValue } from '../graph';\nimport { type ComputeShape } from '../shapes';\n\nimport { useComputeContext } from './compute-context';\n\nexport type ComputeNodeState = {\n node: ComputeNode;\n meta: ComputeMeta;\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: ComputeEventPayload) => 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<ComputeMeta>();\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 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: ComputeEventPayload) => 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, type ComputeNode, DEFAULT_INPUT, DEFAULT_OUTPUT } from '@dxos/conductor';\nimport { ObjectId, Ref } from '@dxos/echo/internal';\nimport { invariant } from '@dxos/invariant';\nimport { getSpace } from '@dxos/react-client/echo';\nimport { type CanvasGraphModel, type Connection, type GraphMonitor } from '@dxos/react-ui-canvas-editor';\nimport { isNonNullable } from '@dxos/util';\n\nimport { createComputeNode, isValidComputeNode } from '../graph';\nimport { type ComputeShape, type TriggerShape } from '../shapes';\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 }: Connection,\n): ComputeEdge => {\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 id: ObjectId.random(),\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 invariant(node.type);\n if (!isValidComputeNode(node.type)) {\n return;\n }\n\n const computeNode = createComputeNode(node);\n if (node.type === 'trigger') {\n linkTriggerToCompute(model, computeNode, node as TriggerShape);\n }\n model.addNode(computeNode);\n node.node = computeNode.id;\n },\n\n onLink: ({ graph, edge }) => {\n if (model) {\n model.addEdge(mapEdge(graph, edge));\n }\n },\n\n onDelete: ({ subgraph }) => {\n if (model) {\n const nodeIds = subgraph.nodes.map((shape) => (shape as ComputeShape).node) as string[];\n\n // NOTE(ZaymonFC): Based on the information we have, this is O(edges to remove * compute edges).\n const edgeIds = subgraph.edges\n .map(({ source, target, output = DEFAULT_OUTPUT, input = DEFAULT_INPUT }) => {\n return model.edges.find((computeEdge) => computeEdge.input === input && computeEdge.output === output)\n ?.id;\n })\n .filter(isNonNullable);\n\n model.removeNodes(nodeIds);\n model.removeEdges(edgeIds);\n\n deleteTriggerObjects(model, subgraph);\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 if (isValidComputeNode(shape.type)) {\n const node = createComputeNode(shape);\n computeGraph.addNode(node);\n shape.node = node.id;\n }\n }\n\n for (const edge of graph.edges) {\n computeGraph.addEdge(mapEdge(graph, edge));\n }\n }\n\n return computeGraph;\n};\n\nconst linkTriggerToCompute = (graph: ComputeGraphModel, computeNode: ComputeNode, triggerData: TriggerShape) => {\n const functionTrigger = triggerData.functionTrigger?.target;\n invariant(functionTrigger);\n functionTrigger.function = Ref.make(graph.root);\n functionTrigger.inputNodeId = computeNode.id;\n};\n\nconst deleteTriggerObjects = (computeGraph: ComputeGraphModel, deleted: CanvasGraphModel) => {\n const space = getSpace(computeGraph.root);\n if (!space) {\n return;\n }\n for (const node of deleted.nodes) {\n if (node.type === 'trigger') {\n const trigger = node as TriggerShape;\n space.db.remove(trigger.functionTrigger!.target!);\n }\n }\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 { ObjectId, toJsonSchema } from '@dxos/echo/internal';\nimport { invariant } from '@dxos/invariant';\n\nimport { type ComputeShape, type ConstantShape, type TemplateShape } from '../shapes';\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' as const]: () => createNode('text-to-image'), // TODO(burdon): Rename ai-impage-tool\n ['and' as const]: () => createNode('and'),\n ['append' as const]: () => createNode('append'),\n ['audio' as const]: () => createNode('audio'),\n ['beacon' as const]: () => createNode('beacon'),\n ['chat' as const]: () => createNode('chat'),\n ['constant' as const]: (shape) =>\n createNode('constant', {\n value: (shape as ConstantShape).value,\n }),\n ['make-queue' as const]: () => createNode('make-queue'),\n ['database' as const]: () => createNode('database'),\n ['gpt' as const]: () => createNode('gpt'),\n ['gpt-realtime' as const]: () => createNode('gpt-realtime'),\n ['if' as const]: () => createNode('if'),\n ['if-else' as const]: () => createNode('if-else'),\n ['function' as const]: () => createNode('function'),\n ['json' as const]: () => createNode('json'),\n ['json-transform' as const]: () => createNode('json-transform'),\n ['not' as const]: () => createNode('not'),\n ['or' as const]: () => createNode('or'),\n ['queue' as const]: () => createNode('queue'),\n ['rng' as const]: () => createNode('rng'),\n ['reducer' as const]: () => createNode('reducer'),\n ['scope' as const]: () => createNode('scope'),\n ['surface' as const]: () => createNode('surface'),\n ['switch' as const]: () => createNode('switch'),\n ['template' as const]: (shape) => {\n const node = createNode('template', { valueType: (shape as TemplateShape).valueType, value: shape.text });\n node.inputSchema = toJsonSchema(getTemplateInputSchema(node));\n return node;\n },\n ['text' as const]: () => createNode('text'),\n ['thread' as const]: () => createNode('thread'),\n ['trigger' as const]: () => createNode(NODE_INPUT),\n};\n\nconst createNode = (type: string, props?: Partial<ComputeNode>): ComputeNode => ({\n id: ObjectId.random(),\n type,\n ...props,\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 functionShape,\n gptRealtimeShape,\n gptShape,\n ifElseShape,\n ifShape,\n jsonShape,\n jsonTransformShape,\n notShape,\n orShape,\n queueShape,\n randomShape,\n reducerShape,\n scopeShape,\n surfaceShape,\n switchShape,\n templateShape,\n textShape,\n textToImageShape,\n threadShape,\n triggerShape,\n} from './shapes';\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 queueShape,\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 2025 DXOS.org\n//\n\nimport React, { type PropsWithChildren, type ReactNode, forwardRef } from 'react';\n\nimport { invariant } from '@dxos/invariant';\nimport { Icon, IconButton, type ThemedClassName } from '@dxos/react-ui';\nimport { useEditorContext, useShapeDef } from '@dxos/react-ui-canvas-editor';\nimport { type Shape } from '@dxos/react-ui-canvas-editor';\nimport { mx } from '@dxos/react-ui-theme';\n\nexport const headerHeight = 32;\nexport const footerHeight = 32;\n\nexport type BoxActionHandler = (action: 'run' | 'open' | 'close') => void;\n\nexport type BoxProps = PropsWithChildren<\n ThemedClassName<{\n shape: Shape;\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 const { icon, name, openable } = useShapeDef(shape.type) ?? { icon: 'ph--placeholder--regular' };\n const { debug } = useEditorContext();\n\n return (\n <div ref={forwardedRef} className='flex flex-col h-full w-full justify-between'>\n <div className='flex shrink-0 w-full justify-between items-center h-[32px] bg-hoverSurface'>\n <Icon icon={icon} classNames='mx-2' />\n <div className='grow text-sm truncate'>{debug ? shape.type : (name ?? shape.text ?? title)}</div>\n <IconButton\n classNames='p-1 text-green-500'\n variant='ghost'\n icon='ph--play--regular'\n size={4}\n label='run'\n iconOnly\n onDoubleClick={(ev) => ev.stopPropagation()}\n onClick={(ev) => {\n ev.stopPropagation();\n onAction?.('run');\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] bg-hoverSurface'>\n <div className='grow px-2 text-sm truncate'>{debug ? shape.id : status}</div>\n {openable && (\n <IconButton\n classNames='p-1'\n variant='ghost'\n icon={open ? 'ph--caret-up--regular' : 'ph--caret-down--regular'}\n size={4}\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 * as SchemaAST from 'effect/SchemaAST';\nimport React, { type JSX, useRef, useState } from 'react';\n\nimport { VoidInput, VoidOutput } from '@dxos/conductor';\nimport { useCanvasContext } from '@dxos/react-ui-canvas';\nimport { type Polygon, type Shape } from '@dxos/react-ui-canvas-editor';\nimport { createAnchors, getParentShapeElement, rowHeight } from '@dxos/react-ui-canvas-editor';\n\nimport { Box, type BoxProps, footerHeight, headerHeight } from '../common';\nimport { createAnchorId, getProperties } from '../defs';\n\nconst bodyPadding = 8;\nconst expandedHeight = 200;\n\nexport type FunctionBodyProps = {\n shape: Shape;\n name?: string;\n content?: JSX.Element;\n inputSchema?: Schema.Schema.Any;\n outputSchema?: Schema.Schema.Any;\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 const { scale } = useCanvasContext();\n const rootRef = useRef<HTMLDivElement>(null);\n const [open, setOpen] = useState(false);\n\n const handleAction: BoxProps['onAction'] = (action) => {\n if (!rootRef.current) {\n return;\n }\n\n switch (action) {\n case 'open': {\n const el = getParentShapeElement(rootRef.current, shape.id)!;\n const { height } = el.getBoundingClientRect();\n el.style.height = `${height / scale + expandedHeight}px`;\n setOpen(true);\n break;\n }\n case 'close': {\n const el = getParentShapeElement(rootRef.current, shape.id)!;\n el.style.height = '';\n setOpen(false);\n break;\n }\n }\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'\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\nexport const getHeight = (input: Schema.Schema<any>) => {\n const properties = SchemaAST.getPropertySignatures(input.ast);\n return headerHeight + footerHeight + bodyPadding * 2 + properties.length * rowHeight + 2; // Incl. borders.\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 * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\n\nimport { DEFAULT_INPUT, DEFAULT_OUTPUT } from '@dxos/conductor';\nimport { ObjectId } from '@dxos/echo/internal';\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 = Schema.extend(\n Polygon,\n Schema.Struct({\n // TODO(burdon): Rename computeNode?\n node: Schema.optional(ObjectId.annotations({ description: 'Compute node id' })),\n }).pipe(Schema.mutable),\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 ?? ObjectId.random(),\n ...rest,\n } as S;\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport React from 'react';\n\nimport { ComputeValueType } from '@dxos/conductor';\nimport { Select, type SelectRootProps } from '@dxos/react-ui';\n\n// TODO(burdon): Factor out.\nexport const TypeSelect = ({ value, onValueChange }: Pick<SelectRootProps, 'value' | 'onValueChange'>) => {\n return (\n <Select.Root value={value} onValueChange={onValueChange}>\n <Select.TriggerButton variant='ghost' classNames='w-full !px-0' />\n <Select.Portal>\n <Select.Content>\n <Select.ScrollUpButton />\n <Select.Viewport>\n {ComputeValueType.literals.map((type) => (\n <Select.Option key={type} value={type}>\n {type}\n </Select.Option>\n ))}\n </Select.Viewport>\n <Select.ScrollDownButton />\n <Select.Arrow />\n </Select.Content>\n </Select.Portal>\n </Select.Root>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport React from 'react';\n\nimport { ReducerInput, ReducerOutput } from '@dxos/conductor';\nimport { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';\n\nimport { FunctionBody, createFunctionAnchors, getHeight } from './common';\nimport { ComputeShape, type CreateShapeProps, createShape } from './defs';\n\n//\n// Data\n//\n\nexport const ReducerShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\n type: Schema.Literal('reducer'),\n }),\n);\n\nexport type ReducerShape = Schema.Schema.Type<typeof ReducerShape>;\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//\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: (props) => <ReducerComponent {...props} />,\n createShape: createReducer,\n getAnchors: (shape) => createFunctionAnchors(shape, ReducerInput, ReducerOutput),\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport React from 'react';\n\nimport { AppendInput } from '@dxos/conductor';\nimport { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';\n\nimport { FunctionBody, createFunctionAnchors, getHeight } from './common';\nimport { ComputeShape, type CreateShapeProps, createShape } from './defs';\n\nexport const AppendShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\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 AppendComponent = ({ shape }: ShapeComponentProps<AppendShape>) => {\n return <FunctionBody shape={shape} inputSchema={AppendInput} />;\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 * as Schema from 'effect/Schema';\nimport React, { useEffect, useState } from 'react';\n\nimport { Icon } from '@dxos/react-ui';\nimport { type ShapeComponentProps, type ShapeDef, createAnchorMap } from '@dxos/react-ui-canvas-editor';\n\nimport { useComputeNodeState } from '../hooks';\n\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';\n\nexport const AudioShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\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 AudioComponent = ({ shape }: ShapeComponentProps<AudioShape>) => {\n const { node } = useComputeNodeState(shape);\n const [active, setActive] = useState(false);\n useEffect(() => {\n node.value = 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\n icon={active ? 'ph--microphone--regular' : 'ph--microphone-slash--regular'}\n classNames={['transition opacity-20 duration-1000', active && 'opacity-100 text-red-500']}\n size={8}\n onClick={() => setActive(!active)}\n />\n </div>\n );\n};\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 * as Schema from 'effect/Schema';\nimport React from 'react';\n\nimport { DEFAULT_INPUT, isTruthy } from '@dxos/conductor';\nimport { Icon } from '@dxos/react-ui';\nimport { type ShapeComponentProps, type ShapeDef, createAnchorMap } from '@dxos/react-ui-canvas-editor';\n\nimport { useComputeNodeState } from '../hooks';\n\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';\n\nexport const BeaconShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\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 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\n icon='ph--sun--regular'\n classNames={['transition opacity-20 duration-1000', isTruthy(value) && 'opacity-100 text-yellow-500']}\n size={8}\n />\n </div>\n );\n};\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 * as Schema from 'effect/Schema';\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';\n\n//\n// Gate utils.\n// https://en.wikipedia.org/wiki/Logic_gate\n//\n\ntype GateType = 'and' | 'or' | 'not';\n\nconst GateShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\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='w-full h-full'>\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 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport React, { useRef } from 'react';\n\nimport { DEFAULT_OUTPUT } from '@dxos/conductor';\nimport {\n type ShapeComponentProps,\n type ShapeDef,\n TextBox,\n type TextBoxControl,\n type TextBoxProps,\n} from '@dxos/react-ui-canvas-editor';\nimport { createAnchorMap } from '@dxos/react-ui-canvas-editor';\n\nimport { useComputeNodeState } from '../hooks';\n\nimport { Box } from './common';\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';\n\n//\n// Data\n//\n\nexport const ChatShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\n type: Schema.Literal('chat'),\n }),\n);\n\nexport type ChatShape = Schema.Schema.Type<typeof ChatShape>;\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//\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 * as Schema from 'effect/Schema';\nimport React, { useCallback, useRef, useState } from 'react';\n\nimport { ComputeValueType } from '@dxos/conductor';\nimport { Input } from '@dxos/react-ui';\nimport {\n type ShapeComponentProps,\n type ShapeDef,\n TextBox,\n type TextBoxControl,\n type TextBoxProps,\n} from '@dxos/react-ui-canvas-editor';\nimport { createAnchorMap } from '@dxos/react-ui-canvas-editor';\nimport { safeParseJson } from '@dxos/util';\n\nimport { useComputeNodeState } from '../hooks';\n\nimport { Box, TypeSelect } from './common';\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';\n\n//\n// Data\n//\n\nexport const ConstantShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\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// Component\n//\n\nexport type ConstantComponentProps = ShapeComponentProps<ConstantShape> &\n TextBoxProps & { title?: string; chat?: boolean };\n\nconst inferType = (value: any): string | 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 <Input.Root>\n <Input.Switch\n checked={node.value}\n onCheckedChange={(value) => {\n node.value = value;\n }}\n />\n </Input.Root>\n </div>\n )}\n </Box>\n );\n};\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 * as Schema from 'effect/Schema';\nimport React from 'react';\n\nimport { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';\nimport { createAnchorMap } from '@dxos/react-ui-canvas-editor';\n\nimport { Box } from './common';\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';\n\nexport const DatabaseShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\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 DatabaseComponent = ({ shape }: ShapeComponentProps<DatabaseShape>) => {\n return <Box shape={shape} />;\n};\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 * as Schema from 'effect/Schema';\nimport React, { useCallback, useRef } from 'react';\n\nimport { AnyOutput, FunctionInput } from '@dxos/conductor';\nimport { Ref, getSnapshot, isInstanceOf } from '@dxos/echo/internal';\nimport { Function, Script } from '@dxos/functions';\nimport { useClient } from '@dxos/react-client';\nimport { Filter, parseId } from '@dxos/react-client/echo';\nimport {\n type ShapeComponentProps,\n type ShapeDef,\n TextBox,\n type TextBoxControl,\n type TextBoxProps,\n} from '@dxos/react-ui-canvas-editor';\n\nimport { useComputeNodeState } from '../hooks';\n\nimport { Box, createFunctionAnchors } from './common';\nimport { ComputeShape, type CreateShapeProps, createShape } from './defs';\n\nexport const FunctionShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\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>({ type: 'function', size: { width: 256, height: 192 }, ...props });\n\n//\n// Component\n//\n\ntype TextInputComponentProps = ShapeComponentProps<FunctionShape> & TextBoxProps & { title?: string };\n\nconst TextInputComponent = ({ shape, title, ...props }: TextInputComponentProps) => {\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.getObjectById(objectId);\n if (!space || !isInstanceOf(Script.Script, object)) {\n return;\n }\n\n const {\n objects: [fn],\n } = await space.db.query(Filter.type(Function.Function, { 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 = getSnapshot(fn.inputSchema);\n node.outputSchema = getSnapshot(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//\n// Defs\n//\n\nexport const functionShape: ShapeDef<FunctionShape> = {\n type: 'function',\n name: 'Function',\n icon: 'ph--function--regular',\n component: TextInputComponent,\n createShape: createFunction,\n getAnchors: (shape) => createFunctionAnchors(shape, FunctionInput, AnyOutput),\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport React, { useEffect, useState } from 'react';\n\nimport { GptInput, GptOutput } from '@dxos/conductor';\nimport { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';\n\nimport { useComputeNodeState } from '../hooks';\n\nimport { FunctionBody, createFunctionAnchors, getHeight } from './common';\nimport { ComputeShape, type CreateShapeProps, createShape } from './defs';\n\nexport const GptShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\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 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={<div className='px-2 py-1 overflow-y-scroll'>{text}</div>}\n status={`${tokens} tokens`}\n inputSchema={meta.input}\n outputSchema={meta.output}\n />\n );\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 * as Schema from 'effect/Schema';\nimport React from 'react';\n\nimport { DEFAULT_INPUT, DefaultOutput, JsonTransformInput } from '@dxos/conductor';\nimport { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';\nimport { createAnchorMap } from '@dxos/react-ui-canvas-editor';\nimport { JsonFilter } from '@dxos/react-ui-syntax-highlighter';\n\nimport { useComputeNodeState } from '../hooks';\n\nimport { Box, createFunctionAnchors, getHeight } from './common';\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';\n\n//\n// Data\n//\n\nexport const JsonShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\n type: Schema.Literal('json'),\n }),\n);\n\nexport type JsonShape = Schema.Schema.Type<typeof JsonShape>;\n\nexport const JsonTransformShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\n type: Schema.Literal('json-transform'),\n }),\n);\n\nexport type JsonTransformShape = Schema.Schema.Type<typeof JsonTransformShape>;\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 <JsonFilter data={value} classNames='text-xs' />\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//\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: (props) => <JsonComponent {...props} />,\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: (props) => <JsonTransformComponent {...props} />,\n createShape: createJsonTransform,\n getAnchors: (shape) => createFunctionAnchors(shape, JsonTransformInput, DefaultOutput),\n resizable: true,\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport React from 'react';\n\nimport { IfElseInput, IfElseOutput, IfInput, IfOutput } from '@dxos/conductor';\nimport { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';\n\nimport { FunctionBody, createFunctionAnchors, getHeight } from './common';\nimport { ComputeShape, type CreateShapeProps, createShape } from './defs';\n\n//\n// Data\n//\n\nexport const IfShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\n type: Schema.Literal('if'),\n }),\n);\n\nexport type IfShape = Schema.Schema.Type<typeof IfShape>;\n\nexport const IfElseShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\n type: Schema.Literal('if-else'),\n }),\n);\n\nexport type IfElseShape = Schema.Schema.Type<typeof IfElseShape>;\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//\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: (props) => <IfComponent {...props} />,\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: (props) => <IfElseComponent {...props} />,\n createShape: createIfElse,\n getAnchors: (shape) => createFunctionAnchors(shape, IfElseInput, IfElseOutput),\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport React, { Fragment } from 'react';\n\nimport { DEFAULT_OUTPUT, QueueInput, QueueOutput } from '@dxos/conductor';\nimport { type ThemedClassName } from '@dxos/react-ui';\nimport { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';\nimport { mx } from '@dxos/react-ui-theme';\n\nimport { useComputeNodeState } from '../hooks';\n\nimport { createFunctionAnchors } from './common';\nimport { Box, type BoxActionHandler } from './common';\nimport { ComputeShape, type CreateShapeProps, createShape } from './defs';\n\nexport const QueueShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\n type: Schema.Literal('queue'),\n }),\n);\n\nexport type QueueShape = Schema.Schema.Type<typeof QueueShape>;\n\nexport type CreateQueueProps = CreateShapeProps<QueueShape>;\n\nexport const createQueue = (props: CreateQueueProps) =>\n createShape<QueueShape>({ type: 'queue', size: { width: 256, height: 512 }, ...props });\n\nexport const QueueComponent = ({ shape }: ShapeComponentProps<QueueShape>) => {\n const { runtime } = useComputeNodeState(shape);\n const items = runtime.outputs[DEFAULT_OUTPUT]?.type === 'executed' ? runtime.outputs[DEFAULT_OUTPUT].value : [];\n\n const handleAction: BoxActionHandler = (action) => {\n if (action === 'run') {\n runtime.evalNode();\n }\n };\n\n return (\n <Box shape={shape} status={`${items.length} items`} onAction={handleAction}>\n <div className='flex flex-col w-full overflow-y-scroll divide-y divide-separator'>\n {[...items].map((item, i) => (\n <QueueItem key={i} classNames='p-1 px-2' item={item} />\n ))}\n </div>\n </Box>\n );\n};\n\nexport const QueueItem = ({ classNames, item }: 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-subdued'>{key}</div>\n <div>{typeof value === 'string' ? value : JSON.stringify(value)}</div>\n </Fragment>\n ))}\n </div>\n );\n};\n\nexport const queueShape: ShapeDef<QueueShape> = {\n type: 'queue',\n name: 'Queue',\n icon: 'ph--queue--regular',\n component: QueueComponent,\n createShape: createQueue,\n getAnchors: (shape) => createFunctionAnchors(shape, QueueInput, QueueOutput),\n resizable: true,\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport React, { useEffect, useState } from 'react';\n\nimport { DEFAULT_OUTPUT } from '@dxos/conductor';\nimport { Icon, type IconProps } from '@dxos/react-ui';\nimport { type ShapeComponentProps, type ShapeDef, createAnchorMap } from '@dxos/react-ui-canvas-editor';\n\nimport { useComputeNodeState } from '../hooks';\n\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';\n\nexport const RandomShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\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>({ type: 'rng', size: { width: 64, height: 64 }, ...props });\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 const handleClick: 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={icon} classNames={spin && 'animate-[spin_1s]'} size={10} onClick={handleClick} />\n </div>\n );\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 * as Schema from 'effect/Schema';\nimport React from 'react';\n\nimport { DEFAULT_INPUT } from '@dxos/conductor';\nimport { type ShapeComponentProps, type ShapeDef, createAnchorMap } from '@dxos/react-ui-canvas-editor';\nimport { Chaos, shaderPresets, useAudioStream } from '@dxos/react-ui-sfx';\n\nimport { useComputeNodeState } from '../hooks';\n\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';\n\nexport const ScopeShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\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 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\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 * as Schema from 'effect/Schema';\nimport React from 'react';\n\nimport { Surface } from '@dxos/app-framework';\nimport { DEFAULT_INPUT } from '@dxos/conductor';\nimport { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';\nimport { createAnchorMap } from '@dxos/react-ui-canvas-editor';\n\nimport { useComputeNodeState } from '../hooks';\n\nimport { Box, type BoxActionHandler } from './common';\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';\n\nexport const SurfaceShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\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>({ type: 'surface', size: { width: 384, height: 384 }, ...props });\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 const handleAction: BoxActionHandler = (action) => {\n if (action === 'run') {\n runtime.evalNode();\n }\n };\n\n return (\n <Box shape={shape} onAction={handleAction}>\n {value !== null && <Surface role='card--extrinsic' data={{ value }} limit={1} />}\n </Box>\n );\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 * as Schema from 'effect/Schema';\nimport React, { useEffect, useState } from 'react';\n\nimport { DEFAULT_OUTPUT } from '@dxos/conductor';\nimport { Input } from '@dxos/react-ui';\nimport { type ShapeComponentProps, type ShapeDef, createAnchorMap } from '@dxos/react-ui-canvas-editor';\n\nimport { useComputeNodeState } from '../hooks';\n\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';\n\nexport const SwitchShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\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\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 <div className='flex w-full justify-center items-center' onClick={(ev) => ev.stopPropagation()}>\n <Input.Root>\n <Input.Switch checked={value} onCheckedChange={(value) => setValue(value)} />\n </Input.Root>\n </div>\n );\n};\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 * as Schema from 'effect/Schema';\nimport React from 'react';\n\nimport { createInputSchema, createOutputSchema } from '@dxos/conductor';\nimport { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';\nimport { DataType } from '@dxos/schema';\n\nimport { Box, createFunctionAnchors } from './common';\nimport { ComputeShape, type CreateShapeProps, createShape } from './defs';\n\nconst InputSchema = createInputSchema(DataType.Message);\nconst OutputSchema = createOutputSchema(Schema.mutable(Schema.Array(DataType.Message)));\n\nexport const TableShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\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 TableComponent = ({ shape }: ShapeComponentProps<TableShape>) => {\n // const items = shape.node.items.value;\n\n return <Box shape={shape}></Box>;\n};\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, TemplateOutput, VoidInput, getTemplateInputSchema } from '@dxos/conductor';\nimport { toJsonSchema } from '@dxos/echo/internal';\nimport { invariant } from '@dxos/invariant';\nimport {\n type ShapeComponentProps,\n type ShapeDef,\n TextBox,\n type TextBoxControl,\n type TextBoxProps,\n} from '@dxos/react-ui-canvas-editor';\n\nimport { useComputeNodeState } from '../hooks';\n\nimport { Box, TypeSelect, createFunctionAnchors } from './common';\nimport { ComputeShape, type CreateShapeProps, createShape } from './defs';\n\n//\n// Data\n//\n\nexport const TemplateShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\n type: Schema.Literal('template'),\n valueType: Schema.optional(ComputeValueType),\n }),\n);\n\nexport type TemplateShape = Schema.Schema.Type<typeof TemplateShape>;\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 = 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 = 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\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: (props) => <TextInputComponent {...props} placeholder={'Prompt'} />,\n createShape: createTemplate,\n getAnchors: (shape) => createFunctionAnchors(shape, VoidInput, TemplateOutput),\n resizable: true,\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport React from 'react';\n\nimport { DEFAULT_INPUT } from '@dxos/conductor';\nimport { type ShapeComponentProps, type ShapeDef, TextBox } from '@dxos/react-ui-canvas-editor';\nimport { createAnchorMap } from '@dxos/react-ui-canvas-editor';\n\nimport { useComputeNodeState } from '../hooks';\n\nimport { Box, type BoxActionHandler } from './common';\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';\n\nexport const TextShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\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 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 const handleAction: BoxActionHandler = (action) => {\n if (action === 'run') {\n runtime.evalNode();\n }\n };\n\n return (\n <Box shape={shape} onAction={handleAction}>\n <TextBox value={value} />\n </Box>\n );\n};\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 * as Schema from 'effect/Schema';\nimport React, { useEffect, useRef } from 'react';\n\nimport { createInputSchema, createOutputSchema } from '@dxos/conductor';\nimport { type ThemedClassName } from '@dxos/react-ui';\nimport { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';\nimport { mx } from '@dxos/react-ui-theme';\nimport { DataType } from '@dxos/schema';\n\nimport { Box, createFunctionAnchors } from './common';\nimport { ComputeShape, type CreateShapeProps, createShape } from './defs';\n\nconst InputSchema = createInputSchema(DataType.Message);\nconst OutputSchema = createOutputSchema(Schema.mutable(Schema.Array(DataType.Message)));\n\nexport const ThreadShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\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 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 <div ref={scrollRef} className='flex flex-col w-full overflow-y-scroll gap-2 p-2'>\n {[...items].map((item, i) => (\n <ThreadItem key={i} item={item} />\n ))}\n </div>\n </Box>\n );\n};\n\nexport const ThreadItem = ({ classNames, item }: 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\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';\nimport React from 'react';\n\nimport { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';\nimport { createAnchorMap } from '@dxos/react-ui-canvas-editor';\n\nimport { Box } from './common';\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';\n\nexport const TextToImageShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\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 TextToImageComponent = ({ shape }: ShapeComponentProps<TextToImageShape>) => {\n return <Box shape={shape} />;\n};\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 * as Schema from 'effect/Schema';\nimport React, { useEffect } from 'react';\n\nimport { VoidInput } from '@dxos/conductor';\nimport { Filter, Query } from '@dxos/echo';\nimport { ObjectId, Ref } from '@dxos/echo/internal';\nimport { Trigger, TriggerEvent } from '@dxos/functions';\nimport { DXN, SpaceId } from '@dxos/keys';\nimport { useSpace } from '@dxos/react-client/echo';\nimport { Select, type SelectRootProps } from '@dxos/react-ui';\nimport { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';\n\nimport { FunctionBody, createFunctionAnchors, getHeight } from './common';\nimport { ComputeShape, type CreateShapeProps, createShape } from './defs';\n\nexport const TriggerShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\n type: Schema.Literal('trigger'),\n functionTrigger: Schema.optional(Ref(Trigger.Trigger)),\n }),\n);\nexport type TriggerShape = Schema.Schema.Type<typeof TriggerShape>;\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 type TriggerComponentProps = ShapeComponentProps<TriggerShape>;\n\nexport const TriggerComponent = ({ shape }: TriggerComponentProps) => {\n const space = useSpace();\n const functionTrigger = shape.functionTrigger?.target;\n\n useEffect(() => {\n if (functionTrigger && !functionTrigger.spec) {\n functionTrigger.spec = createTriggerSpec({ triggerKind: 'email', spaceId: space?.id });\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 functionTrigger!.spec = createTriggerSpec({ triggerKind: kind, spaceId: space?.id });\n }\n };\n\n if (!functionTrigger?.spec) {\n return;\n }\n\n return (\n <FunctionBody\n shape={shape}\n status={\n <TriggerKindSelect value={functionTrigger.spec?.kind} onValueChange={(kind) => setKind(kind as Trigger.Kind)} />\n }\n inputSchema={VoidInput}\n outputSchema={getOutputSchema(functionTrigger.spec!.kind!)}\n />\n );\n};\n\n// TODO(burdon): Factor out.\nconst TriggerKindSelect = ({ value, onValueChange }: Pick<SelectRootProps, 'value' | 'onValueChange'>) => {\n return (\n <Select.Root value={value} onValueChange={onValueChange}>\n <Select.TriggerButton variant='ghost' classNames='w-full !px-0' />\n <Select.Portal>\n <Select.Content>\n <Select.ScrollUpButton />\n <Select.Viewport>\n {Trigger.Kinds.map((kind) => (\n <Select.Option key={kind} value={kind}>\n {kind}\n </Select.Option>\n ))}\n </Select.Viewport>\n <Select.ScrollDownButton />\n <Select.Arrow />\n </Select.Content>\n </Select.Portal>\n </Select.Root>\n );\n};\n\nconst createTriggerSpec = (props: { triggerKind?: Trigger.Kind; spaceId?: SpaceId }): Trigger.Spec => {\n const kind = props.triggerKind ?? 'email';\n switch (kind) {\n case 'timer':\n return { kind: 'timer', cron: '*/10 * * * * *' } satisfies Trigger.TimerSpec;\n case 'webhook':\n return { kind: 'webhook', method: 'POST' } satisfies Trigger.WebhookSpec;\n case 'subscription':\n return {\n kind: 'subscription',\n query: {\n ast: Query.select(Filter.nothing()).ast,\n },\n } satisfies Trigger.SubscriptionSpec;\n case 'email':\n return { kind: 'email' } satisfies Trigger.EmailSpec;\n case 'queue': {\n const dxn = new DXN(DXN.kind.QUEUE, ['data', props.spaceId ?? SpaceId.random(), ObjectId.random()]).toString();\n return { kind: 'queue', queue: dxn } satisfies Trigger.QueueSpec;\n }\n }\n};\n\nconst 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 ['queue']: TriggerEvent.QueueEvent,\n };\n return kindToSchema[kind];\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 React, { useState } from 'react';\n\nimport { log } from '@dxos/log';\nimport { useConfig } from '@dxos/react-client';\nimport { Icon } from '@dxos/react-ui';\nimport { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';\n\nimport { createFunctionAnchors } from './common';\nimport { ComputeShape, type CreateShapeProps, createShape } from './defs';\n\nexport const GptRealtimeShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\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 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 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\n const AiServiceUrl = new URL(\n '/rtc-connect',\n config.values.runtime?.services?.ai?.server ?? DEFAULT_AI_SERVICE_URL,\n );\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\n icon={isReady ? 'ph--waveform--regular' : isLive ? 'ph--pulse--regular' : 'ph--play--regular'}\n size={16}\n classNames={!isLive && 'cursor-pointer'}\n onClick={start}\n />\n </div>\n );\n};\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\nconst DEFAULT_AI_SERVICE_URL = 'http://localhost:8788';\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { DefaultInput, DefaultOutput } from '@dxos/conductor';\nimport { toEffectSchema } from '@dxos/echo/internal';\nimport { type Anchor, ShapeLayout, type ShapeRegistry } from '@dxos/react-ui-canvas-editor';\n\nimport { type ComputeGraphController } from './graph';\nimport { type ComputeShape, createFunctionAnchors } from './shapes';\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 ? toEffectSchema(node.inputSchema) : DefaultInput;\n const outputSchema = node.outputSchema ? toEffectSchema(node.outputSchema) : DefaultOutput;\n anchors = createFunctionAnchors(shape, inputSchema, outputSchema);\n }\n }\n\n return anchors;\n }\n}\n"],
5
- "mappings": ";;;AAKA,YAAYA,YAAY;AACxB,YAAYC,YAAY;AACxB,YAAYC,UAAU;AACtB,YAAYC,WAAW;AAEvB,SAASC,OAAOC,oBAAoB;AACpC,SAQEC,eACAC,UACAC,qBACK;AACP,SAASC,gBAAgB;AAGzB,SAASC,WAAW;;;ACtBpB,SAASC,eAAeC,kBAAkB;AAE1C,SAASC,aAAa;AAQf,IAAMC,iBAAiBC,cAAyC,IAAA;AAEhE,IAAMC,oBAAoB,MAAA;AAC/B,SAAOC,WAAWH,cAAAA,KAAmBI,MAAM,IAAIC,MAAM,wBAAA,CAAA;AACvD;;;ACdA,SAAyBC,WAAWC,gBAAgB;AASpD,IAAMC,UAAU,IAAIC,QAAAA;AAClB,SAAO,MAAA;AACL,eAAWC,MAAMD,KAAK;AACpBC,SAAAA;IACF;EACF;AACF;AAOO,IAAMC,4BAA4B,CAAC,EAAEC,YAAYC,OAAOC,UAAS,MAAoC;AAC1G,QAAM,CAAA,EAAGC,WAAAA,IAAeC,SAAS,CAAC,CAAA;AAElCC,YAAU,MAAA;AACR,QAAI,CAACL,cAAc,CAACC,OAAO;AACzB;IACF;AAEA,SAAKD,WAAWM,KAAI;AACpB,UAAMC,MAAMX;MACVI,WAAWQ,OAAOC,GAAG,MAAA;AACnB,aAAKP,UAAUQ,SAASF,OAAAA;AACxBL,oBAAY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AU,CAAC;AAChD,QAAIA,MAAMM,MAAM;AACd,YAAMA,OAAO,KAAKT,YAAYU,MAAMC,QAAQR,MAAMM,IAAI;AACtD,UAAIA,KAAKG,eAAeH,KAAKI,cAAc;AAEzC,cAAMD,cAAcH,KAAKG,cAAcE,eAAeL,KAAKG,WAAW,IAAIG;AAC1E,cAAMF,eAAeJ,KAAKI,eAAeC,eAAeL,KAAKI,YAAY,IAAIG;AAC7ER,kBAAUS,sBAAsBd,OAAOS,aAAaC,YAAAA;MACtD;IACF;AAEA,WAAOL;EACT;AACF;",
6
- "names": ["Effect", "Either", "Exit", "Scope", "Event", "synchronized", "GraphExecutor", "ValueBag", "isNotExecuted", "Resource", "log", "createContext", "useContext", "raise", "ComputeContext", "createContext", "useComputeContext", "useContext", "raise", "Error", "useEffect", "useState", "combine", "cbs", "cb", "useComputeGraphController", "controller", "graph", "editorRef", "forceUpdate", "useState", "useEffect", "open", "off", "update", "on", "current", "output", "nodeId", "property", "value", "type", "edge", "edges", "find", "source", "getNode", "node", "action", "close", "Schema", "useCallback", "useEffect", "useState", "invariant", "useComputeNodeState", "shape", "controller", "useComputeContext", "invariant", "meta", "setMeta", "useState", "useEffect", "disposed", "queueMicrotask", "node", "getComputeNode", "getMeta", "evalNode", "useCallback", "subscribeToEventLog", "cb", "events", "on", "ev", "nodeId", "input", "Struct", "output", "runtime", "inputs", "getInputs", "outputs", "getOutputs", "setOutput", "property", "value", "useMemo", "ComputeGraphModel", "DEFAULT_INPUT", "DEFAULT_OUTPUT", "ObjectId", "Ref", "invariant", "getSpace", "isNonNullable", "mapEdge", "graph", "source", "target", "output", "DEFAULT_OUTPUT", "input", "DEFAULT_INPUT", "sourceNode", "findNode", "targetNode", "invariant", "node", "id", "ObjectId", "random", "useGraphMonitor", "model", "useMemo", "onCreate", "type", "isValidComputeNode", "computeNode", "createComputeNode", "linkTriggerToCompute", "addNode", "onLink", "edge", "addEdge", "onDelete", "subgraph", "nodeIds", "nodes", "map", "shape", "edgeIds", "edges", "find", "computeEdge", "filter", "isNonNullable", "removeNodes", "removeEdges", "deleteTriggerObjects", "createComputeGraph", "computeGraph", "ComputeGraphModel", "create", "triggerData", "functionTrigger", "function", "Ref", "make", "root", "inputNodeId", "deleted", "space", "getSpace", "trigger", "db", "remove", "NODE_INPUT", "NODE_OUTPUT", "getTemplateInputSchema", "registry", "raise", "ObjectId", "toJsonSchema", "invariant", "resolveComputeNode", "node", "impl", "type", "isValidComputeNode", "nodeFactory", "undefined", "createComputeNode", "shape", "Error", "factory", "createNode", "value", "valueType", "text", "inputSchema", "props", "id", "random", "InvalidStateError", "Error", "AUTO_TRIGGER_NODES", "createComputeGraphController", "graph", "serviceContainer", "computeGraph", "createComputeGraph", "controller", "ComputeGraphController", "Resource", "_executor", "GraphExecutor", "computeNodeResolver", "node", "resolveComputeNode", "_diagnostics", "_forcedOutputs", "_runtimeStateInputs", "_runtimeStateOutputs", "update", "Event", "output", "events", "_serviceContainer", "_graph", "toJSON", "state", "inputs", "outputs", "forcedOutputs", "diagnostics", "userState", "inputStates", "outputStates", "ids", "Set", "Object", "keys", "fromEntries", "map", "id", "getNode", "input", "addNode", "addEdge", "edge", "getComputeNode", "nodeId", "getInputs", "getOutputs", "setOutput", "property", "value", "queueMicrotask", "exec", "err", "log", "catch", "getMeta", "meta", "checkGraph", "executor", "clone", "load", "getDiagnostics", "evalNode", "entries", "setOutputs", "succeed", "ValueBag", "make", "serviceLayer", "createLayer", "runPromise", "gen", "scope", "executable", "promise", "computingOutputs", "effect", "computeOutputs", "computeInputs", "pipe", "withSpan", "extend", "flatMap", "computeValueBag", "provide", "tap", "values", "key", "_onOutputComputed", "_onInputComputed", "close", "void", "emit", "startFromNode", "triggerNodes", "nodes", "filter", "type", "includes", "allAffectedNodes", "getAllDependantNodes", "tasks", "push", "all", "_createLogger", "event", "_handleEvent", "undefined", "bag", "eff", "either", "isLeft", "isNotExecuted", "left", "error", "right", "noteShape", "React", "forwardRef", "invariant", "Icon", "IconButton", "useEditorContext", "useShapeDef", "mx", "headerHeight", "footerHeight", "Box", "children", "classNames", "shape", "title", "status", "open", "onAction", "forwardedRef", "type", "icon", "name", "openable", "debug", "div", "ref", "className", "text", "variant", "size", "label", "iconOnly", "onDoubleClick", "ev", "stopPropagation", "onClick", "id", "SchemaAST", "React", "useRef", "useState", "VoidInput", "VoidOutput", "useCanvasContext", "createAnchors", "getParentShapeElement", "rowHeight", "Schema", "SchemaAST", "DEFAULT_INPUT", "DEFAULT_OUTPUT", "ObjectId", "Polygon", "getProperties", "ast", "getPropertySignatures", "map", "name", "toString", "createAnchorId", "kind", "property", "DEFAULT_INPUT", "DEFAULT_OUTPUT", "join", "parseAnchorId", "id", "parts", "match", "slice", "undefined", "ComputeShape", "extend", "Polygon", "Struct", "node", "optional", "ObjectId", "annotations", "description", "pipe", "mutable", "createShape", "rest", "random", "bodyPadding", "expandedHeight", "FunctionBody", "shape", "name", "content", "inputSchema", "VoidInput", "outputSchema", "VoidOutput", "props", "scale", "useCanvasContext", "rootRef", "useRef", "open", "setOpen", "useState", "handleAction", "action", "current", "el", "getParentShapeElement", "id", "height", "getBoundingClientRect", "style", "inputs", "getProperties", "ast", "outputs", "columnCount", "length", "React", "Box", "ref", "title", "classNames", "onAction", "div", "className", "paddingTop", "paddingBottom", "map", "key", "rowHeight", "getHeight", "input", "properties", "getPropertySignatures", "headerHeight", "footerHeight", "createFunctionAnchors", "output", "createAnchorId", "toString", "createAnchors", "center", "x", "y", "React", "ComputeValueType", "Select", "TypeSelect", "value", "onValueChange", "React", "Select", "Root", "TriggerButton", "variant", "classNames", "Portal", "Content", "ScrollUpButton", "Viewport", "ComputeValueType", "literals", "map", "type", "Option", "key", "ScrollDownButton", "Arrow", "Schema", "React", "ReducerInput", "ReducerOutput", "ReducerShape", "extend", "ComputeShape", "Struct", "type", "Literal", "ReducerComponent", "shape", "React", "FunctionBody", "inputSchema", "ReducerInput", "outputSchema", "ReducerOutput", "createReducer", "id", "size", "width", "height", "getHeight", "rest", "createShape", "reducerShape", "name", "icon", "component", "props", "getAnchors", "createFunctionAnchors", "Schema", "React", "AppendInput", "AppendShape", "extend", "ComputeShape", "Struct", "type", "Literal", "createAppend", "props", "createShape", "size", "width", "height", "getHeight", "AppendInput", "AppendComponent", "shape", "React", "FunctionBody", "inputSchema", "appendShape", "name", "icon", "component", "getAnchors", "createFunctionAnchors", "Schema", "React", "useEffect", "useState", "Icon", "createAnchorMap", "AudioShape", "extend", "ComputeShape", "Struct", "type", "Literal", "createAudio", "props", "createShape", "size", "width", "height", "AudioComponent", "shape", "node", "useComputeNodeState", "active", "setActive", "useState", "useEffect", "value", "React", "div", "className", "Icon", "icon", "classNames", "onClick", "audioShape", "name", "component", "getAnchors", "createAnchorMap", "createAnchorId", "x", "y", "Schema", "React", "DEFAULT_INPUT", "isTruthy", "Icon", "createAnchorMap", "BeaconShape", "extend", "ComputeShape", "Struct", "type", "Literal", "createBeacon", "props", "createShape", "size", "width", "height", "BeaconComponent", "shape", "runtime", "useComputeNodeState", "input", "inputs", "DEFAULT_INPUT", "value", "React", "div", "className", "Icon", "icon", "classNames", "isTruthy", "beaconShape", "name", "component", "getAnchors", "createAnchorMap", "createAnchorId", "x", "y", "Schema", "React", "getAnchorPoints", "createAnchors", "GateShape", "extend", "ComputeShape", "Struct", "type", "String", "createGate", "props", "createShape", "size", "width", "height", "defineShape", "name", "icon", "symbol", "Symbol", "inputs", "outputs", "createAnchorId", "component", "React", "div", "className", "getAnchors", "shape", "createAnchors", "createSymbol", "pathConstructor", "strokeWidth", "startX", "endX", "centerY", "paths", "svg", "viewBox", "getAnchorPoints", "x", "y", "map", "i", "line", "key", "x1", "y1", "x2", "y2", "path", "d", "AndSymbol", "arcRadius", "AndShape", "createAnd", "andShape", "OrSymbol", "OrShape", "createOr", "orShape", "NotSymbol", "NotShape", "createNot", "notShape", "Schema", "React", "useRef", "DEFAULT_OUTPUT", "TextBox", "createAnchorMap", "ChatShape", "extend", "ComputeShape", "Struct", "type", "Literal", "TextInputComponent", "shape", "title", "props", "runtime", "useComputeNodeState", "inputRef", "useRef", "handleEnter", "text", "value", "trim", "length", "setOutput", "DEFAULT_OUTPUT", "current", "setText", "React", "Box", "TextBox", "ref", "onEnter", "createChat", "createShape", "size", "width", "height", "chatShape", "name", "icon", "component", "placeholder", "getAnchors", "createAnchorMap", "createAnchorId", "x", "y", "resizable", "Schema", "React", "useCallback", "useRef", "useState", "ComputeValueType", "Input", "TextBox", "createAnchorMap", "safeParseJson", "ConstantShape", "extend", "ComputeShape", "Struct", "type", "Literal", "value", "optional", "Any", "inferType", "ConstantComponent", "shape", "title", "chat", "props", "node", "useComputeNodeState", "setType", "useState", "ComputeValueType", "literals", "inputRef", "useRef", "handleEnter", "useCallback", "text", "trim", "length", "floatValue", "parseFloat", "isNaN", "safeParseJson", "current", "focus", "React", "Box", "status", "TypeSelect", "onValueChange", "TextBox", "ref", "onEnter", "JSON", "stringify", "language", "div", "className", "Input", "Root", "Switch", "checked", "onCheckedChange", "createConstant", "createShape", "size", "width", "height", "constantShape", "name", "icon", "component", "placeholder", "getAnchors", "createAnchorMap", "createAnchorId", "x", "y", "resizable", "Schema", "React", "createAnchorMap", "DatabaseShape", "extend", "ComputeShape", "Struct", "type", "Literal", "createDatabase", "props", "createShape", "size", "width", "height", "DatabaseComponent", "shape", "React", "Box", "databaseShape", "name", "icon", "component", "getAnchors", "createAnchorMap", "createAnchorId", "x", "y", "Schema", "React", "useCallback", "useRef", "AnyOutput", "FunctionInput", "Ref", "getSnapshot", "isInstanceOf", "Function", "Script", "useClient", "Filter", "parseId", "TextBox", "FunctionShape", "extend", "ComputeShape", "Struct", "type", "Literal", "createFunction", "props", "createShape", "size", "width", "height", "TextInputComponent", "shape", "title", "client", "useClient", "node", "runtime", "useComputeNodeState", "inputRef", "useRef", "handleEnter", "useCallback", "text", "value", "trim", "spaceId", "objectId", "parseId", "space", "spaces", "get", "object", "db", "getObjectById", "isInstanceOf", "Script", "objects", "fn", "query", "Filter", "Function", "source", "Ref", "make", "run", "function", "inputSchema", "getSnapshot", "outputSchema", "handleAction", "action", "evalNode", "React", "Box", "onAction", "TextBox", "ref", "language", "valueType", "undefined", "onBlur", "onEnter", "functionShape", "name", "icon", "component", "getAnchors", "createFunctionAnchors", "FunctionInput", "AnyOutput", "Schema", "React", "useEffect", "useState", "GptInput", "GptOutput", "GptShape", "extend", "ComputeShape", "Struct", "type", "Literal", "createGpt", "props", "createShape", "size", "width", "height", "Math", "max", "getHeight", "GptInput", "GptOutput", "GptComponent", "shape", "meta", "runtime", "useComputeNodeState", "text", "setText", "useState", "tokens", "setTokens", "useEffect", "subscribeToEventLog", "ev", "token", "event", "delta", "prev", "split", "length", "React", "FunctionBody", "content", "div", "className", "status", "inputSchema", "input", "outputSchema", "output", "gptShape", "name", "icon", "component", "getAnchors", "createFunctionAnchors", "openable", "Schema", "React", "DEFAULT_INPUT", "DefaultOutput", "JsonTransformInput", "createAnchorMap", "JsonFilter", "JsonShape", "extend", "ComputeShape", "Struct", "type", "Literal", "JsonTransformShape", "JsonComponent", "shape", "props", "runtime", "useComputeNodeState", "input", "inputs", "DEFAULT_INPUT", "value", "undefined", "React", "Box", "JsonFilter", "data", "classNames", "JsonTransformComponent", "createJson", "createShape", "size", "width", "height", "jsonShape", "name", "icon", "component", "getAnchors", "createAnchorMap", "createAnchorId", "x", "y", "resizable", "createJsonTransform", "getHeight", "JsonTransformInput", "jsonTransformShape", "createFunctionAnchors", "DefaultOutput", "Schema", "React", "IfElseInput", "IfElseOutput", "IfInput", "IfOutput", "IfShape", "extend", "ComputeShape", "Struct", "type", "Literal", "IfElseShape", "IfComponent", "shape", "props", "React", "FunctionBody", "inputSchema", "IfInput", "outputSchema", "IfOutput", "IfElseComponent", "IfElseInput", "IfElseOutput", "createIf", "createShape", "size", "width", "height", "getHeight", "ifShape", "name", "icon", "component", "getAnchors", "createFunctionAnchors", "createIfElse", "ifElseShape", "Schema", "React", "Fragment", "DEFAULT_OUTPUT", "QueueInput", "QueueOutput", "mx", "QueueShape", "extend", "ComputeShape", "Struct", "type", "Literal", "createQueue", "props", "createShape", "size", "width", "height", "QueueComponent", "shape", "runtime", "useComputeNodeState", "items", "outputs", "DEFAULT_OUTPUT", "value", "handleAction", "action", "evalNode", "React", "Box", "status", "length", "onAction", "div", "className", "map", "item", "i", "QueueItem", "key", "classNames", "mx", "Object", "entries", "Fragment", "JSON", "stringify", "queueShape", "name", "icon", "component", "getAnchors", "createFunctionAnchors", "QueueInput", "QueueOutput", "resizable", "Schema", "React", "useEffect", "useState", "DEFAULT_OUTPUT", "Icon", "createAnchorMap", "RandomShape", "extend", "ComputeShape", "Struct", "type", "Literal", "min", "optional", "Number", "max", "createRandom", "props", "createShape", "size", "width", "height", "icons", "pickIcon", "Math", "floor", "random", "length", "RandomComponent", "shape", "runtime", "useComputeNodeState", "spin", "setSpin", "useState", "icon", "setIcon", "useEffect", "i", "setInterval", "t1", "setTimeout", "clearInterval", "t2", "clearTimeout", "handleClick", "ev", "stopPropagation", "setOutput", "DEFAULT_OUTPUT", "React", "div", "className", "Icon", "classNames", "onClick", "randomShape", "name", "component", "getAnchors", "createAnchorMap", "createAnchorId", "x", "y", "Schema", "React", "DEFAULT_INPUT", "createAnchorMap", "Chaos", "shaderPresets", "useAudioStream", "ScopeShape", "extend", "ComputeShape", "Struct", "type", "Literal", "createScope", "props", "createShape", "size", "width", "height", "classNames", "ScopeComponent", "shape", "runtime", "useComputeNodeState", "input", "inputs", "DEFAULT_INPUT", "active", "value", "getAverage", "useAudioStream", "React", "div", "className", "Chaos", "getValue", "options", "shaderPresets", "heptapod", "zoom", "scopeShape", "name", "icon", "component", "getAnchors", "createAnchorMap", "createAnchorId", "x", "y", "Schema", "React", "Surface", "DEFAULT_INPUT", "createAnchorMap", "SurfaceShape", "extend", "ComputeShape", "Struct", "type", "Literal", "createSurface", "props", "createShape", "size", "width", "height", "SurfaceComponent", "shape", "runtime", "useComputeNodeState", "input", "inputs", "DEFAULT_INPUT", "value", "handleAction", "action", "evalNode", "React", "Box", "onAction", "Surface", "role", "data", "limit", "surfaceShape", "name", "icon", "component", "getAnchors", "createAnchorMap", "createAnchorId", "x", "y", "resizable", "Schema", "React", "useEffect", "useState", "DEFAULT_OUTPUT", "Input", "createAnchorMap", "SwitchShape", "extend", "ComputeShape", "Struct", "type", "Literal", "createSwitch", "props", "createShape", "size", "width", "height", "SwitchComponent", "shape", "runtime", "useComputeNodeState", "value", "setValue", "useState", "useEffect", "setOutput", "DEFAULT_OUTPUT", "React", "div", "className", "onClick", "ev", "stopPropagation", "Input", "Root", "Switch", "checked", "onCheckedChange", "switchShape", "name", "icon", "component", "getAnchors", "createAnchorMap", "createAnchorId", "x", "y", "Schema", "React", "createInputSchema", "createOutputSchema", "DataType", "InputSchema", "createInputSchema", "DataType", "Message", "OutputSchema", "createOutputSchema", "mutable", "Array", "TableShape", "extend", "ComputeShape", "Struct", "type", "Literal", "createTable", "props", "createShape", "size", "width", "height", "TableComponent", "shape", "React", "Box", "tableShape", "name", "icon", "component", "getAnchors", "createFunctionAnchors", "resizable", "Schema", "React", "useRef", "ComputeValueType", "TemplateOutput", "VoidInput", "getTemplateInputSchema", "toJsonSchema", "invariant", "TextBox", "TemplateShape", "extend", "ComputeShape", "Struct", "type", "Literal", "valueType", "optional", "ComputeValueType", "TextInputComponent", "shape", "title", "props", "node", "useComputeNodeState", "inputRef", "useRef", "handleEnter", "text", "value", "trim", "length", "schema", "getTemplateInputSchema", "inputSchema", "toJsonSchema", "handleTypeChange", "newType", "invariant", "is", "React", "Box", "status", "TypeSelect", "onValueChange", "TextBox", "ref", "language", "undefined", "onBlur", "onEnter", "createTemplate", "createShape", "size", "width", "height", "templateShape", "name", "icon", "component", "placeholder", "getAnchors", "createFunctionAnchors", "VoidInput", "TemplateOutput", "resizable", "Schema", "React", "DEFAULT_INPUT", "TextBox", "createAnchorMap", "TextShape", "extend", "ComputeShape", "Struct", "type", "Literal", "createText", "props", "createShape", "size", "width", "height", "TextComponent", "shape", "runtime", "useComputeNodeState", "input", "inputs", "DEFAULT_INPUT", "value", "handleAction", "action", "evalNode", "React", "Box", "onAction", "TextBox", "textShape", "name", "icon", "component", "getAnchors", "createAnchorMap", "createAnchorId", "x", "y", "resizable", "Schema", "React", "useEffect", "useRef", "createInputSchema", "createOutputSchema", "mx", "DataType", "InputSchema", "createInputSchema", "DataType", "Message", "OutputSchema", "createOutputSchema", "mutable", "Array", "ThreadShape", "extend", "ComputeShape", "Struct", "type", "Literal", "createThread", "props", "createShape", "size", "width", "height", "ThreadComponent", "shape", "items", "scrollRef", "useRef", "useEffect", "current", "scrollTop", "scrollHeight", "React", "Box", "div", "ref", "className", "map", "item", "i", "ThreadItem", "key", "classNames", "mx", "role", "message", "threadShape", "name", "icon", "component", "getAnchors", "createFunctionAnchors", "resizable", "Schema", "React", "createAnchorMap", "TextToImageShape", "extend", "ComputeShape", "Struct", "type", "Literal", "createTextToImage", "props", "createShape", "size", "width", "height", "TextToImageComponent", "shape", "React", "Box", "textToImageShape", "name", "icon", "component", "getAnchors", "createAnchorMap", "createAnchorId", "x", "y", "Schema", "React", "useEffect", "VoidInput", "Filter", "Query", "ObjectId", "Ref", "Trigger", "TriggerEvent", "DXN", "SpaceId", "useSpace", "Select", "TriggerShape", "extend", "ComputeShape", "Struct", "type", "Literal", "functionTrigger", "optional", "Ref", "Trigger", "createTrigger", "props", "make", "enabled", "spec", "createTriggerSpec", "createShape", "size", "width", "height", "getHeight", "TriggerEvent", "EmailEvent", "TriggerComponent", "shape", "space", "useSpace", "target", "useEffect", "triggerKind", "spaceId", "id", "getOutputSchema", "kind", "setKind", "React", "FunctionBody", "status", "TriggerKindSelect", "value", "onValueChange", "inputSchema", "VoidInput", "outputSchema", "Select", "Root", "TriggerButton", "variant", "classNames", "Portal", "Content", "ScrollUpButton", "Viewport", "Kinds", "map", "Option", "key", "ScrollDownButton", "Arrow", "cron", "method", "query", "ast", "Query", "select", "Filter", "nothing", "dxn", "DXN", "QUEUE", "SpaceId", "random", "ObjectId", "toString", "queue", "kindToSchema", "SubscriptionEvent", "TimerEvent", "WebhookEvent", "QueueEvent", "triggerShape", "name", "icon", "component", "getAnchors", "createFunctionAnchors", "Schema", "React", "useState", "log", "useConfig", "Icon", "GptRealtimeShape", "extend", "ComputeShape", "Struct", "type", "Literal", "createGptRealtime", "props", "createShape", "size", "width", "height", "GptRealtimeComponent", "shape", "isLive", "setIsLive", "useState", "isReady", "setIsReady", "config", "useConfig", "start", "peerConnection", "RTCPeerConnection", "ontrack", "event", "audioElement", "document", "createElement", "srcObject", "streams", "autoplay", "controls", "style", "display", "body", "appendChild", "stream", "navigator", "mediaDevices", "getUserMedia", "audio", "getTracks", "forEach", "track", "addTransceiver", "direction", "offer", "createOffer", "setLocalDescription", "AiServiceUrl", "URL", "values", "runtime", "services", "ai", "server", "DEFAULT_AI_SERVICE_URL", "response", "fetch", "method", "sdp", "headers", "answer", "text", "setRemoteDescription", "dataChannel", "createDataChannel", "configureData", "log", "info", "session", "modalities", "tools", "send", "JSON", "stringify", "addEventListener", "ev", "msg", "parse", "data", "error", "React", "div", "className", "Icon", "icon", "classNames", "onClick", "gptRealtimeShape", "name", "component", "getAnchors", "createFunctionAnchors", "Any", "resizable", "computeShapes", "title", "shapes", "constantShape", "templateShape", "chatShape", "switchShape", "audioShape", "triggerShape", "randomShape", "gptShape", "gptRealtimeShape", "functionShape", "databaseShape", "textToImageShape", "appendShape", "ifShape", "ifElseShape", "andShape", "orShape", "notShape", "reducerShape", "jsonTransformShape", "jsonShape", "queueShape", "threadShape", "textShape", "surfaceShape", "beaconShape", "scopeShape", "noteShape", "DefaultInput", "DefaultOutput", "toEffectSchema", "ShapeLayout", "ComputeShapeLayout", "ShapeLayout", "_controller", "registry", "getAnchors", "shape", "shapeDef", "_registry", "getShapeDef", "type", "anchors", "node", "graph", "getNode", "inputSchema", "outputSchema", "toEffectSchema", "DefaultInput", "DefaultOutput", "createFunctionAnchors"]
4
+ "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport type * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Either from 'effect/Either';\nimport * as Exit from 'effect/Exit';\nimport * as Layer from 'effect/Layer';\nimport type * as ManagedRuntime from 'effect/ManagedRuntime';\nimport * as Scope from 'effect/Scope';\n\nimport type { AiService } from '@dxos/ai';\nimport { Event, synchronized } from '@dxos/async';\nimport {\n type ComputeEdge,\n type ComputeGraphModel,\n type ComputeNode,\n type ComputeNodeMeta,\n type GptInput,\n type GptOutput,\n type GraphDiagnostic,\n GraphExecutor,\n ValueBag,\n isNotExecuted,\n} from '@dxos/conductor';\nimport { Resource } from '@dxos/context';\nimport type { Database } from '@dxos/echo';\nimport { unwrapExit } from '@dxos/effect';\nimport {\n ComputeEventLogger,\n type ComputeEventPayload,\n type CredentialsService,\n type FunctionInvocationService,\n type QueueService,\n TracingService,\n} from '@dxos/functions';\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';\nimport { type ComputeShape } from '../shapes';\n\nimport { resolveComputeNode } from './node-defs';\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// TODO(dmaretskyi): Re-use function servies definition.\nexport type ComputeServices =\n | AiService.AiService\n | Database.Service\n | QueueService\n | CredentialsService\n | FunctionInvocationService;\n\n/**\n * Nodes that will automatically trigger the execution of the graph on startup.\n */\nconst AUTO_TRIGGER_NODES = ['chat', 'switch', 'constant'];\n\nexport const createComputeGraphController = (\n graph: CanvasGraphModel<ComputeShape>,\n computeRuntime: ManagedRuntime.ManagedRuntime<ComputeServices, never>,\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<ComputeEventPayload>();\n\n constructor(\n private readonly _computeRuntime: ManagedRuntime.ManagedRuntime<ComputeServices, never>,\n /** Persistent compute graph. */\n private readonly _graph: ComputeGraphModel,\n ) {\n super();\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 unwrapExit(\n await this._computeRuntime.runPromiseExit(\n Effect.gen(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.extend(scope),\n Effect.provide(\n ComputeEventLogger.layerFromTracing.pipe(\n Layer.provideMerge(TracingService.layerNoop), // TODO(dmaretskyi): Plug-in tracing events to visual feedback in the compute graph editor.\n ),\n ),\n Effect.flatMap(computeValueBag),\n Effect.withSpan('test'),\n Effect.tap((values) => {\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 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 unwrapExit(\n await this._computeRuntime.runPromiseExit(\n Effect.gen(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.extend(scope),\n Effect.flatMap(computeValueBag),\n Effect.provide(\n ComputeEventLogger.layerFromTracing.pipe(\n Layer.provideMerge(TracingService.layerNoop), // TODO(dmaretskyi): Plug-in tracing events to visual feedback in the compute graph editor.\n ),\n ),\n\n Effect.withSpan('test'),\n Effect.tap((values) => {\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 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 _createLogger(): Context.Tag.Service<ComputeEventLogger> {\n return {\n log: (event) => {\n this._handleEvent(event);\n },\n nodeId: undefined, // Not in a context of a specific node.\n };\n }\n\n private _handleEvent(event: ComputeEventPayload): 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\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.either(eff).pipe(\n Effect.map((value) => {\n if (Either.isLeft(value)) {\n if (isNotExecuted(value.left)) {\n return [key, { type: 'not-executed' }] as const;\n } else {\n return [key, { type: 'error', error: value.left }] as const;\n }\n } else {\n return [key, { type: 'executed', value: value.right }] as const;\n }\n }),\n ),\n ),\n ).pipe(Effect.map((entries) => Object.fromEntries(entries) as Record<string, RuntimeValue>));\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { createContext, useContext } from 'react';\n\nimport { raise } from '@dxos/debug';\n\nimport type { ComputeGraphController } from '../graph';\n\nexport type ComputeContextType = {\n controller: ComputeGraphController;\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';\nimport { type ComputeShape } from '../shapes';\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 type { ComputeEventPayload } from '@dxos/functions';\nimport { invariant } from '@dxos/invariant';\n\nimport { type RuntimeValue } from '../graph';\nimport { type ComputeShape } from '../shapes';\n\nimport { useComputeContext } from './compute-context';\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: ComputeEventPayload) => 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: ComputeEventPayload) => 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, type ComputeNode, DEFAULT_INPUT, DEFAULT_OUTPUT } from '@dxos/conductor';\nimport { Obj, Ref } from '@dxos/echo';\nimport { invariant } from '@dxos/invariant';\nimport { type CanvasGraphModel, type Connection, type GraphMonitor } from '@dxos/react-ui-canvas-editor';\nimport { isNonNullable } from '@dxos/util';\n\nimport { createComputeNode, isValidComputeNode } from '../graph';\nimport { type ComputeShape, type TriggerShape } from '../shapes';\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 }: Connection,\n): ComputeEdge => {\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 id: Obj.ID.random(),\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 invariant(node.type);\n if (!isValidComputeNode(node.type)) {\n return;\n }\n\n const computeNode = createComputeNode(node);\n if (node.type === 'trigger') {\n linkTriggerToCompute(model, computeNode, node as TriggerShape);\n }\n model.addNode(computeNode);\n node.node = computeNode.id;\n },\n\n onLink: ({ graph, edge }) => {\n if (model) {\n model.addEdge(mapEdge(graph, edge));\n }\n },\n\n onDelete: ({ subgraph }) => {\n if (model) {\n const nodeIds = subgraph.nodes.map((shape) => (shape as ComputeShape).node) as string[];\n\n // NOTE(ZaymonFC): Based on the information we have, this is O(edges to remove * compute edges).\n const edgeIds = subgraph.edges\n .map(({ source, target, output = DEFAULT_OUTPUT, input = DEFAULT_INPUT }) => {\n return model.edges.find((computeEdge) => computeEdge.input === input && computeEdge.output === output)\n ?.id;\n })\n .filter(isNonNullable);\n\n model.removeNodes(nodeIds);\n model.removeEdges(edgeIds);\n\n deleteTriggerObjects(model, subgraph);\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 if (isValidComputeNode(shape.type)) {\n const node = createComputeNode(shape);\n computeGraph.addNode(node);\n shape.node = node.id;\n }\n }\n\n for (const edge of graph.edges) {\n computeGraph.addEdge(mapEdge(graph, edge));\n }\n }\n\n return computeGraph;\n};\n\nconst linkTriggerToCompute = (graph: ComputeGraphModel, computeNode: ComputeNode, triggerData: TriggerShape) => {\n const functionTrigger = triggerData.functionTrigger?.target;\n invariant(functionTrigger);\n Obj.change(functionTrigger, (t) => {\n t.function = Ref.make(graph.root);\n t.inputNodeId = computeNode.id;\n });\n};\n\nconst deleteTriggerObjects = (computeGraph: ComputeGraphModel, deleted: CanvasGraphModel) => {\n const db = Obj.getDatabase(computeGraph.root);\n if (!db) {\n return;\n }\n for (const node of deleted.nodes) {\n if (node.type === 'trigger') {\n const trigger = node as TriggerShape;\n db.remove(trigger.functionTrigger!.target!);\n }\n }\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';\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' as const]: () => createNode('text-to-image'), // TODO(burdon): Rename ai-impage-tool\n ['and' as const]: () => createNode('and'),\n ['append' as const]: () => createNode('append'),\n ['audio' as const]: () => createNode('audio'),\n ['beacon' as const]: () => createNode('beacon'),\n ['chat' as const]: () => createNode('chat'),\n ['constant' as const]: (shape) =>\n createNode('constant', {\n value: (shape as ConstantShape).value,\n }),\n ['make-queue' as const]: () => createNode('make-queue'),\n ['database' as const]: () => createNode('database'),\n ['gpt' as const]: () => createNode('gpt'),\n ['gpt-realtime' as const]: () => createNode('gpt-realtime'),\n ['if' as const]: () => createNode('if'),\n ['if-else' as const]: () => createNode('if-else'),\n ['function' as const]: () => createNode('function'),\n ['json' as const]: () => createNode('json'),\n ['json-transform' as const]: () => createNode('json-transform'),\n ['not' as const]: () => createNode('not'),\n ['or' as const]: () => createNode('or'),\n ['queue' as const]: () => createNode('queue'),\n ['rng' as const]: () => createNode('rng'),\n ['reducer' as const]: () => createNode('reducer'),\n ['scope' as const]: () => createNode('scope'),\n ['surface' as const]: () => createNode('surface'),\n ['switch' as const]: () => createNode('switch'),\n ['template' as const]: (shape) => {\n const node = createNode('template', { valueType: (shape as TemplateShape).valueType, value: shape.text });\n node.inputSchema = JsonSchema.toJsonSchema(getTemplateInputSchema(node));\n return node;\n },\n ['text' as const]: () => createNode('text'),\n ['thread' as const]: () => createNode('thread'),\n ['trigger' as const]: () => 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 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 functionShape,\n gptRealtimeShape,\n gptShape,\n ifElseShape,\n ifShape,\n jsonShape,\n jsonTransformShape,\n notShape,\n orShape,\n queueShape,\n randomShape,\n reducerShape,\n scopeShape,\n surfaceShape,\n switchShape,\n templateShape,\n textShape,\n textToImageShape,\n threadShape,\n triggerShape,\n} from './shapes';\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 queueShape,\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 2025 DXOS.org\n//\n\nimport React, { type PropsWithChildren, type ReactNode, forwardRef } from 'react';\n\nimport { invariant } from '@dxos/invariant';\nimport { Icon, IconButton, type ThemedClassName } from '@dxos/react-ui';\nimport { useEditorContext, useShapeDef } from '@dxos/react-ui-canvas-editor';\nimport { type Shape } from '@dxos/react-ui-canvas-editor';\nimport { mx } from '@dxos/ui-theme';\n\nexport const headerHeight = 32;\nexport const footerHeight = 32;\n\nexport type BoxActionHandler = (action: 'run' | 'open' | 'close') => void;\n\nexport type BoxProps = PropsWithChildren<\n ThemedClassName<{\n shape: Shape;\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 const { icon, name, openable } = useShapeDef(shape.type) ?? { icon: 'ph--placeholder--regular' };\n const { debug } = useEditorContext();\n\n return (\n <div ref={forwardedRef} className='flex flex-col bs-full is-full justify-between'>\n <div className='flex shrink-0 is-full justify-between items-center bs-[32px] bg-hoverSurface'>\n <Icon icon={icon} classNames='mx-2' />\n <div className='grow text-sm truncate'>{debug ? shape.type : (name ?? shape.text ?? title)}</div>\n <IconButton\n classNames='p-1 text-green-500'\n variant='ghost'\n icon='ph--play--regular'\n size={4}\n label='run'\n iconOnly\n onDoubleClick={(ev) => ev.stopPropagation()}\n onClick={(ev) => {\n ev.stopPropagation();\n onAction?.('run');\n }}\n />\n </div>\n <div className={mx('flex flex-col bs-full grow overflow-hidden', classNames)}>{children}</div>\n <div className='flex shrink-0 is-full justify-between items-center bs-[32px] bg-hoverSurface'>\n <div className='grow pli-2 text-sm truncate'>{debug ? shape.id : status}</div>\n {openable && (\n <IconButton\n classNames='p-1'\n variant='ghost'\n icon={open ? 'ph--caret-up--regular' : 'ph--caret-down--regular'}\n size={4}\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 * as SchemaAST from 'effect/SchemaAST';\nimport React, { type JSX, useRef, useState } from 'react';\n\nimport { VoidInput, VoidOutput } from '@dxos/conductor';\nimport { useCanvasContext } from '@dxos/react-ui-canvas';\nimport { type Polygon, type Shape } from '@dxos/react-ui-canvas-editor';\nimport { createAnchors, getParentShapeElement, rowHeight } from '@dxos/react-ui-canvas-editor';\n\nimport { Box, type BoxProps, footerHeight, headerHeight } from '../common';\nimport { createAnchorId, getProperties } from '../defs';\n\nconst bodyPadding = 8;\nconst expandedHeight = 200;\n\nexport type FunctionBodyProps = {\n shape: Shape;\n name?: string;\n content?: JSX.Element;\n inputSchema?: Schema.Schema.Any;\n outputSchema?: Schema.Schema.Any;\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 const { scale } = useCanvasContext();\n const rootRef = useRef<HTMLDivElement>(null);\n const [open, setOpen] = useState(false);\n\n const handleAction: BoxProps['onAction'] = (action) => {\n if (!rootRef.current) {\n return;\n }\n\n switch (action) {\n case 'open': {\n const el = getParentShapeElement(rootRef.current, shape.id)!;\n const { height } = el.getBoundingClientRect();\n el.style.height = `${height / scale + expandedHeight}px`;\n setOpen(true);\n break;\n }\n case 'close': {\n const el = getParentShapeElement(rootRef.current, shape.id)!;\n el.style.height = '';\n setOpen(false);\n break;\n }\n }\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'\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='pli-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='pli-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\nexport const getHeight = (input: Schema.Schema<any>) => {\n const properties = SchemaAST.getPropertySignatures(input.ast);\n return headerHeight + footerHeight + bodyPadding * 2 + properties.length * rowHeight + 2; // Incl. borders.\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 * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\n\nimport { DEFAULT_INPUT, DEFAULT_OUTPUT } from '@dxos/conductor';\nimport { Obj } from '@dxos/echo';\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 = Schema.extend(\n Polygon,\n Schema.Struct({\n // TODO(burdon): Rename computeNode?\n node: Schema.optional(Obj.ID.annotations({ description: 'Compute node id' })),\n }).pipe(Schema.mutable),\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 2025 DXOS.org\n//\n\nimport React from 'react';\n\nimport { ComputeValueType } from '@dxos/conductor';\nimport { Select, type SelectRootProps } from '@dxos/react-ui';\n\n// TODO(burdon): Factor out.\nexport const TypeSelect = ({ value, onValueChange }: Pick<SelectRootProps, 'value' | 'onValueChange'>) => {\n return (\n <Select.Root value={value} onValueChange={onValueChange}>\n <Select.TriggerButton variant='ghost' classNames='is-full !pli-0' />\n <Select.Portal>\n <Select.Content>\n <Select.ScrollUpButton />\n <Select.Viewport>\n {ComputeValueType.literals.map((type) => (\n <Select.Option key={type} value={type}>\n {type}\n </Select.Option>\n ))}\n </Select.Viewport>\n <Select.ScrollDownButton />\n <Select.Arrow />\n </Select.Content>\n </Select.Portal>\n </Select.Root>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport React from 'react';\n\nimport { ReducerInput, ReducerOutput } from '@dxos/conductor';\nimport { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';\n\nimport { FunctionBody, createFunctionAnchors, getHeight } from './common';\nimport { ComputeShape, type CreateShapeProps, createShape } from './defs';\n\n//\n// Data\n//\n\nexport const ReducerShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\n type: Schema.Literal('reducer'),\n }),\n);\n\nexport type ReducerShape = Schema.Schema.Type<typeof ReducerShape>;\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//\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: (props) => <ReducerComponent {...props} />,\n createShape: createReducer,\n getAnchors: (shape) => createFunctionAnchors(shape, ReducerInput, ReducerOutput),\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport React from 'react';\n\nimport { AppendInput } from '@dxos/conductor';\nimport { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';\n\nimport { FunctionBody, createFunctionAnchors, getHeight } from './common';\nimport { ComputeShape, type CreateShapeProps, createShape } from './defs';\n\nexport const AppendShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\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 AppendComponent = ({ shape }: ShapeComponentProps<AppendShape>) => {\n return <FunctionBody shape={shape} inputSchema={AppendInput} />;\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 * as Schema from 'effect/Schema';\nimport React, { useEffect, useState } from 'react';\n\nimport { Icon } from '@dxos/react-ui';\nimport { type ShapeComponentProps, type ShapeDef, createAnchorMap } from '@dxos/react-ui-canvas-editor';\n\nimport { useComputeNodeState } from '../hooks';\n\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';\n\nexport const AudioShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\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 AudioComponent = ({ shape }: ShapeComponentProps<AudioShape>) => {\n const { node } = useComputeNodeState(shape);\n const [active, setActive] = useState(false);\n useEffect(() => {\n node.value = active;\n }, [active]);\n\n // https://docs.pmnd.rs/react-three-fiber/api/canvas#render-props\n return (\n <div className='flex is-full justify-center items-center'>\n <Icon\n icon={active ? 'ph--microphone--regular' : 'ph--microphone-slash--regular'}\n classNames={['transition opacity-20 duration-1000', active && 'opacity-100 text-red-500']}\n size={8}\n onClick={() => setActive(!active)}\n />\n </div>\n );\n};\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 * as Schema from 'effect/Schema';\nimport React from 'react';\n\nimport { DEFAULT_INPUT, isTruthy } from '@dxos/conductor';\nimport { Icon } from '@dxos/react-ui';\nimport { type ShapeComponentProps, type ShapeDef, createAnchorMap } from '@dxos/react-ui-canvas-editor';\n\nimport { useComputeNodeState } from '../hooks';\n\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';\n\nexport const BeaconShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\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 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 is-full justify-center items-center'>\n <Icon\n icon='ph--sun--regular'\n classNames={['transition opacity-20 duration-1000', isTruthy(value) && 'opacity-100 text-yellow-500']}\n size={8}\n />\n </div>\n );\n};\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 * as Schema from 'effect/Schema';\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';\n\n//\n// Gate utils.\n// https://en.wikipedia.org/wiki/Logic_gate\n//\n\ntype GateType = 'and' | 'or' | 'not';\n\nconst GateShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\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 is-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='is-full bs-full'>\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 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport React, { useRef } from 'react';\n\nimport { DEFAULT_OUTPUT } from '@dxos/conductor';\nimport {\n type ShapeComponentProps,\n type ShapeDef,\n TextBox,\n type TextBoxControl,\n type TextBoxProps,\n} from '@dxos/react-ui-canvas-editor';\nimport { createAnchorMap } from '@dxos/react-ui-canvas-editor';\n\nimport { useComputeNodeState } from '../hooks';\n\nimport { Box } from './common';\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';\n\n//\n// Data\n//\n\nexport const ChatShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\n type: Schema.Literal('chat'),\n }),\n);\n\nexport type ChatShape = Schema.Schema.Type<typeof ChatShape>;\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//\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 * as Schema from 'effect/Schema';\nimport React, { useCallback, useRef, useState } from 'react';\n\nimport { ComputeValueType } from '@dxos/conductor';\nimport { Input } from '@dxos/react-ui';\nimport {\n type ShapeComponentProps,\n type ShapeDef,\n TextBox,\n type TextBoxControl,\n type TextBoxProps,\n} from '@dxos/react-ui-canvas-editor';\nimport { createAnchorMap } from '@dxos/react-ui-canvas-editor';\nimport { safeParseJson } from '@dxos/util';\n\nimport { useComputeNodeState } from '../hooks';\n\nimport { Box, TypeSelect } from './common';\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';\n\n//\n// Data\n//\n\nexport const ConstantShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\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// Component\n//\n\nexport type ConstantComponentProps = ShapeComponentProps<ConstantShape> &\n TextBoxProps & { title?: string; chat?: boolean };\n\nconst inferType = (value: any): string | 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 <Input.Root>\n <Input.Switch\n checked={node.value}\n onCheckedChange={(value) => {\n node.value = value;\n }}\n />\n </Input.Root>\n </div>\n )}\n </Box>\n );\n};\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 * as Schema from 'effect/Schema';\nimport React from 'react';\n\nimport { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';\nimport { createAnchorMap } from '@dxos/react-ui-canvas-editor';\n\nimport { Box } from './common';\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';\n\nexport const DatabaseShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\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 DatabaseComponent = ({ shape }: ShapeComponentProps<DatabaseShape>) => {\n return <Box shape={shape} />;\n};\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 * as Schema from 'effect/Schema';\nimport React, { useCallback, useRef } from 'react';\n\nimport { AnyOutput, FunctionInput } from '@dxos/conductor';\nimport { Ref, getSnapshot, isInstanceOf } from '@dxos/echo/internal';\nimport { Function, Script } from '@dxos/functions';\nimport { useClient } from '@dxos/react-client';\nimport { Filter, parseId } from '@dxos/react-client/echo';\nimport {\n type ShapeComponentProps,\n type ShapeDef,\n TextBox,\n type TextBoxControl,\n type TextBoxProps,\n} from '@dxos/react-ui-canvas-editor';\n\nimport { useComputeNodeState } from '../hooks';\n\nimport { Box, createFunctionAnchors } from './common';\nimport { ComputeShape, type CreateShapeProps, createShape } from './defs';\n\nexport const FunctionShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\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// Component\n//\n\ntype TextInputComponentProps = ShapeComponentProps<FunctionShape> & TextBoxProps & { title?: string };\n\nconst TextInputComponent = ({ shape, title, ...props }: TextInputComponentProps) => {\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.getObjectById(objectId);\n if (!space || !isInstanceOf(Script.Script, object)) {\n return;\n }\n\n const [fn] = await space.db.query(Filter.type(Function.Function, { 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 ? getSnapshot(fn.inputSchema) : undefined;\n node.outputSchema = fn.outputSchema ? getSnapshot(fn.outputSchema) : undefined;\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//\n// Defs\n//\n\nexport const functionShape: ShapeDef<FunctionShape> = {\n type: 'function',\n name: 'Function',\n icon: 'ph--function--regular',\n component: TextInputComponent,\n createShape: createFunction,\n getAnchors: (shape) => createFunctionAnchors(shape, FunctionInput, AnyOutput),\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport React, { useEffect, useState } from 'react';\n\nimport { GptInput, GptOutput } from '@dxos/conductor';\nimport { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';\n\nimport { useComputeNodeState } from '../hooks';\n\nimport { FunctionBody, createFunctionAnchors, getHeight } from './common';\nimport { ComputeShape, type CreateShapeProps, createShape } from './defs';\n\nexport const GptShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\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 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={<div className='pli-2 plb-1 overflow-y-auto'>{text}</div>}\n status={`${tokens} tokens`}\n inputSchema={meta.input}\n outputSchema={meta.output}\n />\n );\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 * as Schema from 'effect/Schema';\nimport React from 'react';\n\nimport { DEFAULT_INPUT, DefaultOutput, JsonTransformInput } from '@dxos/conductor';\nimport { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';\nimport { createAnchorMap } from '@dxos/react-ui-canvas-editor';\nimport { JsonFilter } from '@dxos/react-ui-syntax-highlighter';\n\nimport { useComputeNodeState } from '../hooks';\n\nimport { Box, createFunctionAnchors, getHeight } from './common';\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';\n\n//\n// Data\n//\n\nexport const JsonShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\n type: Schema.Literal('json'),\n }),\n);\n\nexport type JsonShape = Schema.Schema.Type<typeof JsonShape>;\n\nexport const JsonTransformShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\n type: Schema.Literal('json-transform'),\n }),\n);\n\nexport type JsonTransformShape = Schema.Schema.Type<typeof JsonTransformShape>;\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 <JsonFilter data={value} classNames='text-xs' />\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//\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: (props) => <JsonComponent {...props} />,\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: (props) => <JsonTransformComponent {...props} />,\n createShape: createJsonTransform,\n getAnchors: (shape) => createFunctionAnchors(shape, JsonTransformInput, DefaultOutput),\n resizable: true,\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport React from 'react';\n\nimport { IfElseInput, IfElseOutput, IfInput, IfOutput } from '@dxos/conductor';\nimport { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';\n\nimport { FunctionBody, createFunctionAnchors, getHeight } from './common';\nimport { ComputeShape, type CreateShapeProps, createShape } from './defs';\n\n//\n// Data\n//\n\nexport const IfShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\n type: Schema.Literal('if'),\n }),\n);\n\nexport type IfShape = Schema.Schema.Type<typeof IfShape>;\n\nexport const IfElseShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\n type: Schema.Literal('if-else'),\n }),\n);\n\nexport type IfElseShape = Schema.Schema.Type<typeof IfElseShape>;\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//\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: (props) => <IfComponent {...props} />,\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: (props) => <IfElseComponent {...props} />,\n createShape: createIfElse,\n getAnchors: (shape) => createFunctionAnchors(shape, IfElseInput, IfElseOutput),\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport React, { Fragment } from 'react';\n\nimport { DEFAULT_OUTPUT, QueueInput, QueueOutput } from '@dxos/conductor';\nimport { type ThemedClassName } from '@dxos/react-ui';\nimport { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';\nimport { mx } from '@dxos/ui-theme';\n\nimport { useComputeNodeState } from '../hooks';\n\nimport { createFunctionAnchors } from './common';\nimport { Box, type BoxActionHandler } from './common';\nimport { ComputeShape, type CreateShapeProps, createShape } from './defs';\n\nexport const QueueShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\n type: Schema.Literal('queue'),\n }),\n);\n\nexport type QueueShape = Schema.Schema.Type<typeof QueueShape>;\n\nexport type CreateQueueProps = CreateShapeProps<QueueShape>;\n\nexport const createQueue = (props: CreateQueueProps) =>\n createShape<QueueShape>({\n type: 'queue',\n size: { width: 256, height: 512 },\n ...props,\n });\n\nexport const QueueComponent = ({ shape }: ShapeComponentProps<QueueShape>) => {\n const { runtime } = useComputeNodeState(shape);\n const items = runtime.outputs[DEFAULT_OUTPUT]?.type === 'executed' ? runtime.outputs[DEFAULT_OUTPUT].value : [];\n\n const handleAction: BoxActionHandler = (action) => {\n if (action === 'run') {\n runtime.evalNode();\n }\n };\n\n return (\n <Box shape={shape} status={`${items.length} items`} onAction={handleAction}>\n <div className='flex flex-col is-full overflow-y-auto divide-y divide-separator'>\n {[...items].map((item, i) => (\n <QueueItem key={i} classNames='p-1 pli-2' item={item} />\n ))}\n </div>\n </Box>\n );\n};\n\nexport const QueueItem = ({ classNames, item }: 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-subdued'>{key}</div>\n <div>{typeof value === 'string' ? value : JSON.stringify(value)}</div>\n </Fragment>\n ))}\n </div>\n );\n};\n\nexport const queueShape: ShapeDef<QueueShape> = {\n type: 'queue',\n name: 'Queue',\n icon: 'ph--queue--regular',\n component: QueueComponent,\n createShape: createQueue,\n getAnchors: (shape) => createFunctionAnchors(shape, QueueInput, QueueOutput),\n resizable: true,\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport React, { useEffect, useState } from 'react';\n\nimport { DEFAULT_OUTPUT } from '@dxos/conductor';\nimport { Icon, type IconProps } from '@dxos/react-ui';\nimport { type ShapeComponentProps, type ShapeDef, createAnchorMap } from '@dxos/react-ui-canvas-editor';\n\nimport { useComputeNodeState } from '../hooks';\n\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';\n\nexport const RandomShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\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\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 const handleClick: 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={icon} classNames={spin && 'animate-[spin_1s]'} size={10} onClick={handleClick} />\n </div>\n );\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 * as Schema from 'effect/Schema';\nimport React from 'react';\n\nimport { DEFAULT_INPUT } from '@dxos/conductor';\nimport { type ShapeComponentProps, type ShapeDef, createAnchorMap } from '@dxos/react-ui-canvas-editor';\nimport { Chaos, shaderPresets, useAudioStream } from '@dxos/react-ui-sfx';\n\nimport { useComputeNodeState } from '../hooks';\n\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';\n\nexport const ScopeShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\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 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 is-full justify-center items-center bg-black'>\n <Chaos active={active} getValue={getAverage} options={{ ...shaderPresets.heptapod, zoom: 1.2 }} />\n </div>\n );\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 * as Schema from 'effect/Schema';\nimport React from 'react';\n\nimport { Surface } from '@dxos/app-framework/react';\nimport { DEFAULT_INPUT } from '@dxos/conductor';\nimport { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';\nimport { createAnchorMap } from '@dxos/react-ui-canvas-editor';\n\nimport { useComputeNodeState } from '../hooks';\n\nimport { Box, type BoxActionHandler } from './common';\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';\n\nexport const SurfaceShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\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 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 const handleAction: BoxActionHandler = (action) => {\n if (action === 'run') {\n runtime.evalNode();\n }\n };\n\n return (\n <Box shape={shape} onAction={handleAction}>\n {value !== null && <Surface role='card--extrinsic' data={{ value }} limit={1} />}\n </Box>\n );\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 * as Schema from 'effect/Schema';\nimport React, { useEffect, useState } from 'react';\n\nimport { DEFAULT_OUTPUT } from '@dxos/conductor';\nimport { Input } from '@dxos/react-ui';\nimport { type ShapeComponentProps, type ShapeDef, createAnchorMap } from '@dxos/react-ui-canvas-editor';\n\nimport { useComputeNodeState } from '../hooks';\n\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';\n\nexport const SwitchShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\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\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 <div className='flex is-full justify-center items-center' onClick={(ev) => ev.stopPropagation()}>\n <Input.Root>\n <Input.Switch checked={value} onCheckedChange={(value) => setValue(value)} />\n </Input.Root>\n </div>\n );\n};\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 * as Schema from 'effect/Schema';\nimport React from 'react';\n\nimport { createInputSchema, createOutputSchema } from '@dxos/conductor';\nimport { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';\nimport { Message } from '@dxos/types';\n\nimport { Box, createFunctionAnchors } from './common';\nimport { ComputeShape, type CreateShapeProps, createShape } from './defs';\n\nconst InputSchema = createInputSchema(Message.Message);\nconst OutputSchema = createOutputSchema(Schema.mutable(Schema.Array(Message.Message)));\n\nexport const TableShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\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 TableComponent = ({ shape }: ShapeComponentProps<TableShape>) => {\n // const items = shape.node.items.value;\n\n return <Box shape={shape}></Box>;\n};\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, TemplateOutput, VoidInput, getTemplateInputSchema } from '@dxos/conductor';\nimport { toJsonSchema } from '@dxos/echo/internal';\nimport { invariant } from '@dxos/invariant';\nimport {\n type ShapeComponentProps,\n type ShapeDef,\n TextBox,\n type TextBoxControl,\n type TextBoxProps,\n} from '@dxos/react-ui-canvas-editor';\n\nimport { useComputeNodeState } from '../hooks';\n\nimport { Box, TypeSelect, createFunctionAnchors } from './common';\nimport { ComputeShape, type CreateShapeProps, createShape } from './defs';\n\n//\n// Data\n//\n\nexport const TemplateShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\n type: Schema.Literal('template'),\n valueType: Schema.optional(ComputeValueType),\n }),\n);\n\nexport type TemplateShape = Schema.Schema.Type<typeof TemplateShape>;\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 = 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 = 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\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: (props) => <TextInputComponent {...props} placeholder={'Prompt'} />,\n createShape: createTemplate,\n getAnchors: (shape) => createFunctionAnchors(shape, VoidInput, TemplateOutput),\n resizable: true,\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport React from 'react';\n\nimport { DEFAULT_INPUT } from '@dxos/conductor';\nimport { type ShapeComponentProps, type ShapeDef, TextBox } from '@dxos/react-ui-canvas-editor';\nimport { createAnchorMap } from '@dxos/react-ui-canvas-editor';\n\nimport { useComputeNodeState } from '../hooks';\n\nimport { Box, type BoxActionHandler } from './common';\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';\n\nexport const TextShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\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 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 const handleAction: BoxActionHandler = (action) => {\n if (action === 'run') {\n runtime.evalNode();\n }\n };\n\n return (\n <Box shape={shape} onAction={handleAction}>\n <TextBox value={value} />\n </Box>\n );\n};\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 * as Schema from 'effect/Schema';\nimport React, { useEffect, useRef } from 'react';\n\nimport { createInputSchema, createOutputSchema } from '@dxos/conductor';\nimport { type ThemedClassName } from '@dxos/react-ui';\nimport { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';\nimport { Message } from '@dxos/types';\nimport { mx } from '@dxos/ui-theme';\n\nimport { Box, createFunctionAnchors } from './common';\nimport { ComputeShape, type CreateShapeProps, createShape } from './defs';\n\nconst InputSchema = createInputSchema(Message.Message);\nconst OutputSchema = createOutputSchema(Schema.mutable(Schema.Array(Message.Message)));\n\nexport const ThreadShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\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 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 <div ref={scrollRef} className='flex flex-col is-full overflow-y-auto gap-2 p-2'>\n {[...items].map((item, i) => (\n <ThreadItem key={i} item={item} />\n ))}\n </div>\n </Box>\n );\n};\n\nexport const ThreadItem = ({ classNames, item }: 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 pli-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\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';\nimport React from 'react';\n\nimport { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';\nimport { createAnchorMap } from '@dxos/react-ui-canvas-editor';\n\nimport { Box } from './common';\nimport { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';\n\nexport const TextToImageShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\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 TextToImageComponent = ({ shape }: ShapeComponentProps<TextToImageShape>) => {\n return <Box shape={shape} />;\n};\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 * as Schema from 'effect/Schema';\nimport React, { useEffect } from 'react';\n\nimport { VoidInput } from '@dxos/conductor';\nimport { Filter, Obj, Query, Ref, Type } from '@dxos/echo';\nimport { type Mutable } from '@dxos/echo/internal';\nimport { Trigger, TriggerEvent } from '@dxos/functions';\nimport { DXN, SpaceId } from '@dxos/keys';\nimport { useSpace } from '@dxos/react-client/echo';\nimport { Select, type SelectRootProps } from '@dxos/react-ui';\nimport { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';\n\nimport { FunctionBody, createFunctionAnchors, getHeight } from './common';\nimport { ComputeShape, type CreateShapeProps, createShape } from './defs';\n\nexport const TriggerShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\n type: Schema.Literal('trigger'),\n functionTrigger: Schema.optional(Type.Ref(Trigger.Trigger)),\n }),\n);\n\nexport interface TriggerShape extends Schema.Schema.Type<typeof TriggerShape> {}\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 type TriggerComponentProps = ShapeComponentProps<TriggerShape>;\n\nexport const TriggerComponent = ({ shape }: TriggerComponentProps) => {\n const space = useSpace();\n const functionTrigger = shape.functionTrigger?.target;\n\n useEffect(() => {\n if (functionTrigger && !functionTrigger.spec) {\n Obj.change(functionTrigger, (t) => {\n t.spec = createTriggerSpec({ triggerKind: 'email', spaceId: space?.id }) as 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.change(functionTrigger!, (t) => {\n t.spec = createTriggerSpec({ triggerKind: kind, spaceId: space?.id }) as Mutable<Trigger.Spec>;\n });\n }\n };\n\n if (!functionTrigger?.spec) {\n return;\n }\n\n return (\n <FunctionBody\n shape={shape}\n status={\n <TriggerKindSelect value={functionTrigger.spec?.kind} onValueChange={(kind) => setKind(kind as Trigger.Kind)} />\n }\n inputSchema={VoidInput}\n outputSchema={getOutputSchema(functionTrigger.spec!.kind!)}\n />\n );\n};\n\n// TODO(burdon): Factor out.\nconst TriggerKindSelect = ({ value, onValueChange }: Pick<SelectRootProps, 'value' | 'onValueChange'>) => {\n return (\n <Select.Root value={value} onValueChange={onValueChange}>\n <Select.TriggerButton variant='ghost' classNames='is-full !pli-0' />\n <Select.Portal>\n <Select.Content>\n <Select.ScrollUpButton />\n <Select.Viewport>\n {Trigger.Kinds.map((kind) => (\n <Select.Option key={kind} value={kind}>\n {kind}\n </Select.Option>\n ))}\n </Select.Viewport>\n <Select.ScrollDownButton />\n <Select.Arrow />\n </Select.Content>\n </Select.Portal>\n </Select.Root>\n );\n};\n\nconst createTriggerSpec = (props: { triggerKind?: Trigger.Kind; spaceId?: SpaceId }): Trigger.Spec => {\n const kind = props.triggerKind ?? 'email';\n switch (kind) {\n case 'timer':\n return { kind: 'timer', cron: '*/10 * * * * *' } satisfies Trigger.TimerSpec;\n case 'webhook':\n return { kind: 'webhook', method: 'POST' } satisfies Trigger.WebhookSpec;\n case 'subscription':\n return {\n kind: 'subscription',\n query: {\n ast: Query.select(Filter.nothing()).ast,\n },\n } satisfies Trigger.SubscriptionSpec;\n case 'email':\n return { kind: 'email' } satisfies Trigger.EmailSpec;\n case 'queue': {\n const dxn = new DXN(DXN.kind.QUEUE, ['data', props.spaceId ?? SpaceId.random(), Obj.ID.random()]).toString();\n return { kind: 'queue', queue: dxn } satisfies Trigger.QueueSpec;\n }\n }\n};\n\nconst 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 ['queue']: TriggerEvent.QueueEvent,\n };\n return kindToSchema[kind];\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 React, { useState } from 'react';\n\nimport { log } from '@dxos/log';\nimport { useConfig } from '@dxos/react-client';\nimport { Icon } from '@dxos/react-ui';\nimport { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';\n\nimport { createFunctionAnchors } from './common';\nimport { ComputeShape, type CreateShapeProps, createShape } from './defs';\n\nexport const GptRealtimeShape = Schema.extend(\n ComputeShape,\n Schema.Struct({\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 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 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\n const AiServiceUrl = new URL(\n '/rtc-connect',\n config.values.runtime?.services?.ai?.server ?? DEFAULT_AI_SERVICE_URL,\n );\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 is-full justify-center items-center'>\n <Icon\n icon={isReady ? 'ph--waveform--regular' : isLive ? 'ph--pulse--regular' : 'ph--play--regular'}\n size={16}\n classNames={!isLive && 'cursor-pointer'}\n onClick={start}\n />\n </div>\n );\n};\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\nconst DEFAULT_AI_SERVICE_URL = 'http://localhost:8788';\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { DefaultInput, DefaultOutput } from '@dxos/conductor';\nimport { toEffectSchema } from '@dxos/echo/internal';\nimport { type Anchor, ShapeLayout, type ShapeRegistry } from '@dxos/react-ui-canvas-editor';\n\nimport { type ComputeGraphController } from './graph';\nimport { type ComputeShape, createFunctionAnchors } from './shapes';\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 ? toEffectSchema(node.inputSchema) : DefaultInput;\n const outputSchema = node.outputSchema ? toEffectSchema(node.outputSchema) : DefaultOutput;\n anchors = createFunctionAnchors(shape, inputSchema, outputSchema);\n }\n }\n\n return anchors;\n }\n}\n"],
5
+ "mappings": ";;;AAKA,YAAYA,YAAY;AACxB,YAAYC,YAAY;AACxB,YAAYC,UAAU;AACtB,YAAYC,WAAW;AAEvB,YAAYC,WAAW;AAGvB,SAASC,OAAOC,oBAAoB;AACpC,SAQEC,eACAC,UACAC,qBACK;AACP,SAASC,gBAAgB;AAEzB,SAASC,kBAAkB;AAC3B,SACEC,oBAKAC,sBACK;AACP,SAASC,WAAW;;;ACjCpB,SAASC,eAAeC,kBAAkB;AAE1C,SAASC,aAAa;AAQf,IAAMC,iBAAiBC,cAA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Q;;MAENC;MACAC;MACAC;MACAC;MACAC;MACAC;MACAC;;EAEJ;EACA;IACER,OAAO;IACPC,QAAQ;;MAENQ;MACAC;MACAC;MACAC;MACAC;MACAC;;EAEJ;EACA;IACEd,OAAO;IACPC,QAAQ;;MAENc;MACAC;MACAC;MACAC;MACAC;MACAC;MACAC;;EAEJ;EACA;IACErB,OAAO;IACPC,QAAQ;;MAENqB;MACAC;MACAC;MACAC;MACAC;MACAC;MACAC;;EAEJ;EACA;IACE5B,OAAO;IACPC,QAAQ;;MAEN4B;;EAEJ;;;;A6B9FF,SAASC,cAAcC,iBAAAA,sBAAqB;AAC5C,SAASC,sBAAsB;AAC/B,SAAsBC,mBAAuC;AAMtD,IAAMC,qBAAN,cAAiCC,YAAAA;;EACtC,YACUC,aACRC,WACA;AACA,UAAMA,SAAAA,GAAAA,KAHED,cAAAA;EAIV;;EAGSE,WAAWC,OAA6C;AAC/D,UAAMC,WAAW,KAAKC,UAAUC,YAAYH,MAAMI,IAAI;AACtD,QAAIC,UAAUJ,UAAUF,aAAaC,KAAAA,KAAU,CAAC;AAChD,QAAIA,MAAMM,MAAM;AACd,YAAMA,OAAO,KAAKT,YAAYU,MAAMC,QAAQR,MAAMM,IAAI;AACtD,UAAIA,KAAKG,eAAeH,KAAKI,cAAc;AAEzC,cAAMD,cAAcH,KAAKG,cAAcE,eAAeL,KAAKG,WAAW,IAAIG;AAC1E,cAAMF,eAAeJ,KAAKI,eAAeC,eAAeL,KAAKI,YAAY,IAAIG;AAC7ER,kBAAUS,sBAAsBd,OAAOS,aAAaC,YAAAA;MACtD;IACF;AAEA,WAAOL;EACT;AACF;",
6
+ "names": ["Effect", "Either", "Exit", "Layer", "Scope", "Event", "synchronized", "GraphExecutor", "ValueBag", "isNotExecuted", "Resource", "unwrapExit", "ComputeEventLogger", "TracingService", "log", "createContext", "useContext", "raise", "ComputeContext", "createContext", "useComputeContext", "useContext", "raise", "Error", "useEffect", "useState", "combine", "cbs", "cb", "useComputeGraphController", "controller", "graph", "editorRef", "forceUpdate", "useState", "useEffect", "open", "off", "update", "on", "current", "output", "nodeId", "property", "value", "type", "edge", "edges", "find", "source", "getNode", "node", "action", "close", "Schema", "useCallback", "useEffect", "useState", "invariant", "useComputeNodeState", "shape", "controller", "useComputeContext", "invariant", "meta", "setMeta", "useState", "useEffect", "disposed", "queueMicrotask", "node", "getComputeNode", "getMeta", "evalNode", "useCallback", "subscribeToEventLog", "cb", "events", "on", "ev", "nodeId", "input", "Struct", "output", "runtime", "inputs", "getInputs", "outputs", "getOutputs", "setOutput", "property", "value", "useMemo", "ComputeGraphModel", "DEFAULT_INPUT", "DEFAULT_OUTPUT", "Obj", "Ref", "invariant", "isNonNullable", "mapEdge", "graph", "source", "target", "output", "DEFAULT_OUTPUT", "input", "DEFAULT_INPUT", "sourceNode", "findNode", "targetNode", "invariant", "node", "id", "Obj", "ID", "random", "useGraphMonitor", "model", "useMemo", "onCreate", "type", "isValidComputeNode", "computeNode", "createComputeNode", "linkTriggerToCompute", "addNode", "onLink", "edge", "addEdge", "onDelete", "subgraph", "nodeIds", "nodes", "map", "shape", "edgeIds", "edges", "find", "computeEdge", "filter", "isNonNullable", "removeNodes", "removeEdges", "deleteTriggerObjects", "createComputeGraph", "computeGraph", "ComputeGraphModel", "create", "triggerData", "functionTrigger", "change", "t", "function", "Ref", "make", "root", "inputNodeId", "deleted", "db", "getDatabase", "trigger", "remove", "NODE_INPUT", "NODE_OUTPUT", "getTemplateInputSchema", "registry", "raise", "JsonSchema", "Obj", "invariant", "resolveComputeNode", "node", "impl", "type", "isValidComputeNode", "nodeFactory", "undefined", "createComputeNode", "shape", "Error", "factory", "createNode", "value", "valueType", "text", "inputSchema", "toJsonSchema", "props", "id", "ID", "random", "InvalidStateError", "Error", "AUTO_TRIGGER_NODES", "createComputeGraphController", "graph", "computeRuntime", "computeGraph", "createComputeGraph", "controller", "ComputeGraphController", "Resource", "_executor", "GraphExecutor", "computeNodeResolver", "node", "resolveComputeNode", "_diagnostics", "_forcedOutputs", "_runtimeStateInputs", "_runtimeStateOutputs", "update", "Event", "output", "events", "_computeRuntime", "_graph", "toJSON", "state", "inputs", "outputs", "forcedOutputs", "diagnostics", "userState", "inputStates", "outputStates", "ids", "Set", "Object", "keys", "fromEntries", "map", "id", "getNode", "input", "addNode", "addEdge", "edge", "getComputeNode", "nodeId", "getInputs", "getOutputs", "setOutput", "property", "value", "queueMicrotask", "exec", "err", "log", "catch", "getMeta", "meta", "checkGraph", "executor", "clone", "load", "getDiagnostics", "evalNode", "entries", "setOutputs", "succeed", "ValueBag", "make", "unwrapExit", "runPromiseExit", "gen", "scope", "executable", "promise", "computingOutputs", "effect", "computeOutputs", "computeInputs", "pipe", "withSpan", "extend", "provide", "ComputeEventLogger", "layerFromTracing", "provideMerge", "TracingService", "layerNoop", "flatMap", "computeValueBag", "tap", "values", "key", "_onOutputComputed", "_onInputComputed", "close", "void", "emit", "startFromNode", "triggerNodes", "nodes", "filter", "type", "includes", "allAffectedNodes", "getAllDependantNodes", "tasks", "push", "all", "_createLogger", "event", "_handleEvent", "undefined", "bag", "eff", "either", "isLeft", "isNotExecuted", "left", "error", "right", "noteShape", "React", "forwardRef", "invariant", "Icon", "IconButton", "useEditorContext", "useShapeDef", "mx", "headerHeight", "footerHeight", "Box", "children", "classNames", "shape", "title", "status", "open", "onAction", "forwardedRef", "type", "icon", "name", "openable", "debug", "div", "ref", "className", "text", "variant", "size", "label", "iconOnly", "onDoubleClick", "ev", "stopPropagation", "onClick", "id", "SchemaAST", "React", "useRef", "useState", "VoidInput", "VoidOutput", "useCanvasContext", "createAnchors", "getParentShapeElement", "rowHeight", "Schema", "SchemaAST", "DEFAULT_INPUT", "DEFAULT_OUTPUT", "Obj", "Polygon", "getProperties", "ast", "getPropertySignatures", "map", "name", "toString", "createAnchorId", "kind", "property", "DEFAULT_INPUT", "DEFAULT_OUTPUT", "join", "parseAnchorId", "id", "parts", "match", "slice", "undefined", "ComputeShape", "extend", "Polygon", "Struct", "node", "optional", "Obj", "ID", "annotations", "description", "pipe", "mutable", "createShape", "rest", "random", "bodyPadding", "expandedHeight", "FunctionBody", "shape", "name", "content", "inputSchema", "VoidInput", "outputSchema", "VoidOutput", "props", "scale", "useCanvasContext", "rootRef", "useRef", "open", "setOpen", "useState", "handleAction", "action", "current", "el", "getParentShapeElement", "id", "height", "getBoundingClientRect", "style", "inputs", "getProperties", "ast", "outputs", "columnCount", "length", "React", "Box", "ref", "title", "classNames", "onAction", "div", "className", "paddingTop", "paddingBottom", "map", "key", "rowHeight", "getHeight", "input", "properties", "getPropertySignatures", "headerHeight", "footerHeight", "createFunctionAnchors", "output", "createAnchorId", "toString", "createAnchors", "center", "x", "y", "React", "ComputeValueType", "Select", "TypeSelect", "value", "onValueChange", "React", "Select", "Root", "TriggerButton", "variant", "classNames", "Portal", "Content", "ScrollUpButton", "Viewport", "ComputeValueType", "literals", "map", "type", "Option", "key", "ScrollDownButton", "Arrow", "Schema", "React", "ReducerInput", "ReducerOutput", "ReducerShape", "extend", "ComputeShape", "Struct", "type", "Literal", "ReducerComponent", "shape", "React", "FunctionBody", "inputSchema", "ReducerInput", "outputSchema", "ReducerOutput", "createReducer", "id", "size", "width", "height", "getHeight", "rest", "createShape", "reducerShape", "name", "icon", "component", "props", "getAnchors", "createFunctionAnchors", "Schema", "React", "AppendInput", "AppendShape", "extend", "ComputeShape", "Struct", "type", "Literal", "createAppend", "props", "createShape", "size", "width", "height", "getHeight", "AppendInput", "AppendComponent", "shape", "React", "FunctionBody", "inputSchema", "appendShape", "name", "icon", "component", "getAnchors", "createFunctionAnchors", "Schema", "React", "useEffect", "useState", "Icon", "createAnchorMap", "AudioShape", "extend", "ComputeShape", "Struct", "type", "Literal", "createAudio", "props", "createShape", "size", "width", "height", "AudioComponent", "shape", "node", "useComputeNodeState", "active", "setActive", "useState", "useEffect", "value", "React", "div", "className", "Icon", "icon", "classNames", "onClick", "audioShape", "name", "component", "getAnchors", "createAnchorMap", "createAnchorId", "x", "y", "Schema", "React", "DEFAULT_INPUT", "isTruthy", "Icon", "createAnchorMap", "BeaconShape", "extend", "ComputeShape", "Struct", "type", "Literal", "createBeacon", "props", "createShape", "size", "width", "height", "BeaconComponent", "shape", "runtime", "useComputeNodeState", "input", "inputs", "DEFAULT_INPUT", "value", "React", "div", "className", "Icon", "icon", "classNames", "isTruthy", "beaconShape", "name", "component", "getAnchors", "createAnchorMap", "createAnchorId", "x", "y", "Schema", "React", "getAnchorPoints", "createAnchors", "GateShape", "extend", "ComputeShape", "Struct", "type", "String", "createGate", "props", "createShape", "size", "width", "height", "defineShape", "name", "icon", "symbol", "Symbol", "inputs", "outputs", "createAnchorId", "component", "React", "div", "className", "getAnchors", "shape", "createAnchors", "createSymbol", "pathConstructor", "strokeWidth", "startX", "endX", "centerY", "paths", "svg", "viewBox", "getAnchorPoints", "x", "y", "map", "i", "line", "key", "x1", "y1", "x2", "y2", "path", "d", "AndSymbol", "arcRadius", "AndShape", "createAnd", "andShape", "OrSymbol", "OrShape", "createOr", "orShape", "NotSymbol", "NotShape", "createNot", "notShape", "Schema", "React", "useRef", "DEFAULT_OUTPUT", "TextBox", "createAnchorMap", "ChatShape", "extend", "ComputeShape", "Struct", "type", "Literal", "TextInputComponent", "shape", "title", "props", "runtime", "useComputeNodeState", "inputRef", "useRef", "handleEnter", "text", "value", "trim", "length", "setOutput", "DEFAULT_OUTPUT", "current", "setText", "React", "Box", "TextBox", "ref", "onEnter", "createChat", "createShape", "size", "width", "height", "chatShape", "name", "icon", "component", "placeholder", "getAnchors", "createAnchorMap", "createAnchorId", "x", "y", "resizable", "Schema", "React", "useCallback", "useRef", "useState", "ComputeValueType", "Input", "TextBox", "createAnchorMap", "safeParseJson", "ConstantShape", "extend", "ComputeShape", "Struct", "type", "Literal", "value", "optional", "Any", "inferType", "ConstantComponent", "shape", "title", "chat", "props", "node", "useComputeNodeState", "setType", "useState", "ComputeValueType", "literals", "inputRef", "useRef", "handleEnter", "useCallback", "text", "trim", "length", "floatValue", "parseFloat", "isNaN", "safeParseJson", "current", "focus", "React", "Box", "status", "TypeSelect", "onValueChange", "TextBox", "ref", "onEnter", "JSON", "stringify", "language", "div", "className", "Input", "Root", "Switch", "checked", "onCheckedChange", "createConstant", "createShape", "size", "width", "height", "constantShape", "name", "icon", "component", "placeholder", "getAnchors", "createAnchorMap", "createAnchorId", "x", "y", "resizable", "Schema", "React", "createAnchorMap", "DatabaseShape", "extend", "ComputeShape", "Struct", "type", "Literal", "createDatabase", "props", "createShape", "size", "width", "height", "DatabaseComponent", "shape", "React", "Box", "databaseShape", "name", "icon", "component", "getAnchors", "createAnchorMap", "createAnchorId", "x", "y", "Schema", "React", "useCallback", "useRef", "AnyOutput", "FunctionInput", "Ref", "getSnapshot", "isInstanceOf", "Function", "Script", "useClient", "Filter", "parseId", "TextBox", "FunctionShape", "extend", "ComputeShape", "Struct", "type", "Literal", "createFunction", "props", "createShape", "size", "width", "height", "TextInputComponent", "shape", "title", "client", "useClient", "node", "runtime", "useComputeNodeState", "inputRef", "useRef", "handleEnter", "useCallback", "text", "value", "trim", "spaceId", "objectId", "parseId", "space", "spaces", "get", "object", "db", "getObjectById", "isInstanceOf", "Script", "fn", "query", "Filter", "Function", "source", "Ref", "make", "run", "function", "inputSchema", "getSnapshot", "undefined", "outputSchema", "handleAction", "action", "evalNode", "React", "Box", "onAction", "TextBox", "ref", "language", "valueType", "onBlur", "onEnter", "functionShape", "name", "icon", "component", "getAnchors", "createFunctionAnchors", "FunctionInput", "AnyOutput", "Schema", "React", "useEffect", "useState", "GptInput", "GptOutput", "GptShape", "extend", "ComputeShape", "Struct", "type", "Literal", "createGpt", "props", "createShape", "size", "width", "height", "Math", "max", "getHeight", "GptInput", "GptOutput", "GptComponent", "shape", "meta", "runtime", "useComputeNodeState", "text", "setText", "useState", "tokens", "setTokens", "useEffect", "subscribeToEventLog", "ev", "token", "event", "delta", "prev", "split", "length", "React", "FunctionBody", "content", "div", "className", "status", "inputSchema", "input", "outputSchema", "output", "gptShape", "name", "icon", "component", "getAnchors", "createFunctionAnchors", "openable", "Schema", "React", "DEFAULT_INPUT", "DefaultOutput", "JsonTransformInput", "createAnchorMap", "JsonFilter", "JsonShape", "extend", "ComputeShape", "Struct", "type", "Literal", "JsonTransformShape", "JsonComponent", "shape", "props", "runtime", "useComputeNodeState", "input", "inputs", "DEFAULT_INPUT", "value", "undefined", "React", "Box", "JsonFilter", "data", "classNames", "JsonTransformComponent", "createJson", "createShape", "size", "width", "height", "jsonShape", "name", "icon", "component", "getAnchors", "createAnchorMap", "createAnchorId", "x", "y", "resizable", "createJsonTransform", "getHeight", "JsonTransformInput", "jsonTransformShape", "createFunctionAnchors", "DefaultOutput", "Schema", "React", "IfElseInput", "IfElseOutput", "IfInput", "IfOutput", "IfShape", "extend", "ComputeShape", "Struct", "type", "Literal", "IfElseShape", "IfComponent", "shape", "props", "React", "FunctionBody", "inputSchema", "IfInput", "outputSchema", "IfOutput", "IfElseComponent", "IfElseInput", "IfElseOutput", "createIf", "createShape", "size", "width", "height", "getHeight", "ifShape", "name", "icon", "component", "getAnchors", "createFunctionAnchors", "createIfElse", "ifElseShape", "Schema", "React", "Fragment", "DEFAULT_OUTPUT", "QueueInput", "QueueOutput", "mx", "QueueShape", "extend", "ComputeShape", "Struct", "type", "Literal", "createQueue", "props", "createShape", "size", "width", "height", "QueueComponent", "shape", "runtime", "useComputeNodeState", "items", "outputs", "DEFAULT_OUTPUT", "value", "handleAction", "action", "evalNode", "React", "Box", "status", "length", "onAction", "div", "className", "map", "item", "i", "QueueItem", "key", "classNames", "mx", "Object", "entries", "Fragment", "JSON", "stringify", "queueShape", "name", "icon", "component", "getAnchors", "createFunctionAnchors", "QueueInput", "QueueOutput", "resizable", "Schema", "React", "useEffect", "useState", "DEFAULT_OUTPUT", "Icon", "createAnchorMap", "RandomShape", "extend", "ComputeShape", "Struct", "type", "Literal", "min", "optional", "Number", "max", "createRandom", "props", "createShape", "size", "width", "height", "icons", "pickIcon", "Math", "floor", "random", "length", "RandomComponent", "shape", "runtime", "useComputeNodeState", "spin", "setSpin", "useState", "icon", "setIcon", "useEffect", "i", "setInterval", "t1", "setTimeout", "clearInterval", "t2", "clearTimeout", "handleClick", "ev", "stopPropagation", "setOutput", "DEFAULT_OUTPUT", "React", "div", "className", "Icon", "classNames", "onClick", "randomShape", "name", "component", "getAnchors", "createAnchorMap", "createAnchorId", "x", "y", "Schema", "React", "DEFAULT_INPUT", "createAnchorMap", "Chaos", "shaderPresets", "useAudioStream", "ScopeShape", "extend", "ComputeShape", "Struct", "type", "Literal", "createScope", "props", "createShape", "size", "width", "height", "classNames", "ScopeComponent", "shape", "runtime", "useComputeNodeState", "input", "inputs", "DEFAULT_INPUT", "active", "value", "getAverage", "useAudioStream", "React", "div", "className", "Chaos", "getValue", "options", "shaderPresets", "heptapod", "zoom", "scopeShape", "name", "icon", "component", "getAnchors", "createAnchorMap", "createAnchorId", "x", "y", "Schema", "React", "Surface", "DEFAULT_INPUT", "createAnchorMap", "SurfaceShape", "extend", "ComputeShape", "Struct", "type", "Literal", "createSurface", "props", "createShape", "size", "width", "height", "SurfaceComponent", "shape", "runtime", "useComputeNodeState", "input", "inputs", "DEFAULT_INPUT", "value", "handleAction", "action", "evalNode", "React", "Box", "onAction", "Surface", "role", "data", "limit", "surfaceShape", "name", "icon", "component", "getAnchors", "createAnchorMap", "createAnchorId", "x", "y", "resizable", "Schema", "React", "useEffect", "useState", "DEFAULT_OUTPUT", "Input", "createAnchorMap", "SwitchShape", "extend", "ComputeShape", "Struct", "type", "Literal", "createSwitch", "props", "createShape", "size", "width", "height", "SwitchComponent", "shape", "runtime", "useComputeNodeState", "value", "setValue", "useState", "useEffect", "setOutput", "DEFAULT_OUTPUT", "React", "div", "className", "onClick", "ev", "stopPropagation", "Input", "Root", "Switch", "checked", "onCheckedChange", "switchShape", "name", "icon", "component", "getAnchors", "createAnchorMap", "createAnchorId", "x", "y", "Schema", "React", "createInputSchema", "createOutputSchema", "Message", "InputSchema", "createInputSchema", "Message", "OutputSchema", "createOutputSchema", "mutable", "Array", "TableShape", "extend", "ComputeShape", "Struct", "type", "Literal", "createTable", "props", "createShape", "size", "width", "height", "TableComponent", "shape", "React", "Box", "tableShape", "name", "icon", "component", "getAnchors", "createFunctionAnchors", "resizable", "Schema", "React", "useRef", "ComputeValueType", "TemplateOutput", "VoidInput", "getTemplateInputSchema", "toJsonSchema", "invariant", "TextBox", "TemplateShape", "extend", "ComputeShape", "Struct", "type", "Literal", "valueType", "optional", "ComputeValueType", "TextInputComponent", "shape", "title", "props", "node", "useComputeNodeState", "inputRef", "useRef", "handleEnter", "text", "value", "trim", "length", "schema", "getTemplateInputSchema", "inputSchema", "toJsonSchema", "handleTypeChange", "newType", "invariant", "is", "React", "Box", "status", "TypeSelect", "onValueChange", "TextBox", "ref", "language", "undefined", "onBlur", "onEnter", "createTemplate", "createShape", "size", "width", "height", "templateShape", "name", "icon", "component", "placeholder", "getAnchors", "createFunctionAnchors", "VoidInput", "TemplateOutput", "resizable", "Schema", "React", "DEFAULT_INPUT", "TextBox", "createAnchorMap", "TextShape", "extend", "ComputeShape", "Struct", "type", "Literal", "createText", "props", "createShape", "size", "width", "height", "TextComponent", "shape", "runtime", "useComputeNodeState", "input", "inputs", "DEFAULT_INPUT", "value", "handleAction", "action", "evalNode", "React", "Box", "onAction", "TextBox", "textShape", "name", "icon", "component", "getAnchors", "createAnchorMap", "createAnchorId", "x", "y", "resizable", "Schema", "React", "useEffect", "useRef", "createInputSchema", "createOutputSchema", "Message", "mx", "InputSchema", "createInputSchema", "Message", "OutputSchema", "createOutputSchema", "mutable", "Array", "ThreadShape", "extend", "ComputeShape", "Struct", "type", "Literal", "createThread", "props", "createShape", "size", "width", "height", "ThreadComponent", "shape", "items", "scrollRef", "useRef", "useEffect", "current", "scrollTop", "scrollHeight", "React", "Box", "div", "ref", "className", "map", "item", "i", "ThreadItem", "key", "classNames", "mx", "role", "message", "threadShape", "name", "icon", "component", "getAnchors", "createFunctionAnchors", "resizable", "Schema", "React", "createAnchorMap", "TextToImageShape", "extend", "ComputeShape", "Struct", "type", "Literal", "createTextToImage", "props", "createShape", "size", "width", "height", "TextToImageComponent", "shape", "React", "Box", "textToImageShape", "name", "icon", "component", "getAnchors", "createAnchorMap", "createAnchorId", "x", "y", "Schema", "React", "useEffect", "VoidInput", "Filter", "Obj", "Query", "Ref", "Type", "Trigger", "TriggerEvent", "DXN", "SpaceId", "useSpace", "Select", "TriggerShape", "extend", "ComputeShape", "Struct", "type", "Literal", "functionTrigger", "optional", "Type", "Ref", "Trigger", "createTrigger", "props", "make", "enabled", "spec", "createTriggerSpec", "createShape", "size", "width", "height", "getHeight", "TriggerEvent", "EmailEvent", "TriggerComponent", "shape", "space", "useSpace", "target", "useEffect", "Obj", "change", "t", "triggerKind", "spaceId", "id", "getOutputSchema", "kind", "setKind", "React", "FunctionBody", "status", "TriggerKindSelect", "value", "onValueChange", "inputSchema", "VoidInput", "outputSchema", "Select", "Root", "TriggerButton", "variant", "classNames", "Portal", "Content", "ScrollUpButton", "Viewport", "Kinds", "map", "Option", "key", "ScrollDownButton", "Arrow", "cron", "method", "query", "ast", "Query", "select", "Filter", "nothing", "dxn", "DXN", "QUEUE", "SpaceId", "random", "ID", "toString", "queue", "kindToSchema", "SubscriptionEvent", "TimerEvent", "WebhookEvent", "QueueEvent", "triggerShape", "name", "icon", "component", "getAnchors", "createFunctionAnchors", "Schema", "React", "useState", "log", "useConfig", "Icon", "GptRealtimeShape", "extend", "ComputeShape", "Struct", "type", "Literal", "createGptRealtime", "props", "createShape", "size", "width", "height", "GptRealtimeComponent", "shape", "isLive", "setIsLive", "useState", "isReady", "setIsReady", "config", "useConfig", "start", "peerConnection", "RTCPeerConnection", "ontrack", "event", "audioElement", "document", "createElement", "srcObject", "streams", "autoplay", "controls", "style", "display", "body", "appendChild", "stream", "navigator", "mediaDevices", "getUserMedia", "audio", "getTracks", "forEach", "track", "addTransceiver", "direction", "offer", "createOffer", "setLocalDescription", "AiServiceUrl", "URL", "values", "runtime", "services", "ai", "server", "DEFAULT_AI_SERVICE_URL", "response", "fetch", "method", "sdp", "headers", "answer", "text", "setRemoteDescription", "dataChannel", "createDataChannel", "configureData", "log", "info", "session", "modalities", "tools", "send", "JSON", "stringify", "addEventListener", "ev", "msg", "parse", "data", "error", "React", "div", "className", "Icon", "icon", "classNames", "onClick", "gptRealtimeShape", "name", "component", "getAnchors", "createFunctionAnchors", "Any", "resizable", "computeShapes", "title", "shapes", "constantShape", "templateShape", "chatShape", "switchShape", "audioShape", "triggerShape", "randomShape", "gptShape", "gptRealtimeShape", "functionShape", "databaseShape", "textToImageShape", "appendShape", "ifShape", "ifElseShape", "andShape", "orShape", "notShape", "reducerShape", "jsonTransformShape", "jsonShape", "queueShape", "threadShape", "textShape", "surfaceShape", "beaconShape", "scopeShape", "noteShape", "DefaultInput", "DefaultOutput", "toEffectSchema", "ShapeLayout", "ComputeShapeLayout", "ShapeLayout", "_controller", "registry", "getAnchors", "shape", "shapeDef", "_registry", "getShapeDef", "type", "anchors", "node", "graph", "getNode", "inputSchema", "outputSchema", "toEffectSchema", "DefaultInput", "DefaultOutput", "createFunctionAnchors"]
7
7
  }