# Driving PureAnim from an AI agent **Status:** Live. **Editor:** https://flekta.app/app **This file:** https://flekta.app/agents.md **Command reference:** https://flekta.app/scripting.md --- ## Who this is for You are an AI assistant that can control a web browser, and someone has asked you to animate an SVG in PureAnim — something like *"open PureAnim, load my logo, and make the bell swing."* You do not need an API key, an account, or a PureAnim plugin. The editor has a **script console** that runs authoring commands against the open document, and every control you need to reach it has a stable `data-testid`. Your job is to operate that console. If you were instead asked to write a script for a human to paste, you only need [scripting.md](https://flekta.app/scripting.md) — stop reading here. --- ## 1. What your browser tooling must be able to do | Capability | Needed? | Used for | |---|---|---| | Navigate to a URL | **Required** | Opening the editor | | Click an element | **Required** | Menus and the Run button | | Type into a field | **Required** | Entering the script | | Read text from an element, or screenshot | **Required** | Reading results back | | Set a file on a file input | Optional | Loading the user's SVG unattended | | Evaluate JavaScript in the page | **Strongly preferred** | `window.pureanim`, which replaces most of the clicking | Chrome DevTools MCP and Playwright MCP both cover all six. A browser tool limited to click / type / screenshot still works — you read results from a screenshot of the log panel, and the user loads their own file. **Check your tool list first.** In a browser that supports WebMCP, PureAnim registers four tools — `pureanim_get_state`, `pureanim_list_commands`, `pureanim_run_script`, `pureanim_set_time`. If you can see them, use them and ignore the rest of this section; they need no selectors and no setup on your side. **Otherwise, if you can evaluate JavaScript, use `window.pureanim`.** Same executor, same guarantees, reachable from any browser: one call instead of six interactions, with results returned as JSON instead of read off a screenshot. §2 covers it. **Do not reach past it into the editor's internals.** `window.pureanim` is the only global PureAnim exposes. The document itself lives in React state you can neither see nor usefully patch, so the API and the script console are the two ways in — and both are complete. --- ## 2. The loop Every selector below is stable and safe to depend on. ### If you have tools or JavaScript, skip Steps 3–6 The user turns on **Preferences → Allow agent control** once. It is off by default and you cannot enable it yourself — ask them, in those words. That switch is what registers the WebMCP tools and installs the global; until it is on, neither exists. Four WebMCP tools appear where the browser supports them. `pureanim_run_script` is the one that authors — it takes `source`, the same script you would type into the console. `pureanim_list_commands` returns all 115 command names, so you never have to guess at the surface. To **draw something new** ("add a hamster"), call `api.createLayer({ svg })` with an SVG fragment of paths and shapes — not `pasteLayers`, which cannot parse markup inside the script sandbox. Unsupported markup (gradients, `