Free · Daily brief + weekly playbookDaily 60-sec AI Voice Brief + Weekly Production AI Agent PlaybookGet the brief →
ReleaseInsight · On RadarHabr AI→ original

A developer hooked OpenCode into DeepSeek's web interface with a bridge of a couple hundred lines

OpenCode is an AI coding agent, but it lives in the terminal: after a restart the context is lost, and the only way to stop it is Ctrl+C. The developer connected it to the DeepSeek Harness web interface, where the agent loop is a swappable plugin, using a bridge of a couple hundred lines. The result is OpenHarn: a window with a Stop button and sessions that survive restarts, with no changes to OpenCode's code. The takeaway: on a plugin-based platform, the engine and the interface can be replaced without forking.

AI-processed from Habr AI; edited by Hamidun News
A developer hooked OpenCode into DeepSeek's web interface with a bridge of a couple hundred lines
Source: Habr AI. Collage: Hamidun News.
Listen to article
Article Fact Sheet & Key Figures
ParameterDetails
Primary sourceHabr AI ↗
Editor-in-Chief
Key metric #1Inno Setup shrank the distribution from 1.78 GB to 361 MB, with a build time of about 4 minutes
Key metric #2For model selection, there is OpenCode's free pool of 55+ models and custom providers
Key metric #3@electron/packager on Node 26 exits silently with code 0, so the author used robocopy instead

Imagine this: you use an AI programming agent. It reads the code itself, calls tools, and edits files. But it works in the terminal.

You restart the program and have to type the context in again. Tool calls come out as one continuous transcript. You can stop the agent only with Ctrl+C.

This is exactly the problem the author of the OpenHarn project on Habr ran into. He was fully satisfied with the OpenCode agent engine: the agent loop, the tools, and the free model pool. Only the shell bothered him.

So instead of writing a new interface, he connected OpenCode to the ready-made DeepSeek Harness (DSH) web interface through a small bridge, roughly a couple hundred lines of code.

How the engine swap works

The ready-made interface turned out to be the npm package @deepseek-ai/dsh, that is, the DeepSeek Harness web interface. It runs on the Cordis framework, where everything, including the agent loop, is a plugin. The built-in loop is declared in the YAML configuration under the id agent-loop, so the author needed only a small patch. He disabled the standard loop and put his own module in its place, specifying the OpenCode server address, the path to the executable, and the model.

The module implements the AgentFactory contract with two methods. createAgent() creates a new session, and resume() restores an old one. Both return an agent and a dispose() function. The session registry, the interface, and shared access to working folders remain on the DSH side. If no password is set, the bridge itself launches opencode serve and takes a one-time password from its log.

The bridge's main job is translating events. OpenCode emits an SSE stream: the start of a turn, text deltas, tool results, permission requests. DSH keeps a strict session log in which every entry is validated. So the bridge maps events one to one. For example, session.text.delta becomes live streaming of the response, and session.tool.success lands in the interface trace. Interrupting execution closes the turn as aborted, and that is what makes the Stop button work.

There are three details. The session identifiers of the interface and the engine differ, so the bridge keeps a JSON file of mappings. Thanks to it, resume works even after a full restart. OpenCode 2.x and 1.x send events in different legacy formats, and the author wrote normalization code of about fifty lines. He made the OpenCode client on bare http in 400 lines with no dependencies, while the node_modules of DSH itself contains about 670 packages.

The desktop build and its pitfalls

Next, the author wanted an exe. This is where the project turns into a set of practical lessons.

  • @electron/packager on Node 26 exits silently with code 0 and builds nothing. The programmatic API did not help either: the promise never resolves, and the process simply exits. The author recalled that an Electron application consists of two parts: the runtime in the root folder and the app in resources/app. He replaced packager with a 60-line script using robocopy.
  • First mistake: he globally excluded dist folders during copying. But npm packages also have dist folders containing prebuilt bundles. The window opened, but the server crashed with ENOENT. The rule: do not exclude dist globally.
  • DSH checks the Electron runtime "fingerprint" against a specific list of versions: 43.0.0, 44.0.0, 44.7.0, 44.11.5, and 45.0.0-alpha.6. Version 45.5.0 did not pass, so he rolled back to 44.11.5 and pinned it without a caret in package.json.
  • In the packaged application, the server runs through Electron itself with the environment variable ELECTRON_RUN_AS_NODE=1, so Node is not needed on the machine.

