dsh-plugin-browser
Agent 与会话 活跃维护

dsh-plugin-browser

xu1132/dsh-plugin-browser

依托 Playwright 的无头浏览器驱动插件,可直接获取渲染后页面文本、生成页面截图,也支持各类页面自动化操作,无需手动配置浏览器运行环境,调用即用,可稳定适配各类网页渲染场景。

1
Stars 标星
0
Forks 分支
1
Watchers 关注
0
Open Issues
TypeScript
主要语言
MIT
开源协议
11 KB
仓库大小
1 个月前
最后推送
一键安装扩展 / 插件指令
dsh plugin --profile web add github:xu1132/dsh-plugin-browser
git clone https://github.com/xu1132/dsh-plugin-browser.git
git clone git@github.com:xu1132/dsh-plugin-browser.git
README.md main

dsh-plugin-browser

A DeepSeek Harness community plugin that drives a headless browser with Playwright. It registers six model-callable tools that let the model read JavaScript-rendered pages, take screenshots, and automate page interactions — the capabilities the built-in web_fetch (plain HTTP) cannot provide.

Tools

Tool What it does
browser_navigate(url) Open a URL, wait for load, return rendered title, body text, and links
browser_snapshot() Return the current page's rendered text (use between automation steps)
browser_click(selector) Click an element (any Playwright CSS selector)
browser_type(selector, text) Fill a text input
browser_screenshot(path?) Save a viewport PNG; defaults to browser-<timestamp>.png in screenshotDir
browser_close() Close the current browser session and release resources

Each agent gets its own isolated browser session; calls without an agent share a default session. Sessions start lazily on first use and close when the plugin unloads.

Install

The plugin uses Playwright's bundled chromium by default. First-time setup installs the browser binary:

dsh plugin --profile demo add github:you/dsh-plugin-browser
npx playwright install chromium   # from the profile directory

Then boot and ask the model, for example: "Open https://example.com and tell me what's on the page." The model calls browser_navigate and receives the rendered text.

Configure

Override the row in the profile's cordis.patch.yml:

- id: browser
  name: dsh-plugin-browser
  config:
    timeoutMs: 30000      # navigation/click/type timeout
    maxTextChars: 20000   # cap on extracted body text per snapshot
    maxLinks: 20          # cap on links listed per snapshot
    screenshotDir: .      # default directory for screenshots
    executablePath: /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

executablePath points at a system browser instead of Playwright's bundled chromium — useful when you do not want the browser download.

Development

pnpm install
pnpm run typecheck
pnpm run build     # emits lib/index.js and lib/index.d.ts
pnpm run test

The test suite boots a local HTTP server and drives the system Chrome (skipped when Chrome is absent), so it needs no browser download and no real network. With Playwright's bundled chromium instead, install it once: npx playwright install chromium.

Structure

browser/
├── package.json       # bundle manifest (dsh.bundle), scripts, deps
├── cordis.patch.yml   # the configuration layer the bundle inserts
├── src/index.ts       # plugin: name / inject / Config / apply
├── src/session.ts     # headless session + per-agent session manager
├── src/tools.ts       # the six tool definitions
├── tests/browser.spec.ts
├── tsconfig.json
└── vitest.config.ts

License

MIT