With this, a member of your mind can watch an agent build an interface while it talks: chat on the left, a live canvas on the right, and every step the agent takes changes the canvas in place. Nothing is generated as a file and reloaded. The agent edits the DOM directly, so a counter appears while the answer is still being written, and a second request changes the same elements instead of starting again. It is a playground for members, not a public app builder.
The canvas is lent, not stored
Each browser tab is a session, and each session is an ordinary agent at /agents/canvas2/<member user id>/<session>, so the chat stays in that agent's log like any other. The canvas is something else: the DOM of a frame in that one tab. The page lends the agent one function on that agent's context alone, for as long as its socket is open:
// in public/app.js: the lend ends when the tab closes or the session resets
const lend = await itx.cd(AGENT).provide("itx.canvas", (code) => canvas.run(code), { description });
// in the agent's own script: runs in the member's canvas, answers what it returned
await itx.canvas(`document.body.append(h("button", { id: "inc", onclick: () => count++ }, "+"))`);
Close the tab and the name is gone from the agent's tree; its next call fails, and its instructions tell it to say so rather than pretend. Another session's agent never sees this canvas.
A sandbox around the agent's code
The agent writes arbitrary JavaScript, so the frame is sandboxed with scripts but without allow-same-origin, and the frame's own response carries the same sandbox in its content security policy. Its origin is opaque: no cookies of the mind, no storage, no reach into the page around it, and no way to open the member's socket. Page and frame talk only by postMessage, and each side checks the sender's window, its origin and a per-frame nonce. The member's page, which does hold the member's connection to the mind, never runs the agent's code.
Checkpoints and scrawls
Live does not mean lost. After thirty seconds of stillness the frame takes an idle checkpoint: the DOM as HTML (typed values kept, password and card fields left out), a picture of it drawn from the DOM, and the scrawl state. The page keeps it under the agent's path and adds a passive note to the agent's context that starts no model request; the next turn a person starts can read it, and a member can ask the agent to restore the canvas from it. A restore brings back markup, styles and form values, not JavaScript state, so the agent wires the controls again. Identical states are kept once, and the number and size of checkpoints are bounded.
A member can also scrawl: hold Shift and draw round the thing they mean, drop numbered pins, and type what they want. The agent gets a contact sheet of keyframes and a handle on each marked element. No microphone and no screen capture are ever asked for.
Adapting the pattern
Copy the apps/canvas2/ folder, mount it behind this.auth.require, and point your agents backend at its agent.md for the session agents. Test that a signed-out visitor gets nothing, that a closed tab ends the lend, that two tabs never see each other's canvas, and that the agent's code cannot reach the page or its cookies. Agents explains the authenticated socket the page uses; the blog keeps this recipe current when the app's code changes.