← Blog

How do you watch what your AI agent is doing in real time?

Stream an Orgo computer's screen, desktop events, terminal, and audio while the agent works, and keep the connections alive.

Updated

Open one of the computer's live WebSocket streams. Every Linux or Windows computer on Orgo has four, at wss://www.orgo.ai/desktops/{id}/ws/{stream}?token={password}, all opened with the same per-computer password:

  • Screen (/ws/websockify): the live desktop over VNC, for a person to watch or take over.
  • Events (/ws/events): window focus, windows opening and closing, clipboard, processes, screen size, audio streams, and idle or active state, as JSON when they happen.
  • Terminal (/ws/terminal): an interactive root shell.
  • Audio (/ws/audio): the computer's speaker as raw PCM in 20 ms frames.

For following an agent, start with the events stream. It is small, structured, has no idle timeout, and says what the agent is doing ("focus moved to Google Chrome") without decoding pixels. Orgo provides the computer, not the agent, so the streams work the same whichever agent drives it.

StreamPathWhat you getFormatIdle close
Screen/ws/websockifyLive pixels, and input if the viewer sends itVNC over websockify4008 after 30 minutes on the shared timer
Events/ws/eventsWindow, clipboard, process, screen, audio, idle eventsJSON text framesNone
Terminal/ws/terminalInteractive shellJSON text frames with ANSI output4008 after 30 minutes; output counts
Audio/ws/audioSpeaker outputRaw s16le PCM, binary frames4008 after 30 minutes; your ping counts, the audio does not
ScreenshotGET /computers/{id}/screenshotOne image per requestURL, base64, or bytesNot a stream

Sources: Embed computers, Events WebSocket, Terminal WebSocket, Audio WebSocket, Take screenshot.

Connecting

Your server reads the computer's password with your API key:

bash
curl https://www.orgo.ai/api/computers/$COMPUTER_ID/vnc-password \
  -H "Authorization: Bearer $ORGO_API_KEY"

The response carries password; GET /computers/{id} also returns it as vnc_password. The password can change, for example when a computer is started again from its archive, or after an API key that could read it is revoked. Fetch it for each session instead of storing it. While a change is in progress the call answers 503 with Retry-After: 30 (Get VNC password). This endpoint takes the computer's UUID only.

Then open the stream with the password as token:

Plain text
wss://www.orgo.ai/desktops/{id}/ws/events?token={password}

Build the URL from the computer's id (UUID). Its instance_id also resolves, but it changes when the computer is started from its archive or wakes from storage.

Three rules about the credential:

  • The password goes in ?token=, not a header. On the events, terminal and audio streams, Orgo accepts an Authorization header but does not forward it to the computer, so the socket opens and then closes with 1000.
  • An API key does not work here. On those streams an sk_ key in ?token= fails the same way, and from a browser (any connection with an Origin header) it is refused with 4001. Never send the API key to a browser.
  • The password is root on that computer. The same value opens the terminal and the screen, so give it only to people and pages allowed to control the computer.

Only the owner and Full access members can read the password. A Can chat member gets 403, and so do an MCP sign-in and a computer's own identity token. A Can chat member signed in to Orgo can still watch the screen and open the audio stream with their session; the terminal and events streams close with 4001 for them.

The events stream

A new connection receives nothing until it sends subscribe, so you choose the types you need (Events WebSocket):

json
{ "type": "subscribe", "event_types": ["window_focus", "process_start", "process_stop", "idle", "active"] }

Each event then arrives as:

json
{
  "type": "event",
  "event": {
    "type": "window_focus",
    "timestamp": "2026-03-03T12:00:00.123Z",
    "data": { "window_id": "52428804", "window_name": "Google Chrome" }
  }
}

The Linux events and how often each is checked:

EventFires whenChecked
window_focus, window_open, window_closeThe active window changes, or a window opens or closesEvery 100 ms
clipboardClipboard content changes (text capped at 1024 bytes, with truncated)Every 250 ms
audio_stream_start, audio_stream_stopAn audio stream starts or stopsEvery 500 ms
screen_changeThe display resolution changesEvery 1 s
idle, activeNo input for 30 seconds, then input resumesEvery 1 s
process_start, process_stopA process starts or exitsEvery 2 s

