A small TypeScript kit for direct A2UI v0.8 answer contracts, compatibility keys, and normalization helpers for rich agent answers.
This repository focuses on one boundary:
- the model returns a typed final answer
- the backend validates and normalizes it
- the UI renders the final payload natively
- transport lifecycle remains a separate concern
It is part of a small public code series:
agent-code-playbook-kitfor process IR and compiled runtime playbooksagent-code-runner-sandboxfor bounded execution primitivesagent-code-observer-mcpfor semantic tool surfaces and MCP bridgingagent-code-a2ui-contractsfor structured rich-answer contractsorg-aware-agentsfor the docs-first architecture layer
src/types.ts—A2UI v0.8message-batch and structured-answer typessrc/normalize.ts— defensive normalization helpers for direct rich answerssrc/reasoning.ts— reasoning-summary normalization helpersrc/schema.ts— JSON-schema builder for final answer outputexamples/— public-safe answer payloadstest/— focused tests for invariants
Many agent systems stop at:
- markdown answers
- free-form JSON
- UI-specific widget DTOs
That is not a stable contract.
A stronger setup uses:
- one typed final-answer protocol
- a compatibility key for thread reuse / rollout boundaries
- backend-side validation and normalization
- explicit separation between interaction transport and final presentation
npm install
npm test
npm run build
npm run demo- direct
A2UI v0.8message batches - structured answers with
summaryMarkdown + presentation.kind + payload - message-batch to document projection for renderers
- user-facing text sanitization
- reasoning-summary cleanup
- compatibility-key based rollout thinking