Skip to content

Add AGUIMock — AG-UI protocol mock#100

Merged
jpr5 merged 5 commits into
mainfrom
feat/agui-mock
Apr 9, 2026
Merged

Add AGUIMock — AG-UI protocol mock#100
jpr5 merged 5 commits into
mainfrom
feat/agui-mock

Conversation

@jpr5

@jpr5 jpr5 commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

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.

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

  • 32 new tests (core 14, builders 5, edge cases 7, record/replay 6)
  • All 2246 tests pass
  • Build passes
  • 3-round CR loop converged at 0 findings

🤖 Generated with Claude Code

@pkg-pr-new

pkg-pr-new Bot commented Apr 9, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@copilotkit/aimock@100

commit: 3f36d90

@jpr5
jpr5 force-pushed the feat/agui-mock branch 3 times, most recently from 9a90085 to 76067f0 Compare April 9, 2026 23:12
jpr5 added 3 commits April 9, 2026 16:18
All 33 AG-UI event types, 11 convenience builders, fluent registration
API, SSE streaming with disconnect handling, and record/replay with
tee streaming and proxy-only mode.
32 unit tests (core, builders, edge cases, record/replay) plus 8
schema drift tests comparing against canonical @ag-ui/core Zod schemas.
@jpr5
jpr5 force-pushed the feat/agui-mock branch from 76067f0 to d2d8c0a Compare April 9, 2026 23:18
New AGUIMock docs page. Remove section bar from all pages (dead code).
Update homepage feature grid and competitive matrix with AG-UI.
Add AG-UI schema drift CI workflow.
@jpr5
jpr5 force-pushed the feat/agui-mock branch from d2d8c0a to 63aab1e Compare April 9, 2026 23:21
@jpr5
jpr5 merged commit 819ea26 into main Apr 9, 2026
20 checks passed
@jpr5
jpr5 deleted the feat/agui-mock branch April 9, 2026 23:28
jpr5 added a commit that referenced this pull request Jul 15, 2026
## 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant