Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/claude/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,8 @@ export class ClaudeExecutor {
: { type: 'preset', preset: 'claude_code', append: promptAppend },

// 加载项目设置 (CLAUDE.md 等);路由 agent 传 [] 避免加载
settingSources: settingSourcesOverride ?? ['user', 'project'],
// 'local' 加载 .claude/settings.local.json(优先级最高,覆盖 project)
settingSources: settingSourcesOverride ?? ['user', 'project', 'local'],

// MCP 服务器:工作区管理工具 + 飞书工具 (空对象等同于无 MCP 服务器)
mcpServers: Object.keys(mcpServers).length > 0 ? mcpServers : undefined,
Expand Down Expand Up @@ -984,7 +985,8 @@ export class ClaudeExecutor {

try {
// 遍历 SDK 流式消息
for await (const message of q) {
// label 用于在收到 result 后跳出循环(result 是 SDK 协议的终止消息)
messageLoop: for await (const message of q) {
// 每收到消息重置 idle 计时器
resetIdleTimer(`msg:${message.type}${'subtype' in message ? ':' + (message as Record<string, unknown>).subtype : ''}`);

Expand Down Expand Up @@ -1123,7 +1125,7 @@ export class ClaudeExecutor {

case 'result':
resultMessage = message;
break;
break messageLoop;

default:
// tool_progress, stream_event 等其他消息类型 — 记录以便诊断 idle timeout 间隙
Expand All @@ -1132,6 +1134,10 @@ export class ClaudeExecutor {
break;
}
}

// 提前 break(收到 result)时子进程可能仍在运行(如有 background task),
// 主动 close 确保不泄漏;正常迭代结束时 close 是幂等的 no-op
q.close();
} catch (err) {
clearTimeout(idleTimer);
if (hardTimer) clearTimeout(hardTimer);
Expand Down
Loading