Adapting an Agent Harness Shell Across Four Platforms Without Modifying the Web UI
Many agent harness frameworks ship with a complete Web UI, but running it in a browser tab limits system tray integration, native notifications, and independent window management. This article explains how a shell layer can wrap the same agent harness across desktop, two HarmonyOS variants, and Android while keeping the original UI untouched. It covers the in-process Host + local Web server + same-origin data plane architecture, the two dimensions that actually differ per platform, and engineering practices for maintaining a unified multi-platform codebase.
Introduction: From Browser Tab to Native Application
Agent harness frameworks have become important infrastructure for agent engineering. Most of them follow an “everything is a plugin” design: the model adapter layer, tool registry, session logs, and even the main loop are replaceable components. That provides strong extensibility and adaptability. However, many implementations expose management through a Web UI that runs in a browser tab. They lack system-level tray integration, native notifications, and independent window management, so they do not feel like a real desktop application.
Turning that Web UI into a native application is a cross-platform engineering problem: one architecture must cover desktop (Windows/Linux/macOS), Android, and the HarmonyOS ecosystem, instead of building a separate stack for each platform.
Core Design Principle: Zero UI Changes First
Before doing platform adaptation, one constraint matters: the upstream Web UI is iterating quickly. If each platform modifies the original interface code, two long-term problems appear:
- Maintenance cost rises sharply: every upstream release requires re-applying historical patches in multiple branches, which can lead to omissions or conflicts.
- Technical debt becomes permanent: once the UI code is forked, the team is responsible for maintaining the most active part of the upstream project indefinitely.
Therefore, the first principle should be: keep the UI layer unchanged and handle platform-specific work only in the shell layer. Specifically:
- Do not modify the original Web UI HTML/CSS/JS.
- Do not introduce custom protocols.
- Do not add a separate IPC mechanism.
- Serve page resources through a local Web server to avoid CORS problems.
- Reuse the original framework’s authentication mechanism; do not add another auth layer.
These constraints look strict, but they are the prerequisite for making one architecture reusable across multiple platforms.
Architecture: In-Process Host + Local Web Server + Same-Origin Data Plane
In-Process Host
The Host is the core runtime of the agent harness: it loads plugins, schedules model calls, and maintains session state. Embedding the Host directly into the application’s main process instead of running it as a separate background service avoids IPC overhead and deployment complexity.
Local Web Server
After the Host starts, it launches a local Web server that exposes the original Web UI static assets and API interfaces. The native window loads that local address. The benefits are:
- The rendered content is identical to the page served by the
dsh webcommand. - Because the service and the UI are same-origin, CORS issues are naturally avoided.
- The framework’s existing session and authentication mechanism can be reused directly.
Same-Origin Data Plane
All platforms share the same data interaction logic: configuration file format, session storage structure, and plugin interface protocol are identical. Users can migrate data across devices without format conversion, and the risk of inconsistent behavior between platforms is reduced.
These three layers form a stable base that different platform shells can reuse.
Four Platform Targets: Only Window Provider and Runtime Provider Differ
Under this unified architecture, differences across the four platform versions are narrowed to two dimensions:
| Dimension | What it decides |
|---|---|
| Window provider | UI container and system integration capabilities such as tray, notifications, and multi-window management |
| Runtime provider | JavaScript execution environment; whether to bundle a full runtime or reuse system capabilities |
Desktop (Windows / Linux / macOS)
Use a common cross-platform desktop application framework. It embeds a browser engine for rendering and bundles a complete JavaScript runtime. This is the most mature route for desktop cross-platform development, with a full ecosystem and debugging toolchains.
HarmonyOS Variant 1 (Tablet / 2-in-1 Devices)
Adapt the cross-platform desktop runtime to HarmonyOS. Rendering still uses an embedded browser engine, while the runtime environment is adapted to HarmonyOS’s process model and permission system. This version is distributed as an HAP (HarmonyOS Ability Package).
HarmonyOS Variant 2 (Tablet / 2-in-1 Devices)
The alternative path is to reuse HarmonyOS’s system-provided Web rendering engine instead of bundling a browser engine, and start the JavaScript runtime in-process through a lightweight embedded runtime library. This reduces package size and is closer to the native HarmonyOS application form.
Android
Use the system WebView plus an in-process embedded runtime, distributed as an APK and targeting arm64. This avoids the package-size expansion caused by bundling a full browser engine, which matters more on mobile.
Regardless of which component provides the window and runtime, the rendered UI, data interaction protocol, and plugin extension method remain identical across the four versions. That is the core of the architecture: isolate the volatile upstream UI behind the shell, and treat window containers and runtimes as replaceable components.
Engineering Practice Suggestions
- Unified workspace management: Use one repository structure for all targets and let build configurations distinguish platform artifacts. Avoid maintaining separate repositories for each platform.
- Version anchoring strategy: Bind the shell code to an upstream version explicitly, such as by tag or version number. Upgrades should rerun the build pipeline instead of applying manual patches.
- Layered testing strategy: Keep core data-plane logic tests platform-independent. Platform-specific tests should only cover shell-layer capabilities such as window management and system notifications.
- Package size control: On mobile, prefer reusing the system rendering engine to reduce the package-size burden from bundling a full browser engine.
Conclusion
Cross-platform native adaptation is not about rewriting the UI four times. It is about using architecture layering to reduce change points to the minimum. Treat the UI and data logic as a stable kernel, and treat window management and runtime environments as replaceable shell components. This preserves upstream compatibility while allowing one architecture to cover multiple platform targets. The same approach is also useful for other tooling products that need multi-platform adaptation.
