Cross-Platform AI Agent Desktop App: One Architecture for Four Platforms
This article explains how to turn a plugin-based AI agent framework's web UI into a native desktop and mobile application without modifying the upstream code. It covers a three-layer architecture built on an in-process host, a loopback local server, and a same-origin data plane, compares four editions across desktop, HarmonyOS, and mobile targets, and shares practical guidance on workspace layout, incremental rollout, and engineering caveats.
1. The Problem: The Last Mile for Agent Frameworks
Open-source agent runtimes built around an “everything is a plugin” philosophy have become common: model adapters, tool registries, session logs, and even the main loop are all replaceable. Most of them ship a fully featured web admin UI that you use by starting a local service and opening it in a browser.
The problem is that a browser tab lacks several capabilities that matter for a long-running developer tool: no system tray, no native notifications, no independent window management, and no participation in the application lifecycle. For a tool you want to keep resident and summon at any moment, that is a clear experience gap.
This article covers how to promote such a web UI to a first-class native application without touching the upstream interface, while covering four device categories across desktop and mobile.
2. Core Design: In-Process Host + Local Server + Same-Origin Data Plane
The whole approach abstracts into three layers:
- Host layer: Load the agent framework core into the application process as a library, with its lifecycle managed by the shell rather than an external CLI process.
- Service layer (local server): Start an in-process HTTP server bound only to the loopback address, exposing an API identical to the official UI.
- Data plane: The window loads pages returned by the local server directly, so every request the page makes is same-origin by nature.
Same-origin is the pivot of the entire architecture. Because the page and the API come from the same origin, the browser’s default same-origin policy applies directly. As a result:
- No need to disable or relax cross-origin restrictions.
- No extra auth layer (loopback binding plus in-process coupling already narrows the attack surface enough).
- No custom URL scheme or private protocol for inter-process communication.
- No additional IPC channel.
- Zero changes to the upstream core code.
A schematic skeleton (pseudocode, structure only):
app.onReady:host = loadHostLibrary() // Load the core in-processhost.start()server = createLoopbackServer(host.router) // Bind 127.0.0.1 onlyserver.listen(port)createWindow({ url: `http://127.0.0.1:${port}/` })
3. Capability Differences Across the Four Editions
All four editions share the same skeleton. They differ along only two dimensions: who provides the window (the rendering container) and who provides the Node runtime.
| Edition | Rendering | Runtime | Target Devices |
|---|---|---|---|
| Desktop Standard | Bundled browser engine | Framework-bundled runtime | The three major desktop OSes |
| Desktop HarmonyOS | Bundled browser engine (newer version) | Runtime ported to HarmonyOS | HarmonyOS 2-in-1 devices / tablets |
| HarmonyOS Native | System web rendering component | In-process Node shared library | HarmonyOS 2-in-1 devices / tablets |
| Mobile | System web rendering component | In-process Node shared library | Phones / tablets (arm64 package) |
The two desktop editions go with “bundled engine + bundled runtime”: larger packages, but a controlled and version-consistent environment. The mobile and HarmonyOS native editions go with “system rendering component + in-process shared library”: small packages and a native look and feel, but constrained by the version of the system component. The UI, the data plane, and the extension mechanism are identical across all four.
4. Why Insist on Zero Changes
The upstream framework is still iterating quickly. The shell only needs to pin a specific upstream version tag, and upgrading means re-running the build pipeline rather than maintaining a patch set. Rewriting the UI, on the other hand, permanently forks the most active part of the upstream project into your own repository, once per platform, so maintenance cost scales linearly. The essence of the zero-change strategy is pushing customization down from the code layer to the build layer.
5. Workspace Organization and Getting Started
A single workspace with multiple outputs is the recommended layout: one core shell package handles host loading, server startup, and window creation; each platform directory keeps only its platform-specific manifest, permission declarations, build scripts, and icon assets; shared build scripts fetch the pinned upstream version, inject configuration, and produce installers for each platform.
A four-step path to get started:
- Get the minimal loop working on the desktop platform you know best: in-process host + loopback server + window loading.
- Abstract a platform adaptation interface covering three things: window creation, rendering container, and runtime loading.
- Integrate a second platform to validate the abstraction.
- Fill in system capabilities such as tray, notifications, single-instance handling, and port conflict handling.
6. Engineering Notes
The loopback server needs to handle port occupancy and random-port scenarios; validate request origin to prevent other local processes from accessing it by mistake; store logs and session data under the user directory with a clear cleanup policy; on mobile, account for session recovery after the app is killed in the background. If cloud collaboration is needed later, generic cloud capabilities can be reused (object storage for session archives, a message queue for task distribution, logging and monitoring with alerting for observability), but the same-origin data plane principle should remain intact.
