π€― LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
π fix(acceptance): reuse upstream capture helpers (#19822)
AmAzing-3be8e4da2c33
diff --git a/.agents/acceptance/PROCESS.md b/.agents/acceptance/PROCESS.mdindex 5fc25017eb3..528790a2b3e 100644--- a/.agents/acceptance/PROCESS.md+++ b/.agents/acceptance/PROCESS.md@@ -131,7 +131,8 @@ regardless.6. **Screen-recording preflight, only for OS-capture surfaces.** macOS`screencapture`/osascript returns a fully black frame when Screen Recordingpermission is missing _or_ the display is asleep. Gate on- `.agents/acceptance/scripts/check-screen-recording.sh` (exit 0 = safe), and keep+ `bash .agents/skills/acceptance/scripts/check-screen-recording.sh`+ (only exit 0 confirms permission and a measured non-black frame), and keepthe display awake for the session with `caffeinate -dimsu &`. CDP capture(`agent-browser screenshot`, `cdp-screenshot.sh`, `record-app-screen.sh`) isunaffected.@@ -192,18 +193,27 @@ will not take the intended path, call the server endpoint directly.### Step 4 β RunProject scripts live in `.agents/acceptance/scripts/` and are described in-`PROJECT.md` Β§5. The generic capture toolchain:--| Script | Use |-| --------------------------- | ------------------------------------------------------------------- |-| `report-init.sh` | Scaffold a report directory grouped by acceptance subject |-| `fixture.mjs` | Per-check fixtures: `init-check`, `list`, `compose` |-| `record-gif.sh` | Frame sequence β GIF for time-based behavior |-| `check-screen-recording.sh` | Preflight for OS capture (permission + display awake) |-| `cdp-screenshot.sh` | Electron/Chrome screenshot over raw CDP (bypasses the daemon) |-| `capture-app-window.sh` | Screenshot one app window (macOS OS capture) |-| `record-app-screen.sh` | Record an app screen (CDP frames β video + gallery) |-| `agent-browser-klm.mjs` | Wrap an `agent-browser` action and append its interaction-cost atom |+`PROJECT.md` Β§5:++| Script | Use |+| ----------------------- | ------------------------------------------------------------------- |+| `report-init.sh` | Scaffold a report directory grouped by acceptance subject |+| `fixture.mjs` | Per-check fixtures: `init-check`, `list`, `compose` |+| `record-gif.sh` | Frame sequence β GIF for time-based behavior |+| `capture-app-window.sh` | Screenshot one app window (macOS OS capture) |+| `record-app-screen.sh` | Record an app screen (CDP frames β video + gallery) |+| `agent-browser-klm.mjs` | Wrap an `agent-browser` action and append its interaction-cost atom |++Generic capture helpers come from the installed skill, not the project layer:++```bash+bash .agents/skills/acceptance/scripts/check-screen-recording.sh --json+bash .agents/skills/acceptance/scripts/cdp-screenshot.sh --port 9222 --out "$DIR/assets/window.png"+```++Follow [`screenshot-helpers.md`](../skills/acceptance/references/screenshot-helpers.md)+for prerequisites and exit codes. A missing tool or an undetermined check is not+a pass.macOS automation patterns: [`references/osascript.md`](./references/osascript.md).Screen recording: [`references/record-app-screen.md`](./references/record-app-screen.md).diff --git a/.agents/acceptance/PROJECT.md b/.agents/acceptance/PROJECT.mdindex b010c1eeb54..d91b101d1e7 100644--- a/.agents/acceptance/PROJECT.md+++ b/.agents/acceptance/PROJECT.md@@ -17,9 +17,13 @@ Its two siblings:or release is not required. Do not hand-edit this installed copy.`.claude/skills` shares `.agents/skills`.-Every script referenced below lives under `.agents/acceptance/scripts/`, including-the generic capture toolchain (`report-init.sh`, `cdp-screenshot.sh`,-`record-gif.sh`, `check-screen-recording.sh`, β¦).+Project helpers (`report-init.sh`, `record-gif.sh`, `capture-app-window.sh`, β¦)+live under `.agents/acceptance/scripts/`. Generic CDP capture and screen-recording+preflight live only under `.agents/skills/acceptance/scripts/`; invoke their shell+scripts with `bash`. See the installed skill's+[`screenshot-helpers.md`](../skills/acceptance/references/screenshot-helpers.md)+for commands, prerequisites, and exit codes. Do not copy these implementations+into the project layer.## 1. Project summary@@ -359,7 +363,7 @@ in `.agents/acceptance/references/agent-gateway.md`.- **OS-capture surfaces are macOS-only** (bot channels, `capture-app-window.sh`,osascript screenshots): they come out black without Screen Recording (TCC)permission or when the display is asleep/locked. CDP-based evidence- (`agent-browser screenshot`, `.agents/acceptance/scripts/cdp-screenshot.sh`) is+ (`agent-browser screenshot`, `bash .agents/skills/acceptance/scripts/cdp-screenshot.sh`) isunaffected. Electron runs on Linux/cloud only under `xvfb-run`, and there OScapture does not work β prefer CDP evidence for cloud-portable runs.diff --git a/.agents/acceptance/references/osascript.md b/.agents/acceptance/references/osascript.mdindex 9d80a426f16..efa42a3c3a0 100644--- a/.agents/acceptance/references/osascript.md+++ b/.agents/acceptance/references/osascript.md@@ -6,8 +6,8 @@ a general macOS-automation asset, not tied to any one app or surface. Use it whetest needs to drive a native macOS app that is not reachable over CDP.macOS only. See also [record-app-screen.md](./record-app-screen.md) for capture and-the screen-recording preflight (`scripts/check-screen-recording.sh`) before any-OS-level capture.+run `bash .agents/skills/acceptance/scripts/check-screen-recording.sh` before any+OS-level capture. The preflight belongs to the installed acceptance skill.## Core Patterns@@ -198,5 +198,5 @@ screencapture /tmp/app-test.pnglayout.- **`entire contents` is extremely slow** β avoid for complex UIs; use screenshots.- **OS screenshots go BLACK when the display is asleep/locked/screensaver** β gate- with `scripts/check-screen-recording.sh` and keep the display awake with+ with `bash .agents/skills/acceptance/scripts/check-screen-recording.sh` and keep the display awake with`caffeinate -dimsu &` for the whole capture run.diff --git a/.agents/acceptance/references/probe-field-notes.md b/.agents/acceptance/references/probe-field-notes.mdindex f4c2dc42e16..d09d7cf8958 100644--- a/.agents/acceptance/references/probe-field-notes.md+++ b/.agents/acceptance/references/probe-field-notes.md@@ -404,8 +404,8 @@ executionTarget: 'local'` in `agencyConfig`) + one message per case asking CC to`WebContentsView`s (not renderer `<webview>` guests β that is E16/D15, a different shape).- **Doesn't work**: assuming any tool that "just connects to the CDP port" lands on the app.Every live page shows up in `/json/list` as its own `type: page` target, so both- `agent-browser` and `scripts/cdp-screenshot.sh` can silently attach to a _web page the app- is hosting_ instead of the app itself. Measured: `cdp-screenshot.sh` reported+ `agent-browser` and `bash .agents/skills/acceptance/scripts/cdp-screenshot.sh` can silently+ attach to a _web page the app is hosting_ instead of the app itself. Measured: `cdp-screenshot.sh` reported`targetUrl: https://example.com/` and wrote that page's pixels while the intended evidencewas the app window; an `agent-browser get url` on the same port hung.- **Works β pin the target by URL prefix.** Raw CDP, pick the target whose `url` starts withdiff --git a/.agents/acceptance/scripts/capture-app-window.sh b/.agents/acceptance/scripts/capture-app-window.shindex 5a04cd19c2a..1708aa594b7 100755--- a/.agents/acceptance/scripts/capture-app-window.sh+++ b/.agents/acceptance/scripts/capture-app-window.sh@@ -29,8 +29,8 @@ OUTPUT="${2:?Usage: capture-app-window.sh <process_name> <output_path>}"# remediation instead of silently writing a black artifact. Set SKIP_SCREEN_CHECK=1 to bypass.if [ "${SKIP_SCREEN_CHECK:-0}" != "1" ]; thenSCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"- if ! "$SCRIPT_DIR/check-screen-recording.sh"; then- echo "[capture] Aborting: OS screen capture would be black. Fix the above, or wrap the run in 'caffeinate -dimsu' to keep the display awake." >&2+ if ! bash "$SCRIPT_DIR/../../skills/acceptance/scripts/check-screen-recording.sh"; then+ echo "[capture] Aborting: screen-recording preflight did not pass. Resolve the diagnostic above before capturing evidence." >&2exit 1fifidiff --git a/.agents/acceptance/scripts/capture-app-window.test.sh b/.agents/acceptance/scripts/capture-app-window.test.shnew file mode 100644index 00000000000..a15007e0942--- /dev/null+++ b/.agents/acceptance/scripts/capture-app-window.test.sh@@ -0,0 +1,80 @@+#!/usr/bin/env bash+# Test the project capture helper's boundary with the installed acceptance skill.+# Stub the preflight and OS commands; never capture the user's real desktop.+set -euo pipefail++SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+TEST_TMP="$(mktemp -d)"+trap 'rm -rf "$TEST_TMP"' EXIT++fail() {+ echo "FAIL: $*" >&2+ exit 1+}++PROJECT="$TEST_TMP/project with spaces"+CAPTURE="$PROJECT/.agents/acceptance/scripts/capture-app-window.sh"+PREFLIGHT="$PROJECT/.agents/skills/acceptance/scripts/check-screen-recording.sh"+mkdir -p "$(dirname "$CAPTURE")" "$(dirname "$PREFLIGHT")" "$TEST_TMP/bin"+cp "$SCRIPT_DIR/capture-app-window.sh" "$CAPTURE"++# Skills CLI installs this resource without executable permission.+cat > "$PREFLIGHT" <<'SH'+printf '%s\n' preflight >> "${CAPTURE_TEST_LOG:?}"+echo 'fixture preflight diagnostic'+exit "${CAPTURE_TEST_PREFLIGHT_STATUS:?}"+SH+chmod 644 "$PREFLIGHT"++cat > "$TEST_TMP/bin/swift" <<'SH'+#!/usr/bin/env bash+printf '%s\n' window-lookup >> "${CAPTURE_TEST_LOG:?}"+echo 42+SH+cat > "$TEST_TMP/bin/screencapture" <<'SH'+#!/usr/bin/env bash+printf '%s\n' "capture:$*" >> "${CAPTURE_TEST_LOG:?}"+SH+chmod +x "$TEST_TMP/bin/swift" "$TEST_TMP/bin/screencapture"++export PATH="$TEST_TMP/bin:$PATH"+export CAPTURE_TEST_LOG="$TEST_TMP/calls.log"+export CAPTURE_TEST_PREFLIGHT_STATUS=0+export SKIP_SCREEN_CHECK=0+OUTPUT="$TEST_TMP/window shot.png"++# Invoke from outside the project to catch cwd-relative paths as well.+pushd "$TEST_TMP" >/dev/null+if ! output="$(bash "$CAPTURE" 'Test App' "$OUTPUT" 2>&1)"; then+ fail "capture should continue after a passing installed preflight: $output"+fi+expected="$(printf 'preflight\nwindow-lookup\ncapture:-l 42 -x %s' "$OUTPUT")"+[ "$(cat "$CAPTURE_TEST_LOG")" = "$expected" ] || fail "wrong capture call order or arguments"++# Undetermined, denied, and black-frame checks must all block OS capture.+for status in 2 3 4; do+ export CAPTURE_TEST_PREFLIGHT_STATUS="$status"+ : > "$CAPTURE_TEST_LOG"+ if output="$(bash "$CAPTURE" 'Test App' "$OUTPUT" 2>&1)"; then+ fail "preflight exit $status did not block capture"+ fi+ [ "$(cat "$CAPTURE_TEST_LOG")" = preflight ] || fail "OS commands ran after preflight exit $status"+ [[ "$output" == *'fixture preflight diagnostic'* ]] || fail "preflight diagnostic was lost"+ [[ "$output" == *'preflight did not pass'* ]] || fail "failure was not reported as an unverified preflight"+done++rm "$PREFLIGHT"+: > "$CAPTURE_TEST_LOG"+if bash "$CAPTURE" 'Test App' "$OUTPUT" >/dev/null 2>&1; then+ fail "missing installed preflight did not block capture"+fi+[ ! -s "$CAPTURE_TEST_LOG" ] || fail "OS commands ran without the installed preflight"++# Preserve the existing explicit bypass for callers that already checked capture.+export SKIP_SCREEN_CHECK=1+bash "$CAPTURE" 'Test App' "$OUTPUT"+expected="$(printf 'window-lookup\ncapture:-l 42 -x %s' "$OUTPUT")"+[ "$(cat "$CAPTURE_TEST_LOG")" = "$expected" ] || fail "explicit bypass changed capture behavior"+popd >/dev/null++echo 'capture-app-window tests passed (6 cases)'diff --git a/.agents/acceptance/scripts/cdp-capture.cjs b/.agents/acceptance/scripts/cdp-capture.cjsdeleted file mode 100755index 26144976d68..00000000000--- a/.agents/acceptance/scripts/cdp-capture.cjs+++ /dev/null@@ -1,131 +0,0 @@-#!/usr/bin/env node-// cdp-capture.cjs β capture a screenshot from a CDP target via RAW DevTools protocol,-// bypassing the agent-browser daemon. Proven reliable against headful Electron/Chrome-// regardless of display sleep or window minimization/occlusion (Page.captureScreenshot-// forces a compositor frame). Every CDP call is hard-timeout guarded so a stall fails-// fast instead of wedging anything.-//-// Usage: node cdp-capture.cjs --port 9222 --out shot.png [--full] [--target-url <substr>] [--timeout 12000]-// Prints one line of JSON: {"ok":true,"bytes":N,"ms":N,"targetUrl":"..."} or {"ok":false,"error":"..."}-// Exit 0 on success, non-zero on failure/timeout.-//-// Requires the `ws` package. The script lives in this repo's own-// `.agents/acceptance/scripts/`, so Node's ancestor node_modules walk reaches the-// workspace root β no NODE_PATH wiring, and an unresolvable `ws` means the repo's-// dependencies simply are not installed.--const http = require('node:http');-const fs = require('node:fs');--function resolveWs() {- try {- return require('ws');- } catch {- console.log(- JSON.stringify({- ok: false,- error:- "Cannot find module 'ws' from " +- __filename +- '. Install the repository dependencies (pnpm install) and retry.',- }),- );- process.exit(7);- }-}--const WebSocket = resolveWs();--const arg = (k, d) => {- const i = process.argv.indexOf(k);- return i > -1 ? process.argv[i + 1] : d;-};-const has = (k) => process.argv.includes(k);-const PORT = parseInt(arg('--port', '9222'), 10);-const OUT = arg('--out', '/tmp/cdp-capture.png');-const FULL = has('--full');-const TURL = arg('--target-url', '');-const TIMEOUT = parseInt(arg('--timeout', '12000'), 10);--const done = (obj, code) => {- console.log(JSON.stringify(obj));- process.exit(code);-};-const httpGet = (path) =>- new Promise((res, rej) => {- const req = http.get({ host: '127.0.0.1', port: PORT, path }, (r) => {- let d = '';- r.on('data', (c) => (d += c));- r.on('end', () => {- try {- res(JSON.parse(d));- } catch (e) {- rej(e);- }- });- });- req.on('error', rej);- req.setTimeout(4000, () =>- req.destroy(- new Error(- 'CDP HTTP timeout β is the app running with --remote-debugging-port=' + PORT + '?',- ),- ),- );- });--function client(url) {- const ws = new WebSocket(url, { maxPayload: 512 * 1024 * 1024 });- const pending = new Map();- let id = 0;- const ready = new Promise((r, j) => {- ws.on('open', r);- ws.on('error', j);- });- ws.on('message', (m) => {- const o = JSON.parse(m);- if (o.id && pending.has(o.id)) {- pending.get(o.id)(o);- pending.delete(o.id);- }- });- const send = (method, params = {}, timeout = TIMEOUT) =>- new Promise((res, rej) => {- const myid = ++id;- pending.set(myid, (o) =>- o.error ? rej(new Error(method + ': ' + o.error.message)) : res(o.result),- );- ws.send(JSON.stringify({ id: myid, method, params }));- setTimeout(() => {- if (pending.has(myid)) {- pending.delete(myid);- rej(new Error('TIMEOUT ' + method + ' after ' + timeout + 'ms'));- }- }, timeout);- });- return { ws, ready, send };-}--(async () => {- const targets = await httpGet('/json');- const pages = targets.filter((t) => t.type === 'page' && t.webSocketDebuggerUrl);- const page = TURL ? pages.find((t) => (t.url || '').includes(TURL)) : pages[0];- if (!page) throw new Error('no page target found' + (TURL ? ' matching "' + TURL + '"' : ''));- const pg = client(page.webSocketDebuggerUrl);- await pg.ready;- let params = { format: 'png' };- if (FULL) {- const m = await pg.send('Page.getLayoutMetrics', {});- const s = m.cssContentSize || m.contentSize;- params = {- format: 'png',- captureBeyondViewport: true,- clip: { x: 0, y: 0, width: Math.ceil(s.width), height: Math.ceil(s.height), scale: 1 },- };- }- const t0 = Date.now();- const r = await pg.send('Page.captureScreenshot', params);- const buf = Buffer.from(r.data, 'base64');- fs.writeFileSync(OUT, buf);- done({ ok: true, bytes: buf.length, ms: Date.now() - t0, targetUrl: page.url }, 0);-})().catch((e) => done({ ok: false, error: e.message }, 1));diff --git a/.agents/acceptance/scripts/cdp-screenshot.sh b/.agents/acceptance/scripts/cdp-screenshot.shdeleted file mode 100755index cd37a93e844..00000000000--- a/.agents/acceptance/scripts/cdp-screenshot.sh+++ /dev/null@@ -1,83 +0,0 @@-#!/usr/bin/env bash-#-# cdp-screenshot.sh β Reliable Electron/Chrome screenshot via RAW CDP (bypasses the-# agent-browser daemon) + optional preflight verdict.-#-# Why this exists: agent-browser's `screenshot` goes through a long-lived daemon that-# can wedge ("CDP response channel closed" / "daemon busy") after an interrupted or-# mis-invoked capture β and once wedged, every later screenshot fails while eval/get-# still work. Raw `Page.captureScreenshot` is fast (~60ms) and robust: it forces a-# compositor frame, so it works even when the DISPLAY IS ASLEEP or the WINDOW IS-# MINIMIZED/OCCLUDED (both verified). Use this instead of `agent-browser screenshot`-# for Electron evidence, and as a preflight to prove capture works before relying on it.-#-# Usage:-# ./cdp-screenshot.sh [--port 9222] [--out shot.png] [--full] [--target-url <substr>] [--check]-#-# --check preflight mode: capture a throwaway frame, verify it is non-black,-# print a PASS/FAIL verdict. Exit 0 only if a real frame was captured.-#-# Exit codes: 0 ok Β· 5 capture failed/timeout Β· 6 captured but BLACK Β· 7 node/dependency missing-set -uo pipefail--SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"-PORT=9222; OUT=""; CHECK=0; PASS=()-while [ $# -gt 0 ]; do- case "$1" in- --port) PORT="$2"; shift 2 ;;- --out) OUT="$2"; shift 2 ;;- --check) CHECK=1; shift ;;- --full|--target-url) PASS+=("$1"); [ "$1" = "--target-url" ] && { PASS+=("$2"); shift; }; shift ;;- *) PASS+=("$1"); shift ;;- esac-done-[ -z "$OUT" ] && OUT="${TMPDIR:-/tmp}/cdp-shot-$PORT.png"--command -v node >/dev/null 2>&1 || { echo "[cdp-shot] node not found"; exit 7; }--# cdp-capture.cjs resolves the `ws` package itself via Node's normal ancestor-# node_modules lookup from its own file location β no NODE_PATH plumbing needed.-res="$(node "$SCRIPT_DIR/cdp-capture.cjs" --port "$PORT" --out "$OUT" --timeout 12000 ${PASS[@]+"${PASS[@]}"} 2>&1)"-ok="$(printf '%s' "$res" | sed -n 's/.*"ok":\([a-z]*\).*/\1/p')"--if [ "$ok" != "true" ]; then- case "$res" in- *"Cannot find module 'ws'"*)- echo "[cdp-shot] MISSING DEPENDENCY: $res"- exit 7- ;;- esac- echo "[cdp-shot] CAPTURE FAILED: $res"- echo "[cdp-shot] Fix: ensure the app runs with --remote-debugging-port=$PORT and CDP is reachable (curl 127.0.0.1:$PORT/json/version). If agent-browser wedged the session earlier, reset it: 'agent-browser close --all'. Raw CDP here does not use that daemon."- exit 5-fi--# blackness verdict (sips + python3; skip silently if unavailable)-verdict="unknown"; maxv=""-if command -v sips >/dev/null 2>&1 && command -v python3 >/dev/null 2>&1; then- sips -z 16 16 "$OUT" --out "$OUT.s.png" >/dev/null 2>&1- sips -s format bmp "$OUT.s.png" --out "$OUT.bmp" >/dev/null 2>&1- maxv="$(python3 - "$OUT.bmp" <<'PY' 2>/dev/null || echo -1-import sys-d=open(sys.argv[1],'rb').read();off=int.from_bytes(d[10:14],'little');w=int.from_bytes(d[18:22],'little');h=abs(int.from_bytes(d[22:26],'little',signed=True))-bpp=int.from_bytes(d[28:30],'little') or 24;B=bpp//8;row=((w*bpp+31)//32)*4;mx=0-for y in range(h):- for x in range(w):- q=off+y*row+x*B- if q+2<len(d): mx=max(mx,d[q],d[q+1],d[q+2])-print(mx)-PY-)"- rm -f "$OUT.s.png" "$OUT.bmp" 2>/dev/null- [[ "$maxv" =~ ^[0-9]+$ ]] && { (( maxv < 12 )) && verdict="black" || verdict="live"; }-fi--if [ "$verdict" = "black" ]; then- echo "[cdp-shot] CAPTURED BUT BLACK ($res). Unusual for CDP β check the page actually rendered (not a blank route)."- [ "$CHECK" = "1" ] && exit 6- exit 6-fi--echo "[cdp-shot] OK ($res)${maxv:+ maxBrightness=$maxv}"-[ "$CHECK" = "1" ] && { rm -f "$OUT" 2>/dev/null; echo "[cdp-shot] PREFLIGHT PASS β CDP screenshot works on port $PORT."; }-exit 0diff --git a/.agents/acceptance/scripts/check-screen-recording.sh b/.agents/acceptance/scripts/check-screen-recording.shdeleted file mode 100755index 0aa88278aca..00000000000--- a/.agents/acceptance/scripts/check-screen-recording.sh+++ /dev/null@@ -1,144 +0,0 @@-#!/usr/bin/env bash-#-# check-screen-recording.sh β Preflight gate for OS-level screen capture (macOS).-#-# OS screenshots (`screencapture`, osascript, bot-channel captures) come out-# ENTIRELY BLACK when either:-# 1. Screen Recording (TCC) permission is not granted to the responsible app, or-# 2. the display is asleep / locked / running a screensaver (permission is fine-# but there is nothing lit to capture β common after a long idle test run).-# A black artifact is easy to mistake for a real capture, so gate on this BEFORE-# any OS-capture step. CDP-based evidence (agent-browser screenshot, record-app-screen)-# renders from the browser engine and is NOT affected β this check is only for the-# OS-capture surfaces (bot tests, capture-app-window.sh, osascript screenshots).-#-# Usage:-# ./check-screen-recording.sh # human-readable; exit 0 if OS capture will work-# ./check-screen-recording.sh --json # machine-readable one-line JSON-#-# Exit codes:-# 0 OS capture works (permission granted AND a live, non-black frame captured)-# 0 non-macOS (OS capture N/A β use CDP evidence)-# 3 permission NOT granted β grant Screen Recording, then restart the app-# 4 permission ok but frame BLACK β wake/unlock display, quit screensaver, or restart app-# 2 could not determine (no screencapture/toolchain)-#-set -uo pipefail--JSON=0-for a in "$@"; do case "$a" in --json) JSON=1 ;; esac; done--emit() { # $1=ok(true/false) $2=perm $3=capture $4=exit $5=message [$6=app]- if [[ $JSON == 1 ]]; then- printf '{"platform":"%s","ok":%s,"permission":"%s","capture":"%s","responsibleApp":"%s","message":"%s"}\n' \- "$(uname -s)" "$1" "${2:-unknown}" "${3:-unknown}" "${6:-}" "$5"- else- echo "[screen-recording] $5"- fi- exit "$4"-}--os=$(uname -s)-if [[ "$os" != "Darwin" ]]; then- emit true "n/a" "n/a" 0 "non-macOS ($os): OS screen capture N/A; CDP-based evidence is unaffected. OK."-fi--# --- responsible app: TCC attributes Screen Recording to the ancestor .app bundle ----responsible_app() {- local pid=$$ ppid comm- for _ in $(seq 1 12); do- if ! read -r ppid comm < <(ps -o ppid=,comm= -p "$pid" 2>/dev/null); then break; fi- [[ -z "${ppid:-}" ]] && break- if [[ "$comm" == *.app/Contents/MacOS/* ]]; then- local app="${comm%%.app/*}"; echo "${app##*/}.app"; return 0- fi- [[ "${ppid:-0}" -le 1 ]] && break- pid=$ppid- done- echo "${TERM_PROGRAM:-your terminal app}"-}-APP="$(responsible_app)"--# --- layer 1: TCC permission via CGPreflightScreenCaptureAccess (no prompt, no display) ----perm="unknown"-bin="${TMPDIR:-/tmp}/lobehub-scrcheck"-if [[ ! -x "$bin" ]] && command -v clang >/dev/null 2>&1; then- src="${TMPDIR:-/tmp}/lobehub-scrcheck.c"- cat > "$src" <<'EOF'-#include <CoreGraphics/CoreGraphics.h>-#include <stdio.h>-int main(void){ bool ok = CGPreflightScreenCaptureAccess(); printf(ok?"granted\n":"denied\n"); return ok?0:1; }-EOF- clang -framework CoreGraphics -o "$bin" "$src" 2>/dev/null || rm -f "$bin"-fi-if [[ -x "$bin" ]]; then- perm="$("$bin" 2>/dev/null || echo denied)"-elif command -v swift >/dev/null 2>&1; then- perm="$(swift - <<'EOF' 2>/dev/null || echo denied-import CoreGraphics-print(CGPreflightScreenCaptureAccess() ? "granted" : "denied")-EOF-)"-fi--# --- layer 2: liveness β capture one real frame and detect a fully-black image ----# Uses the brightest pixel across a downscaled grid: a live desktop always has some-# lit chrome (menu bar / cursor / window), a blocked/asleep capture is uniformly ~0.-capture="unknown"; maxv=""-if command -v screencapture >/dev/null 2>&1; then- shot="${TMPDIR:-/tmp}/lobehub-scrlive.png"- small="${TMPDIR:-/tmp}/lobehub-scrlive.bmp"- rm -f "$shot" "$small"- screencapture -x "$shot" 2>/dev/null || true- if [[ -s "$shot" ]] && command -v sips >/dev/null 2>&1 && command -v python3 >/dev/null 2>&1; then- sips -z 16 16 "$shot" --out "${shot}.s.png" >/dev/null 2>&1- sips -s format bmp "${shot}.s.png" --out "$small" >/dev/null 2>&1- if [[ -s "$small" ]]; then- maxv="$(python3 - "$small" <<'PY' 2>/dev/null || echo -1-import sys-d=open(sys.argv[1],'rb').read()-off=int.from_bytes(d[10:14],'little')-w=int.from_bytes(d[18:22],'little')-h=abs(int.from_bytes(d[22:26],'little',signed=True))-bpp=int.from_bytes(d[28:30],'little') or 24-Bpp=bpp//8-row=((w*bpp+31)//32)*4-mx=0-for y in range(h):- base=off+y*row- for x in range(w):- p=base+x*Bpp- if p+2 < len(d):- mx=max(mx, d[p], d[p+1], d[p+2])-print(mx)-PY-)"- if [[ "${maxv:-}" =~ ^[0-9]+$ ]]; then- # brightest channel < 12/255 across the whole screen β effectively black- if (( maxv < 12 )); then capture="black"; else capture="live"; fi- fi- fi- fi- rm -f "$shot" "${shot}.s.png" "$small" 2>/dev/null || true-fi--# --- decision ----if [[ "$capture" == "live" ]]; then- emit true "$perm" "$capture" 0 "OK β Screen Recording works (permission granted, display live). OS captures and bot tests will render real frames." "$APP"-fi--if [[ "$capture" == "black" ]]; then- if [[ "$perm" == "denied" ]]; then- emit false "$perm" "$capture" 3 "BLOCKED β Screen Recording permission is NOT granted to '$APP'. Enable it in: System Settings βΈ Privacy & Security βΈ Screen Recording βΈ turn ON '$APP', then FULLY QUIT & reopen '$APP' (TCC only takes effect on a fresh launch). Until then every OS screenshot/recording and bot test will be BLACK." "$APP"- fi- emit false "$perm" "$capture" 4 "BLACK FRAME β permission looks OK but the capture is black. The display is likely asleep / locked / on a screensaver, or '$APP' was just granted permission but not restarted. Wake & unlock the display, disable the screensaver for the test run (caffeinate -d), or restart '$APP', then re-run this check." "$APP"-fi--# capture couldn't be measured β fall back to the permission verdict-if [[ "$perm" == "denied" ]]; then- emit false "$perm" "$capture" 3 "BLOCKED β Screen Recording permission is NOT granted to '$APP'. Enable it: System Settings βΈ Privacy & Security βΈ Screen Recording βΈ turn ON '$APP', then fully quit & reopen '$APP'." "$APP"-elif [[ "$perm" == "granted" ]]; then- emit true "$perm" "$capture" 0 "Permission granted for '$APP'; could not verify a live frame (no screencapture/sips/python3). Proceeding β if OS captures come out black, wake/unlock the display." "$APP"-else- emit false "$perm" "$capture" 2 "UNDETERMINED β could not check Screen Recording permission or capture a test frame (missing clang/swift/screencapture). Verify manually in System Settings βΈ Privacy & Security βΈ Screen Recording for '$APP'." "$APP"-fidiff --git a/.agents/skills/agent-testing-bot/SKILL.md b/.agents/skills/agent-testing-bot/SKILL.mdindex 2f681116188..0d51c3756d2 100644--- a/.agents/skills/agent-testing-bot/SKILL.md+++ b/.agents/skills/agent-testing-bot/SKILL.md@@ -54,8 +54,9 @@ Every osascript platform script shares one interface:```The script activates the app, navigates to the channel/contact, sends the-message, waits, and screenshots the result window (via the generic skill's-`../../acceptance/scripts/capture-app-window.sh`). iMessage is the exception: it+message, waits, and screenshots the result window (via the project adapter's+`../../acceptance/scripts/capture-app-window.sh`, which runs the installed+acceptance skill's screen-recording preflight). iMessage is the exception: ituses a BlueBubbles bridge, not osascript β see [imessage/index.md](./imessage/index.md).## osascript prerequisites@@ -74,9 +75,12 @@ Screen Recording (TCC) permission is missing OR the display is asleep / locked /on a screensaver. Gate BEFORE any bot capture:```bash-./.agents/acceptance/scripts/check-screen-recording.sh # exit 0 = OS capture will work+bash .agents/skills/acceptance/scripts/check-screen-recording.sh```+Only exit 0 confirms both permission and a measured non-black frame. Missing+tools or an undetermined check must block capture, not count as a pass.+Keep the display awake for the whole capture session (`caffeinate -dimsu &`, killwhen done). Because this surface depends on OS capture and native macOS apps,**bot channels are macOS-only β they do not run headless / in cloud.**