---
catalog_id: "R-041"
kind: "repo"
domain: "backend"
domain_label: "后端隐私 / Backend & Infra"
date: "2026-11-27"
title: "generalaction/emdash"
verdict: "无头守护进程 SSH 零中继编排，划清 2.0 商业分叉"
summary: "Local-first 开源桌面多 Agent 编排器（Emdash Classic）：Electron 桌面端直连本地或经 SSH Unix Socket 转发的无头 workspace-server 守护进程（@emdash/wire 协议），零云端代码中继、支持 38 种 Agent（ACP/TUI）并保留明显的 Classic vs Emdash 2.0 商业分叉边界"
summary_en: "Local-first Electron orchestrator linking to a headless workspace-server over local or SSH sockets for 38 agents, before a 2.0 split."
canonical_url: "https://oumuatown.com/repos/generalaction__emdash/"
markdown_url: "https://oumuatown.com/repos/generalaction__emdash.md"
og_image_zh: "https://oumuatown.com/og/zh/R-041.png"
og_image_en: "https://oumuatown.com/og/en/R-041.png"
cite_count: 76
repo: "generalaction/emdash"
github_url: "https://github.com/generalaction/emdash"
commit: "c876989"
tags:
  - "coding-agent-orchestrator"
  - "git-worktree"
  - "ssh-workspace-server"
  - "electron-desktop"
  - "telemetry-audit"
  - "acp-pty-harness"
github_repos:
  - "https://github.com/generalaction/emdash/tree/c876989"
---

# R-041 · generalaction/emdash

> **结论 / Verdict**: 无头守护进程 SSH 零中继编排，划清 2.0 商业分叉
> **EN Summary**: Local-first Electron orchestrator linking to a headless workspace-server over local or SSH sockets for 38 agents, before a 2.0 split.

## Provenance & Evidence

