← Catalog

pi-control-surfbird-for-kitesurf

Pi package: AI agent controls a Kitesurf/surfbird browser engine over CDP — 28 surfbird_* tools with per-session isolation, semantic snapshots, screenshots/PDF. Shares the host-independent src/cdp core with the DSH and OpenCode plugins.

Package

Install

Install with PiG

pig install npm:pi-control-surfbird-for-kitesurf

Install with Pi

pi install npm:pi-control-surfbird-for-kitesurf
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "skills": [
    "./skills"
  ],
  "extensions": [
    "./extensions/surfbird.ts"
  ]
}

README

Written by the package's publisher, shown as published in version 0.6.0 (README.md). PiG does not review it.

pi-control-surfbird-for-kitesurf

English · 中文

A Pi package that gives an AI agent full control of a Kitesurf browser engine over the Chrome DevTools Protocol (CDP) — like a human operating a browser. Works with the self-hosted surfbird distribution (raw or token-auth mode) and upstream Kitesurf deployments. Exposes 28 surfbird_* tools: tab management, navigation, semantic accessibility snapshots, click/type/fill, waits, JavaScript evaluation, screenshots, PDF export, console/network inspection, WebMCP, and a raw CDP escape hatch — with one isolated browser per agent session.

Sibling projects: dsh-control-surfbird-for-kitesurf (DSH) and opencode-control-surfbird-for-kitesurf (OpenCode) — same tools, other agent harnesses. All three share the host-independent src/cdp/ core.

Requirements

  • Pi coding agent (@earendil-works/pi-coding-agent, extensions API)
  • Node.js >= 22.19
  • A Kitesurf-compatible CDP endpoint — e.g. a surfbird container (auth or raw mode) or upstream kitesurf

Install

pi install npm:pi-control-surfbird-for-kitesurf

Or try it for one session without installing:

pi -e npm:pi-control-surfbird-for-kitesurf
# or a local checkout:
pi -e /path/to/pi-control-surfbird-for-kitesurf

Configuration

Precedence: .pi/surfbird.json (trusted project) > ~/.pi/agent/surfbird.json (global) > environment > defaults.

Easiest: run /surfbird-settings inside pi — an interactive editor (endpoint, token file, session limits, timeouts, screenshot dir, debug log) with a live /json/version probe and paste/import-token actions.

Or write ~/.pi/agent/surfbird.json directly:

{
  "endpoint": "http://127.0.0.1:8080",
  "tokenFile": "~/.pi/agent/surfbird-token",
  "requestTimeoutMs": 120000,
  "keepaliveMs": 300000,
  "maxSessions": 8,
  "idleEvictMs": 300000,
  "screenshotDir": "",
  "debugLog": false
}
OptionDefaultMeaning
endpointhttp://127.0.0.1:8080CDP HTTP base or full ws(s):// URL. Env: SURFBIRD_URL → SURFBIRD_ENDPOINT → KITESURF_URL → KITESURF_ENDPOINT
tokenFile—Token file path — plaintext or surfbird-v1: machine-bound ciphertext. Empty falls back to token/env
token—Bearer token (env SURFBIRD_TOKEN/KITESURF_TOKEN also works)
requestTimeoutMs120000Per-CDP-call timeout (min 1000)
keepaliveMs300000WS keepalive interval (min 30000; engine kills at 10 min idle)
maxSessions8Concurrent session browsers; excess evicts idle sessions only (min 1)
idleEvictMs300000Min idle duration before a session may be evicted (min 60000)
screenshotDir$TMPDIR/surfbirdScreenshot/PDF output directory
debugLogfalseAppend diagnostics to ~/.pi/agent/surfbird-debug.log

Token encryption: /surfbird-settings → "Paste token…"/"Import token file…" writes a surfbird-v1: file encrypted with a key derived from the machine UUID (macOS IOPlatformUUID, Linux machine-id), AES-256-GCM, mode 0600. The ciphertext is useless on other machines. Token plaintext is never written to surfbird.json.

The 28 tools

ToolWhat it does
surfbird_statusEngine probe: product/version, tabs, session stats, config source (never echoes token)
surfbird_tabsList/create/select/close tabs (action=list default)
surfbird_navigateLoad a URL; back/forward/reload are separate tools
surfbird_back / surfbird_forward / surfbird_reloadHistory navigation
surfbird_snapshotBounded semantic digest: [eN] interactive refs, headings, text blocks
surfbird_axRaw accessibility tree for the current tab
surfbird_click / surfbird_double_clickClick by ref/selector/coords, with optional modifiers
surfbird_fillSet control value (Kitesurf setControlValue, React/Vue-safe)
surfbird_typeType text into a field (key events)
surfbird_press_keyNamed key + modifiers (enter/tab/escape/arrows…)
surfbird_scrollScroll page/element by amount or to target
surfbird_waitPredicate waits: load/domcontentloaded/url/text/visible/hidden/enabled/networkidle/stable
surfbird_evaluateRuntime.evaluate in page context
surfbird_extractArticle→Markdown via Readability + Turndown
surfbird_findCtrl+F semantics: count/next/prev/clear, context snippets
surfbird_linksAll page links {url,text}, dedupe url/base, selector scope
surfbird_screenshotViewport / clip rect / target+padding element / fullPage — inline image + saved path
surfbird_pdfPage.printToPDF — saved path
surfbird_consoleConsole messages + exceptions, since cursor, error filter
surfbird_networkRequest log, since cursor, action=body for response bodies
surfbird_webmcpList/invoke/cancel page-declared WebMCP tools
surfbird_cdpRaw CDP escape hatch

Full usage patterns (observe → act → verify, refs and docTokens, WebMCP, limits) live in the bundled skill: skills/surfbird-control/SKILL.md.

Engine limits (upstream Kitesurf, not this plugin)

  • Boa JS + DOM shim, not V8/Chromium — no JS dialogs, no file upload/download, no clipboard, no drag/touch, incomplete KeyboardEvent, partial hit-testing
  • One WS connection = one isolated browser; disconnect destroys all its tabs
  • 60-minute WS hard cap; 10-minute idle timeout (keepalive must stay below it)
  • fullPage screenshots are emulated by temporary viewport resize, capped ~1440px

Development

npm install
npm run check     # tsc --noEmit
npm test          # unit tests (no engine needed)
npm run test:live # live smoke — needs SURFBIRD_URL/TOKEN or a tunnel to a real engine

src/cdp/ is the shared host-independent core — it must not import Pi/host packages; changes here must be manually synced to dsh-control-surfbird-for-kitesurf and opencode-control-surfbird-for-kitesurf (and vice versa).

License

Apache-2.0