---
title: "QA Desktop Agent (Playwright CDP + CUA)"
description: "Run a persistent QA desktop agent with loopback Chrome CDP, batched JPEG CUA actions, Brokered Egress Secrets, and 60fps Voxl streaming."
last_updated: 2026-12-03
url: https://miosa.ai/docs/cookbook/qa-desktop-agent
---

# QA Desktop Agent (Playwright CDP + CUA)

`~5 min` `cURL` `TypeScript` `Python`

| Layer | Capability | Endpoint / Interface |
|---|---|---|
| Browser DOM | Loopback Chromium CDP (`browser` OS user, `/data/chrome-profile`) | `http://127.0.0.1:9222` (Playwright) |
| Vision & OS UI | Fast JPEG screenshots, AT-SPI tree, batched actions (up to 25) | `GET .../desktop/screenshot?format=jpeg&quality=80`, `POST .../act/batch` |
| Secrets | Raw LLM keys never enter VM; non-egress config write-only encrypted | `POST /api/v1/egress/secrets`, `PATCH /api/v1/computers/{id}` |
| Persistence | Survives sleep (`$0` compute), restart, and image upgrades | `/opt/user`, Persistent Volume `/data`, `POST .../image` |
| Live viewer | 60fps Voxl embed with strict per-tenant `CSP frame-ancestors` | `POST .../stream-token` (`view_only: true` vs `false`) |

## 1. Provision Computer, volume, and Egress Secret

```bash
# Persistent 20 GiB volume for /data/chrome-profile and QA artifacts
VOL_ID=$(curl -sS -X POST "https://api.miosa.ai/api/v1/volumes" \
  -H "Authorization: Bearer $MIOSA_API_KEY" -H "Content-Type: application/json" \
  -d '{"name":"qa-chrome-profile","size_bytes":21474836480,"backend":"local"}' | jq -r '.id // .data.id')

# Custom-sized Computer with auto_wake and live soma/elastic-7 autoscale (1c/2G -> 8c/16G)
COMPUTER_ID=$(curl -sS -X POST "https://api.miosa.ai/api/v1/computers" \
  -H "Authorization: Bearer $MIOSA_API_KEY" -H "Content-Type: application/json" \
  -d '{"name":"qa-desktop-1","template_id":"miosa-desktop","vcpus":2,"memory_gib":4,"cpu_tier":"shared","settings":{"auto_wake":true},"autosize":{"enabled":true,"min_cpu":1,"max_cpu":8,"min_memory_mb":2048,"max_memory_mb":16384}}' | jq -r '.id')

curl -sS -X POST "https://api.miosa.ai/api/v1/computers/${COMPUTER_ID}/volumes" \
  -H "Authorization: Bearer $MIOSA_API_KEY" -H "Content-Type: application/json" \
  -d "{\"volume_id\":\"${VOL_ID}\",\"mount_path\":\"/data\"}"

# Brokered Egress Secret (raw key never enters VM) + write-only runtime env
curl -sS -X POST "https://api.miosa.ai/api/v1/egress/secrets" \
  -H "Authorization: Bearer $MIOSA_API_KEY" -H "Content-Type: application/json" \
  -d '{"name":"anthropic_qa","value":"sk-ant-...","type":"api_key","scope":"workspace","expose_as_env":"ANTHROPIC_API_KEY"}'

curl -sS -X PATCH "https://api.miosa.ai/api/v1/computers/${COMPUTER_ID}" \
  -H "Authorization: Bearer $MIOSA_API_KEY" -H "Content-Type: application/json" \
  -d '{"env":{"QA_BASE_URL":"https://staging.acme.example","OLD_URL":null}}'
```

## 2. Drive Playwright CDP (`127.0.0.1:9222`) + batched JPEG CUA

**TypeScript**

```typescript
import { chromium } from "playwright";

// Inside the Computer: connect Playwright to loopback Chromium CDP
const browser = await chromium.connectOverCDP("http://127.0.0.1:9222");
const page = browser.contexts()[0].pages()[0] ?? (await browser.contexts()[0].newPage());
await page.goto(process.env.QA_BASE_URL ?? "https://staging.acme.example");
await page.getByRole("button", { name: "New Invoice" }).click();

// From your orchestrator: atomic multi-step desktop batch + JPEG screenshot
const batch = await fetch(`https://api.miosa.ai/api/v1/computers/${computerId}/act/batch`, {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.MIOSA_API_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    actions: [{ type: "click", x: 640, y: 360 }, { type: "type", text: "INV-2026-042" }, { type: "key", key: "Return" }],
    delay_ms: 50, screenshot: true, format: "jpeg", quality: 80,
  }),
}).then((r) => r.json());
```

**Python**

```python
import os, requests
from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.connect_over_cdp("http://127.0.0.1:9222")
    page = browser.contexts[0].pages[0]
    page.goto(os.environ.get("QA_BASE_URL", "https://staging.acme.example"))
    page.get_by_role("button", name="New Invoice").click()

res = requests.post(
    f"https://api.miosa.ai/api/v1/computers/{computer_id}/act/batch",
    headers={"Authorization": f"Bearer {os.environ['MIOSA_API_KEY']}"},
    json={"actions": [{"type": "click", "x": 640, "y": 360}, {"type": "type", "text": "INV-2026-042"}, {"type": "key", "key": "Return"}], "delay_ms": 50, "screenshot": True, "format": "jpeg", "quality": 80},
    timeout=30,
).json()
```

**cURL**

```bash
# Auto-wake a paused QA desktop and execute Playwright in one call
curl -X POST "https://api.miosa.ai/api/v1/computers/${COMPUTER_ID}/exec" \
  -H "Authorization: Bearer $MIOSA_API_KEY" -H "Content-Type: application/json" \
  -d '{"command":"npx playwright test --project=cdp","auto_wake":true}'

# Fast JPEG screenshot (quality 80)
curl "https://api.miosa.ai/api/v1/computers/${COMPUTER_ID}/desktop/screenshot?format=jpeg&quality=80" \
  -H "Authorization: Bearer $MIOSA_API_KEY" --output qa-step.jpg
```

## 3. Watch-only Voxl embed & disk-preserving template upgrades

```bash
# Watch-only 60fps Voxl stream token (switch to view_only:false for human take-over)
curl -X POST "https://api.miosa.ai/api/v1/computers/${COMPUTER_ID}/stream-token" \
  -H "Authorization: Bearer $MIOSA_API_KEY" -H "Content-Type: application/json" \
  -d '{"view_only":true}'

# Upgrade template in place while preserving Computer ID, viewer URL, /opt/user, and /data
curl -X POST "https://api.miosa.ai/api/v1/computers/${COMPUTER_ID}/image" \
  -H "Authorization: Bearer $MIOSA_API_KEY" -H "Content-Type: application/json" \
  -d '{"template_id":"tpl_qa_desktop_v2"}'
```

- [Desktop API](https://miosa.ai/docs/api-reference/desktop.md): JPEG screenshots, batch actions, AT-SPI, and loopback CDP.
- [Embedding & streaming](https://miosa.ai/docs/computers/embedding.md): 60fps Voxl embeds, view_only tokens, and per-tenant CSP.
- [Persistent Volumes](https://miosa.ai/docs/data/volumes.md): Keep profiles and state across sleep and image upgrades.
