Skip to content
27painterPublic

About

DSH OpenCode and Codex plugin · Drive the local Moli headless browser from DeepSeek Harness: moli_fetch and moli_probe for JS-rendered pages, Markdown, semantic trees, screenshots and PDFs, with sandbox-aware failure classification.

Topics

Resources

Security policy

Stars

7 stars

Watchers

0 watching

Forks

Repository files navigation

dsh-moli

npm version license Cross-agent: DSH | Codex | OpenCode listed in awesome-dsh-plugin HOL Trust Score listed in Awesome Codex Plugins listed in Awesome Moli

A local browser bridge for DeepSeek Harness (DSH), Codex, and OpenCode. It wraps Moli, a Rust headless browser for AI agents, to fetch JavaScript-rendered pages, search the web, and capture screenshots or PDFs.

English | 中文

Why use it

Use this plugin when web_fetch, curl, or a plain HTTP request is not enough:

  • client-rendered applications and documentation;
  • pages behind cookies, consent screens, or a session;
  • text hidden behind lazy loading or a scroll event;
  • screenshots, PDFs, or one value extracted from a large page.

For plain articles, APIs, and static HTML, the host's normal web_fetch is lighter and faster.

Adapter Adds
DSH moli_fetch, moli_probe
Codex moli_search, moli_fetch, moli_capture, moli_probe
OpenCode keyless websearch provider plus moli_fetch, moli_capture, moli_probe

All three adapters use the same browser core and the installed moli engine.

Why DSH exposes fewer tools

The DSH adapter registers two tools where Codex and OpenCode register four. That is a difference in how each host represents a capability, not in what the plugin can do:

  • Screenshots and PDFs are moli_fetch. moli_fetch already takes dump and writeTo, so dump=screenshot (or pdf) with an absolute writeTo is the whole capture path. Codex and OpenCode expose the same call under a separate moli_capture name because their tool protocols carry a read-only vs. write annotation, and a tool that writes a file should not share the read-only one. DSH's tool contract has no such annotation (only isConcurrencySafe), so a second name would add a second schema and a second choice for the model while granting nothing.
  • Search belongs to the host on DSH. DSH provides its own web_search tool over a pluggable provider seam (ctx.web.registerSearchProvider). A browser-backed search is a provider there, selected from the settings page or DSH_WEB_SEARCH_PROVIDER, and it inherits citation rendering, cancellation, error codes, and session replay from the host. A separate moli_search tool would give the model two search entry points and bypass those. Codex has no such seam, so the capability is a tool there (moli_search); OpenCode's seam is a websearch provider, which is what it registers.

A Moli-backed DSH search provider is not part of this release.

Install

Requirements: Node.js >=20.12 and a Moli engine. The engine is installed separately because it is a platform-specific native binary and is released by the upstream Moli project.

1. Install the Moli engine

The easiest route is the plugin's own probe:

moli_probe action=install

Or use Moli's official installer:

# Windows
powershell -ExecutionPolicy ByPass -c "irm https://github.com/lexmount/moli/releases/latest/download/moli-installer.ps1 | iex"
# Linux / macOS
curl --proto '=https' --tlsv1.2 -fsSL https://github.com/lexmount/moli/releases/latest/download/moli-installer.sh | sh

If the binary is in a nonstandard location, set MOLI_BIN for Codex/OpenCode or exePath in the DSH configuration.

2. Install an adapter

DSH

dsh plugin --profile web add dsh-moli

For the desktop profile, use the in-app Plugins → Add plugin page. The CLI refuses to modify the Electron-owned desktop profile directly.

Codex

codex plugin marketplace add 27painter/dsh-moli --ref main
codex plugin add moli@27painter-codex

Start a new Codex conversation after installation. Codex has no direct npm plugin install route; plugins are resolved through a local or Git marketplace.

Codex plugin: Awesome Codex Plugins · HOL registry

OpenCode

opencode plugin add opencode-moli@3.2.0

Or add it to opencode.json / opencode.jsonc:

{
  "plugins": ["[email protected]"]
}

OpenCode-specific options and environment variables are documented in plugins/opencode-moli/README.md.

Quick start

moli_probe
moli_fetch url=https://example.com dump=markdown
moli_fetch url=https://example.com selector="main"
moli_fetch url=https://example.com dump=screenshot writeTo=/absolute/path/page.png

In Codex, moli_search also provides browser-backed search:

moli_search query="current Rust release"

In OpenCode, the plugin registers moli as a websearch provider, so the built-in websearch tool works without a separate search API key.

Usage

moli_fetch supports:

url, dump, writeTo, selector, eval, scroll, wait,
waitSelector, waitScript, waitResponseUrl, waitResponseJson, delayMs,
timeoutMs, maxChars, headers, userAgent, layout, scrollbars, noJs,
noCss, resources, withFrames, insecureTls, failOnHttpError,
profileDir, cookieFile, proxy

Common examples:

moli_fetch url=https://example.com dump=markdown
moli_fetch url=https://example.com dump=semantic_tree_text
moli_fetch url=https://example.com eval="document.title"
moli_fetch url=https://example.com selector=".video-card"
moli_fetch url=https://example.com/feed selector="h2" scroll=2000
moli_fetch url=https://example.com dump=pdf writeTo=/absolute/path/page.pdf
moli_fetch url=https://example.com/missing failOnHttpError=true

writeTo creates missing parent directories, so the screenshot or PDF path does not have to exist in advance. The call fails only when the path is an existing directory or the directory cannot be created.

Use selector for lists

selector returns only the matched elements instead of sending the whole page to the model:

moli_fetch url=https://example.com/feed selector=".video-card"

