DSH Session Bridge: Leveraging Your Logged-In Browser

Introduction

A common challenge in agent development: when you need to interact with a page that requires login, tools like Playwright or Puppeteer force you to spin up an entirely separate browser instance and log in again. This wastes time and means losing the tabs, bookmarks, and extensions already open on your desktop.

DSH Session Bridge (hereafter “DSH Session Bridge”) takes the opposite approach — it directly borrows your already-logged-in browser on the desktop and turns it into DSH’s browser_* tools. It never steals focus; all operations run in the background. Chrome, Edge, Brave, and QQ Browser can connect simultaneously, each operating independently.

What It Is

This is a DSH plugin maintained by wxs-lang. Through a Chrome extension and a local WebSocket service, it exposes your browser’s existing logged-in sessions to DSH, enabling you to perform clicks, text input, screenshots, and other operations without restarting the browser or opening new windows.

Its core problem to solve is “when multiple browsers share a single extension directory, which one should commands be routed to?” By assigning a globally unique tabId to each tab, the bridge remembers which connection each tab belongs to, so commands carrying a tabId can be delivered precisely to the right browser.

Core Capabilities

1. No New Browser, No Focus Stealing

Once the extension is installed, when DSH calls browser_click, browser_type, browser_screenshot, and similar tools, it operates on the browser you’re already using — not a fresh instance.

It leverages CDP (Chrome DevTools Protocol) for background screenshots and real input events, never touching focus. Even if you’re actively working in the foreground, the Agent completes its clicks and inputs in the background.

2. Multiple Browsers Coexisting

Chrome, Edge, Brave, and QQ Browser can all connect to the same bridge simultaneously. Each browser maintains an independent connection, distinguished by the browser parameter. The bridge maintains a tab-ownership table and routes commands to the correct browser based on tabId.

3. Site Authorization: Read-Only by Default

By default, the plugin can only read from any site — writing is not permitted. In the sidebar under “Site Authorization,” you can mark a specific domain as “writable,” or grant temporary write access per-call:

browser_click({ tabId, ref: 'e3-5', allowWrite: true })

High-risk actions (where the target text contains “pay / delete / refund / submit order,” or the target is a password field) are intercepted first and require an additional confirmDanger: true to proceed.

4. Emergency Stop & Action Log

There’s a toggle at the top of the sidebar. When enabled, all write operations are immediately rejected while read operations continue normally. The action log records every action the Agent has performed, retains up to 300 entries, and can be cleared with one click.

Security Risks

This plugin holds control over your browser. Once installed, DSH can use it to read any logged-in page (banking portals, email, admin dashboards, company ERP systems), click, type, submit forms, capture page screenshots, open and close tabs, and list open tabs.

The three layers of defense block “webpage JS from reaching the local bridge” — not “other programs on your machine.” If your machine already has malware, this plugin amplifies its capabilities.

Recommended usage only in trusted environments: your personal computer or a development machine you control. On corporate machines, verify IT policy first. Do not share a browser profile with extensions of unknown origin, do not run automation tasks in a profile that has banking/payment extensions installed, do not change allowed_origins to *, and do not expose the bridge on 0.0.0.0 (the code hardcodes 127.0.0.1).

Tool List

The plugin provides 16 browser_* tools:

  • browser_status: Bridge status, connection list, whether code is stale relative to disk
  • browser_windows: All browser windows (brand / tab count / foreground status)
  • browser_tabs: Tab list (merged across all browsers, filterable by windowId)
  • browser_snapshot: Snapshot of interactive elements on the page (with refs for click/input targeting)
  • browser_click: Click (by ref or viewport coordinates)
  • browser_type: Type text
  • browser_key: Key press (Enter / Escape / Control+a / Shift+Tab)
  • browser_scroll: Scroll (by screen / to element / to top / to bottom)
  • browser_batch: Batch actions, single result returned (measured 11× faster)
  • browser_eval: Execute JS within the page (via CDP, bypasses page CSP)
  • browser_drag: Drag (CDP real mouse down → move → up)
  • browser_mouse: Mouse move / wheel (CDP)
  • browser_lease: Lease: temporary tabs auto-cleaned on expiry
  • browser_navigate: Open / navigate / back forward reload
  • browser_screenshot: Screenshot (CDP background frame capture, never touches focus)
  • browser_close_tabs: Close tabs
  • browser_group_ensure: Collect tabs into the “Big Fat Fish” group
  • browser_group_assign / list / update / close: Group create/delete/update/close

