mirror of
https://github.com/sanbuphy/claude-code-source-code.git
synced 2026-04-03 11:34:54 +08:00
5 bilingual (EN/ZH) analysis documents covering: - Telemetry & privacy (opt-out-free data collection) - Hidden features & model codenames (Tengu, Capybara, Fennec, Numbat) - Undercover mode (AI attribution stripping in open-source) - Remote control & killswitches (managed settings, feature flags) - Future roadmap (Numbat model, KAIROS autonomous mode, voice input) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
3.1 KiB
3.1 KiB
远程控制与紧急开关
基于 Claude Code v2.1.88 反编译源码分析
概述
Claude Code 实现了多种远程控制机制,允许 Anthropic(和企业管理员)在无需用户明确同意的情况下修改行为。
1. 远程托管设置
架构
每个符合条件的会话从以下端点获取设置:
GET /api/claude_code/settings
来源: src/services/remoteManagedSettings/index.ts
轮询行为
const POLLING_INTERVAL_MS = 60 * 60 * 1000 // 每小时
const DEFAULT_MAX_RETRIES = 5
每小时静默轮询一次,最多 5 次重试。
资格
- Console 用户 (API key): 全部符合
- OAuth 用户: 仅 Enterprise/C4E 和 Team 订阅者
"接受否则退出" 对话框
当远程设置包含"危险"变更时,会显示阻塞对话框:
// src/services/remoteManagedSettings/securityCheck.tsx:67-73
export function handleSecurityCheckResult(result: SecurityCheckResult): boolean {
if (result === 'rejected') {
gracefulShutdownSync(1) // 退出码 1,直接终止
return false
}
return true
}
拒绝远程设置的用户,程序直接退出。用户只有两个选择:接受远程设置,或者 Claude Code 关掉。
故障容灾
远程服务器不可达时,使用缓存的旧设置。一旦设置过,就永远无法完全摆脱远程控制。
2. Feature Flag 紧急开关
多种功能可以通过 GrowthBook feature flag 远程禁用:
绕过权限 Kill Switch
// src/utils/permissions/bypassPermissionsKillswitch.ts
// 通过 Statsig gate 禁用绕过权限功能
自动模式断路器
// src/utils/permissions/autoModeState.ts
// autoModeCircuitBroken 状态阻止重新进入自动模式
快速模式 Kill Switch
// src/utils/fastMode.ts
// 从 /api/claude_code_penguin_mode 获取状态
// 可以永久禁用用户的快速模式
分析 Sink Kill Switch
// src/services/analytics/sinkKillswitch.ts:4
const SINK_KILLSWITCH_CONFIG_NAME = 'tengu_frond_boric'
语音模式 Kill Switch
// src/voice/voiceModeEnabled.ts:21
// 'tengu_amber_quartz_disabled' — 语音模式紧急关闭
3. 模型覆盖系统
Anthropic 可以远程覆盖内部员工使用的模型:
// src/utils/model/antModels.ts:32-33
// @[MODEL LAUNCH]: Update tengu_ant_model_override with new ant-only models
tengu_ant_model_override GrowthBook flag 可以:
- 设置默认模型
- 设置默认 effort level
- 追加系统提示词
- 定义自定义模型别名
总结
| 机制 | 范围 | 用户同意 |
|---|---|---|
| 远程托管设置 | Enterprise/Team | 接受或退出 |
| GrowthBook feature flags | 所有用户 | 无 |
| Kill switches | 所有用户 | 无 |
| 模型覆盖 | 内部 (ant) | 无 |
| 快速模式控制 | 所有用户 | 无 |
远程控制基础设施极其广泛,且在很大程度上没有用户可见性或同意机制。企业管理员可以强制执行用户无法覆盖的策略,Anthropic 可以通过 feature flag 远程更改任何用户的行为。