Skip to content

feat(headless): Headless 服务器运行时与 liveagent-server(无需 Tauri) - #409

Open
thirsty5034 wants to merge 5 commits into
Stack-Cairn:mainfrom
thirsty5034:feat/headless-runtime
Open

feat(headless): Headless 服务器运行时与 liveagent-server(无需 Tauri)#409
thirsty5034 wants to merge 5 commits into
Stack-Cairn:mainfrom
thirsty5034:feat/headless-runtime

Conversation

@thirsty5034

@thirsty5034 thirsty5034 commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

关联 issue

Closes #380

概述

为 LiveAgent 增加 Headless 运行时:桌面版通过 #[tauri::command] 暴露的业务命令面,现在同样以独立的 axum HTTP/WebSocket 服务形式运行(--no-default-features,不依赖 Tauri),并通过页内桥接复用现有 GUI 前端。同时提供基于命令清单的生成器流水线,保证 234 个命令适配层可复现、可校验,CI 中带防漂移检查。

5 个逻辑 commit,144 个文件(+13,886 / −1,534)。

改动范围

  • 模块:src-tauri(服务端运行时 / 命令分发)、crates/agent-gui + crates/agent-gateway(桥接 + 同源安全模型)、scripts/(清单生成器 + 校验器)、.github/workflows/ci.yml(headless-rust + gen-verify 任务)
  • 关键路径:
    • src-tauri/src/headless.rs — axum 路由:GET /healthGET /api/statusPOST /api/invokePOST /api/files/importGET /wsGET /* SPA 回退
    • src-tauri/src/tauri_bridge.rs — 同接口桥接,让 WebUI 可在 headless 下运行
    • scripts/manifest/commands.json — 提交的权威命令清单(234 个命令)
    • scripts/gen_headless.sh / verify_headless.py — 生成器 + 双向防漂移校验
    • src-tauri/src/commands/adapters.rs — 桌面端薄适配层

主要亮点

  • 业务层与 Tauri 解耦:业务代码不再依赖 AppHandle / State
  • 同源安全模型:CORS 门禁、/api/invoke Token 鉴权(LIVEAGENT_API_TOKEN)、/ws 来源校验、限流按真实 TCP 对端地址计算
  • 可复现的命令注册表:234 个命令收进 commands.json;适配层与分发分支由生成器产出并在 CI 校验(git diff --exit-code
  • liveagent-server 二进制可独立安装运行,无需桌面窗口

截图 / 预览

Headless WebUI(复用现有 GUI,桥接至服务器)运行效果:

headless WebUI

验证情况

  • cargo build --no-default-features 通过(由新增的 headless-rust CI 任务守护)
  • scripts/gen_headless.sh 重新生成无漂移;verify_headless.py 双向校验清单 ↔ 分发分支一致(234 = 234)
  • 手工验证:liveagent-server 启动后 WebUI 经 tauriBridge 正常工作(health / api / ws / 文件导入均已在部署环境验证)

提交前检查

Replace direct AppHandle/State usage in the command layer with a plain
AppContext assembly plus a typed event emitter, so the same business
commands can run under both the desktop Tauri runtime and a headless
server. Desktop-only modules are feature-gated behind the default
desktop feature. Tests updated to assert the compat abstraction instead
of the raw tauri runtime paths.
A --no-default-features build strips the Tauri desktop runtime and runs
the same command surface over an axum HTTP/WebSocket server: GET /health,
GET /api/status, POST /api/invoke, GET /ws event broadcast, GET /* WebUI
SPA fallback and /proxy/{provider}/ BFF routes. Adds a same-origin
security model (CORS gate, optional Bearer token auth, rate limiting by
real peer IP) and a runtime-fallback mode for browsers without the Tauri
bridge.
Add a tauriBridge module exposing the same invoke interface to the
existing GUI code so the WebUI runs unchanged on the headless server
(runtime-fallback over fetch/WebSocket). Adds HeadlessFolderPicker and
headless-aware file upload. All GUI imports now go through the bridge
instead of @tauri-apps/api directly.
scripts/manifest/commands.json is the committed source of truth for the
234 Tauri commands; build_type_map.py derives the Rust type map,
gen_adapters.py regenerates commands/adapters.rs and verify_headless.py
asserts headless.rs dispatch arms match the manifest both ways. The
gen-verify CI job fails on any drift.
Add headless-rust (cargo check/test/build --no-default-features) and
gen-verify (generator drift check) jobs. Document the headless security
model and the command-registry workflow in the README.
@thirsty5034

Copy link
Copy Markdown
Contributor Author

#379 的评审意见完成拆分,提交历史也已整理为少量逻辑提交:

建议合并顺序:先审本 PR,再审 #410。两个 PR 的 CI workflow 需要 Approve 后才会运行。

@thirsty5034 thirsty5034 changed the title feat(headless): headless server runtime with liveagent-server binary (no Tauri) feat(headless): Headless 服务器运行时与 liveagent-server(无需 Tauri) Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(headless): headless server runtime for LiveAgent

1 participant