It is usually the cheapest and most accurate way to read search results, feeds, tables, and product lists. A selector with no match is an error. selector cannot be combined with dump or eval. The saving is large in practice: on a GitHub README page the whole page as Markdown was 46,305 characters, while selector="article" returned 13,135 — about 72% less for the same content.

Wait for the actual response

Prefer a specific readiness signal over a fixed delay:

moli_fetch url=https://example.com/feed waitResponseUrl="/api/feed"
moli_fetch url=https://example.com/feed waitResponseJson="data.list.0.id=42"
moli_fetch url=https://example.com/app waitScript="window.appReady === true"

scroll runs before capture for lazy-loaded content. eval without dump returns the expression value; using both is allowed, but the value is discarded and the result reports evalDiscarded.

Configuration

DSH configuration is optional and lives in the profile patch layer:

- insert:
    - id: dsh-moli
      name: dsh-moli
      config:
        exePath: 'C:\Users\me\AppData\Local\Moli\bin\moli.exe'
        defaultTimeoutMs: 30000
        maxChars: 200000
        proxy: 'http://127.0.0.1:7890'
        insecureTls: true

The same fields are editable from the DSH plugin settings page.

Codex reads these environment variables:

Variable Default
MOLI_BIN auto-detected engine path
MOLI_PROXY existing HTTPS_PROXY, HTTP_PROXY, or ALL_PROXY
MOLI_SEARCH_URLS DuckDuckGo HTML → Baidu → Bing → Brave
MOLI_TIMEOUT_MS 30000
MOLI_MAX_CHARS 200000
MOLI_INSECURE_TLS 0

Proxy settings apply to every Moli call, not only to page loads: MOLI_PROXY, HTTPS_PROXY, HTTP_PROXY, ALL_PROXY, and the per-call proxy option cover fetch, search, capture, and probe. In Codex and OpenCode, moli_probe also reports the configured search providers and the resolved proxy.

To make Moli the normal search path in Codex, place this before the first TOML table:

web_search = "disabled"

[plugins."moli@27painter-codex"]
enabled = true

OpenCode accepts equivalent options in its plugin entry and reads the same MOLI_* environment variables. See plugins/opencode-moli/README.md.

Search

Codex's moli_search and the OpenCode moli websearch provider render one of the configured public result pages with Moli and extract the ordinary result links. Providers are tried in order: DuckDuckGo HTML, Baidu, Bing, Brave. Searches wait for domcontentloaded; in testing DuckDuckGo HTML returned ten results in about 1.0–1.2 seconds.

Results are validated for relevance before they are accepted. When none of the titles, URLs, or snippets contains a query term, the attempt counts as invalid — that is what a mixed-up intermediate response or an anti-bot page looks like — and the next provider is tried. If every provider fails or is rejected, the call returns ok: false with an attempts record for each provider instead of passing unrelated results off as a success.

Result links are unwrapped: Bing's u=a1... redirects and DuckDuckGo's /l/?uddg= links are decoded to the real target URL. Baidu's link?url= links still need one more redirect hop.

Search is free and keyless, but result quality and anti-bot behavior are those of the public search pages, not a paid search API.

Platform support

Platform Status
Windows Verified by the maintainer
Linux Contributed and verified on Ubuntu 24.04 by @nd002723
macOS Engine-backed CI coverage on Apple Silicon

The plugin searches the standard Moli installation paths and $PATH. Set MOLI_BIN or exePath when the engine is installed elsewhere.

Limitations

  • Moli is not bundled with any npm package.
  • Moli's CDP/WebDriver server and session-import commands are not exposed.
  • A normal fetch cannot be cancelled mid-flight; engine installation runs asynchronously.
  • insecureTls defaults to true for filtering proxies. Set it to false on a healthy network.
  • Use failOnHttpError=true when a 4xx/5xx response must be reported as a failure.
  • DSH sandbox HTTPS may require danger-full-access on affected Windows configurations.
  • writeTo artifact calls are serialized.

Development

npm install
npm run build:codex
npm run verify:codex
npm run build:opencode
node verify/empty-verify.mjs

The main CI matrix runs on Windows, Linux, and macOS. Engine-dependent suites download a real Moli release. Test scripts live in verify/, and GitHub Actions is the source of truth for the full suite.

Security

Local execution, network, proxy, cookie, TLS, and installer boundaries are documented in SECURITY.md.

Versions

3.2.0

Search defaults to DuckDuckGo HTML → Baidu → Bing → Brave and waits for domcontentloaded. A provider whose results share no term with the query is treated as an invalid attempt so the next one is tried; when all providers fail, the call returns ok: false with per-provider attempts. The proxy flag is placed before the -- separator, so MOLI_PROXY, HTTPS_PROXY, HTTP_PROXY, ALL_PROXY, and the per-call proxy option now reach fetch, search, capture, and probe. writeTo creates missing parent directories, and moli_probe reports the configured search providers and proxy state.

Earlier releases
  • 3.1.0 — native OpenCode V2 adapter, including keyless websearch, moli_fetch, moli_capture, and moli_probe. DSH and Codex tool contracts are unchanged.
  • 2.1.1 — Codex directory metadata, security files, pinned Actions, and HOL scanner workflow.
  • 2.1.0 — Codex MCP adapter with search, fetch, capture, and probe tools.
  • 1.1.11 / 1.1.12 — deprecated; use a maintained release.

License

MIT. See LICENSE. Moli is also MIT-licensed; this project is an independent integration and is not affiliated with or endorsed by the Moli project.

About

DSH OpenCode and Codex plugin · Drive the local Moli headless browser from DeepSeek Harness: moli_fetch and moli_probe for JS-rendered pages, Markdown, semantic trees, screenshots and PDFs, with sandbox-aware failure classification.

Topics

Resources

Security policy

Stars

7 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages