🤖 AG-UI WASM Worker Test (Pure Rust) - CopilotKit Protocol
Test the AG-UI (Agent User Interaction Protocol) Rust SDK running in a Cloudflare Worker via WASM - Pure Rust Implementation
❓ What is AG-UI?
AG-UI (Agent User Interaction Protocol) is an open, lightweight, event-based protocol created by CopilotKit that standardizes how AI agents communicate with user interfaces in real-time.
- 🔄 Real-time Streaming: AI agents send events as they work (like typing indicators and progressive responses)
- 📋 Standardized Events: Common event types like RUN_STARTED, TEXT_MESSAGE_CONTENT, etc.
- 🌐 Universal Protocol: Works across different AI providers and user interfaces
- ⚡ Live Updates: Users see AI thinking and responding in real-time, not just final results
📖 Learn more at github.com/attackordie/ag-ui | docs.ag-ui.com | copilotkit.ai
🚀 Why This Demo is Impressive
- 🔧 Complete Web Service in Rust: HTTP handling, HTML interface, and AG-UI protocol (by CopilotKit) - all in Rust via WASM
- ⚡ Real-time Streaming: Server-Sent Events with native Rust Web Streams API integration
- 🛡️ Type Safety: Full Rust type checking across the entire stack with zero runtime errors
- 🌐 Production Ready: Proper CORS, error handling, and async streams in serverless environment
- 📦 Self-Contained: This HTML page is embedded as a Rust string constant!
📋 What You'll See When You Run the Agent
Click "🚀 Run Agent" to see exactly 5 AG-UI events stream in real-time. Here's what each one means:
- RUN_STARTED: Workflow begins - Rust router processes your request and initializes the AG-UI stream
- TEXT_MESSAGE_START: Assistant message begins - UUID generated in Rust for message tracking
- TEXT_MESSAGE_CONTENT: Message content streams - Demonstrates real-time delta content delivery
- TEXT_MESSAGE_END: Message complete - Same UUID links all message events together
- RUN_FINISHED: Workflow complete - Stream closes and resources cleaned up automatically
💡 All events happen synchronously in this demo, but in production they could be spaced out as real AI processing occurs!
Ready to test AG-UI Worker (Pure Rust) - CopilotKit Protocol
🔍 Technical Details
- Architecture: Browser → Cloudflare Worker V8 Isolate → JavaScript shim (26 lines) → WASM module → Rust code (400+ lines)
- WASM Compilation: Rust source compiled to WebAssembly binary via wasm-bindgen, running in V8's secure isolate sandbox
- JavaScript Shim: Minimal 26-line loader that initializes WASM module and forwards requests to Rust handler
- V8 Isolate: Each request runs in its own isolated V8 context with deterministic execution and memory limits
- Stream Flow: Rust creates ReadableStream → SSEEncoder formats events → Server-Sent Events → Browser EventSource API
- Type Safety: Every event uses strongly-typed Rust structs from ag-ui-wasm crate, compiled to WASM with zero runtime overhead
- Protocol: Full AG-UI compliance with proper event lifecycle management (CopilotKit's protocol)
- Performance: Zero-copy WASM integration, automatic memory management, and V8 JIT optimization
📖 View source code and documentation: github.com/attackordie/ag-ui/tree/main/rust-sdk