import type { NodeType } from "@/types/canvas"; export type CanvasAgentSource = "canvas" | "realtime-canvas"; export type CanvasAgentFocusPolicy = | "auto" | "selected" | "latest_result" | "original" | "slot"; export type CanvasAgentSlotType = "image" | "video" | "ui-screen"; export type CanvasAgentSlotFillPolicy = | "replace-empty" | "append-version" | "replace-existing"; export type CanvasAgentSlotAcceptedSource = | "text" | "image" | "selection" | "annotation"; export interface CanvasViewportContext { x: number; y: number; zoom: number; width?: number; height?: number; } export type CanvasAgentNodeType = NodeType | "agent-slot"; export interface CanvasAgentNodeRef { nodeId: string; type: CanvasAgentNodeType; assetId?: string; url?: string; title?: string; prompt?: string; x: number; y: number; width?: number; height?: number; isSelected?: boolean; metadata?: { sourceNodeId?: string; revisionOf?: string; generatedByAgent?: boolean; model?: string; taskId?: string; role?: string; [key: string]: unknown; }; } export interface CanvasAgentSlotRef { nodeId: string; slotType: CanvasAgentSlotType; label?: string; x: number; y: number; width: number; height: number; aspectRatio: string; isSelected?: boolean; fillPolicy: CanvasAgentSlotFillPolicy; acceptedSources?: CanvasAgentSlotAcceptedSource[]; } export interface CanvasAgentSlotSpec { slotType: CanvasAgentSlotType; label?: string; aspectRatio?: string; fillPolicy?: CanvasAgentSlotFillPolicy; acceptedSources?: CanvasAgentSlotAcceptedSource[]; } export interface CanvasAgentAnnotationRef { id: string; sourceNodeId: string; type: "text-note" | "arrow-note" | "box" | "freehand" | "crop-box"; text?: string; bounds?: { x: number; y: number; width: number; height: number; }; targetPoint?: { x: number; y: number; }; color?: string; createdAt?: string; } export interface CanvasAgentContext { version: 1; source: CanvasAgentSource; projectId?: string; canvasRevision?: string; canvasUpdatedAt?: string; viewport?: CanvasViewportContext; selectedNodeIds: string[]; selectedNodes: CanvasAgentNodeRef[]; candidateNodes: CanvasAgentNodeRef[]; slots: CanvasAgentSlotRef[]; annotations: CanvasAgentAnnotationRef[]; focusPolicy: CanvasAgentFocusPolicy; } export type CanvasOperationKind = | "create_agent_slot" | "create_text_node" | "fill_slot" | "insert_beside" | "append_revision" | "replace_node_media" | "add_annotation" | "link_nodes" | "move_nodes" | "delete_nodes" | "rename_node" | "update_note" | "update_text"; export interface CanvasMediaItem { mediaItemId: string; type: "image" | "video" | "model3d" | "world3d"; url: string; assetId?: string; width?: number; height?: number; title?: string; prompt?: string; sourceNodeIds?: string[]; metadata?: Record; } export interface CanvasOperationPlan { version: 1; operationId: string; operation: CanvasOperationKind; projectId: string; baseCanvasRevision?: string; baseCanvasUpdatedAt?: string; sourceNodeIds?: string[]; targetNodeIds?: string[]; targetSlotId?: string; anchorNodeId?: string; edgeType?: "default" | "reference" | "conversation"; textContent?: string; confirmed?: boolean; layoutStrategy?: "row" | "column" | "grid"; spacing?: number; targetPosition?: { x: number; y: number; }; slot?: CanvasAgentSlotSpec; annotations?: Array< Partial & { type: CanvasAgentAnnotationRef["type"]; } >; placement?: "right" | "left" | "below" | "above" | "viewport-center"; placementStrategy?: "single" | "row" | "grid" | "overlay" | "beside_each_source"; preserveOriginal?: boolean; media?: Omit; mediaItems?: CanvasMediaItem[]; metadata?: Record; } export type CanvasViewOperationKind = | "focus_node" | "focus_nodes" | "focus_selection" | "focus_latest_result" | "fit_all" | "zoom_in" | "zoom_out" | "zoom_to" | "pan_to"; export interface CanvasViewOperationPlan { version: 1; viewOperationId: string; operation: CanvasViewOperationKind; projectId?: string; nodeIds?: string[]; anchorNodeId?: string; zoom?: number; padding?: number; durationMs?: number; persist?: false; center?: { x: number; y: number; }; reason?: string; }