The installer and the result

For the installer, the author used Inno Setup 7: a per-user install without UAC, shortcuts, and an uninstaller. The LZMA2 algorithm compressed the 1.78 GB distribution down to 361 MB, and compilation takes about four minutes. OpenCode is bundled inside as a single 266 MB exe. On startup, the application first looks for engine\opencode.exe next to itself and only then checks PATH.

Two more Windows lessons. Start-Process in PowerShell 5.1 does not quote arguments containing spaces, so a path like /DIR=C:\Users\7ims (Admin)\... gets split into three arguments, and Inno exits with code 1 without a log. In addition, installation success is better verified by checking key files rather than by the exit code.

To sum up: a double click launches the window, the interface server, and the engine, and closing the window kills the entire process tree. Sessions survive restarts. For model selection, there is OpenCode's free pool of 55+ models and custom providers, which are added via Ctrl+U: base URL, key, and model list. They are saved to ~/.openharn/providers.json. Engine data is stored separately in ~/.openharn/opencode-data and does not interfere with other OpenCode installations. OpenCode itself was not forked or modified.

The author names the limitations himself. While auto-approval is enabled and the confirmation buttons are not ready, the permission.asked events are already projected. Multi-agent support exists in both OpenCode and DSH, but they still need to be connected. Repository: github.com/StageCodes/openharn, with the installer in Releases. Running from source requires Node 20+ and @opencode/cli.

The practical takeaway for developers: if an agent platform is built on plugins, the engine and the interface can be changed independently. A thin adapter is enough for that, not a fork.

Story

Key Questions Answered

How the engine swap works?

The ready-made interface turned out to be the npm package @deepseek-ai/dsh, that is, the DeepSeek Harness web interface. It runs on the Cordis framework, where everything, including the agent loop, is a plugin. The built-in loop is declared in the YAML configuration under the id agent-loop, so the author needed only a small patch. He disabled the standard loop and put his own module in its place, specifying the OpenCode server address, the path to the executable, and the model.

What are the key details on The desktop build and its pitfalls?

Next, the author wanted an exe. This is where the project turns into a set of practical lessons. @electron/packager on Node 26 exits silently with code 0 and builds nothing. The programmatic API did not help either: the promise never resolves, and the process simply exits. The author recalled that an Electron application consists of two parts: the runtime in the root folder and the app in resources/app. He replaced packager with a 60-line script using robocopy.

What are the key details on The installer and the result?

For the installer, the author used Inno Setup 7: a per-user install without UAC, shortcuts, and an uninstaller. The LZMA2 algorithm compressed the 1.78 GB distribution down to 361 MB, and compilation takes about four minutes. OpenCode is bundled inside as a single 266 MB exe. On startup, the application first looks for engine\opencode.exe next to itself and only then checks PATH. Two more Windows lessons.

ZK
Zhemal Khamidun — Head of AI at Alpina Digital · MIPT (academic supervisor of the Tech Entrepreneurship department). Building AI products since 2019. Hamidun News is a pet project that grew into a production aggregator with 6,000+ readers.
✦ Unified AI Workspace · Nomad

Test Frontier LLMs & Autonomous Agents in One Workspace

Run Claude Opus 5.5, GPT-6, Gemini 3.1, and DeepSeek side-by-side in Nomad AI (nomadnet.ai) — unified model routing, deep research, and multimodal workflows under one subscription.

Try Nomad AI →Launch Nomad Agent
Jemal Hamidun

Editor-in-chief · Cite this analysis

Jemal Hamidun

Head of AI at Alpina Digital · Academic Supervisor of the Tech Entrepreneurship Department at MIPT

Head of AI & CPO of AlpinaGPT at Alpina Digital, Academic Lead of Tech Entrepreneurship at MIPT. Founder of Hamidun News and Vibe Academy.

Ready-to-paste citation for journalists, blogs and Telegram channels

Source: Hamidun News — A developer hooked OpenCode into DeepSeek's web interface with a bridge of a couple hundred lines https://news.hamidun.com/en/news/18960/a-developer-hooked-opencode-into-deepseek-s-web-interface-wi

What do you think?
Loading comments…