import type { SerializedNode, SetTransformMessage, SetMaterialMessage, AddObjectPayload, BoundsResult, DistanceResult, FrustumResult, AnimationInfo, AnimationControlResult, PhysicsResult, PerformanceResult, ProfileResult, InjectionEntry } from './types.js'; export type TransformInput = Omit; export type MaterialInput = Omit; export interface WebSocketManagerOptions { /** Port for the WebSocket server. Default: 3333 */ port: number; } /** * Runs a WebSocket **server** that the MCPProvider (browser) connects to. * Provides a typed async API for each MCP tool — all requestId correlation * and timeout logic lives here so callers just `await` a Promise. * * Architecture: * Claude / Cursor * ↕ MCP stdio * WebSocketManager ← this class, Node.js process * ↕ ws://localhost:PORT * SceneBridge inside MCPProvider ← browser, inside R3F */ export declare class WebSocketManager { private readonly port; private wss; /** The single authenticated browser client. */ private client; /** * Connections that have opened but have not yet sent a valid handshake. * Value is the timeout handle that will close the socket if it stays silent. */ private readonly pendingSockets; /** * In-flight requests keyed by requestId. Each entry holds resolve/reject * callbacks plus a timeout handle, enabling multiple concurrent requests. */ private readonly pending; /** Snapshot stored by scene_graph and scene_diff tools for diffing. */ private lastSnapshot; /** * Code registry for injected preview components. * Keyed by injection name — populated when inject_code confirms success. * Used by commit_component to write code to disk. */ private injectionRegistry; constructor(options: WebSocketManagerOptions); storeSnapshot(scene: SerializedNode): void; getLastSnapshot(): { scene: SerializedNode; timestamp: string; } | null; /** Bind the port and start accepting browser connections. */ listen(): Promise; /** Close the server and reject all pending requests. */ close(): Promise; private handleHandshake; /** * Send a typed command to the browser and await the matching response. * Rejects after REQUEST_TIMEOUT_MS if no response arrives. */ private sendRequest; private handleIncoming; /** Atomically reject and discard all in-flight requests. */ private rejectAll; /** Fetch a complete serialized snapshot of the Three.js scene graph. */ requestSceneGraph(): Promise; /** * Fetch a single object by UUID or name. * Returns null when no object matches — does not throw. */ requestObject(identifier: string): Promise; /** Apply a partial transform to an object. Returns true on success. */ requestTransformEdit(identifier: string, transform: TransformInput): Promise; /** Apply material property overrides to an object. Returns true on success. */ requestMaterialEdit(identifier: string, properties: MaterialInput): Promise; /** Toggle the visibility of an object. Returns true on success. */ requestVisibilityEdit(identifier: string, visible: boolean): Promise; /** * Capture a screenshot of the current frame. * Returns a raw base64-encoded JPEG string (no data-URL prefix). */ requestScreenshot(width?: number, height?: number): Promise; /** Create a new object in the scene. Returns the UUID and name of the created object. */ requestAddObject(payload: AddObjectPayload): Promise<{ uuid: string; name: string; }>; /** Remove an object (and its children) from the scene by UUID or name. */ requestRemoveObject(identifier: string): Promise<{ uuid: string; name: string; }>; /** Get the world-space axis-aligned bounding box of an object. */ requestQueryBounds(identifier: string): Promise; /** Measure world-space distance between two objects. */ requestQueryDistance(fromId: string, toId: string): Promise; /** List all objects visible in the camera frustum. */ requestQueryFrustum(cameraId?: string): Promise; /** List all active animations in the scene. */ requestGetAnimations(identifier?: string): Promise<{ animations: AnimationInfo[]; totalAnimations: number; }>; /** Play, pause, stop, or seek an animation. */ requestControlAnimation(target: string, action: 'play' | 'pause' | 'stop' | 'seek', time?: number, animationName?: string): Promise; /** Read the Rapier physics world state. */ requestGetPhysics(identifier?: string): Promise; /** Get a single-frame performance snapshot. */ requestGetPerformance(): Promise; /** * Run a profiling session for `durationSec` seconds and return aggregated stats. * Uses an extended timeout (duration + 10 s) so the request never races the profile. */ requestGetPerformanceProfile(durationSec: number): Promise; /** * Inject component code into the browser for immediate live preview. * On success, the code is stored in the registry for later commit. */ requestInjectCode(code: string, name: string, replace?: string): Promise<{ success: boolean; uuid: string; name: string; error?: string; }>; /** Remove a live preview injection from the browser. */ requestRemoveInjection(name: string): Promise<{ success: boolean; name: string; }>; /** List all currently active live preview injections. */ requestListInjections(): Promise; /** * Retrieve an injection's source code from the registry. * Used by commit_component to write it to disk. */ getInjectionCode(name: string): { code: string; uuid: string; } | null; getInjectionRegistry(): ReadonlyMap; } //# sourceMappingURL=connection.d.ts.map