The mock agents server speaks the real agents server protocol, signed CBOR over HTTP and JSON frames over WebSocket, with scripted replies instead of a model. It lets the Agents UI be tested for streaming, tools, plans, waiting runs and reconnects without spending a model call.
Files
File | Role |
|---|---|
The server. Ported from the archived React Native app's | |
| |
Regenerates |
Run it alone with bun tools/mock-agents/server.ts; the test server imports it at startup. It binds loopback only and keeps no persistent state.
Port note
The server binds 3068. Comments in tools/test-server/index.ts and one net.fetch grant in app.ts still say 3058, and agents.test.ts uses 3058 only as an example URL for pure functions. Those references are stale; nothing listens on 3058.
Protocol endpoints
Path | Behaviour |
|---|---|
| A signed |
|
|
WebSocket | The first frame is a signed envelope whose action carries |
Both path layouts exist because the app resolves a standalone layout and a site mounted layout, see Agents: signed action envelope and endpoints.
Envelope verification
accountFromEnvelope (server.ts L536-L548) requires:
signer is a 34 byte Ed25519 principal (0xed 0x01 prefix).
type is AgentsAction and protocol is 3.
The signature verifies over the envelope encoded with a zero filled 64 byte sig.
account equals signer: "Fixture requires a direct signer", so delegation is not accepted.
action.ts is within 300000 ms (5 minutes) of the server's real clock, else Stale request timestamp.
Implemented actions
handleAction (server.ts L308-L523) implements ListAgents, GetAgent, ListModelProviders, SetSecret, SetModelProvider, CreateAgent, ListProviderModels, ListSessions (cursor paging, default limit 50), CreateSession, GetSession, UpdateSession, MessageSession, RetrySession, ListRuns, GetRun, GetRunJournal, SignalRun, CancelRun, StopSession, DeleteSession, and empty lists for ListAgentInvites, ListAgentTriggers, ListAgentTools, ListSigningIdentities. Anything else answers Mock server does not implement <name>.
Scripted turns
MessageSession returns at once and plays the turn over the socket. scriptFor picks a script by keyword in the user's text (server.ts L119-L125):
Keyword | Script |
|---|---|
| A three step plan updated every 700 ms; the third step is marked |
| A |
| The run parks as |
anything else | A streamed Markdown reply |
Assistant text streams as appendPartial frames, one word every 45 ms, followed by one durable append event.
Control endpoints
All are POST on port 3068. From a Contract test they are written as request POST "/dev/..." { }; the driver sends them to 4790 and the test server forwards /dev/*.
Path | Body | Effect |
|---|---|---|
| none | Clears everything and seeds session |
| none | Seeds fixtures: |
| none | Marks run |
| none | Adds 55 older sessions, enough for a second page |
| none | The next |
| none | Closes every socket subscribed to |
| none | Records subscription count, last read timestamp and read count |
| none | 200 only if no new subscription was opened, at least one read arrived, and the read timestamp advanced by at least 180000 ms; else 409 |
|
| 200 only if a provider saved through |
Who uses it
agents.test.contract: all 15 tests. The file opens at /agents-test, taps agents-test-key to use a fixture signer, and waits with clock until state ... within 15000 because the socket runs on real time. The fixture signer is refused for any server other than MOCK_AGENTS_URL (sources.ts L29-L33).
The Bun agents tests do not start this server; they stub fetch and feed frames to the stream mapper directly.
Do you like what you are reading? Subscribe to receive updates.
Unsubscribe anytime