Not built yet. PROMPT.md is the prompt to build it from.
The other labs cover state that lives on the server: Lab 13 sends a view next to a summary, and home lights has the model and the view share one MCP server. This lab is about state that lives only in the view, like an unsaved form. The agent sent the user a ui:// settings form and now wants to fill it in. There are three ways:
| Mode | How the agent reaches the form |
|---|---|
| push | The app sends its state to the model (ui/update-model-context, stable MCP Apps spec). The model can read but not act. |
| pull | The host calls tools the app registered (app.registerTool, the draft spec's app-provided tools): UI SDK's generic snapshot, query, act. |
| click | Browser automation against the iframe's accessibility tree. |
The same task runs in each mode. The scorecard counts tool calls, characters returned to the model and wall time, and a run is correct when the form saved once with exactly the task's values.
The checks the build should end with: pull is correct; click is correct; pull uses fewer tool calls and fewer characters than click; push reports that it can't act; the model-facing text never contains the app's HTML.
Known going in (checked 2026-12-01)
- ext-apps 2.x on both sides.
@modelcontextprotocol/ext-apps@^2.1.0is a root dev dependency and matches the repo's v2 MCP SDK:App,app.registerTool(),oncalltoolin the app;AppBridgeandPostMessageTransportfrom@modelcontextprotocol/ext-apps/app-bridgein the host, withbridge.listTools()/bridge.callTool(). - Don't host it with
@mcp-ui/client. ItsAppRendererref can't reach host→appcallTool, and itsAppFramedepends on ext-apps 1.x. The host creates the sandboxed iframe and connects a 2.xAppBridgeitself. - App-provided tools are draft-spec only. The app must declare the
toolscapability; record which side refuses if they don't match. - UI SDK is
@ui-sdk/web(0.1.0-beta.23) withcreateAgentandagentToolsin@ui-sdk/web/agent. ItsregisterToolswrites todocument.modelContext, which a sandboxed iframe doesn't have, so register throughapp.registerTool. snapshot()sees only UI SDK components; a bare<button>is invisible to it.
Moved out
- The person-gate (
data-agent-confirmsteps approved as the viewing user) is a second question and blocked on identity: there is norunWithSpeakerin the code, only in the archived ADR 0005. It can be its own lab once an approval can carry a verified speaker. - Driving a view from the chat client (the page sending
tools/callto a view on the model's behalf) needs a relay from the agent process to the browser that doesn't exist yet; D-21 holds the design.
Prompt
Build `examples/18-agent-operable-ui/`: a lab that measures how an agent can fill in a form whose state lives only inside a ui:// MCP App it sent, three ways: the app pushes its state, the host calls tools the app registered (pull), or the agent clicks the iframe.
Read first: `examples/18-agent-operable-ui/README.md` (known facts), `packages/habitat/src/ui-resources.ts` (`buildHabitatUIResource`), `packages/protocols/src/mcp-serve/server.ts`, `examples/_chat/ui/index.html` (how views are hosted: JSON-RPC over postMessage, `ui/initialize`), the `.d.ts` files of `@modelcontextprotocol/ext-apps` (`App`, `AppBridge`, `PostMessageTransport`) and `@ui-sdk/web` / `@ui-sdk/web/agent` (`createAgent`, `agentTools`). Don't read compiled `dist/*.js`. Don't import from another lab.
1. The app (`app/settings.html`, bundled to one inline HTML string with esbuild): a project settings form built only from UI SDK web components, with Field + Input "Project name", Select "Visibility", a members list with a per-row Select "Role for <name>", Switches "Email: Deploy failures", "Email: Weekly digest", "Slack: Deploy failures", and a "Save" Button. Every control has a unique accessible name. It connects `new App(...)` over PostMessageTransport, declares the `tools` capability, creates one `createAgent()` bridge and registers `snapshot`, `query`, `act` with `app.registerTool` using `agentTools`' names, descriptions and schemas verbatim. It pushes its full state with `ui/update-model-context` after every change. On Save it posts the saved values to the host once.
2. An MCP server (createMcpServer on 127.0.0.1) with one tool, `project_settings_card`, returning a one-sentence summary plus `buildHabitatUIResource({ uri: "ui://lab18/settings", html })`.
3. A host page on 127.0.0.1 that renders the resource in an iframe it creates, sandboxed `allow-scripts` only (never with `allow-same-origin`), connected to an ext-apps 2.x AppBridge it owns, and shows the scorecard.
4. `run.ts` runs one task in each mode: rename to Atlas, visibility Internal, Priya Shah admin, Email Deploy failures on, Weekly digest off, Slack untouched, save. push: the model gets only the pushed context and no way to act. pull: the model's tools are the three app tools, routed through `bridge.callTool`. click: the model's tools are Playwright accessibility snapshot / click / type on the iframe. Offline, script a faux model per mode; `--live --model mycel:<id>` uses a Mycel model (no direct vendor keys, D-28) with the same system prompt in every mode. Count tool calls, characters returned to the model, and wall time. A run is correct when the app saved once with exactly those values.
5. `--smoke` launches Chromium headless, runs all three modes offline, prints the scorecard, and prints one PASS/FAIL line per check, exiting 1 on any failure: pull-correct; click-correct; pull-cheaper (fewer tool calls and fewer characters than click, from counted calls); push-cannot-act; no-html-to-model.
6. Bind to 127.0.0.1, keep scratch state in mkdtemp, clean up in `finally`, strict TypeScript with no `any`. README frontmatter (status built) and a FINDINGS.md with what building it taught us.
--live opt-in
What we learned
Not run yet. When it is, record the scorecard (offline and live), whether pull mode held UI SDK's reported 2-call result inside a sandboxed iframe, and which hosts or renderers supported app-provided tools.
Design findings so far:
- The lab tested two things. It also asked whether destructive actions stay gated on a person approved as the viewing user. That needs a verified speaker in the view host, and
runWithSpeakerexists only in the archived ADR 0005, so the gate moved out until identity reaches the view. - Its prompt pointed at paths that don't exist (
examples/lab-10-agent-operable-ui/,examples/15-mcp-oauth-ui-roundtrip/) and at a direct vendor model for live runs. It now uses this folder andmycel:models. @ui-sdk/webis real, contrary to the review that flagged it: it's on npm at0.1.0-beta.23.