canvas

package
v0.14.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package canvas mutates a Workflow's graph atomically. Used by MCP canvas ops (`workflow_add_node`, `workflow_connect`, ...) and by the UI inspector when the operator edits in the visual editor.

Each mutation returns the updated workflow so callers can persist it via service.Update. Mutations never partially apply — if validation fails post-edit, the workflow is returned unchanged.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Canvas

type Canvas struct {
	Service service.Service
}

Canvas wraps a Service for atomic graph edits.

func New

func New(svc service.Service) *Canvas

New binds a Canvas to a Service.

func (*Canvas) AddNode

func (c *Canvas) AddNode(id string, n workflow.Node) (workflow.Workflow, error)

AddNode appends a node to the workflow.

func (*Canvas) AutoLayout added in v0.14.20

func (c *Canvas) AutoLayout(id string, nodeIDs []string) (workflow.Workflow, error)

AutoLayout computes DAG-aware positions and applies them in one draft mutation. nodeIDs restricts re-layout to those IDs only; empty = lay out ALL graph nodes and triggers. Positions for IDs outside scope are preserved.

func (*Canvas) Connect

func (c *Canvas) Connect(id, fromID, toID, caseLabel string) (workflow.Workflow, error)

Connect adds an edge.

func (*Canvas) DeleteNode

func (c *Canvas) DeleteNode(id, nodeID string) (workflow.Workflow, error)

DeleteNode removes a node and every edge touching it.

func (*Canvas) Disconnect

func (c *Canvas) Disconnect(id, fromID, toID string) (workflow.Workflow, error)

Disconnect removes an edge.

func (*Canvas) MoveNode

func (c *Canvas) MoveNode(id, nodeID string, x, y int) (workflow.Workflow, error)

MoveNode updates canvas position metadata.

func (*Canvas) MoveNodes added in v0.14.20

func (c *Canvas) MoveNodes(id string, moves []NodeMove) (workflow.Workflow, error)

MoveNodes batch-updates canvas positions in a single draft mutation. Cheaper than N serial MoveNode calls; avoids partial-update races.

func (*Canvas) SetTriggers

func (c *Canvas) SetTriggers(id string, triggers []workflow.Trigger) (workflow.Workflow, error)

SetTriggers replaces the trigger list.

func (*Canvas) Toggle

func (c *Canvas) Toggle(id string, enabled bool) (workflow.Workflow, error)

Toggle flips enabled.

func (*Canvas) UpdateNode

func (c *Canvas) UpdateNode(id, nodeID string, patch map[string]any) (workflow.Workflow, error)

UpdateNode merges a patch into an existing node.

type NodeMove added in v0.14.20

type NodeMove struct {
	NodeID string `json:"node_id"`
	X      int    `json:"x"`
	Y      int    `json:"y"`
}

NodeMove carries a new canvas position for one node.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL