# a2ui

> Compose, validate, persist, and render A2UI v0.9.1 surfaces for Harness sessions in chat and on an injectable Console page.

| field | value |
|-------|-------|
| version | 0.2.1 |
| type | binary |
| license | Apache-2.0 |
| repo | https://github.com/iii-hq/workers |
| supported_targets | x86_64-apple-darwin, aarch64-apple-darwin, x86_64-pc-windows-msvc, aarch64-pc-windows-msvc, x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu, x86_64-unknown-linux-musl, armv7-unknown-linux-gnueabihf |
| author | iii |

## installation

```sh
iii call compose::add worker=a2ui@0.2.1
```

## dependencies

- `configuration` @ `latest`
- `harness` @ `latest`
- `ide` @ `latest`
- `llm-router` @ `latest`
- `state` @ `latest`

## readme

# a2ui

The A2UI worker turns compact agent intent into validated A2UI v0.9.1 surfaces, stores them under the originating Harness conversation, renders them inline in chat and on an injectable Console page, and sends user actions back to the same conversation.

## Install

```bash
iii call compose::add worker=a2ui
```

## Quickstart

Call `a2ui::generate` from a Harness turn. The Harness hook supplies the authoritative session, and the worker reads that turn's routed model, so the agent only sends intent and data:

```json
{
  "description": "A deployment approval card with service, version, risk, and approve or reject actions.",
  "data": {
    "service": "payments-api",
    "version": "2026.08.20",
    "risk": "medium"
  },
  "surface_id": "deployment-approval"
}
```

The call returns a compact receipt such as `{ "surface_id": "deployment-approval", "revision": 3, "component_count": 11, "page": "a2ui" }`. `page` is the console page id: an agent opens it with `ade::workspace::open { screen: "ext:a2ui" }`. The Console keeps that receipt visible in the chat feed and expands it into the full surface on selection, while the A2UI page keeps every surface in the active conversation live by observing `state::on-changed` filtered on the session's own entry (`{ "input.scope": { "$eq": "a2ui" }, "input.key": { "$eq": <session_id> } }`).

Patch an existing surface with another natural-language request. Supplying `expected_revision` prevents an older composition from overwriting a newer edit:

```json
{
  "surface_id": "deployment-approval",
  "instruction": "Add an owner field and make the risk more prominent.",
  "expected_revision": 3
}
```

Interactive surfaces automatically submit their complete bound data model with button actions, so form values are persisted and forwarded to the originating Harness turn. The page also supports bounded revision history and undo, pinning, duplication, JSON import/export, and a per-session template library.

### Live bindings

