You've already forked agentic-coding-workflow
ACP / MCP 完善
This commit is contained in:
@@ -92,8 +92,7 @@ type Process struct {
|
||||
SessionID uuid.UUID
|
||||
WorkspaceID uuid.UUID
|
||||
UserID uuid.UUID
|
||||
IsMain bool // 主 worktree 占用 → release 走不同路径
|
||||
WorktreeID *uuid.UUID // 子 worktree 时填,用于 release
|
||||
IsMain bool // 主 worktree 占用 → release 走不同路径
|
||||
|
||||
Cmd *exec.Cmd
|
||||
group procgrp.Group // 进程树句柄(整树终止),Spawn 时 Prepare+Adopt
|
||||
@@ -198,6 +197,7 @@ func (s *Supervisor) Spawn(ctx context.Context, sess *Session, kind *AgentKind,
|
||||
}
|
||||
if err := group.Adopt(cmd); err != nil {
|
||||
_ = cmd.Process.Kill()
|
||||
_ = cmd.Wait() // 回收进程资源,避免 Unix 僵尸进程
|
||||
return nil, fmt.Errorf("adopt process group: %w", err)
|
||||
}
|
||||
|
||||
@@ -411,19 +411,18 @@ func (s *Supervisor) onExit(ctx context.Context, proc *Process, status SessionSt
|
||||
s.log.Error("acp.on_exit.update_session", "session_id", proc.SessionID, "err", err.Error())
|
||||
}
|
||||
|
||||
// Release worktree。主 worktree 走 acp 表自己的 CAS;子 worktree 走 workspace
|
||||
// service 的 holder 校验。当前 wtSvc.Release 接受 workspace.Caller,子 worktree
|
||||
// 释放需要绕过 holder 检查(spec 期望 holder = "session:<sid>",与 user holder
|
||||
// 不同),用 IsAdmin: true 强制释放。F4 reaper 会替换为更严格的 byHolder 调用。
|
||||
// Release worktree。主 worktree 走 acp 表自己的 CAS;子 worktree 按 holder
|
||||
// 释放(holder = "session:<sid>",见 workspace.Caller.Holder),与启动 reaper
|
||||
// 一致,不需要知道 worktree ID。
|
||||
if proc.IsMain {
|
||||
if _, err := s.repo.ReleaseMainWorktree(ctx, proc.WorkspaceID, proc.SessionID); err != nil {
|
||||
s.log.Error("acp.on_exit.release_main",
|
||||
"session_id", proc.SessionID, "err", err.Error())
|
||||
}
|
||||
} else if proc.WorktreeID != nil && s.wtSvc != nil {
|
||||
if _, err := s.wtSvc.Release(ctx, workspace.Caller{IsAdmin: true}, *proc.WorktreeID); err != nil {
|
||||
} else if s.wtSvc != nil {
|
||||
if _, err := s.wtSvc.ReleaseByHolder(ctx, "session:"+proc.SessionID.String()); err != nil {
|
||||
s.log.Error("acp.on_exit.release_worktree",
|
||||
"session_id", proc.SessionID, "worktree_id", *proc.WorktreeID, "err", err.Error())
|
||||
"session_id", proc.SessionID, "err", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user