import type { EntityId, Vec2 } from '../core/types'; import { EventBus } from '../core/EventBus'; export type PortDataType = 'flow' | 'boolean' | 'number' | 'string' | 'vec2' | 'color' | 'entity' | 'any'; export type PortDirection = 'input' | 'output'; export interface PortDef { id: string; name: string; direction: PortDirection; dataType: PortDataType; defaultValue?: unknown; /** Whether multiple connections are allowed (outputs only). */ multi?: boolean; } export type NodeCategory = 'flow' | 'math' | 'logic' | 'entity' | 'input' | 'physics' | 'audio' | 'ui' | 'game' | 'variable' | 'custom'; export interface NodeDef { type: string; name: string; category: NodeCategory; description: string; color?: string; ports: PortDef[]; /** Execute the node given input values, return output values. */ execute: (inputs: Record, context: NodeExecutionContext) => Record | void; } export interface NodeExecutionContext { entityId: EntityId | null; dt: number; world: unknown; events: EventBus; variables: Record; services: Record; /** Trigger an output flow port. */ triggerFlow: (portId: string) => void; } export interface NodeInstance { id: string; type: string; position: Vec2; /** Override default values for input ports. */ inputValues: Record; /** Cached output values after execution. */ outputValues: Record; comment?: string; } export interface Connection { id: string; fromNode: string; fromPort: string; toNode: string; toPort: string; } export interface ScriptGraph { id: string; name: string; nodes: NodeInstance[]; connections: Connection[]; variables: GraphVariable[]; /** Graph-level inputs (parameters) for subgraph use. */ parameters: PortDef[]; } export interface GraphVariable { name: string; type: PortDataType; value: unknown; scope: 'local' | 'global'; } export declare class NodeLibrary { private defs; register(def: NodeDef): void; get(type: string): NodeDef | undefined; getAll(): NodeDef[]; getByCategory(category: NodeCategory): NodeDef[]; search(query: string): NodeDef[]; } export declare class GraphExecutor { readonly events: EventBus; private library; constructor(library: NodeLibrary); /** Execute a graph starting from an entry node (e.g. "on_start", "on_update"). */ execute(graph: ScriptGraph, entryType: string, context: NodeExecutionContext): void; private executeNode; } export declare function registerBuiltInNodes(library: NodeLibrary): void; export declare function createDefaultNodeLibrary(): NodeLibrary;