An agent operating a canvas UI, drawn as it happens

A booking form drawn through a shader, leaning in perspective. It offers three tools to an agent. Press "Run the scripted agent", or type a request: each tool call turns the panel to face you, moves a marker to the field and types into the real input.

Book a berth

    Show the code tools for an agent, and a shader that shows each call
    1. An ordinary form with one attribute. fx="agent" draws it through the shader below. It's still a form: you can fill it in by hand.
    2. The tools. Three functions with a name, a description and a JSON schema. Each returns when its animation is over.
    3. Give the tools to the browser's agent. navigator.modelContext is WebMCP. Both spellings of the registration call are tried.
    4. Show a call: four custom properties. The tool writes the lean and the marker position to the form's style.
    5. CSS transitions move them. The properties are registered as numbers, so they animate.
    6. The shader reads them as uniforms. geometry() returns the perspective matrix for hit testing; the fragment function draws the form, dims it away from the marker and draws the rings. GLSL and WGSL.
    7. A request in words, with the Prompt API. The model answers with JSON constrained to the tool names.
    8. Without a model: a pattern matcher.
    9. Ask the model what it sees. The picture is taken from the canvas after the shader has run.
    10. The whole tools file.

    What the model sees

    The button takes the picture that the canvas shows, after the shader, and gives it to the Prompt API with a question. Without a model that accepts images, the picture is still taken and shown here, and the answer line says what is missing.

    How it works

    The form is one drawable element. fx uploads it to a texture on every paint and a fragment shader draws it, with WebGPU when that works and WebGL otherwise. The shader has no state of its own: the lean and the marker position are CSS custom properties on the form, and the tool code only changes those properties and the form's values. ariaNotify() announces each step, because a marker drawn by a shader isn't in the accessibility tree.

    The same three tool objects are used by every caller on this page: the browser's agent through WebMCP when navigator.modelContext exists, the scripted run, the Prompt API planner and the pattern matcher. The log names the caller of each call.

    Live checks

    ResultExperimentDetail

    Findings