pnpm exec tsx examples/23-a2a-view-artifacts/run.ts --smoke
Lab 13 shows a tool's view reaching the person in the chat client. This lab asks whether another agent gets it too. One DurableHabitat with one plain tool (show_status, returning withUIResources(summary, view)) runs an offline faux model and is served over A2A with a bearer token. A second copy is served without uiResources as a control.
| Check | What it shows |
|---|---|
card-advertises-html | The agent card lists text/html output |
task-carries-view | SendMessage answers with the summary and a text/html URL artifact on the agent's origin; fetching it with the token returns the tool's HTML |
view-needs-token | The same URL without the token gets 401 |
view-sandboxed | The view is served with content-security-policy: sandbox … |
wrong-mac-refused | Changing one character of the URL's MAC gets 404 |
off-without-option | Without uiResources the same turn answers with the summary and no view artifact |
Break it
In packages/habitat/src/durable/durable-habitat.ts, make serveUIView accept a missing identity (identity = (await identify()) ?? "bypass"). view-needs-token fails and the smoke exits 1.
Split out of Lab 13, whose smoke used to include these checks with authentication turned off for loopback.
Prompt
Build a self-contained script that opens a DurableHabitat with one plain @umwelten/pi tool returning withUIResources(summary, buildHabitatUIResource(view)), driven by a scripted faux model that calls the tool once and then answers from its summary. Serve it over A2A with createA2ASurface({ uiResources: true, bearerToken }) on a loopback HTTP server, plus a second copy without uiResources as a control. Check, one PASS/FAIL line each and exit 1 on any failure: the card lists text/html output; SendMessage answers with the summary and a text/html URL artifact on the agent's origin that returns the tool's HTML with the token; the same URL without the token is refused; the view is served with a sandbox CSP; a URL with one changed MAC character gets 404; the control answers without a view artifact.
--live opt-in
What we learned
The answer
Another agent gets the view, and only with the token. With uiResources: true a completed task carries each ui:// view as a text/html URL artifact under /a2a/ui/… on the agent's own origin. Fetching it needs the same bearer token as /a2a (401 without), it's served with a sandbox CSP, and a URL with a wrong MAC gets 404. Without the option the same turn carries the summary only.
What going through it found
- Lab 13 never tested the authentication. Its A2A checks ran with
allowUnauthenticatedLoopback, so a view server that ignored the token passed them. This lab sets a bearer token; bypassing the identity check inserveUIViewfailsview-needs-token. - A first break test passed by mistake.
"bypass" ?? auth ? await auth(req) : …parses as("bypass" ?? auth) ? …, so auth still ran. A break test has to be checked for actually breaking something.
Gotchas
- pi-a2a 0.5.1 authenticates the agent card too.
GET /.well-known/agent-card.jsongets 401 without the token, so a client has to know the token before it can read thesecuritySchemesthe card advertises. A2A expects the public card to be readable; this is upstream behavior ina2aHttpHandler, not changed here. - Views are served on the agent's origin because pi-a2a only accepts URL artifacts there; a separate view host wouldn't work.
- The URL's MAC key is per surface instance. Restarting the agent invalidates every view URL it handed out.
Not tested
- A2A streaming (
SendStreamingMessage) artifacts. - More than one view per turn (the surface sends at most four).
- A real A2A client rendering the view.
Smoke run
PASS card-advertises-html: card lists text/html output PASS task-carries-view: answer has the summary; view URL on the agent's origin → 200, the tool's HTML PASS view-needs-token: without the bearer token → 401 PASS view-sandboxed: content-security-policy: sandbox allow-scripts allow-forms PASS wrong-mac-refused: one changed character in the URL → 404 PASS off-without-option: without uiResources: summary present, view artifact absent 6/6 passed