Merge branch 'pr/amDosion/60'

This commit is contained in:
claude-code-best
2026-04-03 17:21:09 +08:00
6 changed files with 209 additions and 22 deletions

View File

@@ -1,5 +1,39 @@
# DEV-LOG
## Enable Remote Control / BRIDGE_MODE (2026-04-03)
**PR**: [claude-code-best/claude-code#60](https://github.com/claude-code-best/claude-code/pull/60)
Remote Control 功能将本地 CLI 注册为 bridge 环境,生成可分享的 URL`https://claude.ai/code/session_xxx`),允许从浏览器、手机或其他设备远程查看输出、发送消息、审批工具调用。
**改动文件:**
| 文件 | 变更 |
|------|------|
| `scripts/dev.ts` | `DEFAULT_FEATURES` 加入 `"BRIDGE_MODE"`dev 模式默认启用 |
| `src/bridge/peerSessions.ts` | stub → 完整实现:通过 bridge API 发送跨会话消息含三层安全防护trim + validateBridgeId 白名单 + encodeURIComponent |
| `src/bridge/webhookSanitizer.ts` | stub → 完整实现:正则 redact 8 类 secretGitHub/Anthropic/AWS/npm/Slack token先 redact 再截断,失败返回安全占位符 |
| `src/entrypoints/sdk/controlTypes.ts` | 12 个 `any` stub → `z.infer<ReturnType<typeof XxxSchema>>` 从现有 Zod schema 推导类型 |
| `src/hooks/useReplBridge.tsx` | `tengu_bridge_system_init` 默认值 `false``true`,使 app 端显示 "active" 而非卡在 "connecting" |
**关键设计决策:**
1. **不改现有代码逻辑** — 只补全 stub、修正默认值、开启编译开关
2. **`tengu_bridge_system_init`** — Anthropic 通过 GrowthBook 给订阅用户推送 `true`,但我们的 build 收不到推送;改默认值是唯一不侵入其他代码的方案
3. **`peerSessions.ts` 认证** — 使用 `getBridgeAccessToken()` 获取 OAuth Bearer token`bridgeApi.ts`/`codeSessionApi.ts` 认证模式一致
4. **`webhookSanitizer.ts` 安全** — fail-closed出错返回 `[webhook content redacted due to sanitization error]`),不泄露原始内容
**验证结果:**
- `/remote-control` 命令可见且可用
- CLI 连接 Anthropic CCR生成可分享 URL
- App 端claude.ai/code显示 "Remote Control active"
- 手机端Claude iOS app通过 URL 连接,双向消息正常
![Remote Control on Mobile](docs/images/remote-control-mobile.png)
---
## GrowthBook 自定义服务器适配器 (2026-04-03)
GrowthBook 功能开关系统原为 Anthropic 内部构建设计,硬编码 SDK key 和 API 地址,外部构建因 `is1PEventLoggingEnabled()` 门控始终禁用。新增适配器模式,通过环境变量连接自定义 GrowthBook 服务器,无配置时所有 feature 读取返回代码默认值。