Skip to content

Add AsyncAPI schema for stream server WebSocket protocol#997

Open
bilby91 wants to merge 2 commits intovercel-labs:mainfrom
crunchloop:feat/asyncapi-stream-schema
Open

Add AsyncAPI schema for stream server WebSocket protocol#997
bilby91 wants to merge 2 commits intovercel-labs:mainfrom
crunchloop:feat/asyncapi-stream-schema

Conversation

@bilby91
Copy link
Copy Markdown

@bilby91 bilby91 commented Mar 24, 2026

Summary

  • Add a formal AsyncAPI 3.0 schema (schemas/stream-server.asyncapi.yaml) documenting all 7 stream server message types
  • Add stream_protocol.rs with typed serde structs derived from the schema, replacing inline json!() macros in stream.rs
  • Update README to reference the schema instead of duplicating JSON examples

Closes #995

Motivation

The stream server's WebSocket protocol is currently defined implicitly via inline json!() macros scattered across stream.rs. This makes it hard for consumers building clients in other languages to depend on a stable contract, and means protocol changes aren't visible as schema diffs.

What changed

schemas/stream-server.asyncapi.yaml — Single source of truth for the wire protocol. Covers server-to-client messages (frame, status, error) and client-to-server messages (input_mouse, input_keyboard, input_touch, status request). Validates clean with @asyncapi/cli.

cli/src/native/stream_protocol.rs — Typed Rust structs with #[derive(Serialize)] / #[derive(Deserialize)] matching the schema. Includes a ClientMessage tagged enum for deserialization dispatch. 8 unit tests verify wire format round-trips.

cli/src/native/stream.rs — Refactored to use the typed structs. All json!() macros for stream protocol messages replaced. Remaining json!() calls are CDP protocol commands (different protocol, unchanged).

README.md — Streaming section now points to the schema for full details, with a compact inline example.

Test plan

  • All 13 stream/protocol unit tests pass (cargo test stream)
  • All 43 e2e tests pass (cargo test e2e -- --ignored --test-threads=1)
  • AsyncAPI schema validates with @asyncapi/cli validate

@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Mar 24, 2026

@bilby91 is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

bilby91 and others added 2 commits March 27, 2026 19:38
Add a formal AsyncAPI 3.0 schema documenting the stream server's
WebSocket protocol and replace inline json!() macros with typed
serde structs derived from it.

- Add schemas/stream-server.asyncapi.yaml with all 7 message types
- Add stream_protocol.rs with Serialize/Deserialize structs and tests
- Refactor stream.rs to use typed protocol structs
- Update README to reference the schema

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Derive CommandMessage, ResultMessage, ConsoleMessage, PageErrorMessage,
TabsMessage, and UrlMessage from the AsyncAPI spec. Replace all remaining
ad-hoc json!() calls in stream.rs with the typed structs. Update the
AsyncAPI schema with the new message types added in main (engine,
recording, tabs, console, page_error, url, windowsVirtualKeyCode).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bilby91 bilby91 force-pushed the feat/asyncapi-stream-schema branch from ba83e7e to 8ac65ec Compare March 27, 2026 22:56
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.

Add AsyncAPI schema for the WebSocket stream server protocol

1 participant