This document defines the agent-agnostic command contract for magic-crayon.
The contract defines standard edit actions against a drawing surface.
- It is transport-agnostic and framework-agnostic.
- It does not prescribe prompt strategy or image style decisions.
- It is intended for preview-and-apply workflows.
Commands use normalized canvas coordinates to support cross-device replay.
xandyare percentages in the range0..100.- Rectangles use the same normalized percentage space.
- Contract version:
1 - TypeScript contract types:
MagicCrayonCommandV1,CommandExecutionResultV1,CommandBatchResultV1,CommandApiStateV1 - Canonical command definitions live in
src/command/types.ts.
This document intentionally does not duplicate the full command union.
- Source of truth for command kinds and payload shapes:
MagicCrayonCommandV1insrc/command/types.ts. - This avoids docs drift when command types evolve.
- This page documents only cross-cutting contract guarantees and runtime semantics.
Each command execution returns:
versionstatus:applied | rejected | noopcommand- optional
reason
Batch execution returns an ordered list of per-command results.
State reads return:
versionundoSizeredoSizedocument(DrawingDocumentV1)
Recommended host flow:
- Generate a candidate command list from an agent.
- Apply list to a temporary pad for preview.
- Show before/after to user.
- On approval, apply same command list to live pad.
- On rejection, discard preview state.
- This document finalizes the v1 contract shape.
- Runtime helper entry points are available in code as
executeCommandV1,executeCommandBatchV1,getCommandApiStateV1, andcreateContext2DCommandRuntime. - Package import path for command types:
magic-crayon/command/types. - Package import path for runtime helpers:
magic-crayon/command/runtime. - Adapter-specific gaps are surfaced as
rejectedresults with reason text (for example,erase-rectrequires adapter support).