Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

feat: consume CHROME_BINARY/CHROME_FLAGS env vars in Go

botfac1af2a658e
diff --git a/Dockerfile b/Dockerfile
index f6fb1e55..a9798d91 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -39,7 +39,7 @@ ENV BRIDGE_PORT=9867 \
BRIDGE_STATE_DIR=/data \
BRIDGE_PROFILE=/data/chrome-profile \
CHROME_BINARY=/usr/bin/chromium-browser \
- CHROME_FLAGS="--no-sandbox"
+ CHROME_FLAGS="--no-sandbox --disable-gpu"
# Expose port
EXPOSE 9867
diff --git a/TODO.md b/TODO.md
index de849d25..761404df 100644
--- a/TODO.md
+++ b/TODO.md
@@ -6,32 +6,21 @@
## DONE
-Core HTTP API, 16 endpoints, session persistence, ref caching, action registry,
+Core HTTP API (16 endpoints), session persistence, ref caching, action registry,
smart diff, readability `/text`, config file, Dockerfile, YAML/file output,
-stealth suite (navigator, WebGL, canvas noise, font metrics, WebRTC, timezone,
-plugins, Chrome flags), human interaction (bezier mouse, typing simulation),
-fingerprint rotation via CDP (`SetUserAgentOverride`, `SetTimezoneOverride`),
-handlers.go split (4 files), architecture docs, image/media blocking
-(`BRIDGE_BLOCK_IMAGES`, `BRIDGE_BLOCK_MEDIA`), stealth injection on all tabs,
-K1-K9 all fixed, multi-agent concurrency verified (MA1-MA8).
-**92 unit tests + ~100 integration tests, 28.9% coverage.**
+stealth suite, human interaction (bezier mouse, typing sim), fingerprint rotation,
+image/media blocking, stealth injection on all tabs, K1-K11 all fixed,
+multi-agent concurrency verified (MA1-MA8), token optimization (`maxTokens`,
+`selector`, `format=compact`), Dockerfile env vars (`CHROME_BINARY`/`CHROME_FLAGS`
+now consumed by Go). **92 unit tests + ~100 integration, 28.9% coverage.**
---
## Open
-### ~~P0: Stability~~ — DONE
-- [x] **K10 — Profile hang** — Fixed: lock file cleanup, unclean exit detection, 15s Chrome timeout, auto-retry with session clear.
-- [ ] **Coverage to 30%** — Add tests for cookie/stealth handler happy paths (~2% gap).
-
-### ~~P1: Token Optimization~~ — DONE
-- [x] **`maxTokens` param on `/snapshot`** — Truncates to ~N tokens, returns `truncated: true` flag. Wikipedia 142K → 1.4K with maxTokens=2000.
-- [x] **`selector` param on `/snapshot`** — Scopes a11y tree to CSS selector subtree (e.g. `?selector=main`, `?selector=%23content`).
-- [x] **`format=compact`** — One-line-per-node format: 56-64% fewer tokens than JSON. All three compose: `?selector=main&maxTokens=2000&format=compact`.
-
-### ~~P2: Bugs~~ — DONE
-- [x] **K11 — File output ignores path** — Fixed: `?output=file&path=X` now honors custom path, auto-creates parent dirs.
-- [x] **`blockImages` on CreateTab** — Fixed: Global `BRIDGE_BLOCK_IMAGES`/`BRIDGE_BLOCK_MEDIA` now applied on `CreateTab`.
+### ~~P0-P2~~ — DONE
+P0 (K10 profile hang), P1 (token optimization: maxTokens/selector/compact),
+P2 (K11 file path, blockImages on CreateTab) — all resolved.
### P3: Multi-Agent
- [ ] **Tab locking** — `POST /tab/lock`, `POST /tab/unlock` with timeout-based deadlock prevention.
@@ -44,7 +33,6 @@ K1-K9 all fixed, multi-agent concurrency verified (MA1-MA8).
- [ ] **Randomized window sizes** — Avoid automation fingerprint.
### Minor
-- [ ] **Dockerfile env vars** — `CHROME_BINARY`/`CHROME_FLAGS` set but not consumed by Go.
- [ ] **humanType global rand** — Accept `*rand.Rand` for reproducible tests.
---
diff --git a/config.go b/config.go
index 84019543..85be83a2 100644
--- a/config.go
+++ b/config.go
@@ -57,6 +57,8 @@ var (
timezone = os.Getenv("BRIDGE_TIMEZONE") // e.g. "America/New_York"
blockImages = os.Getenv("BRIDGE_BLOCK_IMAGES") == "true"
blockMedia = os.Getenv("BRIDGE_BLOCK_MEDIA") == "true" // superset: images + fonts + CSS + video
+ chromeBinary = os.Getenv("CHROME_BINARY") // path to Chrome/Chromium binary
+ chromeExtraFlags = os.Getenv("CHROME_FLAGS") // extra flags (space-separated)
actionTimeout = 15 * time.Second
navigateTimeout = 30 * time.Second
shutdownTimeout = 10 * time.Second
diff --git a/main.go b/main.go
index c9caf507..37b237b3 100644
--- a/main.go
+++ b/main.go
@@ -8,6 +8,7 @@ import (
"net/http"
"os"
"os/signal"
+ "strings"
"sync"
"syscall"
"time"
@@ -114,6 +115,19 @@ func main() {
chromedp.WindowSize(1366, 768),
}
+ if chromeBinary != "" {
+ chromeOpts = append(chromeOpts, chromedp.ExecPath(chromeBinary))
+ }
+ if chromeExtraFlags != "" {
+ for _, f := range strings.Fields(chromeExtraFlags) {
+ if k, v, ok := strings.Cut(f, "="); ok {
+ chromeOpts = append(chromeOpts, chromedp.Flag(strings.TrimLeft(k, "-"), v))
+ } else {
+ chromeOpts = append(chromeOpts, chromedp.Flag(strings.TrimLeft(f, "-"), true))
+ }
+ }
+ }
+
if headless {
chromeOpts = append(chromeOpts, chromedp.Headless)
} else {