Skip to content

AtomCode v5.0.9 新子系统深度分析 — HTTP Daemon + 浏览器 WebUI ​

基于 strings / 源码路径 / 端口 / ws 路由的还原分析 2026-09-09 前置报告:05-version-diff-v4.25.5-to-v5.0.9.md


1. 架构总览 ​

v5.0.9 的集成面由 HTTP daemon(面向 IDE)与 浏览器 WebUI(面向用户远程操作)构成,两者共享同一会话内核:

┌──────────────────────────────────────────────────────────────┐
│ 客户端层                                                      │
│  VS Code 扩展 (13456)   浏览器 WebUI (13457)   atomcode-air   │
└───────────────────────────┬──────────────────────────────────┘
                            │ HTTP / WebSocket (axum)
┌───────────────────────────▼──────────────────────────────────┐
│  atomcode daemon                                             │
│  ┌────────────────┐  ┌──────────────┐  ┌──────────────────┐  │
│  │ api_auth.rs    │  │ auth_token.rs│  │ api_codingplan.rs│  │
│  │ (登录/会话上限)│  │ (令牌管理)   │  │ (CodingPlan 同步)│  │
│  └────────────────┘  └──────────────┘  └──────────────────┘  │
│  ┌────────────────┐  ┌──────────────┐  ┌──────────────────┐  │
│  │ webui.rs       │  │ kernel_runtime│ │ native_live.rs   │  │
│  │ (WebUI 静态服务)│  │ (内核宿主)   │  │ (原生会话流)     │  │
│  └────────────────┘  └──────────────┘  └──────────────────┘  │
│  ┌────────────────┐  ┌──────────────┐  ┌──────────────────┐  │
│  │ legacy_convert │  │ runtime_host │  │ commands.rs      │  │
│  │ (旧会话转换)   │  │ (运行时宿主) │  │ (daemon 命令)    │  │
│  └────────────────┘  └──────────────┘  └──────────────────┘  │
│  axum::serve · graceful shutdown · idle-timeout              │
└──────────────────────────────────────────────────────────────┘

2. HTTP Daemon(IDE 集成) ​

2.1 命令与参数 ​

atomcode daemon
  --client         Client identifier for telemetry (e.g. "vscode", "atomcode-air")
  --idle-timeout   Idle-shutdown timeout in seconds; 0 disables.
                   Env ATOMCODE_DAEMON_IDLE_TIMEOUT overrides. Default 1800 (30 min)
  --host           (默认 127.0.0.1)

Start the HTTP daemon for IDE integration (VS Code extension connects to this)
  • 基于 axum Web 框架(axum::serve error)
  • 空闲 30 分钟自动关闭(可配置/禁用)

2.2 端口分配(二进制内建表) ​

端口客户端说明
13456VS Code 扩展HTTP daemon 主端口
13457浏览器 WebUIWebUI 端口
13413 / 13414 / 13423内部/旧版预留

绑定策略:127.0.0.1(本地)↔ 0.0.0.0(--host 暴露)。

2.3 认证与令牌 ​

x-atom-user-id         ← 请求头:用户标识
Bearer <token>         ← Bearer 认证
ATOMCODE_DAEMON_TOKEN  ← 环境变量令牌通道
failed to write daemon token file:
  • api_auth.rs:登录会话管理(login_session_limit — 会话数量上限)、OAuth 凭据持久化
  • auth_token.rs:daemon 令牌的生成/校验/持久化

2.4 危险工具开关 ​

ATOMCODE_DAEMON_ENABLE_DANGEROUS_TOOLS   ← 环境变量

→ daemon 通道默认不暴露危险工具,需显式开启。

2.5 生命周期 ​

Starting AtomCode daemon on port ...
Received Ctrl-C, starting graceful shutdown
Fatal: daemon server error:

3. WebSocket 路由家族 ​

二进制内 ws:// 前缀拼接串还原出 daemon 的 ws 端点家族(/ws/<module>):

guide · review · session · resume · proxy · rewind · forget · memory
webui · desktop · app · background · mcp · welcome · think · plugin · setup
端点对应功能
session会话生命周期流
resume会话恢复
rewind会话回退(见 DEEP_ANALYSIS 补述)
proxy代理通道
forget会话遗忘
memory记忆工具通道
mcpMCP 服务器管理
webui / desktop / app各客户端绑定
background后台任务
welcome / think / plugin / setup / guide / review引导/思考/插件/初始化/审查

→ daemon 并非单一路由,而是一组按功能拆分的 ws 端点,每个端点对应会话内核的一个子系统。


4. 浏览器 WebUI ​

4.1 构建方式(重要发现) ​

webui assets are not embedded in this binary.
    cd webui && npm install && npm run build
ATOMCODE_WEBUI_DEV   ← 开发模式
  • 前端是独立 npm 工程,默认不嵌入二进制 → 生产发行需 npm run build 后由 webui.rs 静态服务
  • 开发模式用 ATOMCODE_WEBUI_DEV 指向独立前端 dev server

4.2 远程访问 ​

detected, but the webui is bound to localhost only. Run /webui --host {ip}
Launch the browser webui (subcommands: stop, lan, --host <addr>)
Reach this webui from your phone or other devices over the ...
atomcode.atomgit.com/docs/${n}/webui-remote-access.html
  • 默认 localhost-only;/webui lan 或 --host 暴露局域网/远程
  • 官方提供远程访问文档页

4.3 会话同步与通知 ​

live webui session (/sync off to detach)
open a synced session in the browser
atomcode.webui_notify / atomcode.webui_last_notify   ← localStorage 键
X-AtomCode-Client: webui                              ← 客户端标识头
  • WebUI 会话可与 TUI 会话同步(/sync)
  • 浏览器端 localStorage 记录通知去重时间戳(webui_last_notify)
  • 前端轮询节流参数(5e3 = 5s 轮询、120 重试窗口)

4.4 客户端身份 ​

ATOMCODE_DESKTOP_DOWNLOAD_URL / ATOMCODE_APP_RELAY
desktopapp / background / mcp

daemon 同时服务 desktop app(atomcode-air) 与 mobile app(relay) 多客户端。


5. 逆向方法论备注 ​

  1. 端口表 13456 VS Code / 13457 WebUI 以格式化表格字符串存在,直接揭示绑定矩阵
  2. ws 路由是无分隔符拼接串(ws://guide+review+session+...),按已知单词切割还原端点家族
  3. webui assets are not embedded 提示该二进制为未嵌入前端的构建变体,前端产物独立交付
  4. axum 错误串确认 Web 框架选型;graceful shutdown 串揭示优雅停机路径
  5. daemon 各子系统以 crates/atomcode-daemon/src/*.rs 文件名为单位,功能边界清晰可还原

本报告由持续分析循环生成 — v5.0.9 HTTP Daemon + 浏览器 WebUI 深度分析

基于 VitePress 构建 · AtomCode v5.2.3 逆向工程分析文档