Host API
Each running VM exposes a Unix domain socket on the host for programmatic access to VM operations. This enables custom integrations and scripted automation.
Overview
When a VM starts, the GhostVMHelper process creates a Unix socket at:
~/Library/Application Support/GhostVM/api/<VMName>.GhostVM.sockThe socket name is derived from the VM name (e.g. a VM named “dev” gets dev.GhostVM.sock). Any process on the host can connect to this socket to query or control the VM.
Wire Protocol
The Host API uses standard HTTP/1.1 over the Unix socket. Send a normal HTTP request and read an HTTP response.
GET /health HTTP/1.1
Host: localhost
Content-Length: 0HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 15
{"status":"ok"}Any HTTP client that supports Unix domain sockets works — curl --unix-socket, Python's requests_unixsocket, or a raw socket connection.
Endpoints
All requests are proxied through the vsock connection to the GhostTools agent running inside the guest.
| Method | Path | Description |
|---|---|---|
GET | /health | Check if the guest agent is reachable |
GET | /api/v1/clipboard | Get guest clipboard contents |
POST | /api/v1/clipboard | Set guest clipboard contents |
GET | /api/v1/files | List files queued by the guest |
DELETE | /api/v1/files | Clear the guest file queue |
POST | /api/v1/open | Open a path in the guest Finder |
POST | /api/v1/exec | Execute a shell command in the guest |
GET | /api/v1/fs?path=<dir> | List directory contents in the guest |
GET | /api/v1/apps | List running applications in the guest |
POST | /api/v1/apps/launch | Launch an app by bundle ID |
POST | /api/v1/apps/activate | Activate (bring to front) an app by bundle ID |
POST | /api/v1/apps/quit | Quit an app by bundle ID |
GET | /api/v1/apps/frontmost | Get the frontmost application's bundle ID |
Example Usage
You can interact with the Host API using any Unix socket HTTP client. Here is an example using curl:
curl --unix-socket ~/Library/Application\ Support/GhostVM/api/dev.GhostVM.sock \
http://localhost/healthcurl --unix-socket ~/Library/Application\ Support/GhostVM/api/dev.GhostVM.sock \
-X POST -H "Content-Type: application/json" \
-d '{"command":"uname","args":["-a"]}' \
http://localhost/api/v1/execOr with a simple Python script:
import socket, os, json
sock_path = os.path.expanduser(
"~/Library/Application Support/GhostVM/api/dev.GhostVM.sock"
)
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
s.connect(sock_path)
request = "GET /health HTTP/1.1\r\nHost: localhost\r\nContent-Length: 0\r\n\r\n"
s.sendall(request.encode())
response = b""
while True:
chunk = s.recv(4096)
if not chunk:
break
response += chunk
print(response.decode())
s.close()Connection Lifecycle