agentic-canvas 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Pooria Arab
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,168 @@
1
- # Temporary Holding Version
1
+ # agentic-canvas
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![npm version](https://img.shields.io/npm/v/agentic-canvas)](https://www.npmjs.com/package/agentic-canvas)
4
+ [![MIT license](https://img.shields.io/badge/license-MIT-blue)](https://opensource.org/license/mit)
5
+
6
+ [Package](https://www.npmjs.com/package/agentic-canvas) · [Source](https://github.com/pooriaarab/agentic-canvas) · [Support](https://github.com/pooriaarab/agentic-canvas/issues)
7
+
8
+ A shared whiteboard for diagrams, drawn by people and agents.
9
+
10
+ > Status: 0.2.0. The board model, the agent operations, the exports, the CLI, the
11
+ > MCP server, a small Worker API, and live co-editing work. The CLI, the MCP server,
12
+ > and the SDK can join a live room. The web UI is not built yet.
13
+
14
+ ## Install
15
+
16
+ Node 22 or newer.
17
+
18
+ ```sh
19
+ npm install agentic-canvas
20
+ ```
21
+
22
+ To build from source instead, run `npm ci` and `npm run build`.
23
+
24
+ PNG export is optional. It needs the `playwright-core` package (Apache-2.0) and a
25
+ Chromium: `npm i playwright-core && npx playwright-core install chromium`.
26
+ The Chromium download is a one-time call to the Playwright CDN at install time. PNG export
27
+ itself makes no network call.
28
+
29
+ ## Quick start
30
+
31
+ ```sh
32
+ export CANVAS_ACTOR=agent:helper # who writes: <kind>:<id>
33
+ npx agentic-canvas new --id demo --title "Release flow"
34
+ npx agentic-canvas flow demo --text $'direction LR\nCode(Write code) -> Test{Tests pass?}: push\nTest -> Ship[Ship it]: yes'
35
+ npx agentic-canvas read demo # nodes, edges, text as JSON
36
+ npx agentic-canvas export demo --out demo.svg
37
+ npx agentic-canvas export demo --format png --out demo.png
38
+ ```
39
+
40
+ Other commands: `add`, `connect`, `move`, `rm`. Run `npx agentic-canvas --help`.
41
+ `repair` is for the owner only. It needs `CANVAS_ACTOR=human:<id>`.
42
+ Boards live in `./.agentic-canvas` (or `--dir`, or `CANVAS_DIR`). Every write
43
+ needs an actor in `CANVAS_ACTOR`, as `<kind>:<id>`. The operator sets it. A write
44
+ fails when it is unset, empty, or has a bad kind. The CLI has no `--actor` flag and no
45
+ default actor, so a caller cannot pick its own kind. Only the operator can set `human`.
46
+
47
+ ## MCP server
48
+
49
+ ```sh
50
+ CANVAS_ACTOR=agent:helper npx agentic-canvas --dir ./boards mcp
51
+ ```
52
+
53
+ The server speaks MCP on stdio. It has one tool for each CLI command: `create_board`,
54
+ `read_board`, `add_shape`, `connect`, `move`, `remove`, `draw_flow`, `export_svg`, and
55
+ `export_png`. `repair` is not a tool. Only a human operator runs it, from the CLI. The server will not start unless `CANVAS_ACTOR` is set to a valid
56
+ `<kind>:<id>`. That actor stamps every write. No tool takes an actor, author, or kind, so a
57
+ caller cannot choose who it writes as. An error comes back as a tool error with a code.
58
+
59
+ ## SDK
60
+
61
+ ```ts
62
+ import { Board } from "agentic-canvas";
63
+
64
+ const me = { kind: "human", id: "ada" } as const;
65
+ const bot = { kind: "agent_of_human", id: "helper" } as const;
66
+
67
+ const board = new Board();
68
+ board.addShape({ id: "a", type: "rect", x: 0, y: 0, text: "Start" }, me);
69
+ board.addShape({ id: "b", type: "diamond", x: 240, y: 0, text: "Ok?" }, bot);
70
+ board.addConnector({ from: { id: "a" }, to: { id: "b" }, text: "next" }, bot);
71
+ board.list(); // every element, back to front
72
+ ```
73
+
74
+ Read the board as data, and draw a flowchart from text:
75
+
76
+ ```ts
77
+ import { drawFlow, readBoard } from "agentic-canvas";
78
+
79
+ drawFlow(board, "direction LR\nS(Start) -> D{Ok?}: go\nD -> E[Done]: yes", bot);
80
+ readBoard(board); // { title, nodes, edges, groups, texts }
81
+ ```
82
+
83
+ The flow text takes one statement per line: `A -> B: label`. Use `[text]` for a
84
+ box, `(text)` for an ellipse, and `{text}` for a diamond. `direction LR` sets
85
+ the direction. Lines that start with `#` or `//` are comments.
86
+
87
+ ## Features
88
+
89
+ - Shapes: rectangle, ellipse, diamond, text, sticky note, frame, image.
90
+ - Connectors that bind to shapes and follow them when they move.
91
+ - Z-order, and groups that nest.
92
+ - Every element keeps the kind of its author and of its last editor. An agent
93
+ edit stays visible as machine-made.
94
+ - `readBoard`: nodes, edges, groups, and text as plain data, with a machine-made
95
+ flag on each.
96
+ - `drawFlow`: a flowchart from text with a layered layout. It adds nothing when
97
+ anything fails.
98
+ - `toSvg`: a deterministic SVG. It fetches nothing and marks machine-made work
99
+ with `data-machine-made`.
100
+ - `svgToPng`: PNG through a headless Chromium with JavaScript off, service workers blocked,
101
+ and every network request blocked. A board over 16 million pixels exports as SVG only.
102
+ - A CLI over a local file store. Several processes can write at once.
103
+ - An MCP server (stdio) over the same service as the CLI.
104
+ - A Worker (`agentic-canvas/worker`) under `/api/v1/canvas`. Boards live in D1 and images in R2
105
+ (EU jurisdiction), through the shared `Store` and `Blobs` ports. Set `CANVAS_API_TOKENS`
106
+ (a JSON map of token to `{ actor, kind }`, tokens of 32 characters or more) and `CANVAS_REGION`.
107
+ Routes: `POST /boards`, `GET /boards/:id`, `GET /boards/:id/svg`, `POST /boards/:id/shapes`,
108
+ `/connectors`, `/flow`, `/move`, `DELETE /boards/:id/elements/:element`, `POST /images`,
109
+ `GET /images/:id`. An image is stored under the SHA-256 of its bytes, and the reply gives
110
+ the `blob:` ref for a shape. A busy database or bucket answers 503: try again.
111
+ - Live rooms (`agentic-canvas/live-worker`, on `agentic-realtime`). One Durable Object holds one
112
+ board. A token may carry `"role": "viewer"`: a viewer reads and cannot write. `GET /boards/:id/ws`
113
+ opens a room, `GET /me` says who a token is, `GET /boards/:id/state` and
114
+ `POST /boards/:id/checkpoint` seed a room from the stored board and save it back, as a merge. A save
115
+ checks author stamps: a client cannot put another author on its work.
116
+ - The SDK joins a room: `import { LiveBoard, LiveService } from "agentic-canvas/live"`. The CLI and the MCP
117
+ server join when `CANVAS_SERVER` and `CANVAS_TOKEN` are set. The token sets the actor, so
118
+ `CANVAS_ACTOR` is not needed. `--dir`, `CANVAS_DIR`, and `repair` stay local.
119
+ - Yjs underneath: two copies of a board merge without conflicts.
120
+ - No UI code. The model is plain TypeScript on Yjs, with no outbound calls.
121
+
122
+ ## Limits
123
+
124
+ - Canvas takes principal kinds, regions, and the Store and Blobs ports from `agentic-identity` 0.4.
125
+ It does not use the sharing API yet. Its editor and viewer tokens are a separate table in
126
+ `CANVAS_API_TOKENS`. It has no board delete or erase. When it adopts sharing, grants are keyed
127
+ on kind and id, and a delete calls `deleteResource`.
128
+ - A board holds at most 10,000 elements. A flow holds at most 500 nodes and 2,000
129
+ edges.
130
+ - Flow text has no chains (`A -> B -> C`). Write one edge per line.
131
+ - `readBoard` leaves out embedded image bytes.
132
+ - Images hold a `data:` PNG, JPEG, GIF, or WebP, or a `blob:` key. Remote URLs and
133
+ SVG are refused.
134
+ - Two peers that make the same explicit id at the same time keep only one element, with no
135
+ error. Explicit ids are safe with one writer. Leave `id` empty and the board picks a random one.
136
+ - A synced update is untrusted. An element that fails the write rules is hidden, and `repair()`
137
+ deletes it. A board past the element cap refuses to load or read. A human operator runs
138
+ `repair --drop <element>` to delete elements until it fits.
139
+ - `update` cannot clear a required field. Only `fill` and `stroke` accept `undefined`.
140
+ - Z values stop at ±1e9. New elements that pass the limit land at the limit and tie with it.
141
+ While an element sits at +1e9, a front move fails with `LIMIT`. While one sits at -1e9, a back
142
+ move fails. Remove every element at the limit to clear it.
143
+ - Delete against connect can leave a connector with a missing end. Readers hide it. `repair()`
144
+ removes it, and `Board.decode` runs `repair()` for you.
145
+ - `move` writes absolute positions. Two peers that move one shape at the same time do not add up:
146
+ the last writer wins.
147
+ - Frames are plain shapes. They do not own the shapes inside them yet.
148
+ - The store is one file, `canvas.json`, in the store folder. A write takes `canvas.json.lock`.
149
+ A lock whose owner is gone, or that is older than 30 seconds, is taken over. A lock that
150
+ cannot be read counts as held: the call then waits 10 seconds and fails with `UNAVAILABLE`.
151
+ Remove the lock by hand if no process runs.
152
+ - Node 22 or newer is needed. `agentic-canvas/file-store` exports `createFileStore(path)` and
153
+ `openLocalStore(dir)`. A writer that is paused for more than 30 seconds can lose its lock
154
+ and then still write.
155
+ - A room remembers its authors for good, so a client can stamp an element with the name of anyone who
156
+ once sent an update in that room. A save corrects the stored board and not the room: after a save that
157
+ reports `fixed`, join again. A client that adds a root Yjs type of its own blocks later saves of that room.
158
+ - Every Worker token reaches every board. A token has an editor or viewer role, and nothing finer yet. Local
159
+ `wrangler dev` cannot confirm a region, so run it with `CANVAS_REGION=unknown`. The region claim covers D1 only: R2 reports no region, so the bucket is in
160
+ the EU jurisdiction only if you create it so. A real D1
161
+ confirms `eu` or `us` on each query. The Worker has no PNG export.
162
+ - Delete leaves no audit record yet. The Worker logs the actor kind of each delete, and no ids.
163
+ - PNG needs the optional `playwright-core` and a Chromium. Without them it fails with
164
+ `UNAVAILABLE`. SVG always works.
165
+
166
+ ## License
167
+
168
+ MIT.
package/SKILL.md ADDED
@@ -0,0 +1,45 @@
1
+ ---
2
+ name: agentic-canvas
3
+ description: A shared whiteboard for diagrams, drawn by people and agents. Keywords: whiteboard,canvas,diagrams,drawing,collaboration,agents,mcp,cli.
4
+ ---
5
+
6
+ # agentic-canvas
7
+
8
+ A shared whiteboard for diagrams, drawn by people and agents.
9
+
10
+ ## Use the SDK
11
+
12
+ ```js
13
+ import { Board } from "agentic-canvas";
14
+
15
+ const bot = { kind: "agent_of_human", id: "helper" };
16
+ const board = new Board();
17
+ board.addShape({ id: "a", type: "rect", x: 0, y: 0, text: "Start" }, bot);
18
+ ```
19
+
20
+ Draw a flowchart from text, then read the board:
21
+
22
+ ```js
23
+ import { drawFlow, readBoard } from "agentic-canvas";
24
+
25
+ drawFlow(board, "A[Start] -> B{Ok?}: go\nB -> C: yes", bot);
26
+ readBoard(board);
27
+ ```
28
+
29
+ ## Use the CLI
30
+
31
+ ```sh
32
+ export CANVAS_ACTOR=agent:helper
33
+ agentic-canvas new --id demo
34
+ agentic-canvas flow demo --text "A -> B: go"
35
+ agentic-canvas read demo
36
+ agentic-canvas export demo --out demo.svg
37
+ ```
38
+
39
+ To edit a board that a person has open, use live mode. Set `CANVAS_SERVER` and `CANVAS_TOKEN`
40
+ and run the same commands. The token names the actor, so leave `CANVAS_ACTOR` unset.
41
+
42
+ ## Rules
43
+
44
+ - Name the actor on every write.
45
+ - Report a `CanvasError` as a failure.