## Summary
- New `AGUIMock` class implementing the AG-UI (Agent-to-UI) protocol —
the SSE event streaming protocol CopilotKit uses between agents and the
frontend
- All 33 AG-UI event types supported (lifecycle, text, tool calls,
state, activity, reasoning, special, deprecated)
- 11 event builder functions for common patterns (text response, tool
call, state update, reasoning, activity, etc.)
- Fluent registration API: `onMessage()`, `onRun()`, `onToolCall()`,
`onStateKey()`, `onReasoning()`, `onPredicate()`
- Record & replay with tee streaming — proxy to real AG-UI agents,
record event streams as fixtures, replay on subsequent requests
- Proxy-only mode (`--agui-proxy-only`) — forward without saving or
caching
- Standalone and mountable modes (mount at `/agui` on LLMock)
- Config file, suite, and CLI support (`--agui-record`,
`--agui-upstream`, `--agui-proxy-only`)
## Use case
Frontend developers can test CopilotKit UI components without a running
agent backend. Point the frontend at aimock's `/agui` endpoint and get
deterministic AG-UI event streams from fixtures. For demos, use
proxy-only mode with canned fixtures for repeatable scenarios while
proxying unknown traffic to the real agent.
```ts
const agui = new AGUIMock();
agui.onMessage("hello", "Hi! How can I help?");
agui.onToolCall(/search/, "web_search", '{"q":"test"}', { result: "[]" });
agui.enableRecording({ upstream: "http://localhost:8000/agent", proxyOnly: true });
const llm = new LLMock();
llm.mount("/agui", agui);
await llm.start();
```
## New files
- `src/agui-types.ts` — 33 event type definitions, fixture/match types
- `src/agui-handler.ts` — matching, 11 builders, SSE writer
- `src/agui-mock.ts` — AGUIMock class (Mountable)
- `src/agui-recorder.ts` — record/replay with tee streaming, proxy-only
mode
- `src/agui-stub.ts` — barrel exports
- `src/__tests__/agui-mock.test.ts` — 32 tests
## Modified files
- `src/config-loader.ts` — AGUIConfig support
- `src/suite.ts` — agui option in MockSuite
- `src/index.ts` — AG-UI exports
- `src/cli.ts` — AG-UI recording flags
## Test plan
- [x] 32 new tests (core 14, builders 5, edge cases 7, record/replay 6)
- [x] All 2246 tests pass
- [x] Build passes
- [x] 3-round CR loop converged at 0 findings
🤖 Generated with [Claude Code](https://claude.com/claude-code)