Skip to main content
RPC is a workspace session’s in-app API over JSON-RPC 2.0. Each method is named after the call it makes: shell is session.shell, vfs/read is session.vfs.read. Use it when a program drives the terminal: it moves bytes, and gets a line’s stdout, stderr and exit code apart. Every workspace on the Mirage server answers RPC at:

Connect

mirage rpc reads one message per line on stdin and writes one answer per line on stdout. It starts the server if needed and sends your token.
Answers come back as calls finish, so match them by id.

Auth

The same bearer token as the HTTP API. mirage rpc reads it from MIRAGE_TOKEN or ~/.mirage/auth_token.

Methods

? marks an optional param. initialize creates nothing and is optional: it reports the server and the workspace and session this connection is bound to. Bytes travel base64 in the *_base64 fields, and a message is at most 4 MiB, so stream larger stdin over HTTP or SSH. A non-zero exit is a result, not an error. The tools take the inputs listed under Call a tool.

Sessions

Calls run in the workspace’s default session. To use another, add ?session_id=<id> to the URL, or -s <id> to mirage rpc. The session’s profile applies to every method.

Cancel

Send the notification $/cancelRequest with the id of a running request. That request answers -32800, and its job ends canceled. A dropped HTTP request cancels its calls too.

Errors

A file error carries data: {"detail": "...", "errno": "EACCES"}.