feat(cli): use system default browser with real user profile + nodeExec adapter mode#190
Open
bobleer wants to merge 3 commits intoepiral:mainfrom
Open
feat(cli): use system default browser with real user profile + nodeExec adapter mode#190bobleer wants to merge 3 commits intoepiral:mainfrom
bobleer wants to merge 3 commits intoepiral:mainfrom
Conversation
added 3 commits
April 12, 2026 12:57
- Detect the system default browser on macOS/Linux/Windows via OS APIs (LaunchServices on macOS, xdg-settings on Linux, registry on Windows) - Prefer the detected browser if it is Chromium-based; warn and fall back to the existing candidate list if it is not (e.g. Firefox/Safari) - Launch the browser with the user's real user-data-dir so history, bookmarks, passwords and cookies are available to adapters - If the real browser is already running without CDP, gracefully shut it down (SIGTERM all processes sharing the app bundle, wait up to 5 s, SIGKILL stragglers) then restart with --remote-debugging-port - Fix SingletonLock detection: use lstatSync instead of existsSync because Chromium's SingletonLock is a dangling symlink whose target is a "hostname-pid" string, not a real file path - Do not pass a URL argument when launching with the real profile so the browser restores the previous session (tabs) per the user's startup settings; keep about:blank only for the isolated managed profile - Increase launch timeout from 8 s to 15 s to accommodate real profiles with large amounts of data
Some adapters call third-party APIs that do not return Access-Control-Allow-Origin headers, causing fetch() to fail when executed inside a browser page via CDP Runtime.evaluate. Add a nodeExec: boolean field to the @meta block. When true, the adapter function is executed directly in the Node.js process using new Function(), bypassing the browser entirely. This eliminates CORS restrictions and the 30-second CDP command timeout for API-only adapters that do not require browser DOM or user cookies. The Node.js execution path supports the same jq/--json output flags as the browser path, and propagates structured { error, hint, action } objects the same way.
…estart When the user enables remote debugging in chrome://inspect or edge://inspect, the browser writes a DevToolsActivePort file containing the dynamic CDP port. bb-browser now reads this file to connect directly without restarting the browser. Changes: - Add readDevToolsActivePortFile() to parse DevToolsActivePort files - Add discoverViaDevToolsActivePort() scanning all known browser user-data dirs (Edge, Chrome, Brave, Chromium, Arc, Opera, Vivaldi on macOS/Linux/Windows) - Insert as priority 5 in discoverCdpPort(), before launchManagedBrowser() - In launchManagedBrowser(), reuse running browser with CDP instead of restarting - Fix tsup.config.ts: mark Node.js built-ins as external so readFileSync is emitted as ESM static import instead of __require() which fails at runtime
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds three improvements to browser control in bb-browser:
1. Use system default browser (with Chromium fallback)
Instead of hardcoding Chrome as the only option, bb-browser now:
2. Use real user profile (with history, bookmarks, passwords)
Previously bb-browser launched a blank isolated profile. Now it:
--remote-debugging-portwhile keeping the real profileabout:blankoverride)lstatSyncinstead ofexistsSyncto correctly detectSingletonLock(which is a dangling symlink on macOS/Linux)3. Attach to already-running browser via DevToolsActivePort (no restart needed)
When the user enables remote debugging in
chrome://inspect/#remote-debuggingoredge://inspect/#remote-debugging, the browser writes aDevToolsActivePortfile containing the dynamic CDP port. bb-browser now:DevToolsActivePortfiles (Edge, Chrome, Brave, Chromium, Arc, Opera, Vivaldi on macOS/Linux/Windows)DevToolsActivePortis foundThis means users who enable remote debugging once never need to have their browser restarted again.
One-time setup: Open
edge://inspect/#remote-debugging(orchrome://inspect), enable remote debugging, restart the browser once. After that, bb-browser connects instantly without ever restarting the browser.4.
nodeExecadapter mode to bypass browser CORSSite adapters that only need HTTP APIs (no DOM interaction) can now set
"nodeExec": truein their@metablock. bb-browser will execute them directly in the Node.js process instead of viaRuntime.evaluate, bypassing browser CORS restrictions entirely.Bug fix:
tsup.config.tsNode.js built-ins as ESM externalsNode.js built-in modules (
fs,path,os,child_process) are now marked asexternalin tsup config. This ensures they are emitted as ESM static imports (import { readFileSync } from "fs") rather than bundled via__require(), which throws'Dynamic require of "fs" is not supported'at runtime in ESM context.Test plan
DevToolsActivePortdiscovery connects without restarting browser (tested: Edge PID unchanged)DevToolsActivePortpresentnodeExecadapters run in Node.js context with no CORS errorspnpm test: 119 daemon + 24 cli tests, 0 failures)