- Primary Repository: https://github.com/generalaction/emdash (@c876989)
- Verified Source Citations (#Lxx): 76
- Web Reader: https://oumuatown.com/repos/generalaction__emdash/

# generalaction/emdash

> 仓库地址：https://github.com/generalaction/emdash · 审计版本：`generalaction/emdash@c876989` · 审计日期：2026-11-27
> 来源文章：[关联文章](../articles/2026-11-27-chendahuang-t3code-telemetry-and-self-hosted-alternatives.md)

## 定位与解决的真问题

- **核心定位与目标用户**：以 **Emdash Classic** 身份维护的跨平台（macOS / Windows / Linux）本地优先开源 Electron 桌面应用，用于在隔离的 Git worktree 中并行调度多款 Coding Agent，并支持通过直连 SSH/SFTP 驱动远端开发机（`README.md#L1-L4,#L36-L65`）。
- **相比常规做法解决的关键痛点**：
  1. **远端开发不依赖第三方云中继**：通过独立可无头运行的 `workspace-server` Node 守护进程与 SSH streamlocal Unix Socket 转发，实现与本地项目完全一致的远程 Git、文件、ACP 与终端体验，代码与对话不经任何官方云端服务器中转（`agents/architecture/workspace-server.md#L1-L18`、`README.md#L68-L70`）。
  2. **多 Agent 协议与配置碎片化**：使用统一插件抽象（38 款 Agent 插件 + 13 款工单/项目管理集成），同时适配结构化 **ACP（Agent Client Protocol）** 与传统 **TUI/PTY + 本地生命周期钩子**，屏蔽 CLI 安装、Trust 弹窗、MCP 透传与会话恢复差异（`packages/core/src/services/agent-plugins/api/plugins/capabilities/acp.ts#L26-L116`、`packages/plugins/src/agents/impl/claude/index.ts#L20-L179`）。

## 技术栈与核心目录结构

- **语言 / 运行时 / 关键依赖**：TypeScript、Node.js `>=24.0.0`（`.node-version` / `package.json#L23-L34`）、pnpm `10.28.2`、Nx `24.0.6`、Electron `45.4.1`（`electron-vite`）、React `19.2`、MobX `6.15`、SQLite + `better-sqlite3` + Drizzle ORM、`@agentclientprotocol/sdk`、`node-pty`、`ssh2`（带补丁 `patches/ssh2@1.17.0.patch`）、Monaco Editor、`@xterm/xterm`、`@parcel/watcher`、`croner`。
- **关键目录树与职责划分**：
  - `apps/emdash-desktop/`：Electron 主进程、本地 Wire Worker 宿主、SSH 连接管理与渲染进程 Workbench（React + MobX + Monaco + xterm）。
  - `apps/workspace-server/`：完全脱离 Electron 的无头 Node 守护进程，通过 Unix Socket 或 stdio 暴露 `@emdash/wire` 协议供远程客户端连接（`apps/workspace-server/src/index.ts#L24-L97`）。
  - `packages/core/`：领域契约与核心运行时原语（ACP 运行时、Git/Files/Terminals/Automations/Workspace Registry、SemVer 协议协商 `@emdash/core/workspace-server` 与排除策略 `exclusion-policy.ts`）。
  - `packages/wire/`：自研 RPC/LiveModel 传输框架，支持进程间与流式传输转发。
  - `packages/plugins/`：内置 38 个 Coding Agent 插件、13 个 Issue/集成连接器（Linear、GitHub、GitLab、Jira 等）及 GitHub/GitLab PR 适配器。
  - `packages/chat-ui/`、`packages/ui/`、`packages/shared/`、`packages/theme/`：跨层共享 Chat 组件、基础 UI、工具与主题系统。

## 核心实现源码级剖析（附文件路径与行号）

1. **去 Electron 化的 `workspace-server` 守护进程与子 Worker 图（`apps/workspace-server/src/index.ts#L24-L147`、`apps/workspace-server/src/gateway/workspace-workers.ts#L92-L200`）**：
   - `workspace-server` 是桌面运行时宿主的无 Electron 等价实现：启动后加载用户 Shell 环境，拉起由 `createWireWorkerHost` 监管的必需子 Worker（`conversations`、`fs-watch`、`terminals`、`resource-usage`、`host-settings`、`scripts`、`acp`、`agent-config`、`workspace-registry`、`automations` 等）及按需懒加载的可选 Worker（`lsp`、`provider-usage`）（`workspace-workers.ts#L108-L200`、`agents/architecture/workspace-server.md#L75-L89`）。
   - 主入口通过 `serveSocket`（默认 `~/.emdash/workspace-server/` 下 `0700` 目录的 Unix Socket，`apps/workspace-server/src/wire/serve-socket.ts#L19-L48`）或 `serveStdio`（`serve-stdio.ts#L10-L15`）直接提供二进制/帧化的 `@emdash/wire` RPC 服务，内部使用 `forwardContractImpl` 聚合转发所有领域契约（`apps/workspace-server/src/api/controller.ts#L29-L99`）。
   - TUI 进程采用 `always` 生命周期策略，桌面断开重连不中断后台 Agent 执行与 Cron 自动化调度（`agents/architecture/workspace-server.md#L90-L98`）。
2. **SSH Streamlocal 隧道、原子安装器与版本协商（`apps/emdash-desktop/src/core/services/hosts/node/workspace-server/connect/ssh-streamlocal-transport.ts#L6-L14`、`apps/workspace-server/install.sh#L1-L160`）**：
   - 桌面端不直接通过 SSH Shell 拼命令执行业务操作，而是先通过 `WorkspaceServerProvisioner`（`provisioner.ts#L130-L160`）探测远端平台（显式拒绝 Windows 远端主机，`#L144-L146`），若未安装或需要更新，则在远端执行固定版本的 `install.sh`（按 SHA-256 校验并原子切换 `~/.emdash/workspace-server/current` 软链，`install.sh#L93-L129`）。
   - 建立连接时通过 `ssh2` 的 `proxy.forwardOutStreamLocal(target.socketPath)` 直连远端 Unix Domain Socket（`ssh-streamlocal-transport.ts#L11-L13`），再执行 `initialize` SemVer 握手（当前 `PROTOCOL_VERSION = '12.2.0'`，`packages/core/src/workspace-server/versions/index.ts#L3,#L33-L64`），按主版本强校验、按 `min(clientMinor, serverMinor)` 降级兼容，并将端口转发探测纳入控制面（`port-forward-tunnel.ts#L57-L118`）。
3. **ACP + TUI/Hooks 双模 Agent 插件架构（`packages/plugins/src/agents/impl/claude/index.ts#L144-L179`、`packages/plugins/src/agents/impl/claude/hooks.ts#L50-L61`）**：
   - 支持结构化对话的插件实现 `acp` 能力（如 Claude 插件通过 `ELECTRON_RUN_AS_NODE=1` 拉起适配器并指向宿主 `claude` 二进制，`claude/index.ts#L146-L162`），由 `AcpRuntime` 的 `SessionCell` / `SessionMaterializer` 持久化非敏感会话意图并保障断线期间 `sendPrompt` 租约不断（`agents/architecture/acp-runtime.md#L9-L179`）。
   - 终端 TUI 模式则由 `hooks` 能力向用户全局配置写入带 `EMDASH_MARKER` 标识的命令行钩子（向本地回环 `$EMDASH_HOOK_PORT` 上报状态），在退出或卸载时按标记精准过滤保留用户自有配置（`claude/hooks.ts#L50-L61`、`codex/hooks.ts#L173-L237`）。

## 服务端自托管与隐私遥测六维审计

### 1. 无头 Linux Server / VPS 部署可行性
- **Backend 可无头长驻，但绝非独立 Web 服务**：`apps/workspace-server` 可以在无图形界面的 glibc Linux（x64/arm64）VPS 上作为纯后台守护进程独立安装与运行（支持 `start` / `stop` / `status` / `serve` 子命令，`apps/workspace-server/src/index.ts#L31-L47`、`install.sh#L67-L88`）。
- **核心架构限制**：`workspace-server` 仅监听 **Unix Domain Socket 或 stdio** 并只讲 `@emdash/wire` RPC 协议，仓库中**完全没有 HTTP 静态资源服务或自托管 Web UI**（`serve-socket.ts#L19-L48`、`serve-stdio.ts#L10-L15`）。若想操纵 VPS 上的会话，本地仍必须运行 `apps/emdash-desktop` Electron 客户端通过 SSH 隧道接入（不支持在浏览器里直接打开 VPS 页面，这一点与 T3 Code 的纯 Web 架构有本质区别）。

### 2. 远程控制面与供应商中继依赖
- **数据面零中继**：远端控制完全走用户自己的 SSH 通道（支持 ssh-agent、密钥、口令及 OpenSSH 证书，凭据存操作系统钥匙串，`README.md#L60-L62`），不存在类似 Paradev 的云端 Relay 服务器或 Cloudflare Durable Objects。
- **仅剩的三个官方域名触点与 Classic vs Cloud 分叉**：
  1. **远端守护进程分发源**：桌面端默认从 `https://releases.emdash.sh/workspace-server` 下载 `install.sh` 与二进制包，但提供了明确的环境变量覆盖 `EMDASH_WORKSPACE_SERVER_ARTIFACTS_URL`（`apps/emdash-desktop/src/core/services/hosts/node/settings.ts#L10-L14`、`install.sh#L4`），可完全指向私有对象存储（开发文档中即以 MinIO 示例验证）。
  2. **可选 OAuth 账号代理**：集成登录（`EmdashAccountService`）连接认证服务；虽然代码允许开发模式用 `EMDASH_AUTH_SERVER_URL` 覆盖，但**打包后的生产构建强制锁定为 `https://auth.emdash.sh`**（`apps/emdash-desktop/src/core/features/account/node/config.ts#L1-L23`），且该服务仅在用户主动登录 Emdash 账号时触发，本地 Git/Agent 工作流不依赖它。
  3. **Emdash Classic vs Emdash 2.0 商业分叉**：`README.md#L1-L3,#L91` 已将该开源仓库明确界定为单机桌面版 **Emdash Classic**；桌面内嵌的候补名单弹窗 `WaitlistModal`（提交至 `https://emdash.com/api/waitlist`，`waitlist-modal.tsx#L11-L46`、`controller-operations.ts#L5`）清晰揭示：**Web 端、Mobile 端、Slack 触发、团队共享密钥、预算限额（Spend Limits）、预配置云环境与平台 MCP** 均属于尚未在此仓库开源的商业版本 **Emdash 2.0**（`emdash.com`）。

### 3. 遥测（Telemetry）与本地凭证卫生审计
- **PostHog 遥测细节（默认逻辑开启，但自带多重开关与强 PII 清洗）**：
  - 配置解析器 `loadAppConfig`（`apps/emdash-desktop/src/main/bootstrap/core/config.ts#L35-L41`）中 `telemetryEnabled` 默认值为 `'true'`，可通过环境变量 `TELEMETRY_ENABLED=false`（或 `0` / `no`）在启动期强制关闭（`README.md#L76-L78`）。
  - 主进程 `DesktopTelemetryService`（`apps/emdash-desktop/src/main/lib/telemetry.ts#L59-L69,#L347-L388`）在 Vite 开发构建下强制禁用（`!isViteDevBuild`），同时读取构建期注入的 `VITE_POSTHOG_KEY` 与 `VITE_POSTHOG_HOST`（`.github/actions/setup-build/action.yml#L68-L69`）。**若开发者自行从源码编译且未注入密钥，遥测模块自动静默失效**，设置页开关下方也会显式提示 `"Inactive in this build (no PostHog keys)"`（`TelemetryCard.tsx#L49-L53`）。
  - 用户可在设置页直接关闭开关（持久化到 SQLite KV `telemetry:enabled = 'false'`，`telemetry.ts#L514-L517`）；事件属性经过严格白名单 `allowedProps` 清洗并限制字符串长度（`telemetry.ts#L92-L217`），含 5% 会话采样的性能指标 `perf_vitals` 与 PostHog `$exception` 异常堆栈上报（`L480-L491`）。需注意：一旦用户登录 Emdash 账号，`identify` 会向 PostHog 上报 `username`、`$set.email` 及 `github_username`（`L259-L283,#L441-L448`）。
  - **无 Sentry / Axiom / OTel 崩溃上报 SDK**：仓库中出现的 `sentry`、`axiom`、`posthog` 字符串与图标仅用于内置 MCP 目录（`packages/core` / `apps/emdash-desktop/src/core/primitives/mcp/api/catalog.ts#L60-L68,#L571-L579`）和技能图标，未接入任何第三方 APM 或崩溃采集 SDK。
- **本地凭证与配置文件卫生**：
  - **Hook 与 Trust 文件注入**：向 `~/.claude/settings.json` 写入带标识的生命周期 Hook（`claude/hooks.ts#L50-L61`），向 `~/.claude.json` 写入项目信任标记 `hasTrustDialogAccepted: true`（`claude/trust.ts#L7-L37`），向 `~/.codex/config.toml` 写入带 `EMDASH_MARKER` 的 `Stop`/`PermissionRequest`/`SessionStart` Hook 并清理旧版配置（`codex/hooks.ts#L173-L237`）。文档承诺这些 Hook 仅在带 `EMDASH_HOOK_PORT` / `EMDASH_HOOK_NONCE` 的应用内会话生效，外部终端为空操作（`README.md#L51-L53`）。
  - **CLI 令牌导入与隐私保护**：通过 `gh auth status --json hosts --show-token` 显式导入本机 GitHub CLI 认证状态（`github-cli-account-import.ts#L85-L96`）；文件搜索与监听器默认将 `.claude`、`.codex`、`.cursor`、`.emdash` 等 Agent 目录纳入排除列表（`exclusion-policy.ts#L37-L51`）；ACP 意图持久化明确禁止落盘环境变量与 MCP 凭证（`agents/architecture/acp-runtime.md#L164-L165`）。

### 4. 支持的 Agent Harnesses
- **38 款内置 Agent 插件**：`packages/plugins/src/agents/impl/` 下共包含 **38 个实现目录**（包括 `claude`、`codex`、`opencode`、`cursor`、`antigravity`、`amp`、`copilot`、`devin`、`droid`、`jules`、`goose`、`grok`、`hermes`、`kimi`、`kiro`、`letta`、`mistral`、`muse`、`oh-my-pi`、`pi`、`qwen`、`cline`、`continue`、`kilocode`、`rovo` 等）。
- **接入方式**：优先通过 `@agentclientprotocol/sdk` 对接 **ACP**（结构化流式消息、审批与配置选项下发），其余或纯终端偏好场景走 **PTY + Hook** 回调通道，并在 UI 中提供统一的任务与会话视角。

### 5. 与 T3 Code 的 UX 表面对比
| 维度 | Emdash Classic 实际实现 | 源码依据 |
| :--- | :--- | :--- |
| **Desktop GUI** | 原生跨平台 Electron 桌面端（macOS / Windows / Linux x64 & ARM64 全覆盖） | `README.md#L36-L41`、`apps/emdash-desktop/package.json#L38-L41` |
| **Web / Mobile UI** | **缺失**（已剥离至闭源商业版 Emdash 2.0 候补产品） | `waitlist-modal.tsx#L31-L46`、`README.md#L91` |
| **Git Worktrees** | 每任务独立 worktree + `preservePatterns` CoW 拷贝 + `.emdash.json` 生命周期脚本 | `agents/workflows/worktrees.md#L11-L102`、`.emdash.json#L1-L15` |
| **Diff / PR / 工单** | Monaco 编辑器 + 虚拟化 Diff 面板 + GitHub/GitLab PR 审查 + 13 款工单系统直接转任务 | `README.md#L29-L31`、`apps/emdash-desktop/package.json#L62-L67` |
| **Terminal & 预览** | 持久化本地/SSH PTY 终端 + SSH 双栈探测端口转发预览（IPv4/IPv6） | `port-forward-tunnel.ts#L11-L118` |

### 6. 许可证与商业/Open-Core 陷阱
- **纯净 Apache-2.0（无 CLA）**：根目录 `LICENSE.md#L1-L204` 为标准 **Apache License 2.0**（`Copyright 2026 General Action, Inc.`），仓库内未要求签署独立 CLA。
- **Open-Core 产品代际断层（经典版锁定陷阱）**：代码中没有任何 `Paywall` 或订阅付费墙逻辑，开源部分完全免费可用；但商业陷阱在于**架构分叉**：团队协作、Web 控制台、Mobile 端与托管云环境被完整抽离到 `emdash.com` 的闭源 **Emdash 2.0** 中，使得 `generalaction/emdash` 实质定格在“个人单机 Electron + 自备 SSH 服务器”的经典版定位。

## 亮点设计 vs 局限/坑点

- **值得借鉴的设计**：
  - **严格契约化的无头远端守护进程（`@emdash/wire` + SemVer 协商）**：`workspace-server` 通过一条 SSH streamlocal 隧道复用所有领域接口，并通过 `initialize` 协商主次版本，既做到跨桌面版本向后兼容，又避免将 SSH 命令行拼接逻辑散落在业务代码里（`agents/workflows/remote-development.md#L38-L48`）。
  - **可审计的本地优先与白名单遥测**：遥测逻辑集中在一个 `DesktopTelemetryService` 文件中，具备硬环境变量总闸、无密钥自动静默、KV 持久化开关与严格的属性白名单过滤（`telemetry.ts#L59-L217`），对开源用户极度透明友好。
  - **高鲁棒性的生命周期与 CoW Worktree 流水线**：`prepare` → `setup` → `run` 阻塞与异步分离，结合 `cp -c` / `--reflink=auto` 复制 `.env` 等 `preservePatterns` 资产，兼顾新建工作区速度与隔离性（`agents/workflows/worktrees.md#L30-L91`）。
- **局限、隐含假设与潜在坑点**：
  - **不能脱离 Electron 作为纯浏览器服务端使用**：尽管具备成熟的 Linux 后台守护进程 `workspace-server`，但缺失 HTTP/Web UI 入口使其无法像 `t3code` 一样在浏览器或平板中直接打开远程桌面。
  - **生产构建强绑官方 Auth 域名与 Emdash 2.0 生态缺口**：打包版 `auth.emdash.sh` 硬编码不可覆盖（`config.ts#L11-L23`），且需要团队共享、移动审批或浏览器访问的用户无法在开源版内闭环解决。
  - **非标准配置路径与远端 Windows 限制**：Managed `workspace-server` 明确拒绝远端 Windows 主机（`provisioner.ts#L144-L146`），只支持 glibc Linux 与 Apple Silicon macOS 作为远端运行目标。

## 可复用的模块或设计模式

- **如何迁移到未来项目**：
  1. **SSH Streamlocal + 协议协商架构**：在构建任何“本地桌面客户端 + 远程 Linux 算力机”系统时，可直接复用 `ssh-streamlocal-transport` + 远端 Unix Socket 守护进程 + `install.sh` SHA-256 原子切换 + SemVer `agreedMinor` 渐进降级设计，彻底摆脱脆弱的 SSH 文本命令解析。
  2. **透明遥测基础设施**：`DesktopTelemetryService` 的“环境变量强制短路 + 缺省密钥静默 + UI 开关可观测状态 + 属性白名单裁剪”四件套，适合作为开源桌面工具的隐私合规基线模板。
- **关联 Pattern**：[self-hosted-coding-agent-orchestration-and-telemetry-audit](../patterns/self-hosted-coding-agent-orchestration-and-telemetry-audit.md)

## Cross-Referenced Specimens

- [A-010 · T3 Code 默认遥测风波始末与 8 款多智能体编排替代品自托管及隐私边界审计](https://oumuatown.com/articles/2026-11-27-chendahuang-t3code-telemetry-and-self-hosted-alternatives.md) — T3 Code 遥测边界剖析与六款开源编排自托管审计
- [P-017 · 多智能体编程编排器自托管控制面选型与五维遥测凭据隐私审计模式（Self-Hosted Coding-Agent Orchestration & Telemetry Audit）](https://oumuatown.com/patterns/self-hosted-coding-agent-orchestration-and-telemetry-audit.md) — 破除开源即零遥测迷思，确立编排器五维隐私审计与选型铁律