Installation & Setup

1. Install the Plugin

The official script is recommended:

Windows

cd dsh-session-bridge
powershell -NoProfile -ExecutionPolicy Bypass -File install.ps1

macOS / Linux

cd dsh-session-bridge
chmod +x install.sh && ./install.sh

The script automatically completes:
1. Checks Node version and DSH profile existence
2. Copies the plugin to vendor/ and syncs to the node_modules/ copy
3. Installs the ws dependency (tries .npmrc → official registry → domestic mirror in order)
4. Generates and registers the native messaging host (auto-detects installed extension ID)
5. Prints extension loading instructions
6. Optionally appends cordis.patch.yml
7. Runs doctor.mjs self-check

2. Load the Extension

1. Open chrome://extensions
2. Enable "Developer mode" in the top-right corner
3. Click "Load unpacked extension"
4. Select the dsh-session-bridge/extension directory

After installation, the icon is a blue whale: blue in light mode, pure black in dark mode, following the system theme automatically.

For other browsers (Edge / Brave / QQ Browser / 360), repeat the same steps pointing to the same directory — each will connect to the bridge independently without interference.

MV3 Service Workers get killed by the browser, and when they’re killed, the WebSocket drops with them. Relying on WebSocket alone, reconnection after a drop must wait for chrome.alarms to fire (up to 60 seconds).

The native messaging host eliminates this gap: the host process is spawned by the browser, and the extension calls connectNative() the moment it wakes up — no waiting window for alarms.

# 1. Verify the ws module is available
node -e "require('ws'); console.log('ws ok')"

# 2. Update the two fields in com.dsh.session.json with your own paths / extension ID
#    path          → absolute path to dsh-session-native.cmd on your machine
#    allowed_origins → chrome-extension://<id>/

After editing, register it (Windows, current user is sufficient):

reg add "HKCU\Software\Google\Chrome\NativeMessagingHosts\com.dsh.session" /ve ^
  /t REG_SZ /d "<plugin_directory>\com.dsh.session.json" /f

rem Edge
reg add "HKCU\Software\Microsoft\Edge\NativeMessagingHosts\com.dsh.session" /ve ^
  /t REG_SZ /d "<plugin_directory>\com.dsh.session.json" /f

rem QQ Browser
reg add "HKCU\Software\Tencent\QQBrowser\NativeMessagingHosts\com.dsh.session" /ve ^
  /t REG_SZ /d "<plugin_directory>\com.dsh.session.json" /f

After installation, reload the extension once. Going forward, the browser manages the host process lifecycle — if it’s killed, the browser will respawn it.

Verification

After setup, you can run:

browser_status
→ {
    "extensions": 2,
    "extensionVersion": "2.3.1",
    "connections": [
      { "brand": "Chrome",     "commands": 29, "windows": [290992688] },
      { "brand": "NativeHost", "commands": 30 }
    ],
    "codeFresh": { "stale": false }
  }

You’re good if you see extensions >= 1 and stale: false.

The NativeHost connection is a relay channel (host process ↔ extension), not an independent browser — it should not own any tabs. The bridge’s routing excludes it from tabId ownership and only uses it as a fallback when no real browser is available.

Use Cases

Ideal for scenarios where you need to interact with already-logged-in pages without opening a new browser or interrupting your current work. Examples: automating form fills in a backend already running, screenshotting the current page, or switching operations between multiple browsers.

Always review the source code and license before use to ensure it meets your security requirements.

Summary

DSH Session Bridge turns your already-logged-in browser into DSH’s hands. All operations run in the background without stealing focus or interrupting what you’re doing. It solves the multi-browser shared extension directory problem through tabId routing and provides a complete set of browser_* tools.

Plugin directory: https://www.skillhub.cn/plugins/wxs-lang/dsh-session-bridge
GitHub: https://github.com/wxs-lang/dsh-session-bridge

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye