homeagent-runner 0.4.16 → 0.4.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,42 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.19 — XAuth OIDC administrator login and sole-administrator binding
4
+
5
+ - Add optional self-hosted [XAuth](https://github.com/jhxxr/XAuth) OIDC administrator
6
+ login (`XAUTH_ISSUER`, `XAUTH_CLIENT_ID`, `XAUTH_CLIENT_SECRET`) with `S256` PKCE,
7
+ server-stored signed state, nonce validation, JWKS caching/rotation and `RS256` ID
8
+ token verification, supporting XAuth-only or dual XAuth + `ADMIN_PASSWORD` sign-in.
9
+ - Automatically bind the first authenticated XAuth account (`sub`) in SQLite as the
10
+ workspace's sole administrator and reject all subsequent XAuth accounts (`403`),
11
+ surfacing the bound administrator identity and session auth method in the Dashboard.
12
+ - Provide aligned English and Simplified Chinese documentation across all 11 guides
13
+ under `docs/` alongside `README.md` and `README.zh-CN.md`.
14
+
15
+ ## 0.4.18 — Windows PowerShell persistent shell bootstrap
16
+
17
+ - Initialize persistent Windows PowerShell sessions with an explicit `-NonInteractive -EncodedCommand`
18
+ read-eval loop that pins `PSModulePath` to `$PSHOME\Modules` and imports built-in
19
+ `Microsoft.PowerShell.Management` and `Microsoft.PowerShell.Utility` modules directly
20
+ from `$PSHOME` before reading commands, avoiding Windows CI module auto-discovery stalls
21
+ and `Console.In` stream reader resets.
22
+ - Include the fuzzy unified diff, persistent shell session and lightweight LSP toolset
23
+ with synchronized versions and release metadata.
24
+
25
+ ## 0.4.17 — Fuzzy diffs, persistent shell sessions and lightweight LSP
26
+
27
+ - Add bounded fuzzy hunk relocation (`fuzz`) and optional horizontal whitespace
28
+ tolerance (`ignoreWhitespace`) to `apply_unified_diff`, reporting relocated hunk
29
+ offsets while rejecting ambiguous matches and preserving strict `fuzz: 0` mode.
30
+ - Add persistent stateful shell session tools (`start_shell`, `run_shell`,
31
+ `list_shells`, `stop_shell`) supervised by `Processes` (Linux process groups and
32
+ Windows Job Objects), preserving working directory and shell variables across
33
+ commands while enforcing command allowlists and temporary grant expiration.
34
+ - Add lightweight LSP and code intelligence tools (`lsp_document_symbols`,
35
+ `lsp_workspace_symbols`, `lsp_definition`, `lsp_references`, `lsp_hover`,
36
+ `lsp_diagnostics`) with zero-config symbol indexing, cross-file import resolution,
37
+ in-memory syntax/import diagnostics and optional stdio JSON-RPC 2.0 external LSP
38
+ server queries.
39
+
3
40
  ## 0.4.16 — Consistent project identity and permissions
4
41
 
5
42
  - Give newly added projects random IDs and persist per-device identity history;
package/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  <p align="center">
2
- <img src="public/icon.png" width="128" height="128" alt="HomeAgent 图标">
2
+ <img src="public/icon.png" width="128" height="128" alt="HomeAgent logo">
3
3
  </p>
4
4
 
5
5
  <h1 align="center">HomeAgent</h1>
6
6
 
7
7
  <p align="center">
8
- <strong>让 AI 连接你的开发机器。</strong><br>
9
- 自托管 MCP 中继 · 本地执行 · 权限由你掌控
8
+ <strong>Connect AI agents to your own development machines.</strong><br>
9
+ Self-hosted MCP relay · Outbound local execution · Fine-grained permissions
10
10
  </p>
11
11
 
12
12
  <p align="center">
@@ -18,113 +18,114 @@
18
18
  </p>
19
19
 
20
20
  <p align="center">
21
- 简体中文 · <a href="README.en.md">English</a>
21
+ <strong>English</strong> · <a href="README.zh-CN.md">简体中文</a>
22
22
  </p>
23
23
 
24
24
  <p align="center">
25
- <a href="#快速开始">快速开始</a> ·
26
- <a href="docs/DEPLOYMENT.md">部署指南</a> ·
27
- <a href="docs/CLIENTS.md">连接 AI 客户端</a> ·
28
- <a href="docs/README.md">完整文档</a> ·
29
- <a href="CHANGELOG.md">更新日志</a>
25
+ <a href="#quick-start">Quick Start</a> ·
26
+ <a href="#ai-prompting-guide">Prompt Guide</a> ·
27
+ <a href="#remote-assist">Remote Assist</a> ·
28
+ <a href="#mcp-tools">MCP Tools</a> ·
29
+ <a href="docs/DEPLOYMENT.md">Deployment</a> ·
30
+ <a href="docs/CLIENTS.md">AI Clients</a> ·
31
+ <a href="docs/README.md">Docs</a> ·
32
+ <a href="CHANGELOG.md">Changelog</a>
30
33
  </p>
31
34
 
32
35
  ---
33
36
 
34
- HomeAgent 让 Claude、ChatGPT、Cursor 等 MCP 客户端,通过你部署的 Server 操作自己的 Linux / Windows 开发机器。Runner 主动连出,在本地执行授权的文件、命令和 Git 操作,无需开放被控端入站端口。
37
+ **HomeAgent** is a self-hosted [Model Context Protocol (MCP)](https://modelcontextprotocol.io) relay and local execution runner that lets **Claude**, **ChatGPT**, **Cursor**, and other MCP clients work directly on your Linux and Windows development machines.
35
38
 
36
- 系统运行无需模型 API Key、第三方中继、遥测或付费云服务;工具结果会返回给你选择的 AI 客户端。当前版本 **v0.4.15**,支持单管理员、多设备。
39
+ Lightweight **Runners** connect outbound over authenticated WebSockets (`WSS`) to your self-hosted **HomeAgent Server**, executing authorized file, terminal, and Git operations locally without opening inbound firewall ports on your workstations. HomeAgent requires no model API keys, third-party cloud relays, or telemetry—tool outputs go straight back to the AI client you choose.
37
40
 
38
- ## Remote Assist · 邀请朋友
41
+ ## Key Features
39
42
 
40
- 新增远程协助模式:Dashboard 创建绑定指定客户端的一次性邀请;朋友在本机 Runner 选择多个项目、逐项目权限与统一时长,批准后才开放访问,随时可立即停止。普通个人/工作配对保持不变。协助端无需管理员账号或模型 API Key;执行允许列表不是操作系统沙箱。详见[远程协助指南](docs/REMOTE_ASSIST.md)。
43
+ | Your Infrastructure, Your Control | Built for Real-World Development |
44
+ | --- | --- |
45
+ | **Self-Hosted Control Plane**: Run the Server, embedded SQLite database, and audit trail on your own VPS or local network. | **45 Built-In MCP Tools**: Project discovery, batch line-range reads, fuzzy unified diffs, journaled multi-file edits, persistent shell sessions, and LSP navigation/diagnostics. |
46
+ | **Outbound-Only Runners**: Connect Linux and Windows machines over authenticated `WSS` without port forwarding or inbound exposure. | **Observable Process Jobs**: Short commands return inline; long tasks support waiting, rolling output tails, standard input, and process-tree termination. |
47
+ | **Two-Layer Permissions**: Combine per-device capability limits with per-client OAuth / token scopes, plus temporary minute-level elevation. | **Safe Git Workflows**: Inspect status and diffs, commit explicit file paths without disturbing unrelated staged changes, and gate `fetch` / `pull` / `push` separately. |
41
48
 
42
- ## 为什么使用 HomeAgent
49
+ ## Architecture
43
50
 
44
- | 自己的机器,自己的控制权 | 面向日常开发 |
45
- | --- | --- |
46
- | **自托管中继**:Server、SQLite 和审计记录部署在自己的服务器或局域网。 | **文件与代码编辑**:35 个工具覆盖项目上下文、批量按行读取、搜索、严格 diff 和多文件编辑。 |
47
- | **Runner 主动连接**:通过认证的 WebSocket 通道接入,支持 Linux / Windows。 | **可观察的任务**:短命令直接返回,长任务可等待、读取输出、停止,并保留执行记录。 |
48
- | **按项目授权**:管理设备、客户端、只读或完整开发权限,支持临时提权与到期收回。 | **完整 Git 流程**:查看差异、按文件安全提交,以及独立控制的 fetch / pull / push。 |
51
+ ```mermaid
52
+ flowchart TB
53
+ Clients["Claude / ChatGPT / Cursor"] -->|"HTTPS · Streamable MCP · OAuth / Bearer"| Server["HomeAgent Server"]
54
+ Server --- Console["Web Dashboard · SQLite · Audit Log"]
55
+ Runner["Linux / Windows Runner"] -->|"Outbound · WSS"| Server
56
+ Runner --- Files["Project Files & Atomic Edits"]
57
+ Runner --- Commands["Supervised Local Processes"]
58
+ Runner --- Git["Controlled Git Workflows"]
59
+ ```
60
+
61
+ - **Protocol Compatibility**: Built on the official MCP SDK v2 (`Streamable HTTP` at `/mcp`), supporting both `2026-07-28` discovery/envelopes and `2025` legacy protocol clients.
62
+ - **Authentication**: Supports Web Dashboard sign-in via admin password or [XAuth](https://github.com/jhxxr/XAuth) OIDC (binding the first XAuth account as the sole administrator), plus OAuth 2.1 authorization-code flow with `S256` PKCE, scoped Personal Access Tokens (`Bearer`), and one-time browser or pairing-code device enrollment.
63
+ - **Release Scope**: Current release **v0.4.19** supports a single administrator and multiple devices/projects. Persistent interactive PTY shells, detached jobs surviving runner replacement, automatic worktree registration, and preview tunnels are intentionally out of scope.
49
64
 
50
- ## 界面预览
65
+ ## Interface Preview
51
66
 
52
- 运行总览以「客户端 → MCP Server → Runner」展示开发网络,汇总任务、权限提醒、审计活动与日志。设备搜索、状态筛选、操作确认、项目权限和任务输出仍保留在对应管理视图中。
67
+ The Web Dashboard maps **AI Clients → MCP Server → Runners** in a live topology view and consolidates active jobs, permission alerts, and audit events.
53
68
 
54
- ![HomeAgent 大屏控制台:客户端、MCP Server 与 Runner 拓扑,以及任务、权限与审计概览](docs/screenshots/dashboard.png)
69
+ ![HomeAgent widescreen Dashboard: live client-to-MCP-to-Runner topology, jobs, permissions, and audit stream](docs/screenshots/dashboard.png)
55
70
 
56
- 截图由真实浏览器生成,使用本地隔离环境中的演示设备与项目,非生产数据;统计以当前返回的审计样本为准。
71
+ *Screenshots are rendered in a real browser against an isolated local demo environment. The current Web Dashboard UI text is in Simplified Chinese.*
57
72
 
58
73
  <details>
59
- <summary><strong>查看手机布局</strong></summary>
74
+ <summary><strong>View mobile topology layout</strong></summary>
60
75
 
61
- 手机端保留「客户端 → MCP Server → Runner」同屏动态拓扑,通过紧凑节点、环形刻度和调用连线呈现开发网络;点击节点打开完整设置,其他功能通过顶部分段导航访问。
76
+ On mobile screens, a compact topology keeps clients, the central MCP Server, and Runners on a single screen with live call paths and activity indicators. Tap any node to inspect or edit its settings.
62
77
 
63
- <img src="docs/screenshots/dashboard-mobile.png" width="360" alt="HomeAgent 手机控制台:客户端、中央 MCP 与 Runner 同屏连接的动态拓扑">
78
+ <img src="docs/screenshots/dashboard-mobile.png" width="360" alt="HomeAgent mobile Dashboard: compact live client-to-MCP-to-Runner topology">
64
79
 
65
80
  </details>
66
81
 
67
82
  <details>
68
- <summary><strong>查看设备权限设置与任务输出</strong></summary>
83
+ <summary><strong>View device permissions &amp; job output views</strong></summary>
69
84
 
70
- **设备权限** · 在网页中配置项目目录、访问档位、Git 开关和授权时长。
85
+ **Device Permissions** · Configure project directories, access presets, command allowlists, Git switches, and temporary grant durations directly in the browser.
71
86
 
72
- ![设备权限设置:项目目录、完整开发与 Git 权限](docs/screenshots/permissions.png)
87
+ ![Device permission settings: project paths, development access, and Git permissions](docs/screenshots/permissions.png)
73
88
 
74
- **任务与输出** · 筛选任务状态、查看执行记录并读取命令输出。
89
+ **Jobs & Output** · Filter running or completed jobs, inspect execution metadata, and read bounded command output.
75
90
 
76
- ![任务管理:执行记录与测试输出](docs/screenshots/jobs.png)
91
+ ![Job management: execution records and test output](docs/screenshots/jobs.png)
77
92
 
78
93
  </details>
79
94
 
80
- ## 工作原理
81
-
82
- ```mermaid
83
- flowchart TB
84
- Clients["Claude / ChatGPT / Cursor"] -->|"HTTPS · MCP · OAuth / Token"| Server["HomeAgent Server"]
85
- Server --- Console["Web Dashboard · SQLite · 审计"]
86
- Runner["Linux / Windows Runner"] -->|"主动连接 · WSS"| Server
87
- Runner --- Files["项目文件与代码编辑"]
88
- Runner --- Commands["本地命令与任务"]
89
- Runner --- Git["Git 工作流"]
90
- ```
91
-
92
- 使用 MCP 官方 SDK v2,提供 Streamable HTTP `/mcp`,支持 2026-07-28 discovery/envelope 与 2025 协议兼容;认证包括 OAuth 授权码流程、S256 PKCE、限权 Bearer Token 和一次性设备配对。
95
+ ## Quick Start
93
96
 
94
- ## 快速开始
97
+ HomeAgent is published as two separate npm packages:
95
98
 
96
- Server 和 Runner 已拆成两个 npm 包,分别安装在中继服务器和需要被操作的开发机器上:
99
+ | Component | npm Package | CLI Command | Where to Install |
100
+ | --- | --- | --- | --- |
101
+ | **Server & Web Dashboard** | `homeagent-server` | `homeagent-server` | Your VPS, homelab server, or local machine |
102
+ | **Outbound Runner** | `homeagent-runner` | `homeagent` | Each Linux or Windows development machine |
97
103
 
98
- | 组件 | npm 包 | 命令 |
99
- | --- | --- | --- |
100
- | Server / Web Dashboard | `homeagent-server` | `homeagent-server` |
101
- | Runner | `homeagent-runner` | `homeagent` |
102
-
103
- | 场景 | 部署方式 |
104
+ | Deployment Scenario | Recommended Approach |
104
105
  | --- | --- |
105
- | Linux 服务器长期运行 | Docker Compose + 自有域名 + Caddy 自动 HTTPS |
106
- | 已有 Node.js 环境,或先在本机试用 | npm 安装,运行 `homeagent-server` |
107
- | 已有 Nginx / Caddy | Server 监听回环地址,由现有反向代理提供 HTTPS |
106
+ | Public Linux server (24/7) | Docker Compose + custom domain + automatic Caddy HTTPS |
107
+ | Local trial or existing Node.js host | Global npm install (`homeagent-server`) |
108
+ | Existing Nginx / Caddy reverse proxy | Bind Server to `127.0.0.1:3210` behind your proxy |
108
109
 
109
- 部署顺序:**启动 Server → 打开 Dashboard → 安装并配对 Runner → 在 AI 客户端连接 `/mcp`**。Server 使用内置 SQLite,无需额外安装数据库。
110
+ Follow this sequence: **1. Deploy the Server → 2. Pair a Runner → 3. Connect an AI Client**.
110
111
 
111
- ### 1. 部署 Server
112
+ ### 1. Deploy the Server
112
113
 
113
- **方式 A:Docker Compose + Caddy,适合 Linux 公网服务器。**
114
+ #### Option A: Docker Compose with Caddy (Recommended for a Linux VPS)
114
115
 
115
- 准备 Docker Engine、Compose v2 和 Git,将自己的域名解析到服务器,并放行 TCP 80/443。下面以 `mcp.example.com` 为例,执行前替换成自己的域名。
116
+ Requires Docker Engine, Docker Compose v2, and Git. Point your domain's DNS record to the server and open inbound TCP ports `80` and `443`. Replace `mcp.example.com` below with your own domain:
116
117
 
117
118
  ```sh
118
- git clone --branch v0.4.15 --depth 1 https://github.com/jhxxr/HomeAgent.git
119
+ git clone --branch v0.4.19 --depth 1 https://github.com/jhxxr/HomeAgent.git
119
120
  cd HomeAgent
120
121
 
121
- # 用容器生成随机密码和会话密钥,无需在宿主机安装 Node.js
122
+ # Generate random ADMIN_PASSWORD and SESSION_SECRET in .env without installing Node.js on the host
122
123
  docker run --rm --user "$(id -u):$(id -g)" \
123
124
  -v "$PWD:/work" -w /work \
124
125
  node:24.22.1-bookworm-slim node scripts/init.mjs
125
126
  ```
126
127
 
127
- 编辑刚生成的 `.env`,保留随机生成的 `ADMIN_PASSWORD` 和 `SESSION_SECRET`,修改或添加:
128
+ Edit `.env`—keep the generated `ADMIN_PASSWORD` and `SESSION_SECRET`, and set your public domain:
128
129
 
129
130
  ```dotenv
130
131
  PUBLIC_URL=https://mcp.example.com
@@ -132,155 +133,201 @@ DOMAIN=mcp.example.com
132
133
  TRUST_PROXY_HOPS=1
133
134
  ```
134
135
 
136
+ Build and start the stack:
137
+
135
138
  ```sh
136
139
  docker compose --profile proxy up -d --build
137
140
  docker compose --profile proxy ps
138
- docker compose logs --tail=100 server
139
141
  curl --fail https://mcp.example.com/health
140
142
  ```
141
143
 
142
- Caddy 自动申请证书并代理 HTTP/WebSocket。打开 `https://mcp.example.com`,使用 `.env` 中的 `ADMIN_PASSWORD` 登录 Dashboard。Server 端口 `3210` 默认只映射到宿主机 `127.0.0.1`,不需要向公网开放;镜像从源码在本机构建,没有预发布镜像要求。
144
+ Caddy automatically provisions TLS certificates and proxies HTTP and WebSocket traffic. Open `https://mcp.example.com` and sign in with `ADMIN_PASSWORD` from `.env`. Port `3210` binds only to `127.0.0.1` on the host, and SQLite data persists in the `server-data` Docker volume. See the [Deployment Guide](docs/DEPLOYMENT.md) for backups, upgrades, and custom Nginx setups.
143
145
 
144
- SQLite 保存在 `server-data` 命名卷,Compose 配置了 `restart: unless-stopped`。升级前备份数据库和 `.env`;保留 `SESSION_SECRET`,不要用 `docker compose down --volumes` 作为普通重启命令。备份、恢复和已有 Nginx 的配置见 [部署文档](docs/DEPLOYMENT.md)。
146
+ #### Option B: Native via npm (Linux, Windows, or Local Trial)
145
147
 
146
- **方式 B:npm 原生运行,适合 Linux / Windows 本机试用或已有 Node.js 的服务器。**
147
-
148
- 需要 Node.js 24(最低 24.14.0,仓库固定的验证补丁版见 `.nvmrc`)和 npm。以下命令可在 Linux shell 或 Windows PowerShell 中执行:
148
+ Requires **Node.js >= 24.14.0** (see `.nvmrc` for the pinned verification version) and npm. Run in a Linux shell or Windows PowerShell:
149
149
 
150
150
  ```sh
151
151
  npm install -g homeagent-server@latest
152
- mkdir homeagent-server
153
- cd homeagent-server
152
+ mkdir homeagent-server && cd homeagent-server
154
153
  homeagent-server init
155
154
  homeagent-server
156
155
  ```
157
156
 
158
- 本机访问 `http://localhost:3210`,管理员密码在当前目录 `.env` 的 `ADMIN_PASSWORD` 中;初始化命令不打印密码,也不会覆盖已有配置。数据库默认位于当前目录的 `data/server.sqlite`。
159
-
160
- 公网部署时,先将 `.env` 的 `PUBLIC_URL` 改成固定 HTTPS 域名;一层可信反向代理时设 `TRUST_PROXY_HOPS=1`,再由 Nginx/Caddy 代理到 `127.0.0.1:3210`。`homeagent-server` 在前台运行,并从**当前工作目录**读取 `.env`;长期运行需配置服务管理器。Linux systemd 示例见 [原生 Server 部署](docs/DEPLOYMENT.md#原生部署-server)。
157
+ - **Local Access**: Open `http://localhost:3210` and sign in using the `ADMIN_PASSWORD` written to `.env` in the current working directory. SQLite data is stored at `data/server.sqlite`.
158
+ - **Public Access**: Set `PUBLIC_URL=https://mcp.example.com` and `TRUST_PROXY_HOPS=1` in `.env`, then reverse-proxy traffic to `127.0.0.1:3210`. Use `systemd` or a process manager for background execution (see [Native Server Deployment](docs/DEPLOYMENT.md#native-server-deployment)).
161
159
 
162
- ### 2. 安装并配对 Runner
160
+ ### 2. Install & Pair a Runner
163
161
 
164
- 在需要被 AI 操作的开发机器上安装 Node.js 24、npm;Git 工具还需要本机 Git。日常使用只需一个入口:
162
+ On the development machine you want to connect, install **Node.js >= 24.14.0**, npm, and `git`:
165
163
 
166
164
  ```sh
167
165
  npm install -g homeagent-runner@latest
168
166
  homeagent
169
167
  ```
170
168
 
171
- 未登录时也会进入全屏欢迎页,提示“尚未登录”。按 Enter 填写 Web URL 和设备名称,自动生成 `$HOME/.homeagent/runner.json`;等待批准时按 `o` 打开浏览器登录页面,链接有效期为 10 分钟。在网页中核对设备名称、填写被控端的项目名称和目录并批准后,Runner 自动开始连接。也可以稍后在 Dashboard 的“管理设备权限”中添加项目。
169
+ 1. **Interactive Login**: On first launch, the full-screen terminal interface prompts for your Server URL and a device name, creating `~/.homeagent/runner.json`.
170
+ 2. **Browser Approval**: Press `o` to open the 10-minute approval link in your signed-in browser. Verify the device name, enter an initial project directory (e.g., `/home/me/app` or `E:/Projects/my-app`) and optional project name, and approve.
171
+ 3. **Automatic Connection**: Once approved, the Runner connects immediately and remembers its configuration path so you can run `homeagent` from any directory.
172
172
 
173
- **项目目录和权限只由 Server 保存**,本地配置不接受 `projects/root`。本地 `stateDir` 仅用于保存设备凭据和任务状态,不是项目目录。未配置项目时,Runner 不开放任何项目访问。首次项目设置默认永久保存;临时开放可在权限编辑器中另外选择。
173
+ ![HomeAgent Runner TUI with startup card, live connection status, and permission sync logs](docs/screenshots/runner-tui.png)
174
174
 
175
- 项目没有独立的默认目录:旧 `Workspace` 也是普通项目,可修改名称。修改已有项目保留 ID 与授权;删除后新增使用新的 ID,已移除 ID 不能复用。临时未开放、待应用或应用失败的项目会在客户端权限编辑器中标明状态,原有明确项目授权保留,直到主动取消;这不会让暂不可用项目获得执行访问。
175
+ *Terminal output from an isolated demo environment. Interactive shells open the responsive full-screen Runner TUI; services, piped output, and `homeagent run --plain` emit standard line-based logs.*
176
176
 
177
- ```sh
178
- # 以后仍使用同一个入口,自动检查登录并连接:
179
- homeagent
180
- ```
177
+ - **TUI Shortcuts & Mouse Support**: Press `s` for Settings (device name, concurrency limits, config file, Server switching, autostart, logout), `a` for Activity, `o` to open the Dashboard, `p` to pause/resume, `m` to toggle SGR mouse tracking (or set `HOMEAGENT_MOUSE=0`), and `q` or `Ctrl+C` to exit cleanly.
178
+ - **Autostart Service**: Open Settings (`s`) and select **Enable autostart** (or run `homeagent service-install` while stopped) to install a Linux user `systemd` service or a Windows login scheduled task.
179
+ - **Server-Owned Policies**: Project directories, command allowlists, environment profiles, and Git write flags are managed centrally on the Server—never hardcoded in local `runner.json`. Command execution and Git writes are disabled by default until enabled in the Dashboard.
181
180
 
182
- Runner 自动记录成功登录或启动时的配置位置,切换工作目录后仍可直接使用 `homeagent`。按 `s` 打开设置,可以修改设备名称、并发数、任务输出上限和历史记录数,重新登录或切换服务,选择配置文件、启停自启动和退出登录。需要重连或替换凭据的操作会先显示确认。按 `a` 浏览活动,`o` 打开网页,`p` 暂停或恢复连接,Esc 返回,`q` 或 Ctrl+C 退出。
181
+ ### 3. Connect an AI Client
183
182
 
184
- 支持 SGR 鼠标协议的终端可直接点击登录入口、底部按钮和菜单项,使用滚轮浏览长菜单与活动记录,点击输入框定位光标。鼠标经过可点击区域时显示灰蓝色底纹,按下时加深为蓝色,移开恢复原样;单色界面使用反色反馈。按 `m`(输入框以外)或点击“鼠标开/关”切换鼠标模式,关闭后可选择和复制终端文本;设置环境变量 `HOMEAGENT_MOUSE=0` 可默认关闭鼠标。粘贴到输入框的内容按文字处理,不会触发快捷键或自动提交。键盘操作始终可用。
183
+ | Endpoint | Public Deployment Example | Notes |
184
+ | --- | --- | --- |
185
+ | **Web Dashboard** | `https://mcp.example.com` | Admin sign-in, device/client permissions, jobs, and audit logs |
186
+ | **MCP Client URL** | `https://mcp.example.com/mcp` | Streamable HTTP endpoint for Claude, ChatGPT, Cursor, etc. |
187
+ | **Runner `server` URL** | `https://mcp.example.com` | Base origin without `/mcp` |
188
+ | **Health Check** | `https://mcp.example.com/health` | Returns `version` and `runnerProtocol` |
185
189
 
186
- 也可通过 `homeagent --config <路径>` 选择配置。查找顺序仍是显式路径、已记录路径、`~/.homeagent/runner.json`;路径失效时在全屏界面中重新选择,不会静默切换设备。脚本和服务继续兼容 `login`、`run`、`check-config`、`service-install` 和 `service-uninstall` 子命令。
190
+ - **OAuth 2.1**: Point your MCP client to `https://mcp.example.com/mcp` and approve the requested device, project, and scope permissions in your browser.
191
+ - **Personal Access Token (`Bearer`)**: Issue a scoped token (`read`, `write`, `execute`, `git`) in the Dashboard and configure your client with `Authorization: Bearer <token>`.
192
+ - **Version Alignment**: Keep `homeagent-server` and `homeagent-runner` on the same release (`v0.4.19`). Check versions anytime with `homeagent-server --version`, `homeagent --version`, or in the Dashboard header.
193
+ - **Client Guides**: See [Connecting AI Clients](docs/CLIENTS.md) for step-by-step instructions across Claude, ChatGPT, Cursor, and the MCP SDK.
187
194
 
188
- 交互式终端启动时会进入全屏 Runner 界面,暂时隐藏此前的命令和输出,显示应用图标、设备与 Server、最近活动和实时连接状态。窗口缩放时自动调整布局,按 `Ctrl+C` 停止后恢复原终端画面。服务、管道输出或使用 `homeagent run --plain` 时保留普通日志,方便 systemd、计划任务和脚本采集。
195
+ ## AI Prompting Guide
189
196
 
190
- ![HomeAgent Runner TUI:启动卡片、实时连接状态和权限同步日志](docs/screenshots/runner-tui.png)
197
+ Once your AI client (ChatGPT, Claude, Cursor, etc.) is connected to `/mcp`, follow this workflow to drive remote development safely and efficiently.
191
198
 
192
- *v0.4.11 的启动卡片(全屏改版前):隔离演示环境中的实际终端输出,设备与目录均为演示数据。*
199
+ ### How to Instruct the AI
193
200
 
194
- Windows 的项目根目录可在网页中填为 `E:/Projects/my-app`。Runner 配置和 stateDir 都必须位于所有暴露项目之外。本地只维护连接信息、设备凭据和任务状态。
201
+ 1. **Check Permissions First**: Before prompting, verify in the Dashboard that both the **Device Project Policy** and the **Client Grant** allow the required scopes (`read` for inspection, `write` for editing files, `execute` plus command aliases/allowlists for running tests, and `git` for commits).
202
+ 2. **Start with Discovery**: Always ask the AI to call `list_devices` and `get_project_context` first. This tells the AI your exact `deviceId`, `projectId`, active Git branch/HEAD, configured command aliases (such as `test`, `npm`, `python`), and any handoff notes from previous sessions.
203
+ 3. **Require Hash-Verified Edits & Safe Commits**: HomeAgent tools use full-file SHA-256 preconditions (`expectedSha256`) and explicit path commits (`git_commit_paths`) so the AI never blindly overwrites concurrent local edits or sweeps unrelated staged files into a commit.
195
204
 
196
- 需要自启动时,在设置中选择“启用自启动”,确认后会先关闭前台连接,再由后台 Runner 接管。Linux 安装用户 systemd 服务;Windows 安装当前用户登录时启动的计划任务。安装时固定使用当前配置路径。高级用法仍可停止前台 Runner 后执行 `homeagent service-install`。
205
+ ### Ready-to-Use Prompt Templates
197
206
 
198
- 默认不允许执行命令或 Git 写入。需要这些能力时,在 Dashboard 的设备权限中开启,并给客户端对应 scope。命令别名、环境 profile 和 linked worktree 目录同样在网页设备权限中配置。清空项目或断线后会收回全部项目访问;Server 与 Runner 应升级到相同版本。完整示例见 [日常开发工作流](docs/DEVELOPMENT_WORKFLOW.md)。
207
+ Copy and paste any of the templates below into your AI client, replacing the bracketed placeholders (like `[my-workstation]` or `[my-app]`) with your actual device, project, and task.
199
208
 
200
- ### 3. 连接 AI 客户端
209
+ #### 1. Feature Development / Bug Fix (Full Workflow)
201
210
 
202
- | 用途 | 公网部署示例 |
203
- | --- | --- |
204
- | Dashboard | `https://mcp.example.com` |
205
- | AI 客户端 MCP 地址 | `https://mcp.example.com/mcp` |
206
- | Runner 配置的 `server` | `https://mcp.example.com`,不要加 `/mcp` |
207
- | 健康检查 | `https://mcp.example.com/health`,返回 `version` 与 `runnerProtocol` |
211
+ ```text
212
+ Use the HomeAgent MCP tools to work on my remote project:
213
+ - Target device: [my-workstation] (call list_devices first to find the exact deviceId and projectId for [my-app])
214
+ - Task: [Describe the feature to build or bug to fix, e.g., "Fix the pagination off-by-one error in the user list API and add unit tests"]
215
+
216
+ Please follow this exact workflow:
217
+ 1. Call list_devices and get_project_context to inspect the repository state, current Git branch/HEAD, available commandAliases, and any previous handoff notes.
218
+ 2. Use search_files and read_files (with line ranges) to locate and read the relevant code. Keep the returned full-file sha256 hashes.
219
+ 3. Propose your changes and apply them using edit_files or apply_unified_diff with the exact expectedSha256 values.
220
+ 4. Run the test suite via run_command using the configured command alias or executable. If the job stays running, poll with wait_process (and tail_process_output if needed) rather than starting duplicate processes.
221
+ 5. Show me the git_diff summary and test results. Wait for my confirmation before calling git_commit_paths, and finish by saving a brief progress summary with save_project_note.
222
+ ```
208
223
 
209
- 版本核对:`homeagent-server --version` 和 `homeagent --version` 会打印版本、Node 与平台;`homeagent check-config` 也会列出 Runner 版本。Dashboard 顶部、页脚和“连接与安全 → 版本信息”显示 Server 版本,以及每台 Runner 上报的版本和一致性提示。升级时 Server 与 Runner 应保持同一版本。
224
+ #### 2. Read-Only Code Review & Troubleshooting
210
225
 
211
- 客户端可通过 OAuth 连接,在浏览器确认设备和项目权限;也可在 Dashboard 为已配对设备创建客户端令牌,选择 `read / write / execute / git` scope,再以 Bearer token 连接。令牌仅展示一次,设备凭据不能代替客户端令牌。
226
+ ```text
227
+ Connect via HomeAgent MCP to project [my-app] on device [my-workstation] in read-only mode:
228
+ 1. Call list_devices and get_project_context to check the project structure, recent git_log, and git_status.
229
+ 2. Use search_files and read_files to trace how [specific module / endpoint / error] is implemented.
230
+ 3. Do not modify any files or run any commands—summarize the root cause, point out the exact file paths and line numbers, and propose a concrete fix plan for my review.
231
+ ```
212
232
 
213
- 本机验证时地址换成 `http://localhost:3210`;远程必须使用固定 HTTPS origin,不支持将 Server 挂在某个 URL 子路径下。各客户端配置见 [AI 客户端连接](docs/CLIENTS.md)。
233
+ #### 3. Resume Work from a Previous Session (Handoff Continuity)
214
234
 
215
- ### 从源码开发
235
+ ```text
236
+ Connect to project [my-app] on device [my-workstation] via HomeAgent MCP:
237
+ 1. Call list_devices and get_project_context, and read the saved project handoff note, current git_status, git_diff, and list_processes.
238
+ 2. Summarize what was completed in the previous session, whether any background job is still running or finished, and what remains to be done.
239
+ 3. Continue with the next step: [describe the next task or say "proceed with the remaining items in the project note"].
240
+ ```
216
241
 
217
- 需要修改源码时再选择此方式;日常安装使用上面的 npm 包或 Compose:
242
+ #### 4. Autonomous Fix-Test-Commit Loop
218
243
 
219
- ```sh
220
- git clone https://github.com/jhxxr/HomeAgent.git
221
- cd HomeAgent
222
- npm ci
223
- npm run build
224
- npm run init
225
- npm run server
244
+ ```text
245
+ On device [my-workstation], project [my-app], run the test suite via HomeAgent's run_command tool and fix any failing tests:
246
+ 1. Call get_project_context to see the configured test command alias and current Git HEAD.
247
+ 2. Run the tests with run_command (use wait_process if needed) and inspect failures with read_files.
248
+ 3. Patch the code with edit_files using expectedSha256 and re-run the tests until they pass.
249
+ 4. Once all tests pass, verify changes with git_diff, commit only the files you modified using git_commit_paths (preserving any unrelated staged files), and record a summary with save_project_note.
226
250
  ```
227
251
 
228
- 源码 Runner 使用 `npm run runner -- login` 和 `npm run runner -- run`,配置及配对流程相同。
252
+ ## Remote Assist
229
253
 
230
- ## 已实现的工具
254
+ Need a collaborator or teammate's AI agent to help debug a machine without giving them admin credentials or permanent access?
231
255
 
232
- | 类别 | 工具 |
233
- | --- | --- |
234
- | 发现与接续 | `list_devices`, `get_project_context`, `save_project_note` |
235
- | 文件 | `list_directory`, `read_file`, `read_files`, `write_file`, `create_directory`, `move_file`, `get_file_info`, `search_files`, `edit_block`, `edit_files`, `apply_unified_diff`, `get_edit_transactions`, `recover_edit_transaction` |
236
- | 终端 | `start_process`, `run_command`, `wait_process`, `read_process_output`, `tail_process_output`, `write_process_input`, `list_processes`, `stop_process` |
237
- | Git | `git_status`, `git_diff`, `git_log`, `git_add`, `git_commit`, `git_commit_paths`, `git_branches`, `git_switch_branch`, `git_fetch`, `git_pull`, `git_push` |
238
-
239
- 所有机器工具使用 `projectId`。多台有权限的设备同时在线时必须指定 `deviceId`,防止误操作另一台机器。进程使用任务 UUID,由启动它的客户端主体和项目共同拥有,不接受任意系统 PID。
256
+ 1. **Create an Invitation**: In the Dashboard (**Devices & Projects → Invite a Friend**), generate a 10-minute one-time invitation bound to an existing client authorization.
257
+ 2. **Run Locally**: The device owner runs the copied command on their machine:
258
+ ```sh
259
+ homeagent assist "https://mcp.example.com/assist#id=...&token=..."
260
+ ```
261
+ 3. **Explicit Local Consent**: In their local terminal, the device owner selects **1–16 project directories**, per-project read/write/executable allowlists, and a shared time limit (30m / 2h / 8h).
262
+ 4. **Instant Revocation**: Access starts only after local approval and terminates immediately on local stop, exit, expiration, or disconnect. See the [Remote Assist Guide](docs/REMOTE_ASSIST.md).
240
263
 
241
- Dashboard 可查看任务状态、输出和停止执行;Server 仅保存有界任务元数据,输出保留在 Runner。`start_process` 可提供稳定 `idempotencyKey`,避免不确定响应后的重试再次执行。同一 stateDir 的 Runner/配对进程互斥;Windows 用 Job Object、Linux 用进程组管理子孙进程。
264
+ ## MCP Tools
242
265
 
243
- v0.3 以日常开发为重点:短命令同步返回、长任务等待、环形尾部日志、本机命令别名/环境配置、按行批量读取、带恢复日志的多文件编辑与严格 Diff,以及保留用户其他暂存内容的指定文件提交。完整调用顺序、配置和边界见 [日常开发工作流](docs/DEVELOPMENT_WORKFLOW.md)。
266
+ ### 45 Built-In Tools
244
267
 
245
- ### Web 权限管理
268
+ | Category | Tools |
269
+ | --- | --- |
270
+ | **Discovery & Handoff** | `list_devices`, `get_project_context`, `save_project_note` |
271
+ | **Files & Code Editing** | `list_directory`, `read_file`, `read_files`, `write_file`, `create_directory`, `move_file`, `get_file_info`, `search_files`, `edit_block`, `edit_files`, `apply_unified_diff`, `get_edit_transactions`, `recover_edit_transaction` |
272
+ | **LSP & Code Intelligence** | `lsp_document_symbols`, `lsp_workspace_symbols`, `lsp_definition`, `lsp_references`, `lsp_hover`, `lsp_diagnostics` |
273
+ | **Processes & Persistent Shells** | `start_process`, `run_command`, `wait_process`, `read_process_output`, `tail_process_output`, `write_process_input`, `list_processes`, `stop_process`, `start_shell`, `run_shell`, `list_shells`, `stop_shell` |
274
+ | **Git Workflow** | `git_status`, `git_diff`, `git_log`, `git_add`, `git_commit`, `git_commit_paths`, `git_branches`, `git_switch_branch`, `git_fetch`, `git_pull`, `git_push` |
246
275
 
247
- v0.4 的权限分为两层,最终能力取设备上限与客户端授权的交集:
276
+ Every machine tool targets an explicit `projectId` (and requires `deviceId` whenever multiple authorized devices are online). Processes are tracked by job UUIDs owned by the initiating client principal and project—never arbitrary OS PIDs—and supervised via Linux process groups or Windows Job Objects. See [Development Workflow](docs/DEVELOPMENT_WORKFLOW.md) and [Tool Reference](docs/TOOLS.md).
248
277
 
249
- - **设备权限**:在 Dashboard 为每个项目设置项目目录或设备范围文件访问、命令 allowlist 或任意程序、Git 本地写入、fetch/pull 网络访问和单独的 push 权限。
250
- - **客户端权限**:修改已有 PAT 或 OAuth 授权的设备、项目、scope、具体工具,以及“目录外文件”和“任意程序”高级开关,不需要重新复制凭据。
251
- - **临时开放**:设备和客户端权限都可设置分钟级有效期;到期会停止相关托管任务并恢复原权限。权限 revision 冲突会被拒绝,避免覆盖他人的更新。
278
+ ### Two-Layer Web Permissions
252
279
 
253
- 任意程序仍以 Runner 运行账户的权限执行,不会自动获得管理员或 root 权限。设备权限修改会取消在途调用并停止托管任务,已经产生的文件修改不会自动回滚。旧 Runner 无法应用已保存的 Web 覆盖,升级 Server 和 Runner 到同一 `0.4.x` 后再使用。
280
+ Effective access is always the intersection of **Device Capability Limits ∩ Client Authorization**:
254
281
 
255
- ## 文档与项目结构
282
+ - **Device Policy**: Per-project root paths (or explicit device-wide file access), command allowlists (or explicit unrestricted program execution), local Git writes, `fetch`/`pull` network access, and separate `push` authorization.
283
+ - **Client Grants**: Live adjustment of authorized devices, projects, scopes (`read` / `write` / `execute` / `git`), individual tools, and advanced toggles for existing OAuth or PAT credentials—without rotating tokens.
284
+ - **Temporary Elevation**: Grant minute-level temporary permissions on either layer; expiration automatically cancels in-flight calls, stops managed jobs, and restores the baseline policy.
256
285
 
257
- - [文档索引](docs/README.md):按使用、开发、安全与设计资料导航。
258
- - [参考项目对比](docs/COMPARISON.md):源码修订、架构、协议、工具、安全与取舍。
259
- - [WebCodex 逐工具源码审计](docs/WEBCODEX_CODE_AUDIT.md):29 个工具域、192 条声明的逐项映射,已修正缺口和仍未实现的能力;不宣称全量功能对等。
260
- - [架构与技术选型](docs/ARCHITECTURE.md):模块、信任边界、消息协议、持久化及并发。
261
- - [部署与运维](docs/DEPLOYMENT.md):Docker、Caddy、Nginx、可选 Cloudflare Tunnel、配对、自启动、备份恢复。
262
- - [AI 客户端连接](docs/CLIENTS.md):ChatGPT、Claude、Cursor 及 MCP SDK 调试。
263
- - [工具与配置参考](docs/TOOLS.md):调用格式、范围、分页、进程行为和权限。
264
- - [安全模型](SECURITY.md):命令执行的真实权限、默认限制与尚未提供的隔离能力。
265
- - [验证记录](docs/VALIDATION.md):已经执行的验证和未执行的环境验收。
266
- - [日常开发工作流](docs/DEVELOPMENT_WORKFLOW.md):从失败测试到安全提交、断线接续;同时列明仍未实现的交互终端与预览能力。
286
+ ## Project Structure & Documentation
267
287
 
268
288
  ```text
269
- bin/ # npm CLI entry points
289
+ bin/ # CLI entry points for homeagent-server and homeagent
270
290
  src/
271
- shared/ # versioned wire schemas, tool contracts, scopes
272
- server/ # MCP, WS hub, pairing, OAuth, browser auth, SQLite, admin API
273
- runner/ # outbound agent, local policy, files, processes, Git, services
274
- public/ # Dashboard JS/CSS, no CDN or external fonts
275
- deploy/ # Caddy and Nginx examples
276
- scripts/ # secret initialization and SQLite online backup
277
- tests/ # security/tool tests + real SDK/WS/OAuth integration
278
- runtime/ # Windows process-tree supervisor sources
279
- licenses/ # locked runtime dependency license texts
280
- .github/ # Linux/Windows/Docker checks and npm/GitHub Release publishing
291
+ shared/ # Versioned wire schemas, tool contracts, and permission scopes
292
+ server/ # MCP HTTP transport, WebSocket hub, OAuth, pairing, SQLite, admin API
293
+ runner/ # Outbound agent, local policy enforcement, file/process/Git executors, TUI
294
+ public/ # Self-contained Web Dashboard assets (zero CDN or external font dependencies)
295
+ deploy/ # Caddy and Nginx reverse-proxy templates
296
+ scripts/ # Secret initialization, SQLite online backup, and release verification
297
+ tests/ # Security, tool, TUI, and end-to-end MCP/WebSocket/OAuth test suites
298
+ runtime/ # Windows Job Object process-tree supervisor sources
299
+ licenses/ # Locked runtime dependency license notices
281
300
  ```
282
301
 
283
- ## 验证
302
+ *Note: Detailed operational guides in `docs/` are available in both English (canonical, unsuffixed files) and Simplified Chinese (`.zh-CN.md` files), using identical CLI commands and configuration keys across platforms.*
303
+
304
+ | Guide | Description |
305
+ | --- | --- |
306
+ | [Documentation Index](docs/README.md) | Complete documentation overview |
307
+ | [Deployment & Operations](docs/DEPLOYMENT.md) | Docker Compose, Caddy, Nginx, Cloudflare Tunnel, pairing, autostart, and backups |
308
+ | [Connecting AI Clients](docs/CLIENTS.md) | Claude, ChatGPT, Cursor, and MCP SDK setup |
309
+ | [Development Workflow](docs/DEVELOPMENT_WORKFLOW.md) | Command profiles, batch file edits, recovery journals, and workflow boundaries |
310
+ | [Remote Assist Guide](docs/REMOTE_ASSIST.md) | One-time invitations, multi-project local consent, and security considerations |
311
+ | [Tools & Admin Reference](docs/TOOLS.md) | Tool schemas, scopes, pagination limits, and admin endpoints |
312
+ | [Architecture](docs/ARCHITECTURE.md) | Module boundaries, wire protocol, persistence, and concurrency model |
313
+ | [Security Policy](SECURITY.md) | Trust boundaries, execution model, and vulnerability reporting |
314
+ | [Validation Record](docs/VALIDATION.md) | Automated verification coverage and environment scope |
315
+ | [Project Comparison](docs/COMPARISON.md) & [Source Audit](docs/WEBCODEX_CODE_AUDIT.md) | Architectural comparison and tool-by-tool audit against reference systems |
316
+
317
+ ## Development & Verification
318
+
319
+ To build and run from source:
320
+
321
+ ```sh
322
+ git clone https://github.com/jhxxr/HomeAgent.git
323
+ cd HomeAgent
324
+ npm ci
325
+ npm run build
326
+ npm run init
327
+ npm run server
328
+ ```
329
+
330
+ Run the full verification suite before submitting changes:
284
331
 
285
332
  ```sh
286
333
  npm run verify
@@ -288,14 +335,9 @@ npm run notices:check
288
335
  npm audit --omit=dev --audit-level=high
289
336
  ```
290
337
 
291
- 服务端和 Runner 的进程、文件策略是可信组件。目录策略保护内置文件工具;一旦授权通用运行时、shell 或构建工具,命令具有运行账户的实际权限,目录白名单不构成 OS 沙箱。生产环境请用独立低权限账户或只挂载必要目录的容器。项目包含可部署实现与自动化检查,但本地测试通过不等同于独立安全审计或所有客户端、所有平台验收完成。
292
-
293
- ## 贡献与许可证
294
-
295
- 欢迎提交可复现的问题和聚焦的改动,开发方式见 [CONTRIBUTING.md](CONTRIBUTING.md),版本范围见 [CHANGELOG.md](CHANGELOG.md)。安全问题按 [SECURITY.md](SECURITY.md) 私下报告。
296
-
297
- 原始源码使用 [MIT License](LICENSE)。依赖保留自己的许可,见 [第三方声明](THIRD_PARTY_NOTICES.md)。本项目独立开发,不代表 WebCodex、Desktop Commander 或任何 AI 客户端厂商。
338
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for development guidelines and [docs/OPEN_SOURCE.md](docs/OPEN_SOURCE.md) for source archive and dual-package npm release checks.
298
339
 
299
- 发布前执行 [开源与发布检查](docs/OPEN_SOURCE.md)。npm 发布会生成两个包:`homeagent-server` 只包含 Server/Web Dashboard,`homeagent-runner` 只包含 Runner、共享协议和 Windows 辅助程序;两者都采用明确的发布文件白名单。
340
+ ## Security & License
300
341
 
301
- `v0.4.15` 的发布配置会分别生成 `homeagent-server` 和 `homeagent-runner`;本地发布命令不会自动上传 npm 或推送 GitHub。后续发布递增版本,更新版本文件和 changelog 后推送匹配标签;预发布使用 npm `next`,正式版本使用 `latest`。Token 权限、OIDC 切换和重试行为见 [自动发布说明](docs/OPEN_SOURCE.md#github-actions-自动发布)。
342
+ - **Execution Boundary**: Directory policies strictly confine built-in file tools, and Runner state/credentials are always excluded. However, **command allowlists are not an OS sandbox**—once you authorize an interpreter, shell, or build tool, it runs with the OS privileges of the Runner user account. Use a dedicated low-privilege user account, container, or VM when isolating untrusted workloads. See [SECURITY.md](SECURITY.md).
343
+ - **License**: Released under the [MIT License](LICENSE). Third-party runtime dependencies retain their respective licenses in [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md). HomeAgent is an independent open-source project and is not affiliated with WebCodex, Desktop Commander, or any AI client vendor.