Before building on it:

  • Events describe changes, not state. Connecting does not replay what you missed.
  • Names are not validated. A typo in event_types still returns subscribed / ok, then delivers nothing.
  • Each connection buffers 256 events. A slow consumer loses the rest, so hand events to a queue quickly.
  • file_change is not delivered on Linux. To notice a finished download, poll the folder with Execute bash.
  • A Windows computer sends only window_focus, clipboard and file_change, the last for the Administrator's Desktop and Downloads folders.
  • The events stream has no idle timeout.

Logging every action

This watcher runs beside an agent loop and prints each event as a JSON line. Before every connect it fetches the password again and subscribes again, since subscriptions belong to one connection. It backs off exponentially, as the docs recommend.

It does not stop on 4001. The password can change while the watcher runs, and a socket that offers an old password closes with 4001 (an open socket closes with 4003 'Screen password changed'). Fetching the password again and retrying is the fix. It also keeps going when the fetch or the connect fails.

python
import asyncio, json, os
import requests, websockets
 
API = "https://www.orgo.ai/api"
COMPUTER_ID = os.environ["COMPUTER_ID"]  # the computer's UUID
HEADERS = {"Authorization": f"Bearer {os.environ['ORGO_API_KEY']}"}
EVENT_TYPES = ["window_focus", "window_open", "window_close",
               "process_start", "process_stop", "idle", "active"]
FINAL = {4004, 4005}  # no such computer, computer locked
 
class TryLater(Exception):
    def __init__(self, seconds: float):
        self.seconds = seconds
 
def computer_password() -> str:
    r = requests.get(f"{API}/computers/{COMPUTER_ID}/vnc-password",
                     headers=HEADERS, timeout=15)
    if r.status_code == 429 or r.status_code >= 500:  # 503 while it changes
        raise TryLater(float(r.headers.get("Retry-After") or 0))
    r.raise_for_status()  # 401, 403, 404: fix the key, its scope, or the id
    return r.json()["password"]
 
def log(**fields) -> None:
    print(json.dumps(fields), flush=True)
 
async def watch() -> None:
    delay = 2
    while True:
        wait = 0.0
        try:
            password = await asyncio.to_thread(computer_password)
            url = f"wss://www.orgo.ai/desktops/{COMPUTER_ID}/ws/events?token={password}"
            async with websockets.connect(url) as ws:
                await ws.send(json.dumps({"type": "subscribe", "event_types": EVENT_TYPES}))
                async for raw in ws:
                    msg = json.loads(raw)
                    if msg["type"] == "event":
                        delay = 2
                        print(json.dumps(msg["event"]), flush=True)
        except TryLater as e:
            wait = e.seconds
            log(password="try later", retry_after=wait)
        except requests.HTTPError:
            raise  # a refused key will not fix itself
        except requests.RequestException as e:
            log(password_fetch_failed=repr(e))
        except websockets.ConnectionClosed as e:
            code = e.rcvd.code if e.rcvd else None
            log(closed=code)
            if code in FINAL:
                raise
            # 4001 and 4003 too: the next pass fetches the current password
        except (websockets.InvalidHandshake, OSError, TimeoutError) as e:
            log(connect_failed=repr(e))
        await asyncio.sleep(max(wait, delay))
        delay = min(delay * 2, 60)
 
asyncio.run(watch())

A process_start for chrome followed by window_focus events is a trail of what the agent opened and in what order. An idle event during a step that should be busy is a cheap sign the agent is stuck.

For a trace of each agent run rather than of its desktop, Orgo also connects to Latitude, which records each run's steps, tool calls, model, duration, token counts and status. Orgo sets it up for OpenClaw and Hermes Agent on Linux, and the automatic setup never sends prompts, replies, files or screen content.

Watching a long command

Attach to the terminal stream and read its output frames. It is a real PTY, so colors and curses apps render, and you can send input frames ("\r" is Enter) to step in (Terminal WebSocket).

Plain text
wss://www.orgo.ai/desktops/{id}/ws/terminal?token={password}&cols=120&rows=40&session=build
  • A session name of 1 to 32 characters (A-Z, a-z, 0-9, -, _) keeps the shell running after a disconnect. Reconnecting with the same name attaches to it again. Without a name, the shell is killed when the socket closes.
  • Traffic in either direction counts as activity, so a build that keeps printing keeps the socket open. After 30 minutes of silence it closes with 4008; reconnect with the same session.
  • If the shell cannot start, an error frame arrives, then a normal 1000 close. A client that reads only close codes never learns why.