`a2ui::binding::set` binds a JSON Pointer in the surface data model to live data. A binding names a function to observe, with `args` when the function takes them and `filters` on its calls. The Console page observes it for its own view (`capture: ["output"]`, so each event is the function's return value) and stores each delivered value, so a binding is active while the surface is open. Bindings are declarative and cannot invoke arbitrary functions. A surface holds at most 32 bindings.

- **A worker's event function** (recommended): `function_id` is a private function another worker hosts (registered with `private: true`, its handler returning the event), for example `orders::on-changed`. The function must be registered when the binding is set and each time it is refreshed. A function that is not private, such as `state::set`, is rejected. `args` are validated against the `args_format` the function registered, and a function without one takes no args: select its calls with `filters` on `input.<field>`. In event mode, each event (or `event_path` inside it) is applied. With a `query`, the event is only a notification. The page reads the query when it opens the surface (after observing) and again after each notification, through the Console-only `a2ui::binding::refresh`. That covers the initial read, recovery after a reconnect and latest-state semantics. The query function must be registered by the same worker as the observed function, with metadata `{"read_only": true}`, and its payload is validated against the function's request schema.
- **`state::on-changed`** takes no args and exactly the filters `{ "input.scope": { "$eq": <scope> }, "input.key": { "$eq": <key> } }`; the page reads the entry with `state::get` on each event. **`shell::on-changed`** takes exactly the args `{ "path": <path> }`.
- Reserved functions are rejected: `engine::*`, `harness::*`, `browser::*` (Console-side observation would bypass Browser approval boundaries), `a2ui::*`, `observability::*` (each applied value logs and traces again), `iii::*`, any id with a `hook` segment, `http::on-request`, `cron::on-tick`, `queue::on-message`, `publish`, `stream::on-join`, `stream::on-leave` and `ade::ui::asset`.
- **`stream::on-changed`** (filters on `input.stream_name` and `input.group_id`, optional `input.id`) is deprecated legacy compatibility. It is still accepted and keeps working on engines that run iii-stream. The receipt carries a `deprecation` notice, the worker logs a warning, and the page marks the surface. Move these bindings to the producing worker's own event function; see the guide "Migrate from iii-stream and pubsub".

A binding stored under iii 0.25, with `trigger_type` and `config`, loads as the function that replaced the type: `state` as `state::on-changed` with `scope` and `key` filters, `shell::changed` as `shell::on-changed` with `config` as args, `stream` as `stream::on-changed` with `stream_name`, `group_id` and `item_id` (`input.id`) filters, and a worker's `W::X` as `W::on-X`. For `W::on-X` the worker reads `engine::functions::info` when the session loads: `config` (without `metadata` and `condition_function_id`) becomes the args when the function registered an `args_format`, and one `{ "input.<field>": { "$eq": <value> } }` filter per field when it takes none. The result passes the same checks as `a2ui::binding::set`. When the function is not registered or a check fails, the binding moves to the surface's `retired_bindings` (`{ id, function_id, reason }`) and the page lists it; `a2ui::binding::set` with the same id replaces it and `a2ui::binding::delete` removes it. The surface's next change writes the result back in the current shape.

The runnable provider in `examples/counter_provider/` (`cargo run --example counter_provider -- ws://127.0.0.1:49134`) hosts one event function:

| Function | Args | Delivery | Event |
|---|---|---|---|
| `demo::on-counter-changed` | `{ counter }`, 1-64 bytes (`INVALID_ARGS` otherwise) | observers whose `args.counter` is the event's `counter`; at most 64 observers: an observer added while 64 are active is rejected with `OBSERVER_LIMIT` | `{ counter, revision }`, called after each committed `demo::counter::bump` |

An observer of it, from any worker:

```typescript
const clicks = iii.observe(
  { function_id: 'demo::on-counter-changed', args: { counter: 'clicks' }, capture: ['output'] },
  'my-app::on-clicks', // receives the Observed envelope; output is { counter, revision }
)
await clicks.ready() // rejected with OBSERVER_LIMIT past 64 observers
```

A binding to it:

```json
{
  "surface_id": "clicks",
  "binding": {
    "id": "clicks-count",
    "function_id": "demo::on-counter-changed",
    "args": { "counter": "clicks" },
    "target_path": "/count",
    "query": {
      "function_id": "demo::counter::get",
      "payload": { "counter": "clicks" },
      "result_path": "/value"
    }
  }
}
```

The A2UI page does not replace or embed itself in Shell or Browser. Its workspace action materializes a complete runnable React project under `generated/a2ui/<surface>-r<revision>` in the active Harness working directory. Shell then shows the real source files and Git diffs for editing. Run the generated Vite app in Shell and open its local URL in the Browser worker for preview. The same runnable project is available as a React app ZIP through `a2ui::surface::export-code`; JSON exports remain portable through `a2ui::surface::import`.

## Session stamping

Every session-scoped A2UI function takes its session from the Harness, not from the caller. The worker observes `harness::hook::on-pre-call` with `a2ui::stamp-session` and args `{ functions: [<the A2UI functions>], timeout_ms: 5000, on_error: "fail_closed" }`; before one of those functions runs, the hook writes the turn's `session_id` into its arguments, and a hook failure denies the call.

## Configuration

The `configuration` worker stores this worker's live settings, and the worker observes `configuration::on-updated` for its entry to reload them. An optional `--config` YAML file seeds them on first boot:

```yaml
composer_model: null          # inherit the Harness turn's model
composer_provider: null       # inherit its routed provider
max_output_tokens: 8192       # one composition or repair call
max_composer_input_bytes: 786432
repair_attempts: 1            # bounded validation correction
max_surfaces_per_session: 16
max_history_per_surface: 64
max_templates_per_session: 32
max_components_per_surface: 160
max_description_bytes: 32768
max_data_bytes: 524288
max_surface_bytes: 2097152     # current surface plus bounded history
max_session_bytes: 16777216    # surfaces, histories, and templates
forward_actions: true         # send Console actions to harness::send
```

The worker implements the stable A2UI v0.9.1 envelope with the safe `urn:iii:a2ui:console:v0.1` catalog. The catalog maps declarative components onto the running Console's shared React components and design tokens; it never executes model-provided HTML, JavaScript, or CSS.

## skills

This version ships 1 skill file for agents, also browsable on the worker page:

- [`SKILL.md`](https://iii.dev/registry/workers/a2ui?tab=skills&skill=SKILL.md&version=0.2.1)

### SKILL.md

# a2ui

Use `a2ui` when the result should be an interface the person can scan or act on. Describe the desired experience and supply the underlying data; the worker delegates composition through `llm-router`, validates A2UI v0.9.1, and returns a compact receipt while the Console renders the surface.

Surfaces belong to the current Harness session. The Harness pre-call hook stamps that identity authoritatively, and Console actions return to the same conversation as structured user interactions.

## When to Use

- Present a dashboard, status overview, comparison, form, approval, or decision surface.
- Keep a result live while later function calls update its components or data model.
- Let a person respond through buttons or bound inputs without asking them to author JSON.
- Revise an existing interface through a plain-language patch while preserving unspecified content.
- Export a finished surface as portable A2UI JSON for reuse outside the current conversation.
- Reuse, undo, pin, duplicate, import, or export a surface as a runnable React app or a data-serving iii worker template.
- Materialize the React app into the selected workspace when the person wants to inspect and edit its files in Shell, then preview it through Browser.
- Bind surface data to a worker's event function (optionally with its worker's read-only query), an exact state entry (`state::on-changed`), or Shell change events (`shell::on-changed`) when the UI should stay live.

## Boundaries

- Do not use A2UI for plain answers that are clearer as a short message.
- Generated surfaces use the fixed Console catalog; they cannot execute HTML, JavaScript, CSS, or arbitrary components.
- Use `canvas` for diagrams and freeform drawing, and use a domain worker directly when no visual surface is needed.
- `a2ui::action`, `a2ui::binding::apply`, `a2ui::binding::refresh`, `a2ui::stamp-session`, and `a2ui::on-config-change` are internal Console/Harness lifecycle functions, not agent tools.
- Live bindings observe another worker's private event function (registered with `private: true`), `state::on-changed` or `shell::on-changed`, and never `browser::*`, `harness::*`, `engine::*`, `observability::*`, hook, `http::on-request`, `cron::on-tick`, or `queue::on-message`. A binding passes `args` only to a function that registered an `args_format`; otherwise it selects calls with `filters` on `input.<field>`. A binding `query` must be a function registered by the observed function's own worker with metadata `{"read_only": true}`.
- Do not create new `stream::on-changed` bindings: iii-stream is deprecated and will be removed in an upcoming release. Existing ones keep working while iii-stream runs. Bind the producing worker's own event function.

## Functions

- `a2ui::generate` — compose and persist a complete surface from compact intent and optional data.
- `a2ui::surface::apply` — validate and atomically apply A2UI v0.9.1 messages to one surface.
- `a2ui::surface::get` — read one surface with its component graph and data model.
- `a2ui::surface::list` — list compact surface summaries for the current session.
- `a2ui::surface::delete` — remove a surface from the current session.
- `a2ui::surface::patch` — replace a surface from a natural-language change request with optional revision protection.
- `a2ui::surface::export` — return a session-free, replayable A2UI JSON package.
- `a2ui::surface::history`, `undo`, `duplicate`, and `pin` — manage the surface library and revisions.
- `a2ui::surface::import` and `export-code` — move surfaces between sessions or into source code.
- `a2ui::binding::set` and `delete` — manage safe declarative live-data bindings. Example: `{ "id": "clicks-count", "function_id": "demo::on-counter-changed", "args": { "counter": "clicks" }, "target_path": "/count", "query": { "function_id": "demo::counter::get", "payload": { "counter": "clicks" }, "result_path": "/value" } }`.
- `a2ui::template::*` — save, list, read, apply, and delete reusable session templates.
- `a2ui::action` — internal Console action ingress and optional Harness forwarding.
- `a2ui::stamp-session` — internal `harness::hook::on-pre-call` observer that stamps authoritative turn context.
- `a2ui::on-config-change` — internal authoritative configuration reload handler.

## api reference

```json
{
  "functions": [
    {
      "description": "Console-only: persist an A2UI component action and forward it as a structured message to the originating Harness session.",
      "metadata": {},
      "name": "a2ui::action",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "additionalProperties": false,
        "properties": {
          "action_id": {
            "description": "Stable client-generated id reused when Harness delivery is retried.",
            "type": "string"
          },
          "context": {
            "default": null
          },
          "data_model": {
            "default": null,
            "description": "Full client-side model when createSurface.sendDataModel requested it."
          },
          "expected_revision": {
            "description": "Reject a gesture rendered from stale surface state.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "source_component_id": {
            "type": "string"
          },
          "surface_id": {
            "type": "string"
          }
        },
        "required": [
          "action_id",
          "expected_revision",
          "name",
          "source_component_id",
          "surface_id"
        ],
        "title": "ActionRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "accepted": {
            "type": "boolean"
          },
          "forward_error": {
            "type": [
              "string",
              "null"
            ]
          },
          "forwarded": {
            "type": "boolean"
          },
          "revision": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "session_id": {
            "type": "string"
          },
          "surface_id": {
            "type": "string"
          },
          "turn_id": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "accepted",
          "forwarded",
          "revision",
          "session_id",
          "surface_id"
        ],
        "title": "ActionResponse",
        "type": "object"
      }
    },
    {
      "description": "Console-only: persist a value delivered by a declared A2UI live binding.",
      "metadata": {},
      "name": "a2ui::binding::apply",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "additionalProperties": false,
        "properties": {
          "binding_id": {
            "type": "string"
          },
          "surface_id": {
            "description": "Surface receiving the event value.",
            "type": "string"
          },
          "value": true
        },
        "required": [
          "binding_id",
          "surface_id",
          "value"
        ],
        "title": "BindingApplyRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "SurfaceStatus": {
            "enum": [
              "active",
              "deleted"
            ],
            "type": "string"
          }
        },
        "properties": {
          "catalog_id": {
            "type": "string"
          },
          "component_count": {
            "format": "uint",
            "minimum": 0,
            "type": "integer"
          },
          "page": {
            "type": "string"
          },
          "protocol_version": {
            "type": "string"
          },
          "revision": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "session_id": {
            "type": "string"
          },
          "status": {
            "$ref": "#/definitions/SurfaceStatus"
          },
          "surface_id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          }
        },
        "required": [
          "catalog_id",
          "component_count",
          "page",
          "protocol_version",
          "revision",
          "session_id",
          "status",
          "surface_id",
          "title"
        ],
        "title": "SurfaceReceipt",
        "type": "object"
      }
    },
    {
      "description": "Remove a declarative live event binding from an A2UI surface.",
      "metadata": {},
      "name": "a2ui::binding::delete",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "additionalProperties": false,
        "properties": {
          "binding_id": {
            "type": "string"
          },
          "surface_id": {
            "description": "Surface that owns the binding.",
            "type": "string"
          }
        },
        "required": [
          "binding_id",
          "surface_id"
        ],
        "title": "BindingDeleteRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "SurfaceStatus": {
            "enum": [
              "active",
              "deleted"
            ],
            "type": "string"
          }
        },
        "properties": {
          "catalog_id": {
            "type": "string"
          },
          "component_count": {
            "format": "uint",
            "minimum": 0,
            "type": "integer"
          },
          "page": {
            "type": "string"
          },
          "protocol_version": {
            "type": "string"
          },
          "revision": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "session_id": {
            "type": "string"
          },
          "status": {
            "$ref": "#/definitions/SurfaceStatus"
          },
          "surface_id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          }
        },
        "required": [
          "catalog_id",
          "component_count",
          "page",
          "protocol_version",
          "revision",
          "session_id",
          "status",
          "surface_id",
          "title"
        ],
        "title": "SurfaceReceipt",
        "type": "object"
      }
    },
    {
      "description": "Console-only: run a live binding's declared read-only provider query and persist the result into the surface data model.",
      "metadata": {},
      "name": "a2ui::binding::refresh",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "additionalProperties": false,
        "properties": {
          "binding_id": {
            "description": "Binding whose declared provider query should run.",
            "type": "string"
          },
          "surface_id": {
            "description": "Surface that owns the binding.",
            "type": "string"
          }
        },
        "required": [
          "binding_id",
          "surface_id"
        ],
        "title": "BindingRefreshRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "SurfaceStatus": {
            "enum": [
              "active",
              "deleted"
            ],
            "type": "string"
          }
        },
        "description": "Receipt of `a2ui::binding::refresh`.",
        "properties": {
          "catalog_id": {
            "type": "string"
          },
          "changed": {
            "description": "False when the stored value already matched and nothing was written.",
            "type": "boolean"
          },
          "component_count": {
            "format": "uint",
            "minimum": 0,
            "type": "integer"
          },
          "page": {
            "type": "string"
          },
          "protocol_version": {
            "type": "string"
          },
          "revision": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "session_id": {
            "type": "string"
          },
          "status": {
            "$ref": "#/definitions/SurfaceStatus"
          },
          "surface_id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "value": {
            "description": "Value now stored at the binding's target path."
          }
        },
        "required": [
          "catalog_id",
          "changed",
          "component_count",
          "page",
          "protocol_version",
          "revision",
          "session_id",
          "status",
          "surface_id",
          "title",
          "value"
        ],
        "title": "BindingRefreshReceipt",
        "type": "object"
      }
    },
    {
      "description": "Attach a declarative live binding to a surface: a worker's private event function observed with args or filters (optionally with its worker's read-only query), state::on-changed, or shell::on-changed. Legacy stream::on-changed bindings are deprecated.",
      "metadata": {},
      "name": "a2ui::binding::set",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "additionalProperties": false,
        "definitions": {
          "BindingQuery": {
            "additionalProperties": false,
            "description": "Read-only query the worker that hosts an observed event function exposes for the current data. The function must be registered by the same worker as the observed function with metadata `{\"read_only\": true}`.",
            "properties": {
              "function_id": {
                "description": "Provider function that returns the current value.",
                "type": "string"
              },
              "payload": {
                "description": "Fixed request payload, validated against the function's request schema."
              },
              "result_path": {
                "description": "JSON Pointer inside the query result to apply. Defaults to the whole result.",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "function_id"
            ],
            "type": "object"
          },
          "LiveBinding": {
            "additionalProperties": false,
            "description": "Declarative live-data binding rendered by the Console: the page observes `function_id` (with `args` and `filters`) for its own view and writes delivered values to `target_path`. Bindings cannot invoke arbitrary functions.",
            "properties": {
              "args": {
                "description": "Args for a function that takes them, validated against the function's registered `args_format`."
              },
              "event_path": {
                "description": "JSON Pointer inside the event to apply (event mode only).",
                "type": [
                  "string",
                  "null"
                ]
              },
              "filters": {
                "description": "Filters selecting which calls are delivered, each with an explicit operator: `{ \"input.status\": { \"$eq\": \"open\" } }`."
              },
              "function_id": {
                "description": "Function to observe: another worker's private event function (for example `orders::on-changed`), `state::on-changed`, or `shell::on-changed`. `stream::on-changed` is accepted only as deprecated legacy compatibility.",
                "type": "string"
              },
              "id": {
                "description": "Stable binding id within the surface.",
                "type": "string"
              },
              "query": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/BindingQuery"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "Optional provider query for a worker's event source: run for the initial read, after every notification, and on reconnect."
              },
              "target_path": {
                "description": "JSON Pointer in the surface data model that receives the value.",
                "type": "string"
              }
            },
            "required": [
              "function_id",
              "id",
              "target_path"
            ],
            "type": "object"
          }
        },
        "properties": {
          "binding": {
            "$ref": "#/definitions/LiveBinding"
          },
          "surface_id": {
            "description": "Surface that should receive live values.",
            "type": "string"
          }
        },
        "required": [
          "binding",
          "surface_id"
        ],
        "title": "BindingSetRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "SurfaceStatus": {
            "enum": [
              "active",
              "deleted"
            ],
            "type": "string"
          }
        },
        "description": "Receipt of `a2ui::binding::set`.",
        "properties": {
          "catalog_id": {
            "type": "string"
          },
          "component_count": {
            "format": "uint",
            "minimum": 0,
            "type": "integer"
          },
          "deprecation": {
            "description": "Present when the binding observes a deprecated source (`stream::on-changed`); the binding is stored and keeps working while iii-stream runs.",
            "type": [
              "string",
              "null"
            ]
          },
          "page": {
            "type": "string"
          },
          "protocol_version": {
            "type": "string"
          },
          "revision": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "session_id": {
            "type": "string"
          },
          "status": {
            "$ref": "#/definitions/SurfaceStatus"
          },
          "surface_id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          }
        },
        "required": [
          "catalog_id",
          "component_count",
          "page",
          "protocol_version",
          "revision",
          "session_id",
          "status",
          "surface_id",
          "title"
        ],
        "title": "BindingSetReceipt",
        "type": "object"
      }
    },
    {
      "description": "Generate a user interface from a short description and optional data. Renders a safe A2UI v0.9.1 surface in chat and on the A2UI page, returning a compact receipt.",
      "metadata": {},
      "name": "a2ui::generate",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "additionalProperties": false,
        "properties": {
          "data": {
            "default": null,
            "description": "Optional application data. The composer should bind components to this data instead of repeating it in the component graph."
          },
          "description": {
            "description": "Plain-language description of the interface to compose.",
            "type": "string"
          },
          "replace": {
            "default": true,
            "description": "Replace a surface with the same id. Defaults to true.",
            "type": "boolean"
          },
          "surface_id": {
            "default": null,
            "description": "Stable id to use for the generated surface. Omit for a generated id.",
            "type": [
              "string",
              "null"
            ]
          },
          "title": {
            "default": null,
            "description": "Human-readable title shown in the Console sidebar.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "description"
        ],
        "title": "GenerateRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "SurfaceStatus": {
            "enum": [
              "active",
              "deleted"
            ],
            "type": "string"
          }
        },
        "properties": {
          "catalog_id": {
            "type": "string"
          },
          "component_count": {
            "format": "uint",
            "minimum": 0,
            "type": "integer"
          },
          "page": {
            "type": "string"
          },
          "protocol_version": {
            "type": "string"
          },
          "revision": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "session_id": {
            "type": "string"
          },
          "status": {
            "$ref": "#/definitions/SurfaceStatus"
          },
          "surface_id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          }
        },
        "required": [
          "catalog_id",
          "component_count",
          "page",
          "protocol_version",
          "revision",
          "session_id",
          "status",
          "surface_id",
          "title"
        ],
        "title": "SurfaceReceipt",
        "type": "object"
      }
    },
    {
      "description": "Internal: reload the A2UI worker from authoritative configuration after an update.",
      "metadata": {
        "internal": true
      },
      "name": "a2ui::on-config-change",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "id": {
            "default": null,
            "description": "Advisory id only. The handler always re-fetches authoritative state.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "title": "OnConfigChangeEvent",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "properties": {
          "ok": {
            "type": "boolean"
          }
        },
        "required": [
          "ok"
        ],
        "title": "OnConfigChangeResponse",
        "type": "object"
      }
    },
    {
      "description": "Internal: stamp the authoritative Harness session onto A2UI calls before dispatch.",
      "metadata": {},
      "name": "a2ui::stamp-session",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "StampCall": {
            "properties": {
              "arguments": {
                "default": null
              }
            },
            "type": "object"
          }
        },
        "description": "Trusted pre-call hook input supplied by the Harness hook runner.",
        "properties": {
          "call": {
            "anyOf": [
              {
                "$ref": "#/definitions/StampCall"
              },
              {
                "type": "null"
              }
            ]
          },
          "session_id": {
            "default": null,
            "type": [
              "string",
              "null"
            ]
          }
        },
        "title": "StampSessionEvent",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "anyOf": [
          {
            "$ref": "#/definitions/StampSessionResponse"
          },
          {
            "type": "null"
          }
        ],
        "definitions": {
          "HookMutations": {
            "properties": {
              "arguments": true
            },
            "required": [
              "arguments"
            ],
            "type": "object"
          },
          "StampSessionResponse": {
            "properties": {
              "decision": {
                "type": "string"
              },
              "mutations": {
                "$ref": "#/definitions/HookMutations"
              }
            },
            "required": [
              "decision",
              "mutations"
            ],
            "type": "object"
          }
        },
        "title": "Nullable_StampSessionResponse"
      }
    },
    {
      "description": "Apply a batch of A2UI v0.9.1 protocol messages to a surface, validated and applied atomically to the session's durable state.",
      "metadata": {},
      "name": "a2ui::surface::apply",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "additionalProperties": false,
        "definitions": {
          "Component": {
            "additionalProperties": true,
            "properties": {
              "component": {
                "description": "Component name from the negotiated catalog.",
                "type": "string"
              },
              "id": {
                "description": "Unique component id within the surface. `root` is the render root.",
                "type": "string"
              }
            },
            "required": [
              "component",
              "id"
            ],
            "type": "object"
          },
          "CreateSurface": {
            "additionalProperties": false,
            "properties": {
              "catalogId": {
                "type": "string"
              },
              "sendDataModel": {
                "type": [
                  "boolean",
                  "null"
                ]
              },
              "surfaceId": {
                "type": "string"
              },
              "theme": true
            },
            "required": [
              "catalogId",
              "surfaceId"
            ],
            "type": "object"
          },
          "CreateSurfaceMessage": {
            "additionalProperties": false,
            "properties": {
              "createSurface": {
                "$ref": "#/definitions/CreateSurface"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "createSurface",
              "version"
            ],
            "type": "object"
          },
          "DeleteSurface": {
            "additionalProperties": false,
            "properties": {
              "surfaceId": {
                "type": "string"
              }
            },
            "required": [
              "surfaceId"
            ],
            "type": "object"
          },
          "DeleteSurfaceMessage": {
            "additionalProperties": false,
            "properties": {
              "deleteSurface": {
                "$ref": "#/definitions/DeleteSurface"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "deleteSurface",
              "version"
            ],
            "type": "object"
          },
          "ServerMessage": {
            "anyOf": [
              {
                "$ref": "#/definitions/CreateSurfaceMessage"
              },
              {
                "$ref": "#/definitions/UpdateComponentsMessage"
              },
              {
                "$ref": "#/definitions/UpdateDataModelMessage"
              },
              {
                "$ref": "#/definitions/DeleteSurfaceMessage"
              }
            ],
            "description": "Exactly one of the four A2UI v0.9.1 server-to-client envelope messages."
          },
          "UpdateComponents": {
            "additionalProperties": false,
            "properties": {
              "components": {
                "items": {
                  "$ref": "#/definitions/Component"
                },
                "type": "array"
              },
              "surfaceId": {
                "type": "string"
              }
            },
            "required": [
              "components",
              "surfaceId"
            ],
            "type": "object"
          },
          "UpdateComponentsMessage": {
            "additionalProperties": false,
            "properties": {
              "updateComponents": {
                "$ref": "#/definitions/UpdateComponents"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "updateComponents",
              "version"
            ],
            "type": "object"
          },
          "UpdateDataModel": {
            "additionalProperties": false,
            "properties": {
              "path": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "surfaceId": {
                "type": "string"
              },
              "value": {
                "description": "Omit or set null to remove the path. At `/` this replaces the whole data model, matching A2UI v0.9.1 root-update semantics."
              }
            },
            "required": [
              "surfaceId"
            ],
            "type": "object"
          },
          "UpdateDataModelMessage": {
            "additionalProperties": false,
            "properties": {
              "updateDataModel": {
                "$ref": "#/definitions/UpdateDataModel"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "updateDataModel",
              "version"
            ],
            "type": "object"
          }
        },
        "properties": {
          "messages": {
            "description": "Ordered A2UI v0.9.1 envelopes. One batch targets one surface and is persisted atomically after the complete batch validates.",
            "items": {
              "$ref": "#/definitions/ServerMessage"
            },
            "type": "array"
          },
          "title": {
            "default": null,
            "description": "Optional Console title used when this batch creates a surface.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "messages"
        ],
        "title": "ApplyRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "SurfaceStatus": {
            "enum": [
              "active",
              "deleted"
            ],
            "type": "string"
          }
        },
        "properties": {
          "catalog_id": {
            "type": "string"
          },
          "component_count": {
            "format": "uint",
            "minimum": 0,
            "type": "integer"
          },
          "page": {
            "type": "string"
          },
          "protocol_version": {
            "type": "string"
          },
          "revision": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "session_id": {
            "type": "string"
          },
          "status": {
            "$ref": "#/definitions/SurfaceStatus"
          },
          "surface_id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          }
        },
        "required": [
          "catalog_id",
          "component_count",
          "page",
          "protocol_version",
          "revision",
          "session_id",
          "status",
          "surface_id",
          "title"
        ],
        "title": "SurfaceReceipt",
        "type": "object"
      }
    },
    {
      "description": "Delete one A2UI surface from the current Harness session and publish the change to subscribed Console pages.",
      "metadata": {},
      "name": "a2ui::surface::delete",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "additionalProperties": false,
        "description": "Remove one surface from the current Harness session.",
        "properties": {
          "surface_id": {
            "description": "Stable surface id returned by generate, apply, or list.",
            "type": "string"
          }
        },
        "required": [
          "surface_id"
        ],
        "title": "DeleteRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "SurfaceStatus": {
            "enum": [
              "active",
              "deleted"
            ],
            "type": "string"
          }
        },
        "properties": {
          "catalog_id": {
            "type": "string"
          },
          "component_count": {
            "format": "uint",
            "minimum": 0,
            "type": "integer"
          },
          "page": {
            "type": "string"
          },
          "protocol_version": {
            "type": "string"
          },
          "revision": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "session_id": {
            "type": "string"
          },
          "status": {
            "$ref": "#/definitions/SurfaceStatus"
          },
          "surface_id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          }
        },
        "required": [
          "catalog_id",
          "component_count",
          "page",
          "protocol_version",
          "revision",
          "session_id",
          "status",
          "surface_id",
          "title"
        ],
        "title": "SurfaceReceipt",
        "type": "object"
      }
    },
    {
      "description": "Duplicate an A2UI surface inside the current Harness session under a new stable id.",
      "metadata": {},
      "name": "a2ui::surface::duplicate",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "additionalProperties": false,
        "properties": {
          "new_surface_id": {
            "type": "string"
          },
          "surface_id": {
            "description": "Existing surface to copy.",
            "type": "string"
          },
          "title": {
            "default": null,
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "new_surface_id",
          "surface_id"
        ],
        "title": "DuplicateRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "SurfaceStatus": {
            "enum": [
              "active",
              "deleted"
            ],
            "type": "string"
          }
        },
        "properties": {
          "catalog_id": {
            "type": "string"
          },
          "component_count": {
            "format": "uint",
            "minimum": 0,
            "type": "integer"
          },
          "page": {
            "type": "string"
          },
          "protocol_version": {
            "type": "string"
          },
          "revision": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "session_id": {
            "type": "string"
          },
          "status": {
            "$ref": "#/definitions/SurfaceStatus"
          },
          "surface_id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          }
        },
        "required": [
          "catalog_id",
          "component_count",
          "page",
          "protocol_version",
          "revision",
          "session_id",
          "status",
          "surface_id",
          "title"
        ],
        "title": "SurfaceReceipt",
        "type": "object"
      }
    },
    {
      "description": "Export one A2UI surface as a portable, replayable JSON package without Harness session metadata.",
      "metadata": {},
      "name": "a2ui::surface::export",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "additionalProperties": false,
        "properties": {
          "surface_id": {
            "description": "Stable id of the surface to export.",
            "type": "string"
          }
        },
        "required": [
          "surface_id"
        ],
        "title": "ExportRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "Component": {
            "additionalProperties": true,
            "properties": {
              "component": {
                "description": "Component name from the negotiated catalog.",
                "type": "string"
              },
              "id": {
                "description": "Unique component id within the surface. `root` is the render root.",
                "type": "string"
              }
            },
            "required": [
              "component",
              "id"
            ],
            "type": "object"
          },
          "CreateSurface": {
            "additionalProperties": false,
            "properties": {
              "catalogId": {
                "type": "string"
              },
              "sendDataModel": {
                "type": [
                  "boolean",
                  "null"
                ]
              },
              "surfaceId": {
                "type": "string"
              },
              "theme": true
            },
            "required": [
              "catalogId",
              "surfaceId"
            ],
            "type": "object"
          },
          "CreateSurfaceMessage": {
            "additionalProperties": false,
            "properties": {
              "createSurface": {
                "$ref": "#/definitions/CreateSurface"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "createSurface",
              "version"
            ],
            "type": "object"
          },
          "DeleteSurface": {
            "additionalProperties": false,
            "properties": {
              "surfaceId": {
                "type": "string"
              }
            },
            "required": [
              "surfaceId"
            ],
            "type": "object"
          },
          "DeleteSurfaceMessage": {
            "additionalProperties": false,
            "properties": {
              "deleteSurface": {
                "$ref": "#/definitions/DeleteSurface"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "deleteSurface",
              "version"
            ],
            "type": "object"
          },
          "ServerMessage": {
            "anyOf": [
              {
                "$ref": "#/definitions/CreateSurfaceMessage"
              },
              {
                "$ref": "#/definitions/UpdateComponentsMessage"
              },
              {
                "$ref": "#/definitions/UpdateDataModelMessage"
              },
              {
                "$ref": "#/definitions/DeleteSurfaceMessage"
              }
            ],
            "description": "Exactly one of the four A2UI v0.9.1 server-to-client envelope messages."
          },
          "UpdateComponents": {
            "additionalProperties": false,
            "properties": {
              "components": {
                "items": {
                  "$ref": "#/definitions/Component"
                },
                "type": "array"
              },
              "surfaceId": {
                "type": "string"
              }
            },
            "required": [
              "components",
              "surfaceId"
            ],
            "type": "object"
          },
          "UpdateComponentsMessage": {
            "additionalProperties": false,
            "properties": {
              "updateComponents": {
                "$ref": "#/definitions/UpdateComponents"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "updateComponents",
              "version"
            ],
            "type": "object"
          },
          "UpdateDataModel": {
            "additionalProperties": false,
            "properties": {
              "path": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "surfaceId": {
                "type": "string"
              },
              "value": {
                "description": "Omit or set null to remove the path. At `/` this replaces the whole data model, matching A2UI v0.9.1 root-update semantics."
              }
            },
            "required": [
              "surfaceId"
            ],
            "type": "object"
          },
          "UpdateDataModelMessage": {
            "additionalProperties": false,
            "properties": {
              "updateDataModel": {
                "$ref": "#/definitions/UpdateDataModel"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "updateDataModel",
              "version"
            ],
            "type": "object"
          }
        },
        "properties": {
          "catalog_id": {
            "type": "string"
          },
          "format": {
            "type": "string"
          },
          "format_version": {
            "format": "uint32",
            "minimum": 0,
            "type": "integer"
          },
          "messages": {
            "items": {
              "$ref": "#/definitions/ServerMessage"
            },
            "type": "array"
          },
          "protocol_version": {
            "type": "string"
          },
          "surface_id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          }
        },
        "required": [
          "catalog_id",
          "format",
          "format_version",
          "messages",
          "protocol_version",
          "surface_id",
          "title"
        ],
        "title": "SurfaceExport",
        "type": "object"
      }
    },
    {
      "description": "Generate source code from an A2UI surface: a React app or a data-serving iii worker.",
      "metadata": {},
      "name": "a2ui::surface::export-code",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "additionalProperties": false,
        "definitions": {
          "CodeTarget": {
            "enum": [
              "react",
              "worker"
            ],
            "type": "string"
          }
        },
        "properties": {
          "surface_id": {
            "description": "Surface to turn into source files.",
            "type": "string"
          },
          "target": {
            "$ref": "#/definitions/CodeTarget"
          }
        },
        "required": [
          "surface_id",
          "target"
        ],
        "title": "ExportCodeRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "CodeFile": {
            "properties": {
              "content": {
                "type": "string"
              },
              "path": {
                "type": "string"
              }
            },
            "required": [
              "content",
              "path"
            ],
            "type": "object"
          }
        },
        "properties": {
          "files": {
            "items": {
              "$ref": "#/definitions/CodeFile"
            },
            "type": "array"
          },
          "format": {
            "type": "string"
          },
          "surface_id": {
            "type": "string"
          }
        },
        "required": [
          "files",
          "format",
          "surface_id"
        ],
        "title": "CodeExport",
        "type": "object"
      }
    },
    {
      "description": "Read one durable A2UI surface, including its flat component graph and data model, from the current Harness session.",
      "metadata": {},
      "name": "a2ui::surface::get",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "additionalProperties": false,
        "description": "Select one surface in the current Harness session.",
        "properties": {
          "surface_id": {
            "description": "Stable surface id returned by generate, apply, or list.",
            "type": "string"
          }
        },
        "required": [
          "surface_id"
        ],
        "title": "GetRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "ActionRecord": {
            "properties": {
              "action_id": {
                "default": "",
                "type": "string"
              },
              "context": true,
              "data_model": true,
              "name": {
                "type": "string"
              },
              "source_component_id": {
                "type": "string"
              },
              "timestamp_ms": {
                "format": "int64",
                "type": "integer"
              }
            },
            "required": [
              "context",
              "name",
              "source_component_id",
              "timestamp_ms"
            ],
            "type": "object"
          },
          "BindingQuery": {
            "additionalProperties": false,
            "description": "Read-only query the worker that hosts an observed event function exposes for the current data. The function must be registered by the same worker as the observed function with metadata `{\"read_only\": true}`.",
            "properties": {
              "function_id": {
                "description": "Provider function that returns the current value.",
                "type": "string"
              },
              "payload": {
                "description": "Fixed request payload, validated against the function's request schema."
              },
              "result_path": {
                "description": "JSON Pointer inside the query result to apply. Defaults to the whole result.",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "function_id"
            ],
            "type": "object"
          },
          "Component": {
            "additionalProperties": true,
            "properties": {
              "component": {
                "description": "Component name from the negotiated catalog.",
                "type": "string"
              },
              "id": {
                "description": "Unique component id within the surface. `root` is the render root.",
                "type": "string"
              }
            },
            "required": [
              "component",
              "id"
            ],
            "type": "object"
          },
          "LiveBinding": {
            "additionalProperties": false,
            "description": "Declarative live-data binding rendered by the Console: the page observes `function_id` (with `args` and `filters`) for its own view and writes delivered values to `target_path`. Bindings cannot invoke arbitrary functions.",
            "properties": {
              "args": {
                "description": "Args for a function that takes them, validated against the function's registered `args_format`."
              },
              "event_path": {
                "description": "JSON Pointer inside the event to apply (event mode only).",
                "type": [
                  "string",
                  "null"
                ]
              },
              "filters": {
                "description": "Filters selecting which calls are delivered, each with an explicit operator: `{ \"input.status\": { \"$eq\": \"open\" } }`."
              },
              "function_id": {
                "description": "Function to observe: another worker's private event function (for example `orders::on-changed`), `state::on-changed`, or `shell::on-changed`. `stream::on-changed` is accepted only as deprecated legacy compatibility.",
                "type": "string"
              },
              "id": {
                "description": "Stable binding id within the surface.",
                "type": "string"
              },
              "query": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/BindingQuery"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "Optional provider query for a worker's event source: run for the initial read, after every notification, and on reconnect."
              },
              "target_path": {
                "description": "JSON Pointer in the surface data model that receives the value.",
                "type": "string"
              }
            },
            "required": [
              "function_id",
              "id",
              "target_path"
            ],
            "type": "object"
          },
          "RetiredBinding": {
            "description": "A binding stored under iii 0.25 as a worker's type `W::X` whose function `W::on-X` was not registered, or failed the binding checks, when its session loaded.",
            "properties": {
              "function_id": {
                "description": "The function the stored type reads as.",
                "type": "string"
              },
              "id": {
                "description": "The binding id.",
                "type": "string"
              },
              "reason": {
                "description": "Why the binding could not be translated.",
                "type": "string"
              }
            },
            "required": [
              "function_id",
              "id",
              "reason"
            ],
            "type": "object"
          },
          "SurfaceRevision": {
            "properties": {
              "components": {
                "items": {
                  "$ref": "#/definitions/Component"
                },
                "type": "array"
              },
              "data_model": true,
              "last_action": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/ActionRecord"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "reason": {
                "type": "string"
              },
              "revision": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "send_data_model": {
                "type": "boolean"
              },
              "theme": true,
              "title": {
                "type": "string"
              },
              "updated_at_ms": {
                "format": "int64",
                "type": "integer"
              }
            },
            "required": [
              "components",
              "data_model",
              "reason",
              "revision",
              "send_data_model",
              "title",
              "updated_at_ms"
            ],
            "type": "object"
          }
        },
        "properties": {
          "bindings": {
            "default": [],
            "items": {
              "$ref": "#/definitions/LiveBinding"
            },
            "type": "array"
          },
          "catalog_id": {
            "type": "string"
          },
          "components": {
            "items": {
              "$ref": "#/definitions/Component"
            },
            "type": "array"
          },
          "created_at_ms": {
            "format": "int64",
            "type": "integer"
          },
          "data_model": true,
          "history": {
            "default": [],
            "items": {
              "$ref": "#/definitions/SurfaceRevision"
            },
            "type": "array"
          },
          "last_action": {
            "anyOf": [
              {
                "$ref": "#/definitions/ActionRecord"
              },
              {
                "type": "null"
              }
            ]
          },
          "pinned": {
            "default": false,
            "type": "boolean"
          },
          "protocol_version": {
            "type": "string"
          },
          "retired_bindings": {
            "description": "Bindings stored under iii 0.25 that could not be translated when the session loaded, each with the reason. The page lists them; `a2ui::binding::set` with the same id replaces one and `a2ui::binding::delete` removes it.",
            "items": {
              "$ref": "#/definitions/RetiredBinding"
            },
            "type": "array"
          },
          "revision": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "send_data_model": {
            "type": "boolean"
          },
          "session_id": {
            "description": "Authoritative Harness session stamped by the pre-call hook.",
            "type": "string"
          },
          "surface_id": {
            "description": "Globally unique inside the session.",
            "type": "string"
          },
          "theme": true,
          "title": {
            "type": "string"
          },
          "updated_at_ms": {
            "format": "int64",
            "type": "integer"
          }
        },
        "required": [
          "catalog_id",
          "components",
          "created_at_ms",
          "data_model",
          "protocol_version",
          "revision",
          "send_data_model",
          "session_id",
          "surface_id",
          "title",
          "updated_at_ms"
        ],
        "title": "SurfaceRecord",
        "type": "object"
      }
    },
    {
      "description": "List the saved revisions of one A2UI surface, restorable by undo.",
      "metadata": {},
      "name": "a2ui::surface::history",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "additionalProperties": false,
        "properties": {
          "surface_id": {
            "description": "Surface whose restorable snapshots should be listed.",
            "type": "string"
          }
        },
        "required": [
          "surface_id"
        ],
        "title": "HistoryRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "ActionRecord": {
            "properties": {
              "action_id": {
                "default": "",
                "type": "string"
              },
              "context": true,
              "data_model": true,
              "name": {
                "type": "string"
              },
              "source_component_id": {
                "type": "string"
              },
              "timestamp_ms": {
                "format": "int64",
                "type": "integer"
              }
            },
            "required": [
              "context",
              "name",
              "source_component_id",
              "timestamp_ms"
            ],
            "type": "object"
          },
          "Component": {
            "additionalProperties": true,
            "properties": {
              "component": {
                "description": "Component name from the negotiated catalog.",
                "type": "string"
              },
              "id": {
                "description": "Unique component id within the surface. `root` is the render root.",
                "type": "string"
              }
            },
            "required": [
              "component",
              "id"
            ],
            "type": "object"
          },
          "SurfaceRevision": {
            "properties": {
              "components": {
                "items": {
                  "$ref": "#/definitions/Component"
                },
                "type": "array"
              },
              "data_model": true,
              "last_action": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/ActionRecord"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "reason": {
                "type": "string"
              },
              "revision": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "send_data_model": {
                "type": "boolean"
              },
              "theme": true,
              "title": {
                "type": "string"
              },
              "updated_at_ms": {
                "format": "int64",
                "type": "integer"
              }
            },
            "required": [
              "components",
              "data_model",
              "reason",
              "revision",
              "send_data_model",
              "title",
              "updated_at_ms"
            ],
            "type": "object"
          }
        },
        "items": {
          "$ref": "#/definitions/SurfaceRevision"
        },
        "title": "Array_of_SurfaceRevision",
        "type": "array"
      }
    },
    {
      "description": "Import a portable A2UI surface package into the current Harness session.",
      "metadata": {},
      "name": "a2ui::surface::import",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "additionalProperties": false,
        "definitions": {
          "Component": {
            "additionalProperties": true,
            "properties": {
              "component": {
                "description": "Component name from the negotiated catalog.",
                "type": "string"
              },
              "id": {
                "description": "Unique component id within the surface. `root` is the render root.",
                "type": "string"
              }
            },
            "required": [
              "component",
              "id"
            ],
            "type": "object"
          },
          "CreateSurface": {
            "additionalProperties": false,
            "properties": {
              "catalogId": {
                "type": "string"
              },
              "sendDataModel": {
                "type": [
                  "boolean",
                  "null"
                ]
              },
              "surfaceId": {
                "type": "string"
              },
              "theme": true
            },
            "required": [
              "catalogId",
              "surfaceId"
            ],
            "type": "object"
          },
          "CreateSurfaceMessage": {
            "additionalProperties": false,
            "properties": {
              "createSurface": {
                "$ref": "#/definitions/CreateSurface"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "createSurface",
              "version"
            ],
            "type": "object"
          },
          "DeleteSurface": {
            "additionalProperties": false,
            "properties": {
              "surfaceId": {
                "type": "string"
              }
            },
            "required": [
              "surfaceId"
            ],
            "type": "object"
          },
          "DeleteSurfaceMessage": {
            "additionalProperties": false,
            "properties": {
              "deleteSurface": {
                "$ref": "#/definitions/DeleteSurface"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "deleteSurface",
              "version"
            ],
            "type": "object"
          },
          "ServerMessage": {
            "anyOf": [
              {
                "$ref": "#/definitions/CreateSurfaceMessage"
              },
              {
                "$ref": "#/definitions/UpdateComponentsMessage"
              },
              {
                "$ref": "#/definitions/UpdateDataModelMessage"
              },
              {
                "$ref": "#/definitions/DeleteSurfaceMessage"
              }
            ],
            "description": "Exactly one of the four A2UI v0.9.1 server-to-client envelope messages."
          },
          "SurfaceExport": {
            "properties": {
              "catalog_id": {
                "type": "string"
              },
              "format": {
                "type": "string"
              },
              "format_version": {
                "format": "uint32",
                "minimum": 0,
                "type": "integer"
              },
              "messages": {
                "items": {
                  "$ref": "#/definitions/ServerMessage"
                },
                "type": "array"
              },
              "protocol_version": {
                "type": "string"
              },
              "surface_id": {
                "type": "string"
              },
              "title": {
                "type": "string"
              }
            },
            "required": [
              "catalog_id",
              "format",
              "format_version",
              "messages",
              "protocol_version",
              "surface_id",
              "title"
            ],
            "type": "object"
          },
          "UpdateComponents": {
            "additionalProperties": false,
            "properties": {
              "components": {
                "items": {
                  "$ref": "#/definitions/Component"
                },
                "type": "array"
              },
              "surfaceId": {
                "type": "string"
              }
            },
            "required": [
              "components",
              "surfaceId"
            ],
            "type": "object"
          },
          "UpdateComponentsMessage": {
            "additionalProperties": false,
            "properties": {
              "updateComponents": {
                "$ref": "#/definitions/UpdateComponents"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "updateComponents",
              "version"
            ],
            "type": "object"
          },
          "UpdateDataModel": {
            "additionalProperties": false,
            "properties": {
              "path": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "surfaceId": {
                "type": "string"
              },
              "value": {
                "description": "Omit or set null to remove the path. At `/` this replaces the whole data model, matching A2UI v0.9.1 root-update semantics."
              }
            },
            "required": [
              "surfaceId"
            ],
            "type": "object"
          },
          "UpdateDataModelMessage": {
            "additionalProperties": false,
            "properties": {
              "updateDataModel": {
                "$ref": "#/definitions/UpdateDataModel"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "updateDataModel",
              "version"
            ],
            "type": "object"
          }
        },
        "properties": {
          "package": {
            "allOf": [
              {
                "$ref": "#/definitions/SurfaceExport"
              }
            ],
            "description": "Portable A2UI JSON package created by surface export."
          },
          "surface_id": {
            "default": null,
            "type": [
              "string",
              "null"
            ]
          },
          "title": {
            "default": null,
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "package"
        ],
        "title": "ImportRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "SurfaceStatus": {
            "enum": [
              "active",
              "deleted"
            ],
            "type": "string"
          }
        },
        "properties": {
          "catalog_id": {
            "type": "string"
          },
          "component_count": {
            "format": "uint",
            "minimum": 0,
            "type": "integer"
          },
          "page": {
            "type": "string"
          },
          "protocol_version": {
            "type": "string"
          },
          "revision": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "session_id": {
            "type": "string"
          },
          "status": {
            "$ref": "#/definitions/SurfaceStatus"
          },
          "surface_id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          }
        },
        "required": [
          "catalog_id",
          "component_count",
          "page",
          "protocol_version",
          "revision",
          "session_id",
          "status",
          "surface_id",
          "title"
        ],
        "title": "SurfaceReceipt",
        "type": "object"
      }
    },
    {
      "description": "List the A2UI surfaces owned by the current Harness session, newest first, as compact summaries.",
      "metadata": {},
      "name": "a2ui::surface::list",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "additionalProperties": false,
        "description": "List the surfaces belonging to the current Harness session. List generated surfaces in the authoritative Harness session.",
        "title": "ListRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "SurfaceSummary": {
            "properties": {
              "binding_count": {
                "format": "uint",
                "minimum": 0,
                "type": "integer"
              },
              "catalog_id": {
                "type": "string"
              },
              "component_count": {
                "format": "uint",
                "minimum": 0,
                "type": "integer"
              },
              "pinned": {
                "type": "boolean"
              },
              "protocol_version": {
                "type": "string"
              },
              "revision": {
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "surface_id": {
                "type": "string"
              },
              "title": {
                "type": "string"
              },
              "updated_at_ms": {
                "format": "int64",
                "type": "integer"
              }
            },
            "required": [
              "binding_count",
              "catalog_id",
              "component_count",
              "pinned",
              "protocol_version",
              "revision",
              "surface_id",
              "title",
              "updated_at_ms"
            ],
            "type": "object"
          }
        },
        "properties": {
          "count": {
            "format": "uint",
            "minimum": 0,
            "type": "integer"
          },
          "session_id": {
            "type": "string"
          },
          "surfaces": {
            "items": {
              "$ref": "#/definitions/SurfaceSummary"
            },
            "type": "array"
          }
        },
        "required": [
          "count",
          "session_id",
          "surfaces"
        ],
        "title": "ListResponse",
        "type": "object"
      }
    },
    {
      "description": "Update an A2UI surface from a plain-language instruction. Unspecified content is preserved; stale revisions are rejected.",
      "metadata": {},
      "name": "a2ui::surface::patch",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "additionalProperties": false,
        "properties": {
          "data": {
            "default": null,
            "description": "Optional data to merge or use while composing the replacement."
          },
          "expected_revision": {
            "default": null,
            "description": "Reject the update unless the surface is still at this revision.",
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "instruction": {
            "description": "Plain-language change to make while preserving unspecified content.",
            "type": "string"
          },
          "surface_id": {
            "description": "Stable id of the surface to update.",
            "type": "string"
          },
          "title": {
            "default": null,
            "description": "Optional replacement title.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "instruction",
          "surface_id"
        ],
        "title": "PatchRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "SurfaceStatus": {
            "enum": [
              "active",
              "deleted"
            ],
            "type": "string"
          }
        },
        "properties": {
          "catalog_id": {
            "type": "string"
          },
          "component_count": {
            "format": "uint",
            "minimum": 0,
            "type": "integer"
          },
          "page": {
            "type": "string"
          },
          "protocol_version": {
            "type": "string"
          },
          "revision": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "session_id": {
            "type": "string"
          },
          "status": {
            "$ref": "#/definitions/SurfaceStatus"
          },
          "surface_id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          }
        },
        "required": [
          "catalog_id",
          "component_count",
          "page",
          "protocol_version",
          "revision",
          "session_id",
          "status",
          "surface_id",
          "title"
        ],
        "title": "SurfaceReceipt",
        "type": "object"
      }
    },
    {
      "description": "Pin or unpin an A2UI surface so important interfaces remain first in the library.",
      "metadata": {},
      "name": "a2ui::surface::pin",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "additionalProperties": false,
        "properties": {
          "pinned": {
            "type": "boolean"
          },
          "surface_id": {
            "description": "Surface whose library priority should change.",
            "type": "string"
          }
        },
        "required": [
          "pinned",
          "surface_id"
        ],
        "title": "PinRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "SurfaceStatus": {
            "enum": [
              "active",
              "deleted"
            ],
            "type": "string"
          }
        },
        "properties": {
          "catalog_id": {
            "type": "string"
          },
          "component_count": {
            "format": "uint",
            "minimum": 0,
            "type": "integer"
          },
          "page": {
            "type": "string"
          },
          "protocol_version": {
            "type": "string"
          },
          "revision": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "session_id": {
            "type": "string"
          },
          "status": {
            "$ref": "#/definitions/SurfaceStatus"
          },
          "surface_id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          }
        },
        "required": [
          "catalog_id",
          "component_count",
          "page",
          "protocol_version",
          "revision",
          "session_id",
          "status",
          "surface_id",
          "title"
        ],
        "title": "SurfaceReceipt",
        "type": "object"
      }
    },
    {
      "description": "Undo edits to an A2UI surface by restoring a prior revision as a new monotonic revision.",
      "metadata": {},
      "name": "a2ui::surface::undo",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "additionalProperties": false,
        "properties": {
          "surface_id": {
            "description": "Surface to restore.",
            "type": "string"
          },
          "to_revision": {
            "default": null,
            "format": "uint64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          }
        },
        "required": [
          "surface_id"
        ],
        "title": "UndoRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "SurfaceStatus": {
            "enum": [
              "active",
              "deleted"
            ],
            "type": "string"
          }
        },
        "properties": {
          "catalog_id": {
            "type": "string"
          },
          "component_count": {
            "format": "uint",
            "minimum": 0,
            "type": "integer"
          },
          "page": {
            "type": "string"
          },
          "protocol_version": {
            "type": "string"
          },
          "revision": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "session_id": {
            "type": "string"
          },
          "status": {
            "$ref": "#/definitions/SurfaceStatus"
          },
          "surface_id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          }
        },
        "required": [
          "catalog_id",
          "component_count",
          "page",
          "protocol_version",
          "revision",
          "session_id",
          "status",
          "surface_id",
          "title"
        ],
        "title": "SurfaceReceipt",
        "type": "object"
      }
    },
    {
      "description": "Create a new A2UI surface from a reusable template in the current Harness session.",
      "metadata": {},
      "name": "a2ui::template::apply",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "additionalProperties": false,
        "properties": {
          "surface_id": {
            "type": "string"
          },
          "template_id": {
            "description": "Template to instantiate.",
            "type": "string"
          },
          "title": {
            "default": null,
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "surface_id",
          "template_id"
        ],
        "title": "TemplateApplyRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "SurfaceStatus": {
            "enum": [
              "active",
              "deleted"
            ],
            "type": "string"
          }
        },
        "properties": {
          "catalog_id": {
            "type": "string"
          },
          "component_count": {
            "format": "uint",
            "minimum": 0,
            "type": "integer"
          },
          "page": {
            "type": "string"
          },
          "protocol_version": {
            "type": "string"
          },
          "revision": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "session_id": {
            "type": "string"
          },
          "status": {
            "$ref": "#/definitions/SurfaceStatus"
          },
          "surface_id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          }
        },
        "required": [
          "catalog_id",
          "component_count",
          "page",
          "protocol_version",
          "revision",
          "session_id",
          "status",
          "surface_id",
          "title"
        ],
        "title": "SurfaceReceipt",
        "type": "object"
      }
    },
    {
      "description": "Delete one reusable A2UI template from the current Harness session.",
      "metadata": {},
      "name": "a2ui::template::delete",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "additionalProperties": false,
        "properties": {
          "template_id": {
            "description": "Reusable template identifier.",
            "type": "string"
          }
        },
        "required": [
          "template_id"
        ],
        "title": "TemplateSelectRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "title": "Boolean",
        "type": "boolean"
      }
    },
    {
      "description": "Read one reusable A2UI template from the current Harness session.",
      "metadata": {},
      "name": "a2ui::template::get",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "additionalProperties": false,
        "properties": {
          "template_id": {
            "description": "Reusable template identifier.",
            "type": "string"
          }
        },
        "required": [
          "template_id"
        ],
        "title": "TemplateSelectRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "Component": {
            "additionalProperties": true,
            "properties": {
              "component": {
                "description": "Component name from the negotiated catalog.",
                "type": "string"
              },
              "id": {
                "description": "Unique component id within the surface. `root` is the render root.",
                "type": "string"
              }
            },
            "required": [
              "component",
              "id"
            ],
            "type": "object"
          }
        },
        "properties": {
          "catalog_id": {
            "type": "string"
          },
          "components": {
            "items": {
              "$ref": "#/definitions/Component"
            },
            "type": "array"
          },
          "created_at_ms": {
            "format": "int64",
            "type": "integer"
          },
          "data_model": true,
          "description": {
            "type": "string"
          },
          "protocol_version": {
            "type": "string"
          },
          "send_data_model": {
            "type": "boolean"
          },
          "template_id": {
            "type": "string"
          },
          "theme": true,
          "title": {
            "type": "string"
          },
          "updated_at_ms": {
            "format": "int64",
            "type": "integer"
          }
        },
        "required": [
          "catalog_id",
          "components",
          "created_at_ms",
          "data_model",
          "description",
          "protocol_version",
          "send_data_model",
          "template_id",
          "title",
          "updated_at_ms"
        ],
        "title": "SurfaceTemplate",
        "type": "object"
      }
    },
    {
      "description": "List reusable A2UI templates stored for the current Harness session.",
      "metadata": {},
      "name": "a2ui::template::list",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "additionalProperties": false,
        "description": "List reusable templates in the authoritative Harness session.",
        "title": "TemplateListRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "Component": {
            "additionalProperties": true,
            "properties": {
              "component": {
                "description": "Component name from the negotiated catalog.",
                "type": "string"
              },
              "id": {
                "description": "Unique component id within the surface. `root` is the render root.",
                "type": "string"
              }
            },
            "required": [
              "component",
              "id"
            ],
            "type": "object"
          },
          "SurfaceTemplate": {
            "properties": {
              "catalog_id": {
                "type": "string"
              },
              "components": {
                "items": {
                  "$ref": "#/definitions/Component"
                },
                "type": "array"
              },
              "created_at_ms": {
                "format": "int64",
                "type": "integer"
              },
              "data_model": true,
              "description": {
                "type": "string"
              },
              "protocol_version": {
                "type": "string"
              },
              "send_data_model": {
                "type": "boolean"
              },
              "template_id": {
                "type": "string"
              },
              "theme": true,
              "title": {
                "type": "string"
              },
              "updated_at_ms": {
                "format": "int64",
                "type": "integer"
              }
            },
            "required": [
              "catalog_id",
              "components",
              "created_at_ms",
              "data_model",
              "description",
              "protocol_version",
              "send_data_model",
              "template_id",
              "title",
              "updated_at_ms"
            ],
            "type": "object"
          }
        },
        "properties": {
          "count": {
            "format": "uint",
            "minimum": 0,
            "type": "integer"
          },
          "templates": {
            "items": {
              "$ref": "#/definitions/SurfaceTemplate"
            },
            "type": "array"
          }
        },
        "required": [
          "count",
          "templates"
        ],
        "title": "TemplateListResponse",
        "type": "object"
      }
    },
    {
      "description": "Save an A2UI surface as a reusable template in the current Harness session.",
      "metadata": {},
      "name": "a2ui::template::save",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "additionalProperties": false,
        "properties": {
          "description": {
            "default": "",
            "type": "string"
          },
          "surface_id": {
            "description": "Surface to capture as a reusable template.",
            "type": "string"
          },
          "template_id": {
            "type": "string"
          },
          "title": {
            "default": null,
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "surface_id",
          "template_id"
        ],
        "title": "TemplateSaveRequest",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "definitions": {
          "Component": {
            "additionalProperties": true,
            "properties": {
              "component": {
                "description": "Component name from the negotiated catalog.",
                "type": "string"
              },
              "id": {
                "description": "Unique component id within the surface. `root` is the render root.",
                "type": "string"
              }
            },
            "required": [
              "component",
              "id"
            ],
            "type": "object"
          }
        },
        "properties": {
          "catalog_id": {
            "type": "string"
          },
          "components": {
            "items": {
              "$ref": "#/definitions/Component"
            },
            "type": "array"
          },
          "created_at_ms": {
            "format": "int64",
            "type": "integer"
          },
          "data_model": true,
          "description": {
            "type": "string"
          },
          "protocol_version": {
            "type": "string"
          },
          "send_data_model": {
            "type": "boolean"
          },
          "template_id": {
            "type": "string"
          },
          "theme": true,
          "title": {
            "type": "string"
          },
          "updated_at_ms": {
            "format": "int64",
            "type": "integer"
          }
        },
        "required": [
          "catalog_id",
          "components",
          "created_at_ms",
          "data_model",
          "description",
          "protocol_version",
          "send_data_model",
          "template_id",
          "title",
          "updated_at_ms"
        ],
        "title": "SurfaceTemplate",
        "type": "object"
      }
    },
    {
      "description": "Serve the a2ui worker's injected console UI assets (the target of its ade::ui::asset observers; the console calls it through each asset's observer with {path}).",
      "metadata": {
        "internal": true
      },
      "name": "a2ui::ui-content",
      "request_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "Input of the content function: the console asks for one asset by path.",
        "properties": {
          "path": {
            "description": "The asset path from the observer's args (e.g. `state/page.js`).",
            "type": "string"
          }
        },
        "required": [
          "path"
        ],
        "title": "UiContentInput",
        "type": "object"
      },
      "response_schema": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "Output of the content function.",
        "properties": {
          "content": {
            "description": "The asset source, verbatim.",
            "type": "string"
          },
          "content_type": {
            "description": "MIME type the console should serve the asset with.",
            "type": "string"
          }
        },
        "required": [
          "content",
          "content_type"
        ],
        "title": "UiContentResult",
        "type": "object"
      }
    }
  ]
}
```
