A2UI icon indicating copy to clipboard operation
A2UI copied to clipboard

Proposal: Motia-Based A2UI Protocol Server

Open rohitg00 opened this issue 1 week ago • 0 comments

Summary

I'd like to propose adding a Motia-based server implementation for A2UI that provides production-ready infrastructure for the protocol. This complements the existing client renderers with a standardized server-side solution.

Background

A2UI currently provides excellent client-side renderers (Lit, Angular, Flutter) and sample agents. However, each agent implementation currently needs to:

  • Manually manage surface state
  • Implement custom streaming logic
  • Handle session isolation independently
  • Build observability from scratch

Proposed Solution

Motia is an open-source, event-driven backend framework that provides:

Feature Benefit
Event-driven steps Each A2UI operation is a discrete, testable unit
Visual Workbench Debug and visualize flows in real-time
State management Redis-backed with in-memory fallback
Real-time streams WebSocket-based live updates
Session isolation Per-session state namespacing
LLM integration Ready for Gemini/OpenAI/Claude

Demo Screenshots

AI-Powered UI Generation with Gemini

A2UI Demo

Generate complex UIs from natural language prompts

Visual Flow Debugging

Workbench

See A2UI flows as interactive diagrams

Implementation Details

The implementation provides:

REST API Endpoints

Method Endpoint Description
POST /a2ui/surfaces Create surface
GET /a2ui/surfaces List surfaces
GET /a2ui/surfaces/:id Get surface
PUT /a2ui/surfaces/:id/components Update components
PATCH /a2ui/surfaces/:id/data Update data model
DELETE /a2ui/surfaces/:id Delete surface
POST /a2ui/actions Handle user action
POST /demo/generate-ui Gemini AI generation

File Structure

server/motia/
├── motia.config.ts
├── package.json
├── steps/
│   ├── a2ui/           # Core protocol steps
│   ├── streams/        # Real-time streams
│   └── demo/           # Demo agents
└── public/
    └── demo.html       # Interactive demo client

Benefits

  1. Reference Implementation: Canonical server demonstrating best practices
  2. Interoperability Testing: Test any client against the Motia server
  3. Faster Onboarding: Visual tools help understand the protocol
  4. Production Path: From demo to production with the same codebase

Integration Options

Option A: Standalone Server

[Client] ←→ [Motia A2UI Server] ←→ [Gemini LLM]

Option B: Protocol Gateway

[Client] ←→ [Motia Gateway] ←→ [Python ADK Agents]

Try It

cd server/motia
npm install
echo "GEMINI_API_KEY=your_key" > .env
npm run dev

# Open http://localhost:3000 for Workbench
# Serve public/demo.html for interactive demo

Questions for Maintainers

  1. Does this align with the A2UI roadmap?
  2. Should this live in server/motia/ or a separate repo?
  3. Any specific requirements for server implementations?

Additional Context


Looking forward to your feedback! 🙏

If looks good, I can submit a PR.

rohitg00 avatar Dec 16 '25 00:12 rohitg00