To run one command and get its result, Execute bash is simpler. It waits up to 200 seconds by default, and timeout is clamped to 1 to 300.

Audio

The audio stream carries the computer's speaker output: browser media, system alerts, application audio (Audio WebSocket).

PropertyDefault
Encodings16le (signed 16-bit little-endian PCM), no codec or container
Sample rate24,000 Hz (sample_rate=48000 for higher fidelity)
Channels1 (channels=2 for stereo)
Frame20 ms, 960 bytes at the defaults
BitrateAbout 48 KB/s at the defaults

The server first sends a started frame with the settings in use; size playback from it. Browsers need a user gesture before an AudioContext plays. The audio itself does not count as activity, so a lone audio socket should send a ping at least every 30 minutes or it closes with 4008. The docs recommend a ping every 30 seconds on every stream, to catch dead connections early.

Screenshots

For a record rather than a live view, GET /computers/{id}/screenshot returns one image per call: a stored URL by default, or inline with response_format=base64 or binary. It takes png, jpeg or webp, a quality from 1 to 100 (default 80), and a scale. For a small image the docs suggest ?response_format=binary&format=webp&quality=75&scale=0.5 (Take screenshot).

The events stream can decide when to take them. One screenshot on every window_focus gives a record of each screen the agent touched, without recording video.

Close codes

A refused connection gives you only its close code. An embedded VNC screen that fails stays black (Embed computers).

CodeMeaningWhat to do
1000 right after openingThe computer refused the credential, often an API key instead of the passwordSend the computer password in ?token=
1001Orgo is draining for a restart or deployReconnect
1006Dropped with no close frame; the server ends sockets that stop answering its 30-second pingReconnect with backoff
4001No valid credential: a wrong or changed password, an sk_ key from a browser, a signed-in browser on a disallowed origin, or a Can chat member on the terminal or events streamWith the password, fetch it again and retry with backoff; otherwise fix the credential
4003The computer is not running, is asleep in storage, or its workspace is not active. An open socket also closes with 4003 when the screen password changes, the computer's subscription ends, or your workspace access changes (checked every 15 seconds)Start or resume it, or fetch the password again, then reconnect
4004No computer with that idCheck the id
4005The computer is locked (a Mac, iPhone or Android device kept over the account's capacity)Do not retry until the lock is lifted
4006An API key scoped to another workspace (key callers only)Use a key for this workspace
4007MFA required (signed-in browsers)Complete MFA, then reconnect
4008Idle timeout (terminal, audio, screen; never events)Reconnect on the next activity
4010The WebRTC display is off for this computer, or a non-default screen was asked for over WebRTCUse the VNC screen stream
4012?screen= named a screen this computer does not haveList its screens and fix the id
4029Terminal input from an API key went over the plan's computer control rate limitWait, then reconnect
4500, 4502, 4503Proxy error, no route to the host, or lookup failedRetry

A URL that is not a /desktops/{id}/ws/... path gets no close code: it is refused before the socket opens.

The idle timer

The screen, terminal and audio sockets close with 4008 after 30 minutes without activity. The events socket has no idle timer. The timer is shared:

  • Every socket opened with the computer password (an embed, an SDK, your watcher) reads the same clock. A signed-in Orgo user has a separate clock for their own sockets.
  • Activity is any frame a client sends on the terminal or audio socket (a ping included), any terminal output, any screen frame from the viewer other than a plain request for the next frame (keys, pointer, clipboard), and opening a new screen, terminal or audio socket.
  • The screen's pixels and the audio data are not activity.

So a terminal streaming a long build keeps an embedded screen open too, while a screen an agent keeps redrawing, with nobody watching and nothing else open, still closes after 30 minutes. Treat 4008 as a clean close and reconnect on the next action.

A restart keeps the computer's VNC password, but open VNC and terminal sockets drop during the reboot, so reconnect afterwards (Restart computer).

Showing the screen in your own app

Point a noVNC client at wss://www.orgo.ai/desktops/{id}/ws/websockify?token={password}, with the password fetched by your server. How to embed a live AI agent computer in your app walks through it, including the black-screen close codes.

A Linux computer can also run extra screens (Screens). Stream one by adding ?screen={screen id} to the same URL, for example /ws/websockify?screen=screen-101&token={password}. Every screen uses the computer's one password.