Browserhand

Browserhand (serviceId birme-browserhand) is a deterministic web-automation API for AI agents. In Eyevinn Open Source Cloud (OSC) it is a long-running service instance. License: Apache-2.0. Source: birme/browserhand.

What it can do

  • Run managed headless Chromium sessions exposed through a small HTTP and WebSocket API.
  • Give agents a selector-free accessibility snapshot of a page with stable element refs; agents act by ref (click, type, select, hover, press keys, scroll, wait, upload files).
  • Read page content, capture screenshots, collect browser logs and downloads, and export cookies/localStorage for session reuse.
  • Expose a remote Chrome DevTools Protocol endpoint for power users.
  • There is no LLM inside the service. The calling agent does the reasoning and Browserhand executes and reports back.

Creating an instance

Create the instance with create-service-instance using serviceId: "birme-browserhand". The instance name must be alphanumeric and at most 20 characters. Browserhand has no dependencies on other OSC services and needs no persistent disk.

{ "name": "myautomation", "MaxConcurrentSessions": "5", "SessionTimeoutMs": "300000" }

Wait with wait-for-service-ready (or get-instance-status), then use describe-service-instance to read the instance URL, which is your Browserhand endpoint.

Options

Option Required Type Meaning
name Yes string Name of the instance. Alphanumeric/underscore only, at most 20 characters.
MaxConcurrentSessions No string (number) Hard cap on simultaneous sessions. Default 5. Requests beyond the cap get a session_limit_reached (429) error.
SessionTimeoutMs No string (number) Idle timeout in milliseconds before a session is auto-closed. Default 300000 (5 minutes).

Neither option is a secret. BROWSERHAND_API_KEY is not a catalog option; see Authentication.

Authentication

If BROWSERHAND_API_KEY is set on the instance, every request to /v1/* must include:

Authorization: Bearer <your-api-key>

Health check endpoints (/healthz, /readyz) remain open regardless. Inside an OSC agent task, call describe-service-instance for the instance URL, retrieve the BROWSERHAND_API_KEY value from the parameter store with get-parameter, and send it as the bearer token on every /v1/* request.

Using the instance

Session lifecycle

POST /v1/sessions                          -> { sessionId, connectUrl, status }
POST /v1/sessions/:id/navigate { url }
loop:
  GET  /v1/sessions/:id/snapshot           -> nodes:[{ref, role, name, value, ...}], outline
  # the agent decides what to do from the snapshot
  POST /v1/sessions/:id/click  { ref }
  POST /v1/sessions/:id/type   { ref, text, submit? }
  GET  /v1/sessions/:id/content            -> read result / extract data
DELETE /v1/sessions/:id

A ref is a stable element identifier returned by the snapshot. All action endpoints address elements by ref, never by CSS selector or XPath.

API reference

Method and path Purpose
POST /v1/sessions Open a session. Returns { sessionId, connectUrl, status }. Optional body: viewport, timeoutMs, context.
GET /v1/sessions List all open sessions.
GET /v1/sessions/:id Get status of a session.
DELETE /v1/sessions/:id Close a session.
GET /v1/sessions/:id/snapshot Accessibility snapshot: elements with stable refs plus a readable outline.
GET /v1/sessions/:id/content Readable page text. Includes a truncated flag when the page is long.
GET /v1/sessions/:id/screenshot PNG screenshot. Query params: ?fullPage=true, ?ref=eN for a single element.
POST /v1/sessions/:id/navigate Navigate to a URL. Body: { url }. Also supports /back, /forward, /reload sub-paths.
POST /v1/sessions/:id/click Click an element by ref. Body: { ref }.
POST /v1/sessions/:id/type Fill a field. Body: { ref, text, submit? }. Set submit: true to press Enter after typing.
POST /v1/sessions/:id/select Select option(s) in a select element. Body: { ref, values }.
POST /v1/sessions/:id/hover Hover over an element. Body: { ref }.
POST /v1/sessions/:id/press Press a key. Body: { key }.
POST /v1/sessions/:id/scroll Scroll. Body: { direction } or { ref }.
POST /v1/sessions/:id/wait Wait for a condition. Body: { text?, ref?, timeoutMs? }.
POST /v1/sessions/:id/upload Set files on a file input. Body: { ref, files[] } (base64 contents).
GET /v1/sessions/:id/logs Captured browser logs. Query: ?type=network or ?type=console.
GET /v1/sessions/:id/downloads List captured downloads.
GET /v1/sessions/:id/downloads/:downloadId Fetch a specific download.
GET /v1/sessions/:id/context Export cookies and localStorage for session reuse (pass back as context on create).
GET /v1/connect/:id (WebSocket) Remote Chrome DevTools Protocol endpoint.
GET /healthz Liveness check.
GET /readyz Readiness check.

Interactive API docs (Swagger UI) are at <instance-url>/documentation.

Example with curl

INSTANCE_URL="<url from describe-service-instance>"
API_KEY="<value from parameter store>"

SESSION_ID=$(curl -s -X POST "$INSTANCE_URL/v1/sessions" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}' | jq -r '.sessionId')

curl -s -X POST "$INSTANCE_URL/v1/sessions/$SESSION_ID/navigate" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://example.com"}'

curl -s "$INSTANCE_URL/v1/sessions/$SESSION_ID/screenshot" \
  -H "Authorization: Bearer $API_KEY" \
  --output screenshot.png

curl -s -X DELETE "$INSTANCE_URL/v1/sessions/$SESSION_ID" \
  -H "Authorization: Bearer $API_KEY"

Remote browser (CDP)

import { chromium } from 'playwright';
const browser = await chromium.connectOverCDP('wss://<instance-url>/v1/connect/<sessionId>');
const page = browser.contexts()[0].pages()[0];

Error handling

All errors share one shape with a stable machine-readable code:

{
  "error": {
    "code": "stale_ref",
    "message": "Element ref \"e5\" is no longer on the page. Call GET /v1/sessions/:id/snapshot to get fresh refs, then retry.",
    "details": { "ref": "e5" }
  }
}
Code HTTP status Meaning and action
session_not_found 404 Session ID does not exist or has been closed. Open a new session.
session_limit_reached 429 The concurrent session cap was hit. Wait for a session to close or raise MaxConcurrentSessions.
stale_ref 409 The element ref is no longer on the page. Call GET /snapshot again, then retry with the updated ref.
element_not_actionable 409 The element exists but cannot be interacted with (for example hidden). Re-snapshot and reassess.
navigation_failed 502 The browser could not reach the URL.
timeout 504 The action timed out.
invalid_request 400 Malformed request body.
unauthorized 401 Missing or invalid Authorization: Bearer token.

On stale_ref, fetch a fresh snapshot and retry; do not cache refs across navigations.

Limitations

  • Autoplay: headless Chromium follows standard autoplay policies, so video or audio autoplay may be blocked without prior user gesture state.
  • Chromium is memory-heavy: budget roughly 300-500 MB per concurrent session and size MaxConcurrentSessions accordingly.
  • Stateless: no persistent disk; downloads and other artifacts are ephemeral and live only for the session.
  • The service drains all sessions on SIGTERM.

CLI usage

osc create birme-browserhand myautomation \
  -o MaxConcurrentSessions="5" \
  -o SessionTimeoutMs="300000"

Resources