-
Notifications
You must be signed in to change notification settings - Fork 1
feat(browser): browser-use capability (managed CDP + extension bridge) #107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d960862
8d96a81
3d413bc
77a9ecb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,61 @@ | ||||||||||||||||||||||||||||||||||||||
| # jcode Browser Bridge (Chrome extension) | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| Lets jcode see and operate **your** Chrome — with your logins and sessions — | ||||||||||||||||||||||||||||||||||||||
| via the Chrome DevTools Protocol. This is the `extension` backend of jcode's | ||||||||||||||||||||||||||||||||||||||
| browser-use feature (the other backend is a managed Chrome jcode launches | ||||||||||||||||||||||||||||||||||||||
| itself; that one needs no extension). See | ||||||||||||||||||||||||||||||||||||||
| [`internal-doc/browser-use-design.md`](../internal-doc/browser-use-design.md). | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| The extension has a **fixed id** (`ekcnniaefmnhnemnpphikhgfoofnojnd`, pinned by | ||||||||||||||||||||||||||||||||||||||
| the `key` field in `manifest.json`) so the id is stable across machines and | ||||||||||||||||||||||||||||||||||||||
| reloads. That's what makes the one-click deeplink below possible. | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| ## Install (unpacked, for development) | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| 1. Start jcode web/desktop. | ||||||||||||||||||||||||||||||||||||||
| 2. Open `chrome://extensions` (or `edge://extensions`), enable **Developer mode**. | ||||||||||||||||||||||||||||||||||||||
| 3. Click **Load unpacked** and select this `extension/` folder. | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| ## Connect — Auto-connect | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| Make sure jcode is running with browser use enabled (Settings → Browser → on). | ||||||||||||||||||||||||||||||||||||||
| Click the extension's toolbar icon → **Auto-connect to jcode**. | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| It uses Chrome Native Messaging to find the running jcode app (even on a dynamic | ||||||||||||||||||||||||||||||||||||||
| desktop-app port), fetch the server URL + a token, and connect. No code, no URL, | ||||||||||||||||||||||||||||||||||||||
| and it self-heals when the app restarts on a new port. | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| - Requires the native-host manifest, which jcode **installs automatically** when | ||||||||||||||||||||||||||||||||||||||
| it starts with browser use enabled (macOS/Linux: a file under the browser's | ||||||||||||||||||||||||||||||||||||||
| `NativeMessagingHosts` dir; Windows: a registry key under HKCU). If | ||||||||||||||||||||||||||||||||||||||
| Auto-connect reports the host is unavailable, start/restart jcode once with | ||||||||||||||||||||||||||||||||||||||
| browser use enabled, then try again. | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| Auto-connect exchanges for a long-lived token in `chrome.storage.local`; | ||||||||||||||||||||||||||||||||||||||
| afterwards the extension reconnects silently — you connect once. Use | ||||||||||||||||||||||||||||||||||||||
| **Disconnect** in the popup to stop and forget the token. | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| ## How it works | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| - The service worker (`background.js`) holds a websocket to | ||||||||||||||||||||||||||||||||||||||
| `/api/browser/ext/ws` on the jcode server. | ||||||||||||||||||||||||||||||||||||||
| - jcode sends CDP commands over that socket; the worker relays them to the | ||||||||||||||||||||||||||||||||||||||
| target tab with `chrome.debugger.sendCommand` and streams events back. | ||||||||||||||||||||||||||||||||||||||
| - jcode-controlled tabs are placed in a **"jcode 🔎"** tab group so you can see | ||||||||||||||||||||||||||||||||||||||
| which tabs are under agent control. Detaching the debugger (or the Chrome | ||||||||||||||||||||||||||||||||||||||
| "started debugging" bar → Cancel) hands control back — jcode stops. | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| ## Permissions | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| - `debugger` — the CDP control channel (Chrome shows a banner while attached). | ||||||||||||||||||||||||||||||||||||||
| - `tabs`, `tabGroups` — create/switch/group tabs. | ||||||||||||||||||||||||||||||||||||||
| - `storage` — persist the server URL and pairing token. | ||||||||||||||||||||||||||||||||||||||
| - `scripting` — reserved for future in-page helpers. | ||||||||||||||||||||||||||||||||||||||
| - `host_permissions` limited to `127.0.0.1` / `localhost` — it only ever talks | ||||||||||||||||||||||||||||||||||||||
| to your local jcode. | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+48
to
+55
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Permissions list omits manifest.json declares 📝 Proposed addition - `debugger` — the CDP control channel (Chrome shows a banner while attached).
- `tabs`, `tabGroups` — create/switch/group tabs.
- `storage` — persist the server URL and pairing token.
- `scripting` — reserved for future in-page helpers.
+- `alarms` — periodic keepalive ping/reconnect while the service worker sleeps.
+- `nativeMessaging` — talk to the jcode native host for zero-input Auto-connect.
- `host_permissions` limited to `127.0.0.1` / `localhost` — it only ever talks
to your local jcode.📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| ## Security | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| The bridge only connects to a loopback jcode server and authenticates with a | ||||||||||||||||||||||||||||||||||||||
| short-lived pairing code. Nothing is sent to any third party. Use the popup's | ||||||||||||||||||||||||||||||||||||||
| **Disconnect** to revoke the token and detach all tabs. | ||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win
Security section contradicts the token description above.
Lines 34-36 describe a "long-lived token" persisted in storage and reused silently, but the Security section (lines 59-60) says the bridge "authenticates with a short-lived pairing code." This mismatches actual behavior in background.js (token stored via
chrome.storage.localand reused across reconnects until Disconnect) and could confuse users about the real security model.Also applies to: 57-61
🤖 Prompt for AI Agents