{
  "title": "Canvas (macOS app)",
  "content": "The macOS app embeds an agent‑controlled **Canvas panel** using `WKWebView`. It\nis a lightweight visual workspace for HTML/CSS/JS, A2UI, and small interactive\nUI surfaces.\n\n## Where Canvas lives\n\nCanvas state is stored under Application Support:\n\n* `~/Library/Application Support/OpenClaw/canvas/<session>/...`\n\nThe Canvas panel serves those files via a **custom URL scheme**:\n\n* `openclaw-canvas://<session>/<path>`\n\n* `openclaw-canvas://main/` → `<canvasRoot>/main/index.html`\n* `openclaw-canvas://main/assets/app.css` → `<canvasRoot>/main/assets/app.css`\n* `openclaw-canvas://main/widgets/todo/` → `<canvasRoot>/main/widgets/todo/index.html`\n\nIf no `index.html` exists at the root, the app shows a **built‑in scaffold page**.\n\n* Borderless, resizable panel anchored near the menu bar (or mouse cursor).\n* Remembers size/position per session.\n* Auto‑reloads when local canvas files change.\n* Only one Canvas panel is visible at a time (session is switched as needed).\n\nCanvas can be disabled from Settings → **Allow Canvas**. When disabled, canvas\nnode commands return `CANVAS_DISABLED`.\n\nCanvas is exposed via the **Gateway WebSocket**, so the agent can:\n\n* show/hide the panel\n* navigate to a path or URL\n* evaluate JavaScript\n* capture a snapshot image\n\n* `canvas.navigate` accepts **local canvas paths**, `http(s)` URLs, and `file://` URLs.\n* If you pass `\"/\"`, the Canvas shows the local scaffold or `index.html`.\n\nA2UI is hosted by the Gateway canvas host and rendered inside the Canvas panel.\nWhen the Gateway advertises a Canvas host, the macOS app auto‑navigates to the\nA2UI host page on first open.\n\nDefault A2UI host URL:\n\n### A2UI commands (v0.8)\n\nCanvas currently accepts **A2UI v0.8** server→client messages:\n\n* `beginRendering`\n* `surfaceUpdate`\n* `dataModelUpdate`\n* `deleteSurface`\n\n`createSurface` (v0.9) is not supported.\n\n## Triggering agent runs from Canvas\n\nCanvas can trigger new agent runs via deep links:\n\n* `openclaw://agent?...`\n\nThe app prompts for confirmation unless a valid key is provided.\n\n* Canvas scheme blocks directory traversal; files must live under the session root.\n* Local Canvas content uses a custom scheme (no loopback server required).\n* External `http(s)` URLs are allowed only when explicitly navigated.",
  "code_samples": [
    {
      "code": "Notes:\n\n* `canvas.navigate` accepts **local canvas paths**, `http(s)` URLs, and `file://` URLs.\n* If you pass `\"/\"`, the Canvas shows the local scaffold or `index.html`.\n\n## A2UI in Canvas\n\nA2UI is hosted by the Gateway canvas host and rendered inside the Canvas panel.\nWhen the Gateway advertises a Canvas host, the macOS app auto‑navigates to the\nA2UI host page on first open.\n\nDefault A2UI host URL:",
      "language": "unknown"
    },
    {
      "code": "### A2UI commands (v0.8)\n\nCanvas currently accepts **A2UI v0.8** server→client messages:\n\n* `beginRendering`\n* `surfaceUpdate`\n* `dataModelUpdate`\n* `deleteSurface`\n\n`createSurface` (v0.9) is not supported.\n\nCLI example:",
      "language": "unknown"
    },
    {
      "code": "Quick smoke:",
      "language": "unknown"
    },
    {
      "code": "## Triggering agent runs from Canvas\n\nCanvas can trigger new agent runs via deep links:\n\n* `openclaw://agent?...`\n\nExample (in JS):",
      "language": "unknown"
    }
  ],
  "headings": [
    {
      "level": "h2",
      "text": "Where Canvas lives",
      "id": "where-canvas-lives"
    },
    {
      "level": "h2",
      "text": "Panel behavior",
      "id": "panel-behavior"
    },
    {
      "level": "h2",
      "text": "Agent API surface",
      "id": "agent-api-surface"
    },
    {
      "level": "h2",
      "text": "A2UI in Canvas",
      "id": "a2ui-in-canvas"
    },
    {
      "level": "h3",
      "text": "A2UI commands (v0.8)",
      "id": "a2ui-commands-(v0.8)"
    },
    {
      "level": "h2",
      "text": "Triggering agent runs from Canvas",
      "id": "triggering-agent-runs-from-canvas"
    },
    {
      "level": "h2",
      "text": "Security notes",
      "id": "security-notes"
    }
  ],
  "url": "llms-txt#canvas-(macos-app)",
  "links": []
}