High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
chore: add async/drag fixtures, pt script, and task updates
Bosch74d4699037a2
diff --git a/tests/benchmark/AGENT_TASKS.md b/tests/benchmark/AGENT_TASKS.mdindex b483ac87..9aa9eed0 100644--- a/tests/benchmark/AGENT_TASKS.md+++ b/tests/benchmark/AGENT_TASKS.md@@ -9,6 +9,47 @@ Natural language tasks to test how well an agent uses PinchTab from skill docs a3. **Log every command executed**4. Record: `./scripts/record-step.sh --type agent <group> <step> <pass|fail> --tokens <in> <out> "notes"`+### Recommended setup: env vars + `./scripts/pt` wrapper++In normal PinchTab deployments the binary is installed on the host and+invoked directly:++```bash+export PINCHTAB_TOKEN=<token>+export PINCHTAB_TAB=$(pinchtab nav http://example.com)+pinchtab snap -i -c+pinchtab click '#submit'+```++The benchmark harness runs PinchTab **inside a Docker container**, so every+invocation normally has to be prefixed with+`docker exec -e PINCHTAB_TOKEN=... -e PINCHTAB_SERVER=... -e PINCHTAB_TAB=... benchmark-pinchtab-1 pinchtab ...`+— ~140 characters of boilerplate per command. The repo ships a tiny wrapper+at `tests/benchmark/scripts/pt` that handles the Docker preamble so you can+use the same terse CLI as a host install:++```bash+# Capture the shared tab ID. pinchtab prints only the tab ID when stdout+# is a pipe, so $(...) capture works directly.+export PINCHTAB_TAB=$(./scripts/pt nav http://fixtures/)++# Every subsequent tab-scoped command auto-targets $PINCHTAB_TAB:+./scripts/pt snap -i -c+./scripts/pt eval "document.title"+./scripts/pt eval --await-promise "window.fetchPayload()"+./scripts/pt click '#submit'+./scripts/pt drag '#piece' --drag-x 12 --drag-y -158++# Record step results:+./scripts/record-step.sh --type agent 1 2 pass "worked"+```++The wrapper is a ~60-line shell script; read `scripts/pt` for the exact+forwarding rules. Flags after `pt` are forwarded verbatim to `pinchtab`, so+anything that works with `pinchtab ...` works with `./scripts/pt ...`.++Explicit `--tab <id>` on any command still wins over `PINCHTAB_TAB`.+## Environment- PinchTab: `http://localhost:9867`, token: `benchmark-token`@@ -386,6 +427,34 @@ Click the "Click for Confirm" button and cancel the confirm dialog.---+## Group 21: Async / awaitPromise++### 21.1 Await a promise-returning function+Navigate to `http://fixtures/async.html`. The page exposes `window.fetchPayload()`, which returns a `Promise` that resolves after a short delay. Use `eval` to call it and retrieve the **resolved** value, not a Promise wrapper.++**Verify**: The resolved value contains `ASYNC_PAYLOAD_READY_42`.++### 21.2 Await a promise resolving to an object+On the same page, call `window.fetchUser()` and retrieve the resolved object so you can read a field from it.++**Verify**: The resolved object's `name` field equals `ASYNC_USER_NAME_ADA`.++---++## Group 22: Mouse Drag & Drop++### 22.1 Drag a piece into Zone A+Navigate to `http://fixtures/drag.html`. The page contains a draggable square (`#piece`) and three target zones (`#zone-a`, `#zone-b`, `#zone-c`). Drag the piece so its center ends up over **Zone A**.++**Verify**: The page shows `LAST_DROP=DROP_ZONE_A_OK`.++### 22.2 Drag to Zone B, then Zone C+Without reloading the page, drag the piece next into **Zone B**, and then into **Zone C**. The page records an ordered drop sequence.++**Verify**: The page shows `DROP_SEQUENCE=DROP_ZONE_A_OK,DROP_ZONE_B_OK,DROP_ZONE_C_OK` (all three drops in order).++---+## Summary| Group | Tasks | Description |@@ -411,8 +480,10 @@ Click the "Click for Confirm" button and cancel the confirm dialog.| 18 | 1 | File Download || 19 | 2 | iFrame || 20 | 2 | Dialogs |+| 21 | 2 | Async / awaitPromise |+| 22 | 2 | Mouse Drag & Drop |-**Total: 54 tasks**+**Total: 58 tasks**## Key Differences from Baselinediff --git a/tests/benchmark/BASELINE_TASKS.md b/tests/benchmark/BASELINE_TASKS.mdindex 62f1e17e..3f94b12d 100644--- a/tests/benchmark/BASELINE_TASKS.md+++ b/tests/benchmark/BASELINE_TASKS.md@@ -1046,6 +1046,113 @@ curl "http://localhost:9867/tabs/TAB_ID/snapshot?format=compact&maxTokens=500" \---+## Group 21: Async / awaitPromise++### 21.1 Await a promise-returning function+```bash+curl -X POST http://localhost:9867/navigate \+ -H "Authorization: Bearer benchmark-token" \+ -H "Content-Type: application/json" \+ -d '{"tabId":"TAB_ID","url":"http://fixtures/async.html"}'++# Without awaitPromise: returns {} (unresolved Promise representation)+curl -X POST http://localhost:9867/tabs/TAB_ID/evaluate \+ -H "Authorization: Bearer benchmark-token" \+ -H "Content-Type: application/json" \+ -d '{"expression":"window.fetchPayload()","awaitPromise":true}'+```+**Pass if**: Response `.result` equals `"ASYNC_PAYLOAD_READY_42"`. Also verify that repeating the same call with `awaitPromise` omitted returns `{}` (proves `awaitPromise` is actually doing work).++### 21.2 Await a promise resolving to an object+```bash+curl -X POST http://localhost:9867/tabs/TAB_ID/evaluate \+ -H "Authorization: Bearer benchmark-token" \+ -H "Content-Type: application/json" \+ -d '{"expression":"window.fetchUser()","awaitPromise":true}'+```+**Pass if**: Response `.result.name` equals `"ASYNC_USER_NAME_ADA"` (structured value survives the round-trip).++**Note**: See SKILL.md and `references/api.md` — `awaitPromise:true` on `/evaluate` makes the server wait for the returned Promise to settle before responding. Omit the flag when you want the raw Promise reference.++---++## Group 22: Mouse Drag & Drop++### 22.1 Drag piece into Zone A (high-level `drag` action)+```bash+curl -X POST http://localhost:9867/navigate \+ -H "Authorization: Bearer benchmark-token" \+ -H "Content-Type: application/json" \+ -d '{"tabId":"TAB_ID","url":"http://fixtures/drag.html"}'++# Piece center starts at (92, 358); Zone A center is at (104, 200).+# Drag offset: (+12, -158).+curl -X POST http://localhost:9867/tabs/TAB_ID/action \+ -H "Authorization: Bearer benchmark-token" \+ -H "Content-Type: application/json" \+ -d '{"kind":"drag","selector":"#piece","dragX":12,"dragY":-158}'++curl "http://localhost:9867/tabs/TAB_ID/text" \+ -H "Authorization: Bearer benchmark-token"+```+**Pass if**: Page text contains `LAST_DROP=DROP_ZONE_A_OK`.++### 22.2 Low-level sequence: drag into Zone B, then Zone C+```bash+# Zone centers in viewport coords (for the default window size):+# piece starts: (92, 358)+# Zone A: (104, 200)+# Zone B: (344, 200)+# Zone C: (584, 400)+# If the viewport differs, query these with /evaluate ++# Array.from(['piece','zone-a','zone-b','zone-c']).map(id => ...getBoundingClientRect()).++# Drag piece (now at Zone A) to Zone B via explicit mouse-down → mouse-move → mouse-up.+curl -X POST http://localhost:9867/tabs/TAB_ID/action \+ -H "Authorization: Bearer benchmark-token" \+ -H "Content-Type: application/json" \+ -d '{"kind":"mouse-move","x":104,"y":200}'++curl -X POST http://localhost:9867/tabs/TAB_ID/action \+ -H "Authorization: Bearer benchmark-token" \+ -H "Content-Type: application/json" \+ -d '{"kind":"mouse-down","x":104,"y":200,"button":"left"}'++curl -X POST http://localhost:9867/tabs/TAB_ID/action \+ -H "Authorization: Bearer benchmark-token" \+ -H "Content-Type: application/json" \+ -d '{"kind":"mouse-move","x":344,"y":200}'++curl -X POST http://localhost:9867/tabs/TAB_ID/action \+ -H "Authorization: Bearer benchmark-token" \+ -H "Content-Type: application/json" \+ -d '{"kind":"mouse-up","x":344,"y":200,"button":"left"}'++# Now drag Zone B → Zone C+curl -X POST http://localhost:9867/tabs/TAB_ID/action \+ -H "Authorization: Bearer benchmark-token" \+ -H "Content-Type: application/json" \+ -d '{"kind":"mouse-down","x":344,"y":200,"button":"left"}'++curl -X POST http://localhost:9867/tabs/TAB_ID/action \+ -H "Authorization: Bearer benchmark-token" \+ -H "Content-Type: application/json" \+ -d '{"kind":"mouse-move","x":584,"y":400}'++curl -X POST http://localhost:9867/tabs/TAB_ID/action \+ -H "Authorization: Bearer benchmark-token" \+ -H "Content-Type: application/json" \+ -d '{"kind":"mouse-up","x":584,"y":400,"button":"left"}'++curl "http://localhost:9867/tabs/TAB_ID/text" \+ -H "Authorization: Bearer benchmark-token"+```+**Pass if**: Page text contains `DROP_SEQUENCE=DROP_ZONE_A_OK,DROP_ZONE_B_OK,DROP_ZONE_C_OK`.++**Note**: Either path (the high-level `drag` action with `dragX`/`dragY` offsets, or the explicit `mouse-down → mouse-move → mouse-up` sequence at absolute viewport coordinates) works. Use `drag` for simple point-to-point drags, and the low-level trio when the target site depends on intermediate `mousemove` events or when you need precise pacing.++---+## Summary| Group | Tasks | Description |@@ -1071,8 +1178,10 @@ curl "http://localhost:9867/tabs/TAB_ID/snapshot?format=compact&maxTokens=500" \| 18 | 1 | File Download || 19 | 2 | iFrame || 20 | 2 | Dialogs |+| 21 | 2 | Async / awaitPromise |+| 22 | 2 | Mouse Drag & Drop |-**Total: 54 tasks**+**Total: 58 tasks**## Verification Strings@@ -1090,3 +1199,5 @@ curl "http://localhost:9867/tabs/TAB_ID/snapshot?format=compact&maxTokens=500" \| SPA | `VERIFY_SPA_PAGE_99999` || Python Article | `VERIFY_WIKI_PYTHON_LANG` || Rust Article | `VERIFY_WIKI_RUST_LANG` |+| Async | `VERIFY_ASYNC_PAGE_77777` |+| Drag | `VERIFY_DRAG_PAGE_33333` |diff --git a/tests/benchmark/OPTIMIZATION_LOOP.md b/tests/benchmark/OPTIMIZATION_LOOP.mdindex 2544ebd6..def048f7 100644--- a/tests/benchmark/OPTIMIZATION_LOOP.md+++ b/tests/benchmark/OPTIMIZATION_LOOP.md@@ -146,7 +146,12 @@ Each run appends to `results/optimization_log.md`:## Files-- `run-optimization.sh` — Main loop script-- `results/optimization_log.md` — Run history+- `scripts/run-optimization.sh` — Main loop script (initializes reports)+- `scripts/record-step.sh` — Appends a step result to the current report+- `results/optimization_log.md` — Run history (includes per-run metrics table)- `results/best_score.txt` — High-water mark for regression detection- Changes left uncommitted for manual review and commit++Agent runs use the PinchTab CLI directly via the standard env vars+(`PINCHTAB_TOKEN`, `PINCHTAB_SERVER`, `PINCHTAB_TAB`) — no helper file to+source. See `AGENT_TASKS.md` "Recommended setup" for the pattern.diff --git a/tests/benchmark/TEST_CASES.md b/tests/benchmark/TEST_CASES.mdindex a1c08a67..04796639 100644--- a/tests/benchmark/TEST_CASES.md+++ b/tests/benchmark/TEST_CASES.md@@ -1,6 +1,6 @@# PinchTab Benchmark Test Cases-54 test cases covering realistic browser automation scenarios against local fixture pages.+58 test cases covering realistic browser automation scenarios against local fixture pages.| # | Task | Description ||---|------|-------------|@@ -79,3 +79,9 @@| **Group 20: Dialogs** | | || 20.1 | Accept alert | Trigger alert, accept, verify result marker || 20.2 | Cancel confirm | Trigger confirm dialog, cancel, verify cancelled marker |+| **Group 21: Async / awaitPromise** | | |+| 21.1 | Await promise (string) | `eval` with `awaitPromise:true` returns resolved string payload |+| 21.2 | Await promise (object) | `eval` with `awaitPromise:true` returns resolved object fields |+| **Group 22: Mouse Drag & Drop** | | |+| 22.1 | Drag into Zone A | Use high-level `drag` action to move piece into Zone A |+| 22.2 | Low-level drag sequence | Use `mouse-down`/`mouse-move`/`mouse-up` to visit Zone B then C; verify ordered drop sequence |diff --git a/tests/benchmark/fixtures/async.html b/tests/benchmark/fixtures/async.htmlnew file mode 100644index 00000000..61393fe1--- /dev/null+++ b/tests/benchmark/fixtures/async.html@@ -0,0 +1,43 @@+<!DOCTYPE html>+<html lang="en">+<head>+ <meta charset="UTF-8">+ <title>PinchTab Benchmark - Async</title>+</head>+<body>+ <h1>Async API — VERIFY_ASYNC_PAGE_77777</h1>++ <p>This page exposes promise-returning helpers on <code>window</code> for+ benchmarking the <code>awaitPromise</code> option on+ <code>/evaluate</code>.</p>++ <pre id="log"></pre>++ <script>+ // Resolves after ~100ms with a verifiable payload.+ window.fetchPayload = function () {+ return new Promise((resolve) => {+ setTimeout(() => resolve("ASYNC_PAYLOAD_READY_42"), 100);+ });+ };++ // Resolves after ~50ms with a small object — tests non-string payloads.+ window.fetchUser = function () {+ return new Promise((resolve) => {+ setTimeout(() => resolve({+ id: 7,+ name: "ASYNC_USER_NAME_ADA",+ token: "ASYNC_TOKEN_ABC123",+ }), 50);+ });+ };++ // Rejects after ~50ms — tests error path.+ window.fetchBroken = function () {+ return new Promise((_, reject) => {+ setTimeout(() => reject(new Error("ASYNC_REJECTED_BOOM")), 50);+ });+ };+ </script>+</body>+</html>diff --git a/tests/benchmark/fixtures/drag.html b/tests/benchmark/fixtures/drag.htmlnew file mode 100644index 00000000..28f7e9f2--- /dev/null+++ b/tests/benchmark/fixtures/drag.html@@ -0,0 +1,123 @@+<!DOCTYPE html>+<html lang="en">+<head>+ <meta charset="UTF-8">+ <title>PinchTab Benchmark - Drag</title>+ <style>+ body { font-family: sans-serif; margin: 20px; }+ #board {+ position: relative;+ width: 640px;+ height: 360px;+ border: 2px solid #333;+ background: #fafafa;+ }+ .zone {+ position: absolute;+ width: 120px;+ height: 120px;+ border: 2px dashed #888;+ display: flex;+ align-items: center;+ justify-content: center;+ font-weight: bold;+ color: #444;+ }+ #zone-a { left: 20px; top: 20px; background: #ffe4e1; }+ #zone-b { left: 260px; top: 20px; background: #e1f0ff; }+ #zone-c { left: 500px; top: 220px; background: #e1ffe4; }+ #piece {+ position: absolute;+ left: 40px; top: 210px;+ width: 60px; height: 60px;+ background: #333;+ color: white;+ display: flex;+ align-items: center;+ justify-content: center;+ cursor: grab;+ user-select: none;+ border-radius: 6px;+ }+ #piece.dragging { cursor: grabbing; opacity: 0.7; }+ #result { margin-top: 16px; font-family: monospace; }+ .summary { margin-top: 8px; font-size: 14px; color: #555; }+ </style>+</head>+<body>+ <h1>Drag & Drop — VERIFY_DRAG_PAGE_33333</h1>++ <p>Drag the piece into one of the three zones. Use the low-level pointer+ action sequence (mouse-down → mouse-move → mouse-up) or the <code>drag</code>+ helper. Each successful drop emits a distinct marker.</p>++ <div id="board">+ <div class="zone" id="zone-a">Zone A</div>+ <div class="zone" id="zone-b">Zone B</div>+ <div class="zone" id="zone-c">Zone C</div>+ <div id="piece">P</div>+ </div>++ <div id="result"></div>+ <div class="summary" id="summary"></div>++ <script>+ (function () {+ const piece = document.getElementById('piece');+ const board = document.getElementById('board');+ const result = document.getElementById('result');+ const summary = document.getElementById('summary');+ const zones = [+ { id: 'zone-a', marker: 'DROP_ZONE_A_OK' },+ { id: 'zone-b', marker: 'DROP_ZONE_B_OK' },+ { id: 'zone-c', marker: 'DROP_ZONE_C_OK' },+ ];+ const drops = [];++ let dragging = false;+ let offsetX = 0, offsetY = 0;++ piece.addEventListener('mousedown', function (e) {+ dragging = true;+ piece.classList.add('dragging');+ const r = piece.getBoundingClientRect();+ offsetX = e.clientX - r.left;+ offsetY = e.clientY - r.top;+ e.preventDefault();+ });++ document.addEventListener('mousemove', function (e) {+ if (!dragging) return;+ const b = board.getBoundingClientRect();+ let x = e.clientX - b.left - offsetX;+ let y = e.clientY - b.top - offsetY;+ x = Math.max(0, Math.min(x, b.width - piece.offsetWidth));+ y = Math.max(0, Math.min(y, b.height - piece.offsetHeight));+ piece.style.left = x + 'px';+ piece.style.top = y + 'px';+ });++ document.addEventListener('mouseup', function () {+ if (!dragging) return;+ dragging = false;+ piece.classList.remove('dragging');+ const pr = piece.getBoundingClientRect();+ const cx = pr.left + pr.width / 2;+ const cy = pr.top + pr.height / 2;+ for (const z of zones) {+ const el = document.getElementById(z.id);+ const zr = el.getBoundingClientRect();+ if (cx >= zr.left && cx <= zr.right && cy >= zr.top && cy <= zr.bottom) {+ drops.push(z.marker);+ result.textContent = 'LAST_DROP=' + z.marker;+ summary.textContent = 'DROP_SEQUENCE=' + drops.join(',');+ return;+ }+ }+ result.textContent = 'LAST_DROP=DROP_OUTSIDE';+ summary.textContent = 'DROP_SEQUENCE=' + drops.join(',');+ });+ })();+ </script>+</body>+</html>diff --git a/tests/benchmark/fixtures/hovers.html b/tests/benchmark/fixtures/hovers.htmlindex f4e5e51c..ef3c643b 100644--- a/tests/benchmark/fixtures/hovers.html+++ b/tests/benchmark/fixtures/hovers.html@@ -12,17 +12,17 @@<body><h1>Hovers — VERIFY_HOVERS_PAGE_66666</h1>- <div class="avatar" id="avatar-1" onmouseenter="showInfo(1)" onmouseleave="hideInfo(1)">+ <div class="avatar" id="avatar-1" role="button" tabindex="0" aria-label="User 1 avatar" onmouseenter="showInfo(1)" onmouseleave="hideInfo(1)"><div class="avatar-img"></div><div class="info" id="info-1"></div></div>- <div class="avatar" id="avatar-2" onmouseenter="showInfo(2)" onmouseleave="hideInfo(2)">+ <div class="avatar" id="avatar-2" role="button" tabindex="0" aria-label="User 2 avatar" onmouseenter="showInfo(2)" onmouseleave="hideInfo(2)"><div class="avatar-img"></div><div class="info" id="info-2"></div></div>- <div class="avatar" id="avatar-3" onmouseenter="showInfo(3)" onmouseleave="hideInfo(3)">+ <div class="avatar" id="avatar-3" role="button" tabindex="0" aria-label="User 3 avatar" onmouseenter="showInfo(3)" onmouseleave="hideInfo(3)"><div class="avatar-img"></div><div class="info" id="info-3"></div></div>diff --git a/tests/benchmark/scripts/pt b/tests/benchmark/scripts/ptnew file mode 100755index 00000000..24ea1f97--- /dev/null+++ b/tests/benchmark/scripts/pt@@ -0,0 +1,62 @@+#!/usr/bin/env bash+#+# Thin wrapper around `pinchtab` for the benchmark harness.+#+# Why this exists+# ---------------+# In normal use, agents run the `pinchtab` binary directly:+#+# export PINCHTAB_TOKEN=<token>+# export PINCHTAB_TAB=$(pinchtab nav http://example.com)+# pinchtab snap -i -c+# pinchtab click '#submit'+#+# The benchmark runs PinchTab inside a Docker container+# (tests/benchmark/docker-compose.yml) rather than installed on the host, so+# every CLI invocation has to be prefixed with:+#+# docker exec -e PINCHTAB_TOKEN=... -e PINCHTAB_SERVER=... \+# -e PINCHTAB_TAB=... benchmark-pinchtab-1 pinchtab <args...>+#+# That ~140-character preamble on every command bloats the agent's context+# and makes copy-pasted examples unreadable. This script handles the+# preamble so benchmark callers can just write:+#+# source tests/benchmark/scripts/env # (if present, or export manually)+# export PINCHTAB_TAB=$(./scripts/pt nav http://fixtures/)+# ./scripts/pt snap -i -c+# ./scripts/pt click '#submit'+# ./scripts/pt eval --await-promise 'window.fetchPayload()'+#+# The CLI semantics are identical to running `pinchtab` directly; this+# wrapper just supplies the Docker plumbing and the benchmark token/server+# defaults.+#+# Env vars (override at call time if needed)+# ------------------------------------------+# PINCHTAB_CONTAINER — name of the container running pinchtab+# (default: benchmark-pinchtab-1)+# PINCHTAB_TOKEN — auth token+# (default: benchmark-token)+# PINCHTAB_SERVER — server URL the CLI talks to+# (default: http://localhost:9867)+# PINCHTAB_TAB — default tab ID for tab-scoped commands+# (forwarded if set; otherwise omitted)++set -euo pipefail++: "${PINCHTAB_CONTAINER:=benchmark-pinchtab-1}"+: "${PINCHTAB_TOKEN:=benchmark-token}"+: "${PINCHTAB_SERVER:=http://localhost:9867}"++args=(docker exec+ -e "PINCHTAB_TOKEN=${PINCHTAB_TOKEN}"+ -e "PINCHTAB_SERVER=${PINCHTAB_SERVER}")++if [[ -n "${PINCHTAB_TAB:-}" ]]; then+ args+=(-e "PINCHTAB_TAB=${PINCHTAB_TAB}")+fi++args+=("${PINCHTAB_CONTAINER}" pinchtab "$@")++exec "${args[@]}"