refactor: 解耦 BRIDGE_MODE 与 DAEMON,禁用 DAEMON 降低内存占用

- 从 DEFAULT_BUILD_FEATURES 注释掉 DAEMON(内存占用过高)
- remoteControlServer 命令门控从 feature('DAEMON') && feature('BRIDGE_MODE')
  改为仅 feature('BRIDGE_MODE'),bridge 不再依赖 daemon
- --daemon-worker 快速路径改为运行时检测,未启用时输出明确错误提示

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
claude-code-best
2026-04-24 10:01:05 +08:00
parent 4dcbaf1e66
commit f2dd5142b3
4 changed files with 14 additions and 4 deletions

View File

@@ -75,7 +75,7 @@ const bridge = feature('BRIDGE_MODE')
? require('./commands/bridge/index.js').default
: null
const remoteControlServerCommand =
feature('DAEMON') && feature('BRIDGE_MODE')
feature('BRIDGE_MODE')
? require('./commands/remoteControlServer/index.js').default
: null
const voiceCommand = feature('VOICE_MODE')

View File

@@ -3,9 +3,14 @@ import { isBridgeEnabled } from '../../bridge/bridgeEnabled.js'
import type { Command } from '../../commands.js'
function isEnabled(): boolean {
if (!feature('DAEMON') || !feature('BRIDGE_MODE')) {
if (!feature('BRIDGE_MODE')) {
return false
}
if (feature('DAEMON')) {
return isBridgeEnabled()
}
// DAEMON feature disabled — still allow the command but warn at runtime
// that headless/daemon worker mode is unavailable.
return isBridgeEnabled()
}

View File

@@ -170,7 +170,12 @@ async function main(): Promise<void> {
// perf-sensitive. No enableConfigs(), no analytics sinks at this layer —
// workers are lean. If a worker kind needs configs/auth (assistant will),
// it calls them inside its run() fn.
if (feature('DAEMON') && (args[0] === '--daemon-worker' || args[0]?.startsWith('--daemon-worker='))) {
if (args[0] === '--daemon-worker' || args[0]?.startsWith('--daemon-worker=')) {
if (!feature('DAEMON')) {
console.error('Error: --daemon-worker requires DAEMON feature to be enabled. Set FEATURE_DAEMON=1 or add DAEMON to DEFAULT_BUILD_FEATURES.')
process.exitCode = 1
return
}
const kind = args[0] === '--daemon-worker' ? args[1] : args[0].split('=')[1]
const { runDaemonWorker } = await import('../daemon/workerRegistry.js')
await runDaemonWorker(kind)