An open-source Python SDK for building executable learning experiences.
Project description
๐จ Agent Canvas
The executable DSL for AI-generated learning experiences
Write a lesson once in Python. Play it back anywhere โ SVG, PNG, video, or your own renderer.
๐ Quick Start โข โจ Why Agent Canvas โข ๐งฉ Features โข ๐ Architecture โข ๐บ๏ธ Roadmap โข ๐ค Contributing
โก TL;DR
Static slides and videos can't adapt to a learner. LLMs can generate great explanations โ but there's no standard, executable format for what they generate. Agent Canvas is that format.
lesson.add(RectangleCommand(...)).add(TextCommand(...))
lesson.save("hello_lesson.json") # portable, replayable, renderer-agnostic
One typed, validated JSON lesson โ rendered as SVG today, video tomorrow, an interactive canvas next quarter โ without touching your generation pipeline.
๐ง Why Agent Canvas
| The old way | With Agent Canvas |
|---|---|
| โ Static slides/videos that never adapt | โ Lessons that replay, animate, and re-render on demand |
| โ Every AI tutor invents its own ad-hoc output format | โ One typed, Pydantic-validated schema LLMs can target reliably |
| โ Content locked to a single output (a video file, a PDF) | โ Write once, render to SVG, PNG, or video via pluggable renderers |
| โ No safety net between "LLM output" and "on-screen" | โ Full validation layer catches malformed lessons before render |
Built for:
- ๐ Educational platforms generating interactive lessons from AI tutors
- ๐ Content teams building animated tutorials programmatically
- ๐ค AI agent builders who need a structured way to draw, not just talk
- ๐ Docs teams creating executable diagrams and flowcharts that stay in sync with code
๐งฉ Features
|
๐๏ธ Core DSL
๐ Type Safety |
๐ฆ Serialization
๐ Renderer-Agnostic
๐ฌ Timeline-Based Playback
|
๐ Quick Start
Ship your first lesson in under 2 minutes.
1. Install
# pip
pip install agent-canvas
# uv (recommended)
uv add agent-canvas
# editable install for contributors
git clone https://github.com/agent-canvas/agent-canvas.git
cd agent-canvas && pip install -e .
Requires Python 3.12+. Core deps:
pydantic,rich,typer,loguru,networkx,python-dotenv.
2. Build a lesson
from agent_canvas import (
Lesson,
LessonMetadata,
TextCommand,
RectangleCommand,
Point,
Size,
Bounds,
Style,
Color,
)
lesson = Lesson(
metadata=LessonMetadata(
title="Hello, Agent Canvas!",
description="A quick introduction to the SDK",
author="Your Name",
),
timeline=[
# Frame 1: draw a rectangle
{
"timestamp": 0.0,
"command": RectangleCommand(
bounds=Bounds(
position=Point(x=100, y=100),
size=Size(width=400, height=200),
),
style=Style(color=Color(value="#3B82F6"), stroke_width=2),
),
},
# Frame 2: add text
{
"timestamp": 1.0,
"command": TextCommand(
position=Point(x=300, y=200),
text="Welcome to Agent Canvas!",
font_size=24,
style=Style(color=Color(value="#1E293B")),
),
},
],
)
3. Serialize, save, reload โ anywhere
import json
json_output = lesson.model_dump_json(indent=2)
with open("hello_lesson.json", "w") as f:
f.write(json_output)
with open("hello_lesson.json") as f:
loaded = Lesson.model_validate_json(f.read())
print(f"Loaded lesson: {loaded.metadata.title}")
See the resulting JSON
{
"metadata": {
"title": "Hello, Agent Canvas!",
"description": "A quick introduction to the SDK",
"author": "Your Name",
"version": "0.1.0",
"tags": []
},
"timeline": [
{
"timestamp": 0.0,
"command": {
"command": "rectangle",
"bounds": {
"position": { "x": 100, "y": 100 },
"size": { "width": 400, "height": 200 }
},
"style": { "color": "#3B82F6", "stroke_width": 2 }
}
}
]
}
๐ Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Agent Canvas SDK โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โ
โ โ Canvas โ โ Playback โ โ Renderer โ โ
โ โ DSL โโโโโโถโ Engine โโโโโโถโ Registry โ โ
โ โ โ โ โ โ โ โ
โ โ - Models โ โ - Timeline โ โ - SVG โ โ
โ โ - Commands โ โ - Player โ โ - PNG โ โ
โ โ - Validator โ โ - Scheduler โ โ - Custom โ โ
โ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โ
โ โ โ โ
โ โผ โผ โ
โ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โ
โ โ Serializer โ โ Output โ โ
โ โ (JSON) โ โ Files โ โ
โ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
| Component | Description |
|---|---|
| Canvas DSL | Core data models and commands defining the lesson structure |
| Serializer | Converts lessons to/from JSON with validation |
| Playback Engine | Interprets timeline events for animation (planned) |
| Renderer Registry | Pluggable backend for different output formats |
| Validators | Ensures lessons conform to spec before rendering |
๐ Repository Structure
agent-canvas/
โโโ src/agent_canvas/
โ โโโ __init__.py # Public API exports
โ โโโ canvas/ # Core DSL implementation
โ โ โโโ models.py # Pydantic models (Point, Lesson, etc.)
โ โ โโโ commands/ # Command implementations
โ โ โโโ serializer.py # JSON serialization
โ โ โโโ validator.py # Lesson validation
โ โ โโโ registry.py # Renderer registry
โ โโโ renderer/ # Rendering backends
โ โโโ playback/ # Timeline playback (planned)
โ โโโ runtime/ # Runtime engine (planned)
โโโ tests/ # Test suite (288 tests)
โโโ examples/ # Usage examples
โโโ docs/ # Documentation
โโโ SPEC.md # DSL specification
โโโ pyproject.toml # Project configuration
๐งช Examples
| Example | Description |
|---|---|
hello_world.py |
Minimal lesson creation |
draw_text.py |
Text rendering with various styles |
draw_shapes.py |
Rectangles, circles, lines, arrows |
annotations.py |
Highlights and underlines |
timeline.py |
Multi-frame animations |
serialization.py |
Save/load lessons from JSON |
validation.py |
Validate lessons before rendering |
svg_export.py |
Export lesson to SVG |
png_export.py |
Export lesson to PNG |
python examples/hello_world.py
๐ Documentation
| Document | Description |
|---|---|
SPEC.md |
Complete DSL specification |
docs/ARCHITECTURE.md |
High-level architecture |
docs/CANVAS_DSL.md |
DSL reference guide |
docs/PLAYBACK.md |
Playback engine documentation |
docs/TIMELINE.md |
Timeline and animation guide |
docs/RUNTIME.md |
Runtime engine docs |
docs/ROADMAP.md |
Future development plans |
๐บ๏ธ Roadmap
v0.1.0 โ Current โ Core Canvas DSL ย ยทย โ Pydantic models ย ยทย โ JSON serialization ย ยทย โ Validation ย ยทย โ Renderer registry ย ยทย โ Type safety ย ยทย โ 288-test suite
v0.2.0 โ Next
- SVG renderer implementation
- PNG renderer implementation
- CLI tool for lesson preview
- Enhanced animation support
- Custom easing functions
v0.3.0
- HTML5 Canvas renderer
- Interactive playback mode
- Lesson composition utilities
- Performance optimizations
v1.0.0
- Stable public API
- Production-ready renderers
- Comprehensive documentation
- Integration examples
๐ค Contributing
Contributions make this project better โ issues, PRs, and ideas are all welcome. See the Contributing Guide.
# Fork and clone
git clone https://github.com/YOUR_USERNAME/agent-canvas.git
cd agent-canvas
# Set up environment
uv sync --all-groups
# Run tests
pytest
# Lint and type check
ruff check .
mypy src
All PRs must pass CI (Ruff + MyPy + pytest) before merging.
๐ฌ Support
Need help? Check the Support Guide for bug reports, feature requests, questions, and commercial support.
๐ Acknowledgments
Agent Canvas draws inspiration from Manim, Pydantic, Rich, and Textual.
๐ License
Agent Canvas is licensed under the MIT License.
If Agent Canvas is useful to you, a โญ on GitHub goes a long way.
Built with โค๏ธ for educators and developers
Report Issue โข Discussions โข Changelog
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agent_draw-0.1.0.tar.gz.
File metadata
- Download URL: agent_draw-0.1.0.tar.gz
- Upload date:
- Size: 29.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ce375cdc8d6cf8395181540dd0ce2934e2b58cbcbba830963d8d701d6ae1a6d
|
|
| MD5 |
ee5f7e1b09aa5f6f50c3c7e44e0477e1
|
|
| BLAKE2b-256 |
dd457e71a50b6c9b47b4cc80647ae999aa388ccfbcd885005119ab4c2b2318b4
|
File details
Details for the file agent_draw-0.1.0-py3-none-any.whl.
File metadata
- Download URL: agent_draw-0.1.0-py3-none-any.whl
- Upload date:
- Size: 39.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f067f2fcabb20bc0da489a03b680d7fdb3526fa3c2bfce16142c47a49725346d
|
|
| MD5 |
217f1575db303351dae57190143eaa86
|
|
| BLAKE2b-256 |
9cf9a442fe954217e662d9aeebef703f0aa382cc9eb262ef02b052b6f22a286f
|