Extends Lab 28 inside @umwelten/agent and @umwelten/substrate so conversation inspection matches spec-distill governance and publish_ui_resource outputs become first-class interactive artifacts:

What Was Folded Into Packages
- Session (default tab): runs tool-less forks anchored to the latest finished turn covering the entire conversation, seeded with workspace
docs/standards/,docs/specs/, and nextD-Nid: Intent & Glossary,Decisions (JSONL),Tiered Rules & Standards,Open & OGIS Grilling, andFull Spec DistillviaPOST /api/beats/session/ask.- Automatically flags
stale: truewhen newer turns arrive and forks cleanly on the next question. - Turns: isolates single-turn verification (
Is it over?,Is it good?,Still open) onPOST /api/beats/askand clears stale poll error banners cleanly once reconnected.
- Session (default tab): runs tool-less forks anchored to the latest finished turn covering the entire conversation, seeded with workspace
- Transparent Tool Inputs (
chat.js):- Shows inline command/path/argument previews directly in collapsed
<summary>rows (Used bash ls -la) and both Input and Output blocks inside expanded tool details.
- Shows inline command/path/argument previews directly in collapsed
- Extracts direct
publish_ui_resourcedetailsobjects alongsidewithUIResources()arrays. - Prevents flex vertical crushing (
flex-shrink: 0) so inline UI iframes render at readable height (380pxdefault) with Expand (full-viewport<dialog>modal), Open ↗ (/api/ui-resources/view), and Promote to Artifact (POST /api/ui-resources/promote->/api/artifacts/<YYYY-MM-DD>-<slug>.htmlplus optionalartifacts.thefocus.aipublish). - Serves Shell modules with
Cache-Control: no-store.
- Extracts direct
Usage
pnpm exec tsx examples/33-session-introspection-and-ui-artifacts/run.ts --smoke
pnpm exec tsx examples/33-session-introspection-and-ui-artifacts/run.ts --workspace . --port 7460
Checks
| Check | What it proves |
|---|---|
chat-tool-args-and-ui-extracted | GET /api/state preserves tool call arguments and extracts direct publish_ui_resource details into message.ui. |
ui-view-endpoint | GET /api/ui-resources lists ui://demo/landing; GET /api/ui-resources/view serves 200 text/html with sandbox CSP and Cache-Control: no-store. |
ui-promote-local-artifact | POST /api/ui-resources/promote persists an HTML artifact served by GET /api/artifacts/:filename, and path traversal (..%2Fescape.html) returns 403. |
dual-scope-beats-and-session | Turn-level lenses (over, quality, open) reject session-only lenses on /api/beats/ask, while /api/beats/session/ask runs decisions across all finished turns. |
session-staleness-and-refresh | A newer turn marks session.stale: true, and the next session ask re-forks cleanly at beat 3. |
shell-assets-no-store | chat.js and beats.js serve 200 with Cache-Control: no-store, tool arg formatting, artifact promotion, and Session & Beats. |
Break it
In packages/agent/src/runtime/server.ts, revert extractMessageUiResources(message.details) to only check details.uiResources; chat-tool-args-and-ui-extracted, ui-view-endpoint, and ui-promote-local-artifact immediately fail and --smoke exits 1.
What we learned
Testing the upgraded Workbench live against google:gemini-4-hydrogen on /Users/wschenk/The-Focus-AI/umwelten surfaced four immediate real-world bugs that were resolved and folded into the packages:
- Conflating Whole-Session Spec Distillation with Single-Beat Evaluation:
- Observation: Asking "Intent" or "Decisions" on the latest beat alone missed cross-turn decisions settled earlier in the session and ignored active Tier 0 rules in
docs/standards/. - Fix: Split
createBeatLensandbeats.jsinto default whole-session Session mode (SESSION_LENSES:Intent & Glossary,Decisions (JSONL),Tiered Rules & Standards,Open & OGIS Grilling,Full Spec DistillwithloadWorkspaceSpecContext) and per-turn Turns mode (BEAT_LENSES:Is it over?,Is it good?,Still open).
- Observation: Asking "Intent" or "Decisions" on the latest beat alone missed cross-turn decisions settled earlier in the session and ignored active Tier 0 rules in
- Invisible Tool Call Inputs (
Used bash):- Observation: Chat showed
Used bash/Used write, forcing the user to expand output without seeing what command or arguments were passed. - Fix:
chat.jsnow displays an inline argument summary right inside<summary>(Used bash ls -la) and separates Input ($ <command>) and Output inside<details>.
- Observation: Chat showed
- Missing & Vertically Crushed
publish_ui_resourcePreviews:- Observation: First,
transcript()only readmessage.details.uiResources(fromwithUIResources()) and droppedpublish_ui_resourcewhich writes{ uri, mimeType, text }directly ontomessage.details. Second, once extracted,.umw-ui-cardlackedflex-shrink: 0inside the flexing.umw-chat-logcolumn container, crushing the iframe vertically to ~30px beneath a tall Markdown reply. - Fix: Added
extractMessageUiResources(),flex-shrink: 0with380pxdefault frame height, a full-viewport<dialog class="umw-ui-modal">(Expand),GET /api/ui-resources/view(Open ↗), andPOST /api/ui-resources/promote+ jailedGET /api/artifacts/:filename(Promote to Artifact).
- Observation: First,
Cache-Control: no-cacheHeld Stale Component Modules:- Observation: Switching
serve-shell.tsfromno-cachetono-storeensured reloads fetch updated built-in ES modules immediately without revalidation ambiguity.
- Observation: Switching