feat(acp): add session-scoped runtime MCP - #7645
Conversation
E2E / routing verification reportThis PR is protocol infrastructure; the in-process channel loop server is intentionally deferred to the follow-up integration PR.
Live channel-loop tool execution is not expected in this PR because no loop MCP server is registered yet. The follow-up E2E will exercise natural-language loop creation in a daemon-managed channel and verify sibling-session invisibility. |
|
Thanks for the PR! Template looks good ✓ Problem: This is a feature addition, not a bug fix — the motivation is clear. Daemon-managed channels need private MCP tools scoped to a single live session; the existing workspace-scoped route would expose them to unrelated sessions in the same runtime. The linked issues (#7628, #7641) confirm this is a planned building block for the channel-loop integration. Direction: Aligned. Session-scoped MCP routing is a natural extension of the existing workspace-scoped route, and the ACP bridge already has the Size: Cross-package (acp-bridge + cli). Production logic: 471 lines (bridge.ts 23, bridgeClient.ts 21, bridgeOptions.ts 8, bridgeTypes.ts 69, status.ts 2, acpAgent.ts 348). Test: 267 lines. Under the 500-line maintainer-awareness threshold. Approach: The scope feels right. The PR does two things and both are needed: (1) adds session-scoped add/remove ext methods that reuse the same validation and security-stripping logic as the workspace route (extracted into shared helpers — a clean dedup, not a drive-by refactor), and (2) forwards the originating session identity through reverse MCP messages with ownership verification. No unrelated changes. The type extraction in bridgeTypes.ts is a natural consequence of sharing the result types between workspace and session routes. Moving on to code review. 🔍 中文说明感谢贡献! 模板完整 ✓ 问题:这是一个功能新增,不是 bug 修复——动机清晰。daemon 管理的 channel 需要只属于单个 live session 的私有 MCP 工具;现有的 workspace 级路由会将这些工具暴露给同一 runtime 中无关的 session。关联的 issue(#7628、#7641)确认这是 channel-loop 集成的计划组件。 方向:对齐。session 级 MCP 路由是现有 workspace 级路由的自然扩展,ACP bridge 已有 规模:跨包(acp-bridge + cli)。生产逻辑:471 行(bridge.ts 23、bridgeClient.ts 21、bridgeOptions.ts 8、bridgeTypes.ts 69、status.ts 2、acpAgent.ts 348)。测试:267 行。低于 500 行维护者关注阈值。 方案:范围合理。PR 做了两件事且都是必要的:(1) 新增 session 级 add/remove ext method,复用与 workspace 路由相同的校验和安全剥离逻辑(提取为共享 helper——是干净的去重,不是顺手重构);(2) 在反向 MCP 消息中转发来源 session 身份并进行归属校验。没有无关改动。bridgeTypes.ts 中的类型提取是 workspace 和 session 路由共享结果类型的自然结果。 进入代码审查 🔍 — Qwen Code · qwen3.8-max-preview Reviewed at |
|
Closing temporarily to keep this dependent series strictly serialized. The branch and verified commit are retained; this PR will be rebased onto main and reopened after #7641 merges. |
Code ReviewIndependent proposal: Given the goal (session-scoped MCP routing for daemon channels), I would: (1) add two new ext methods ( Comparison with the diff: The PR matches this proposal almost exactly. The implementation is clean and follows established patterns throughout. Key observations:
No critical blockers or AGENTS.md violations found. TestingUnit tests (as specified in the PR's test plan): Typecheck: Lint: ESLint clean on all 6 changed production files. Build + smoke test (this PR is protocol infrastructure — no UI changes, so the tmux test verifies the build is functional): CLI starts and responds correctly with the PR build. 中文说明代码审查独立方案: 给定目标(为 daemon channel 提供 session 级 MCP 路由),我会:(1) 新增两个 ext method( 与 diff 的对比: PR 几乎完全匹配此方案。实现干净,全程遵循既有模式。 关键观察:
未发现关键阻塞问题或 AGENTS.md 违规。 测试单元测试(按 PR 测试计划): 类型检查: Lint: ESLint 对全部 6 个变更的生产文件通过。 构建 + 冒烟测试(本 PR 是协议基础设施——无 UI 变化,tmux 测试验证构建可用): CLI 使用 PR 构建正常启动并响应。 — Qwen Code · qwen3.8-max-preview Reviewed at |
|
Confidence: 4/5 — clean implementation that follows established patterns throughout; the only gap is that full end-to-end verification of the session-scoped routing requires the daemon channel setup that isn't wired yet, so confidence rests on comprehensive unit tests rather than live behavior. This is a well-built PR. The approach matches what I'd propose independently — extract the workspace handler's validation and security-stripping into shared helpers, add session-scoped ext methods that reuse them via What I like: the security stripping is identical between workspace and session routes (same helper, same test proving The author has several related PRs open for the channel/daemon infrastructure effort. This one is well-scoped as a standalone building block: it adds the routing primitive without coupling to channel-loop behavior, and the follow-up integration can build on it cleanly. All 837 unit tests pass, typecheck and lint are clean, and the build produces a working CLI. 中文说明置信度:4/5 — 实现干净,全程遵循既有模式;唯一的差距是 session 级路由的完整端到端验证需要尚未接入的 daemon channel 环境,因此置信度主要基于全面的单元测试而非实际运行行为。 这是一个构建良好的 PR。方案与我独立提出的一致——将 workspace handler 的校验和安全剥离逻辑提取为共享 helper,添加通过 亮点:workspace 和 session 路由的安全剥离完全一致(相同 helper,相同测试证明 作者有多个相关的 channel/daemon 基础设施 PR 处于 open 状态。这个 PR 作为独立的构建块范围合理:添加了路由原语而不耦合 channel-loop 行为,后续集成可以干净地基于它构建。 全部 837 个单元测试通过,类型检查和 lint 干净,构建产出可用的 CLI。 — Qwen Code · qwen3.8-max-preview Reviewed at |
qwen-code-ci-bot
left a comment
There was a problem hiding this comment.
LGTM, looks ready to ship. ✅
What this PR does
Adds a session-owned runtime MCP route alongside the existing workspace-owned route. A daemon host can now add or remove an SDK MCP server for one selected live session without mutating bootstrap state, fanning out to siblings, or publishing workspace-wide events.
Carries the originating session identity through reverse MCP messages and verifies that the claimed session belongs to the ACP channel before forwarding it to the host-side sender.
Why it's needed
Daemon-managed channels need private agent tools that belong to the channel's live session. Reusing the workspace route would expose those tools to unrelated terminal and web sessions in the same runtime. This provides the generic isolation boundary required by the later channel-loop integration while remaining independent of channel behavior.
Reviewer Test Plan
How to verify
cd packages/acp-bridge && npx vitest run src/bridgeClient.test.ts src/bridge.test.ts.cd packages/cli && npx vitest run src/acp-integration/acpAgent.test.ts.npm run build,npm run typecheck, andnpm run lint.Evidence (Before & After)
N/A — protocol and routing infrastructure only; no UI changes.
Tested on
Environment (optional)
Node.js 22 workspace install; package-level Vitest suites and repository build/type/lint checks.
Risk & Scope
Linked Issues
Related to #7628 and #7641.
中文说明
本 PR 做了什么
在现有 workspace 归属的运行时 MCP 路由之外,新增 session 归属的运行时 MCP 路由。daemon host 现在可以只为一个指定的 live session 添加或移除 SDK MCP server,不会修改 bootstrap 状态、扩散到兄弟 session,也不会发布 workspace 级事件。
反向 MCP 消息会携带来源 session 身份;在转交给 host 侧 sender 之前,还会校验该 session 确实归当前 ACP channel 所有。
为什么需要
daemon-managed channel 需要只属于其 live session 的私有 agent tools。如果复用 workspace 路由,这些工具会暴露给同一 runtime 中无关的终端和 Web session。这个 PR 提供后续 channel-loop 集成所需的通用隔离边界,同时不包含任何 channel 业务。
Reviewer 测试计划
如何验证
cd packages/acp-bridge && npx vitest run src/bridgeClient.test.ts src/bridge.test.ts。cd packages/cli && npx vitest run src/acp-integration/acpAgent.test.ts。npm run build、npm run typecheck和npm run lint。证据(前后对比)
N/A——仅协议和路由基础设施,没有 UI 变化。
测试平台
环境(可选)
Node.js 22 workspace 安装;执行 package 级 Vitest suite 与仓库 build/type/lint 检查。
风险与范围
关联 Issue
关联 #7628 和 #7641。