Protocol Overview

The Diagram Scene Protocol (DSP) is a structured format for creating and manipulating diagrams programmatically. It defines how scenes are structured, how operations mutate scenes, and how validation ensures correctness.

Design principles

  1. Operations, not pixels — Agents work with typed operations (createNode, createEdge, move) rather than pixel coordinates and mouse events
  2. Validation-first — Every operation and scene state is validated against 40+ rules before execution
  3. Immutable revisions — Each operation creates a new revision. No destructive mutations.
  4. Format-agnostic — The scene model is independent of rendering format (SVG, PNG, Excalidraw)

Scene structure

A DSP scene contains:

{
  "schemaVersion": "0.1",
  "scene": {
    "id": "unique-id",
    "title": "My Diagram",
    "units": "px",
    "canvas": { "width": 1200, "height": 800, "background": "#ffffff" }
  },
  "elements": [],
  "styles": {},
  "assets": {},
  "constraints": []
}

Element kinds

KindDescription
nodeA shape with a label (rect, roundedRect, ellipse, diamond, cylinder, pill, hexagon, parallelogram, cloud)
edgeA connection between two nodes
groupA logical grouping of elements
frameA visual container with a title bar
textA standalone text block
imageAn image element
guideA horizontal or vertical alignment guide

Layout modes

Constraints

Constraints enforce spatial relationships between elements: