← All Labs Workbench & Surfaces Whole-Session Spec-Distill Introspection & Interactive UI Artifacts
Workbench & Surfaces · Folded back

Whole-Session Spec-Distill Introspection & Interactive UI Artifacts

Dual-scope Session & Beats introspection (whole-conversation spec-distill lenses anchored to docs/standards/ vs single-turn Beat evaluation), transparent tool call Input/Output blocks, readable ui:// iframes with Expand modal, standalone /api/ui-resources/view, and durable /api/ui-resources/promote artifact publishing.

Folded back Needs: tool-calling Smoke: pnpm exec tsx examples/33-session-introspection-and-ui-artifacts/run.ts --smoke Run: pnpm exec tsx examples/33-session-introspection-and-ui-artifacts/run.ts Source: examples/33-session-introspection-and-ui-artifacts

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:

Whole-Session spec-distill introspection alongside transparent tool inputs and interactive UI resource artifacts

What Was Folded Into Packages

  1. Dual-Scope Session & Beats (beats.ts, beats.js):
    • 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 next D-N id:
    • Intent & Glossary, Decisions (JSONL), Tiered Rules & Standards, Open & OGIS Grilling, and Full Spec Distill via POST /api/beats/session/ask.
    • Automatically flags stale: true when newer turns arrive and forks cleanly on the next question.
    • Turns: isolates single-turn verification (Is it over?, Is it good?, Still open) on POST /api/beats/ask and clears stale poll error banners cleanly once reconnected.
  2. 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.
  3. Interactive ui:// Artifacts (server.ts, serve-shell.ts):
    • Extracts direct publish_ui_resource details objects alongside withUIResources() arrays.
    • Prevents flex vertical crushing (flex-shrink: 0) so inline UI iframes render at readable height (380px default) 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>.html plus optional artifacts.thefocus.ai publish).
    • Serves Shell modules with Cache-Control: no-store.

Usage

zsh
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

CheckWhat it proves
chat-tool-args-and-ui-extractedGET /api/state preserves tool call arguments and extracts direct publish_ui_resource details into message.ui.
ui-view-endpointGET /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-artifactPOST /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-sessionTurn-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-refreshA newer turn marks session.stale: true, and the next session ask re-forks cleanly at beat 3.
shell-assets-no-storechat.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:

  1. 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 createBeatLens and beats.js into default whole-session Session mode (SESSION_LENSES: Intent & Glossary, Decisions (JSONL), Tiered Rules & Standards, Open & OGIS Grilling, Full Spec Distill with loadWorkspaceSpecContext) and per-turn Turns mode (BEAT_LENSES: Is it over?, Is it good?, Still open).
  2. 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.js now displays an inline argument summary right inside <summary> (Used bash ls -la) and separates Input ($ <command>) and Output inside <details>.
  3. Missing & Vertically Crushed publish_ui_resource Previews:
    • Observation: First, transcript() only read message.details.uiResources (from withUIResources()) and dropped publish_ui_resource which writes { uri, mimeType, text } directly onto message.details. Second, once extracted, .umw-ui-card lacked flex-shrink: 0 inside the flexing .umw-chat-log column container, crushing the iframe vertically to ~30px beneath a tall Markdown reply.
    • Fix: Added extractMessageUiResources(), flex-shrink: 0 with 380px default frame height, a full-viewport <dialog class="umw-ui-modal"> (Expand), GET /api/ui-resources/view (Open ↗), and POST /api/ui-resources/promote + jailed GET /api/artifacts/:filename (Promote to Artifact).
  4. Cache-Control: no-cache Held Stale Component Modules:
    • Observation: Switching serve-shell.ts from no-cache to no-store ensured reloads fetch updated built-in ES modules immediately without revalidation ambiguity.