Compare commits

...
5 Commits
Author SHA1 Message Date
Ziad Arafat d3b9e0d333 Preflight the rootless podman subuid/subgid ranges in dot boxes
A fedora-toolbox pull dies inside the user namespace ('requested 998:998
for /var/lib/unbound') when the user has no /etc/subuid and /etc/subgid
range, and distrobox only shows podman's unpack error. dot boxes now
checks both files and prints the usermod + podman system migrate fix
before pulling; dot doctor reports the same condition.
tests/boxes-subid.sh covers range summing, small ranges and the hint.
2026-12-02 12:38:40 -07:00
Ziad Arafat 12258063ce remote-browser: make 'cli' a true passthrough and say so
cli used to share the flag parser with the built-in verbs, so a playwright-cli
argument that looked like ours could be swallowed. After 'cli' the args now go
through untouched, '--' is honoured, and the skill documents that the built-ins
are a convenience layer rather than a subset: goto/click/storage/tracing/route/
run-code/pdf/webmcp all work in the attached session with exit codes intact.
2026-12-02 12:29:47 -07:00
Ziad Arafat a21791c630 remote-browser: generalise deck-browser to any device, add a setup workflow
deck-browser assumed one host. remote-browser takes a profile per device
(transport ssh or direct, host, port, ws path, inspect URL) and gains
'profiles', 'setup' and 'check': check walks ssh -> port -> websocket
handshake -> attach -> tabs and prints the first failure instead of a
generic 'could not attach'. The skill ships references/setup.md, a checklist
for onboarding a device with the user, including per-browser toggle URLs, the
Chrome <136 fallback, and a symptom->cause table.
2026-12-02 12:25:45 -07:00
Ziad Arafat 8999c687f9 deck-browser: drive playwright-cli instead of a hand-rolled CDP client
Playwright documents connectOverCDP with a ws:// endpoint, and
playwright-cli attach --cdp=ws://127.0.0.1:9222/devtools/browser works against
the Deck's chrome://inspect toggle. That makes the 270-line stdlib CDP client
redundant: the wrapper is now 130 lines of bash that opens the tunnel, attaches
once and maps tabs/text/html/shot onto playwright-cli (plus a 'cli' passthrough
so agents can reach console, network and the rest without new code).
2026-12-02 12:20:43 -07:00
Ziad Arafat d306474f95 deck-browser: read the Deck's Chrome from arceus over CDP
The user browses on the Steam Deck; agents run on arceus. Chrome's per-instance
remote debugging (chrome://inspect toggle) exposes CDP only as a WebSocket at
/devtools/browser, so playwright attach cannot use it and the HTTP /json paths
return 403. bin/deck-browser speaks CDP directly with the standard library:
tabs, text, html, shot, status, plus an opt-in unsafe-eval. Read-only by design -
no click, type or navigate - because driving authenticated sessions is what gets
accounts restricted. Opens the SSH tunnel itself and reuses an existing one.

Registers the skill for every harness and tells agents it exists.
2026-12-02 12:18:08 -07:00
9 changed files with 589 additions and 0 deletions

No files matched your search

+12
View File
@@ -408,3 +408,15 @@ WEBTOP=1 tests/container-test.sh lscr.io/linuxserver/webtop:fedora-kde full webt
- Plasma only applies panel changes from plasma-manager at the next login. Its panel script deletes `plasma-org.kde.plasma.desktop-appletsrc` first, so `daynight-hooks` re-applies the wallpapers 20 s after login.
- Sensor IDs in the panel monitors are regexes. Avoid backslashes in them: KConfig unescapes them, and the JSON list then fails to parse.
- Managed browser policies show "Managed by your organization" in Chrome and Edge. That's expected.
- `dot boxes` fails mid-pull with `potentially insufficient UIDs or GIDs available in
user namespace (requested 998:998 for /var/lib/unbound)` when rootless podman has no
`/etc/subuid`/`/etc/subgid` range for you: the fedora-toolbox image contains uid 998
and the layer unpack cannot map it. `dot boxes` preflights this and `dot doctor`
reports it, but the fix is root:
```bash
grep -E "^$(id -un):" /etc/subuid /etc/subgid # empty or a tiny range?
sudo usermod --add-subuids 100000-165535 --add-subgids 100000-165535 "$(id -un)"
podman system migrate # rebuild the mapping; keeps images
```
If the store was created without a mapping, `podman system reset` (deletes images and
containers) then `dot boxes` again.
+29
View File
@@ -367,9 +367,37 @@ seed_xpipe() {
ok "XPipe set to sync from RustyRaptor/xpipe-sync (enter the GitHub token on first launch)"
}
# Rootless podman unpacks each image layer inside a user namespace. Without
# /etc/subuid and /etc/subgid ranges for this user, every pull dies in the middle
# with "potentially insufficient UIDs or GIDs available in user namespace".
subid_count() {
local file="$1" total=0 name start count
[ -r "$file" ] || { echo 0; return 0; }
while IFS=: read -r name start count; do
[ "$name" = "$(id -un)" ] || continue
case "$count" in ''|*[!0-9]*) continue ;; esac
total=$(( total + count ))
done <"$file"
echo "$total"
}
podman_subid_ok() {
[ "$(subid_count "${SUBUID_FILE:-/etc/subuid}")" -ge 65536 ] &&
[ "$(subid_count "${SUBGID_FILE:-/etc/subgid}")" -ge 65536 ]
}
podman_subid_hint() {
local me; me="$(id -un)"
warn "rootless podman has no subuid/subgid range for $me"
warn " ${SUBUID_FILE:-/etc/subuid} has $(subid_count "${SUBUID_FILE:-/etc/subuid}") ids, ${SUBGID_FILE:-/etc/subgid} has $(subid_count "${SUBGID_FILE:-/etc/subgid}") (65536 needed)"
warn " fix: sudo usermod --add-subuids 100000-165535 --add-subgids 100000-165535 $me && podman system migrate"
warn " last resort (deletes images/containers): podman system reset"
}
cmd_boxes() {
if in_container; then ok "skipping distrobox inside a container"; return; fi
have distrobox || die "distrobox missing (dot system)"
if have podman && [ "$(id -u)" != 0 ] && ! podman_subid_ok; then podman_subid_hint; fi
distrobox assemble create --file "$HOME/.config/distrobox/distrobox.ini"
}
@@ -891,6 +919,7 @@ cmd_doctor() {
chk "claude" "[ -x ~/.local/bin/claude ]" "dot apps"
if ! in_container; then
chk "podman" "have podman" "dot system"
chk "podman subuid/subgid" "podman_subid_ok" "dot boxes explains the usermod fix"
chk "distrobox" "have distrobox" "dot system"
fi
chk "ssh key" "[ -f ~/.ssh/id_ed25519 ]" "dot secrets pull"
+332
View File
@@ -0,0 +1,332 @@
#!/usr/bin/env bash
# remote-browser — read a Chromium browser running on another machine, over CDP.
#
# Works for any host the agent can reach (an SSH alias, or a direct address) whose
# browser exposes a CDP endpoint. Chrome-family browsers expose one when the user ticks
# chrome://inspect/#remote-debugging → "Allow remote debugging for this browser instance"
# which serves ONLY ws://127.0.0.1:<port>/devtools/browser (HTTP /json/* returns 403).
# Playwright attaches to a ws:// endpoint directly, so this is a thin wrapper that opens
# the tunnel and drives `playwright-cli`. Setup for a new device: see references/setup.md
# in the remote-browser skill, and run `remote-browser check`.
#
# remote-browser profiles list configured devices
# remote-browser setup --name deck --host deck [--port 9222] [--transport ssh]
# remote-browser check [--profile deck] step-by-step readiness test
# remote-browser tabs | status | text | html | shot
# remote-browser cli <playwright-cli args> full passthrough to playwright-cli
# (console, requests, storage, tracing,
# run-code, pdf, tab-*, goto/click…);
# ours flags are not parsed after `cli`
# remote-browser cli -- <args> explicit end-of-options form
#
# Options: --profile/-p NAME, --index N, --match SUBSTR, --limit CHARS, --out FILE.
# Read-only by intent: no click/type/navigate helper exists, because driving an
# authenticated session is what gets accounts restricted.
#
# Env: REMOTE_BROWSER_PROFILE (default profile), REMOTE_BROWSER_DIR (config dir).
set -euo pipefail
CONF_DIR=${REMOTE_BROWSER_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/remote-browser}
PROFILE_DIR="$CONF_DIR/profiles"
PN=$(basename "$0")
die() { echo "$PN: $*" >&2; exit 1; }
info() { echo " $*" >&2; }
usage() { sed -n '2,24p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; }
# --- argument parsing ---------------------------------------------------------
PROFILE=${REMOTE_BROWSER_PROFILE:-}
CMD=""
ARGS=()
while [ $# -gt 0 ]; do
if [ -n "$CMD" ] && [ "$CMD" = cli ]; then
# `cli` is a full passthrough: everything after it belongs to playwright-cli,
# including flags that look like ours.
ARGS+=("$1"); shift; continue
fi
case "$1" in
--profile|-p) PROFILE=${2:-}; shift 2 ;;
-h|--help) usage; exit 0 ;;
--) shift; if [ -z "$CMD" ]; then CMD=${1:-}; shift; fi
while [ $# -gt 0 ]; do ARGS+=("$1"); shift; done ;;
*) if [ -z "$CMD" ]; then CMD=$1; else ARGS+=("$1"); fi; shift ;;
esac
done
# --- profiles -----------------------------------------------------------------
profile_file() { echo "$PROFILE_DIR/$1.env"; }
load_profile() {
[ -n "$PROFILE" ] || die "no profile given (use --profile NAME, or set REMOTE_BROWSER_PROFILE). Try: $PN profiles"
local f; f=$(profile_file "$PROFILE")
[ -f "$f" ] || die "unknown profile '$PROFILE' ($f missing). Try: $PN profiles"
# shellcheck disable=SC1090
. "$f"
: "${RB_HOST:?profile $f has no RB_HOST}"
RB_PORT=${RB_PORT:-9222}
RB_TRANSPORT=${RB_TRANSPORT:-ssh}
RB_WS_PATH=${RB_WS_PATH:-/devtools/browser}
RB_INSPECT_URL=${RB_INSPECT_URL:-chrome://inspect/#remote-debugging}
SESSION="rb-$PROFILE"
if [ "$RB_TRANSPORT" = ssh ]; then
WS="ws://127.0.0.1:${RB_PORT}${RB_WS_PATH}"
else
WS="ws://${RB_HOST}:${RB_PORT}${RB_WS_PATH}"
fi
}
list_profiles() {
[ -d "$PROFILE_DIR" ] || { echo "no profiles yet — create one with: $PN setup --name <name> --host <host>"; return 0; }
shopt -s nullglob
local found=0 f
for f in "$PROFILE_DIR"/*.env; do
found=1
( . "$f"
printf '%-12s %-6s %-24s %s:%s\n' \
"$(basename "$f" .env)" "${RB_TRANSPORT:-ssh}" "${RB_HOST:-?}" "${RB_HOST:-?}" "${RB_PORT:-9222}" )
done
[ $found -eq 1 ] || echo "no profiles yet — create one with: $PN setup --name <name> --host <host>"
}
# --- transport ----------------------------------------------------------------
port_open() { (exec 3<>"/dev/tcp/${1}/${2}") 2>/dev/null; }
host_reachable() {
case "$RB_TRANSPORT" in
ssh) ssh -o BatchMode=yes -o ConnectTimeout=6 "$RB_HOST" true >/dev/null 2>&1 ;;
direct) port_open "$RB_HOST" "$RB_PORT" ;;
*) return 1 ;;
esac
}
ensure_tunnel() {
if [ "$RB_TRANSPORT" = direct ]; then
port_open "$RB_HOST" "$RB_PORT" || die "cannot reach ${RB_HOST}:${RB_PORT} (transport=direct)"
return 0
fi
port_open 127.0.0.1 "$RB_PORT" && return 0
ssh -o BatchMode=yes -o ExitOnForwardFailure=yes -f -N \
-L "${RB_PORT}:127.0.0.1:${RB_PORT}" "$RB_HOST" 2>/dev/null \
|| die "cannot open SSH tunnel to ${RB_HOST} — is it awake and is your key authorised?"
for _ in $(seq 1 25); do port_open 127.0.0.1 "$RB_PORT" && return 0; sleep 0.2; done
die "tunnel up but nothing listening on 127.0.0.1:${RB_PORT}.
On ${RB_HOST}, open ${RB_INSPECT_URL} and tick
'Allow remote debugging for this browser instance', then retry."
}
ws_handshake() { # prints HTTP status line of a WS upgrade attempt
python3 - "${1}" <<'PY' 2>/dev/null || echo "no-response"
import base64, os, socket, sys, urllib.parse as up
url = up.urlparse(sys.argv[1])
s = socket.create_connection((url.hostname, url.port or 80), timeout=5)
key = base64.b64encode(os.urandom(16)).decode()
s.sendall((f"GET {url.path or '/'} HTTP/1.1\r\nHost: {url.hostname}:{url.port}\r\n"
"Upgrade: websocket\r\nConnection: Upgrade\r\n"
f"Sec-WebSocket-Key: {key}\r\nSec-WebSocket-Version: 13\r\n\r\n").encode())
print(s.recv(256).decode(errors="replace").split("\r\n")[0].strip() or "no-response")
s.close()
PY
}
ensure_attached() {
ensure_tunnel
playwright-cli -s="$SESSION" eval '1' >/dev/null 2>&1 && return 0
playwright-cli -s="$SESSION" attach --cdp="$WS" >/dev/null 2>&1 \
|| die "playwright-cli could not attach to ${WS}.
On ${RB_HOST}: open ${RB_INSPECT_URL} and tick
'Allow remote debugging for this browser instance'."
}
# --- helpers ------------------------------------------------------------------
# tab_list → "INDEX<TAB>TITLE<TAB>URL"
tab_list() {
playwright-cli -s="$SESSION" tab-list 2>/dev/null \
| sed -n 's/^- \([0-9]\+\): \(.*\)\[\(.*\)\](\(.*\))$/\1\t\3\t\4/p'
}
resolve_tab() {
local idx="" match=""
while [ $# -gt 0 ]; do
case "$1" in
--index) idx=${2:-}; shift 2 ;;
--match) match=${2:-}; shift 2 ;;
*) shift ;;
esac
done
if [ -n "$match" ]; then
idx=$(tab_list | awk -F'\t' -v m="$(printf '%s' "$match" | tr 'A-Z' 'a-z')" \
'tolower($0) ~ m {print $1; exit}')
[ -n "$idx" ] || die "no tab matching '$match'"
fi
printf '%s' "${idx:-}"
}
json_unquote() {
python3 -c '
import json, sys
for line in sys.stdin.read().splitlines():
line = line.strip()
if line[:1] == chr(34) and line[-1:] == chr(34):
try:
sys.stdout.write(json.loads(line)); break
except Exception:
pass
'
}
# --- commands -----------------------------------------------------------------
cmd_setup() {
local name="" host="" port=9222 transport=ssh path=/devtools/browser inspect=""
local url_default
while [ $# -gt 0 ]; do
case "$1" in
--name) name=${2:-}; shift 2 ;;
--host) host=${2:-}; shift 2 ;;
--port) port=${2:-}; shift 2 ;;
--transport) transport=${2:-}; shift 2 ;;
--ws-path) path=${2:-}; shift 2 ;;
--inspect-url) inspect=${2:-}; shift 2 ;;
*) die "setup: unexpected argument '$1'" ;;
esac
done
[ -n "$name" ] || die "setup: --name is required (a short label, e.g. deck, laptop)"
[ -n "$host" ] || die "setup: --host is required (ssh alias or address)"
case "$transport" in ssh|direct) ;; *) die "setup: --transport must be ssh or direct" ;; esac
mkdir -p "$PROFILE_DIR"
local f; f=$(profile_file "$name")
if [ -f "$f" ]; then
info "updating existing profile $name ($f)"
fi
cat > "$f" <<EOF
# remote-browser profile created $(date -Iseconds) by \`$PN setup\`
# transport=ssh forwards the remote loopback port to 127.0.0.1 locally.
# transport=direct talks to RB_HOST:RB_PORT as-is (no tunnel).
RB_TRANSPORT=$transport
RB_HOST=$host
RB_PORT=$port
RB_WS_PATH=$path
RB_INSPECT_URL=${inspect:-chrome://inspect/#remote-debugging}
EOF
chmod 600 "$f"
echo "wrote $f"
echo
echo "Next: on $host, open ${inspect:-chrome://inspect/#remote-debugging} and tick"
echo " 'Allow remote debugging for this browser instance', then run:"
echo " $PN check --profile $name"
}
cmd_check() {
load_profile
local failures=0
say() { printf '%s %s\n' "$1" "$2"; }
[ -n "$PROFILE" ] && printf 'profile: %s (transport=%s host=%s port=%s)\n\n' "$PROFILE" "$RB_TRANSPORT" "$RB_HOST" "$RB_PORT"
if [ "$RB_TRANSPORT" = ssh ]; then
if ssh -o BatchMode=yes -o ConnectTimeout=6 "$RB_HOST" true >/dev/null 2>&1; then
say "✓" "ssh to $RB_HOST works"
else
say "✗" "ssh to $RB_HOST failed — add an ssh config entry and key, or use --transport direct"
failures=$((failures+1))
fi
fi
if ensure_tunnel 2>/dev/null; then
say "✓" "cdp port reachable at $( [ "$RB_TRANSPORT" = ssh ] && echo "127.0.0.1:$RB_PORT via tunnel" || echo "$RB_HOST:$RB_PORT" )"
else
say "✗" "cdp port not reachable — is the browser running with remote debugging enabled?"
say " " " on $RB_HOST: open $RB_INSPECT_URL and tick the box"
failures=$((failures+1))
fi
if [ $failures -eq 0 ]; then
local status; status=$(ws_handshake "$WS")
case "$status" in
*" 101"*) say "✓" "websocket handshake on ${RB_WS_PATH} accepted" ;;
*) say "✗" "websocket handshake returned '${status}'"
say " " " expected 101; a 403/404 means the endpoint is not the CDP socket"
failures=$((failures+1)) ;;
esac
fi
if [ $failures -eq 0 ] && ensure_attached 2>/dev/null; then
say "✓" "playwright attached (session $SESSION)"
local ua; ua=$(playwright-cli -s="$SESSION" eval 'navigator.userAgent' 2>/dev/null | json_unquote)
say "✓" "browser: ${ua:-unknown}"
local n; n=$(tab_list | wc -l)
if [ "$n" -gt 0 ]; then
say "✓" "$n tab(s) visible — try: $PN tabs --profile $PROFILE"
else
say "!" "attached but no tabs found (open a page in that browser)"
fi
elif [ $failures -eq 0 ]; then
say "✗" "playwright could not attach to $WS"
failures=$((failures+1))
fi
echo
if [ $failures -eq 0 ]; then
echo "ready. Read-only commands: tabs, text, html, shot, status, cli."
return 0
fi
echo "$failures check(s) failed."
return 1
}
case "$CMD" in
""|-h|--help) usage; exit 0 ;;
profiles) list_profiles ;;
setup) cmd_setup "${ARGS[@]+"${ARGS[@]}"}" ;;
check) cmd_check ;;
tabs)
load_profile; ensure_attached
tab_list | awk -F'\t' '{printf "%2s %-52s %s\n", $1, substr($2,1,52), $3}'
;;
status)
load_profile; ensure_attached
playwright-cli -s="$SESSION" eval 'navigator.userAgent' | json_unquote
;;
text|html)
LIMIT=8000; tabargs=()
while [ ${#ARGS[@]} -gt 0 ]; do
case "${ARGS[0]}" in
--limit) LIMIT=${ARGS[1]:-8000}; ARGS=("${ARGS[@]:2}") ;;
*) tabargs+=("${ARGS[0]}"); ARGS=("${ARGS[@]:1}") ;;
esac
done
load_profile; ensure_attached
idx=$(resolve_tab "${tabargs[@]+"${tabargs[@]}"}")
[ -n "$idx" ] && playwright-cli -s="$SESSION" tab-select "$idx" >/dev/null
if [ "$CMD" = text ]; then expr='document.body.innerText'; else expr='document.documentElement.outerHTML'; fi
out=$(playwright-cli -s="$SESSION" eval "$expr" | json_unquote)
printf '%s' "$out" | head -c "$LIMIT"
[ "${#out}" -gt "$LIMIT" ] && printf '\n[truncated %s more characters]\n' "$(( ${#out} - LIMIT ))"
echo
;;
shot)
OUT=/tmp/remote-browser-$(date +%s).png; tabargs=()
while [ ${#ARGS[@]} -gt 0 ]; do
case "${ARGS[0]}" in
--out) OUT=${ARGS[1]:-$OUT}; ARGS=("${ARGS[@]:2}") ;;
*) tabargs+=("${ARGS[0]}"); ARGS=("${ARGS[@]:1}") ;;
esac
done
load_profile; ensure_attached
idx=$(resolve_tab "${tabargs[@]+"${tabargs[@]}"}")
[ -n "$idx" ] && playwright-cli -s="$SESSION" tab-select "$idx" >/dev/null
playwright-cli -s="$SESSION" screenshot --filename="$OUT" >/dev/null
echo "$OUT"
;;
cli)
load_profile; ensure_attached
playwright-cli -s="$SESSION" "${ARGS[@]+"${ARGS[@]}"}"
;;
*)
die "unknown command '$CMD'. Try: $PN --help"
;;
esac
+6
View File
@@ -11,6 +11,12 @@ Locate, outline, then read a window — never paste a file body you have not nar
- `context-guard` blocks unbounded large reads; follow its hint rather than retrying.
- Full playbook: `/skill:context-discipline`. Policies: `/skill:homelab-policies`.
## Reaching the user's browser
The user browses on their own machines (a Steam Deck, a laptop), not on this host. `remote-browser` reads their
browser (tabs, page text, screenshots) over CDP through a tunnel they enable per session — read-only, and set up per
device with the user. Details: `/skill:remote-browser`.
## Document every change in the Wiki.js homelab docs
After any infrastructure, service, application or configuration change, write it up in the wiki — every time, without being asked again.
+1
View File
@@ -37,3 +37,4 @@ Load the skill that matches the task instead of asking for it up front:
| memory, secrets, host safety, forges, codemode, stack defaults | `/skill:homelab-policies` |
| delegate a well-specified task to free models, then review it | `/skill:cli/handoff` |
| runtimes and project tools | `/skill:mise-cli` |
| reading the user's browser on another machine | `/skill:remote-browser` |
+67
View File
@@ -0,0 +1,67 @@
---
name: remote-browser
description: Read a Chromium browser running on another machine (Steam Deck, laptop, desktop) over CDP — list tabs, dump page text/HTML, take screenshots. Use when the user says "look at my browser", "what's on my screen", "read this page I have open", or when a page they can see on another device is unreachable from this host. Includes a setup workflow for onboarding a new device. Read-only; never drive authenticated sessions.
---
# Reading someone else's browser
The user browses on their **own machine** (a Steam Deck, a laptop); agents usually run somewhere else. When they say
"look at my browser" or "the page I have open", `remote-browser` shows it to you: it opens a tunnel to that machine
and drives `playwright-cli` against the browser's CDP endpoint.
Underneath it is Playwright — `playwright-cli attach --cdp=ws://…` (`connectOverCDP` accepts a `ws://` URL) — plus a
tunnel. The wrapper exists to save you from re-deriving that every time.
**New device? Follow [`references/setup.md`](references/setup.md)** with the user. It is a checklist with the exact
commands, the per-browser switch, and a failure→fix table. Then confirm with `remote-browser check`. Do not invent
your own procedure: the failure modes below cost hours.
## Everyday use
```bash
remote-browser profiles # what is configured
remote-browser check --profile deck # readiness test (run this first when something feels off)
remote-browser tabs --profile deck # index, title, url
remote-browser text --profile deck --match linkedin --limit 4000
remote-browser html --profile deck --index 3 --limit 20000
remote-browser shot --profile deck --index 3 --out /tmp/x.png
remote-browser --profile deck cli console # full playwright-cli passthrough
```
Profile defaults to `$REMOTE_BROWSER_PROFILE`, so a single-device setup needs no flag.
### `cli` is not a subset
The built-in verbs are a convenience layer. `remote-browser --profile X cli <anything>` runs that exact
`playwright-cli` command in the **attached** session — `goto`, `click`, `fill`, `console`, `requests`, `storage`
(`state-save`, `cookie-list`, `localstorage-*`), `tracing-start/stop`, `video-start/stop`, `route` mocking,
`run-code`, `pdf`, `tab-*`, `webmcp-list`, `resize`, and the rest of `playwright-cli --help`. Nothing is filtered or
re-implemented, and exit codes propagate.
Two contract details:
- Everything after `cli` is passed through untouched, so put the profile **before** it:
`remote-browser --profile deck cli console`. (`--profile` after a built-in verb, e.g. `remote-browser tabs --profile
deck`, is still parsed by us; after `cli` it is not.)
- `run-code` wants a function: `cli run-code '() => page.title()'`, not `'page.title()'`.
## Rules
- **Read-only by default, not by force.** No click/type/navigate helper is wrapped, because driving an
authenticated session (LinkedIn, Gmail, banking) risks the account being restricted and the user ruled LinkedIn
automation out. The capability is still reachable through `cli` — use it for the user's own pages only when they
ask for it, and say what you are about to do first.
- **Screenshots may contain private data.** Write to `/tmp`, never a Git repo; name the path; never restate
credentials, tokens, cookies or payment details you see in a capture.
- `chrome://` / `edge://` tabs (newtab, apps, inspect) return little text — Chrome blocks script there. Use `shot`.
- Prefer `--match` over `--index`: tabs reorder between calls.
- If attach fails mid-task the user probably unticked the debugging box: re-run `check`, and ask rather than
flipping chrome settings for them.
- Teardown when finished: `pkill -f "ssh -N -L <port>:127.0.0.1:<port>"` and ask them to untick the box.
## The one background fact worth remembering
Chrome ≥136 ignores `--remote-debugging-port` on a normal profile; the `chrome://inspect/#remote-debugging` toggle is
the only way in on a browser the user is already using. That endpoint serves **only**
`ws://127.0.0.1:<port>/devtools/browser` — HTTP `/json/version` and `/json/list` return 403/404, which is why the URL
handed to Playwright must be `ws://`, not `http://`.
@@ -0,0 +1,89 @@
# Setting up a new device
Run this **with the user**, top to bottom. Each step has a check you can perform; do not skip ahead to "try it" when a
check fails — the failures look identical (`attach failed`) for three different causes.
Ask at the start, in one message:
1. **Which machine and which browser?** (Chrome, Chromium, Brave, Edge — not Firefox)
2. **Do I have SSH to it?** `ssh -o BatchMode=yes -o ConnectTimeout=6 <host> true` — if that fails, either ask them
to add a key/entry for their agent host, or use `--transport direct` on a trusted LAN.
3. **Which port?** Default `9222` unless they already run something there (`ss -ltn | grep 9222`).
## Step 1 — create the profile
```bash
remote-browser setup --name <label> --host <ssh-alias-or-address> [--port 9222] [--transport ssh|direct]
remote-browser profiles # confirm the row
```
Profiles live in `~/.config/remote-browser/profiles/<label>.env`, mode 600, and hold no secrets — only transport,
host, port, websocket path and the inspect URL used in error messages. Use `--inspect-url` for non-Chrome browsers
(`edge://inspect/#remote-debugging`, `brave://inspect/#remote-debugging`).
## Step 2 — turn on remote debugging in their browser (user does this)
| Browser | What to open | What to tick |
| --- | --- | --- |
| Chrome / Chromium | `chrome://inspect/#remote-debugging` | "Allow remote debugging for this browser instance" |
| Brave | `brave://inspect/#remote-debugging` | same |
| Edge | `edge://inspect/#remote-debugging` | same |
| Chrome < 136 (or a browser with no toggle) | launch with `--remote-debugging-port=9222 --user-data-dir=<separate dir>` | n/a — separate profile, no logins |
| Firefox | — | not supported (no CDP); offer a PDF/paste route instead |
They keep their logins either way. Chrome prints `Server running at: 127.0.0.1:9222` when the toggle is on.
**Never** set `--remote-debugging-address=0.0.0.0` or open the port on the LAN: CDP is equivalent to handing over the
browser's cookies. Loopback plus an SSH tunnel, or nothing.
## Step 3 — confirm the port on their side
```bash
ssh <host> 'ss -ltn | grep -E "9222|LISTEN"' # Linux
ssh <host> 'lsof -nP -iTCP:9222 -sTCP:LISTEN' # macOS
# Windows: netstat -an | findstr 9222
```
Expect `127.0.0.1:9222`. If it is absent, the toggle is off or the browser was restarted.
## Step 4 — run the readiness test
```bash
remote-browser check --profile <label>
```
It checks, in order: SSH reachability → port reachable through the tunnel → websocket handshake returns 101 →
Playwright attaches → tab count. Read the first ✗ only; later steps are skipped because they cannot pass.
| Symptom | Cause | Fix |
| --- | --- | --- |
| `ssh to <host> failed` | no key, no config entry, host asleep | fix SSH first; or `--transport direct` on a trusted network |
| `cdp port not reachable` | toggle off, browser restarted, different port | re-tick in the browser, check `ss -ltn`, confirm `--port` |
| `websocket handshake returned 403/404` | wrong path, or an HTTP endpoint | profile must use `/devtools/browser`; the URL given to Playwright must be `ws://` |
| `playwright could not attach` | `playwright-cli` missing or too old | `playwright-cli --version`; it must support `attach --cdp=` with a `ws://` value |
| `attached but no tabs found` | browser window has no pages | open any page |
## Step 5 — smoke test, then hand back
```bash
remote-browser tabs --profile <label>
remote-browser text --profile <label> --index 0 --limit 200 # any visible text
remote-browser shot --profile <label> --index 0 --out /tmp/rb-smoke.png
ls -l /tmp/rb-smoke.png # a few hundred KB, not 0
```
Tell the user plainly: what now works, that it is read-only (no clicks, no navigation), that the tunnel can be closed
with `pkill -f "ssh -N -L 9222:127.0.0.1"`, and that unticking the box in their browser disables it entirely.
## Step 6 — record it
- Wiki: add the device and profile to the remote-browser page (host, port, transport, how the toggle was enabled).
- Memory: save one entry naming the profile, the transport, and anything surprising about that device.
- If a step needed a workaround, add it to the table above — the next agent reads this file, not your conversation.
## Housekeeping worth knowing
- One tunnel per port. Two devices both on 9222 collide; give the second profile `--port 9333` and forward that.
- Playwright sessions are named `rb-<profile>`, so parallel devices do not fight over one session.
- `remote-browser cli --profile <label> console` (or `requests`, `cookie-list`) is available when reading page text is
not enough — but treat cookie and storage output as secret, never echo it.
+1
View File
@@ -9,6 +9,7 @@ let
sharedSkills = [
"git" "gt" "mise-cli" "secrets_man" "searxng" "playwright-cli"
"context-discipline" "homelab-policies" "memory-layer" "roku-tv" "zsa-moonlander"
"remote-browser"
];
cliSkills = [ "infra-change" "wiki-update" "wiki-view" "lapis-memory" "handoff" ];
allSkills = sharedSkills ++ cliSkills;
+52
View File
@@ -0,0 +1,52 @@
#!/usr/bin/env bash
# Rootless podman needs /etc/subuid and /etc/subgid ranges; without them every
# image pull fails inside the user namespace, which is what `dot boxes` preflights.
set -euo pipefail
cd "$(dirname "$0")/.."
fixture="$(mktemp -d)"
trap 'rm -rf "$fixture"' EXIT
export HOME="$fixture/home"
mkdir -p "$HOME/.config/dotfiles" "$fixture/repo"
DOTFILES_DIR="$fixture/repo"
export DOTFILES_DIR
source <(sed '$d' bin/dot)
STATE_DIR="$HOME/.config/dotfiles"
me="$(id -un)"
# Counts only this user's ranges, and sums several lines.
{
echo "someoneelse:100000:65536"
echo "$me:100000:65536"
echo "$me:1000000:65536"
} >"$fixture/subuid"
[ "$(subid_count "$fixture/subuid")" = 131072 ] || { echo "FAIL: range sum"; exit 1; }
[ "$(subid_count "$fixture/missing")" = 0 ] || { echo "FAIL: missing file"; exit 1; }
# Empty file means no mapping for us.
: >"$fixture/empty"
SUBUID_FILE="$fixture/empty" SUBGID_FILE="$fixture/empty"
export SUBUID_FILE SUBGID_FILE
if podman_subid_ok; then echo "FAIL: empty subid files reported as ok"; exit 1; fi
SUBUID_FILE="$fixture/subuid" SUBGID_FILE="$fixture/subuid"
if ! podman_subid_ok; then echo "FAIL: sufficient ranges rejected"; exit 1; fi
# A too-small range is the failure mode from the bug report.
printf '%s\n' "$me:100000:1024" >"$fixture/small"
SUBUID_FILE="$fixture/small" SUBGID_FILE="$fixture/small"
if podman_subid_ok; then echo "FAIL: 1024 ids accepted"; exit 1; fi
# dot boxes warns before the pull instead of dying mid-unpack, and still runs.
have() { case "$1" in distrobox|podman) return 0;; *) return 1;; esac; }
in_container() { return 1; }
distrobox() { printf 'distrobox %s\n' "$*"; }
out="$(cmd_boxes 2>&1)"
grep -q 'usermod --add-subuids 100000-165535' <<<"$out" || { echo "FAIL: no fix hint"; echo "$out"; exit 1; }
grep -q '^distrobox assemble create' <<<"$out" || { echo "FAIL: assemble skipped"; echo "$out"; exit 1; }
SUBUID_FILE="$fixture/subuid" SUBGID_FILE="$fixture/subuid"
out="$(cmd_boxes 2>&1)"
if grep -q 'usermod' <<<"$out"; then echo "FAIL: warned with sufficient ranges"; exit 1; fi
echo "ok dot boxes subid preflight"