Ruyi

Ruyi (如意)

An AI browser-automation workbench
Stream a Chrome that runs on a remote machine into your own browser and drive it with your mouse and keyboard.
Then tell it what to do: the AI plans, locates, acts, and turns every action into a self-healing script.

AGPL-3.0 License Python 3.9+ Node 18+ macOS | Linux tech validation demo

What it validates · Quick start · What it does · Who it's for · Roadmap · 中文

> **Technical-validation demo**: one complete user flow that exercises the streaming and AI-automation techniques listed below. Run from source. Developed and verified on macOS; Linux and Windows launch scripts are included but not systematically tested. You need an API key for a vision-language model (Qwen3-VL, Doubao, GPT-4o, Claude, Gemini all work) or a local model.

Type a request, the AI plans, locates, clicks, and the step is recorded

On the left is the remote Chrome, streamed live. Typing "click the Q&A button": the AI plans first, then locates the Q&A entry in the navigation bar and clicks it. After the page changes, the step is written into the script on the right. Recorded in a local demo against testerhome.com.

## The browser it controls is remote This is the main difference between Ruyi and most "AI drives the browser" tools: the Chrome being driven does not have to be on your machine. - **Chrome runs remotely.** A server, a machine inside your network, or a headless instance on your own box. It is taken over through CDP and its screen is pushed to your browser over WebRTC or MJPEG in real time. - **You drive it locally.** Mouse, wheel, keyboard and CJK input travel back from your browser to the remote side, so it feels like a local browser. Frame rate, quality and resolution are adjustable live, and a TURN setup script is included for cross-network use. - **AI and humans share one browser.** You watch every click the AI makes as it happens; when it gets stuck, you take over directly, without stopping the service or logging into the remote machine for a screenshot. - **One pipeline, many uses.** Cloud browser, remote debugging, a visible window into headless environments, several clients watching the same screen. The AI chat, recording and self-healing scripts below are all built on top of this remote browser. ## What this demo validates The streaming pipeline is where most of the effort went. Each stage below lists what it validates and where the code lives. ### Screen streaming and remote control | What is validated | Code | |-------------------|------| | **Capture**: push-mode frames through CDP `Page.startScreencast`, with `captureScreenshot` polling as the fallback | `headless/cdp_client.py` | | **Encoding**: three routes compared. Raw JPEG passthrough for MJPEG, no re-encoding, quality equal to the screenshot; a patched aiortc VP8 encoder tuned for text and UI content; hardware H.264 via VideoToolbox, NVENC, QSV or VAAPI, with libx264 as the fallback | `headless/mjpeg_server.py`, `headless/encoder_patch.py`, `headless/h264_encoder.py` | | **Low-latency mode**: a scrcpy-style path. Push capture, lossless PNG input, ultrafast and zerolatency, no B-frames, fixed GOP, and a custom binary frame protocol (video, SPS/PPS, control and stats messages with PTS) | `headless/scrcpy_capture.py`, `headless/scrcpy_encoder.py`, `headless/h264_stream_protocol.py` | | **Transport**: WebRTC (aiortc, SDP negotiation plus a DataChannel) and WebSocket, dispatched by one stream server according to the active mode; TURN setup script included | `headless/webrtc_bridge.py`, `headless/stream_server.py`, `setup_turn_china.sh` | | **Decoding**: chosen by browser capability. `` per frame for MJPEG, MSE feeding H.264 into `