You've already forked agentic-coding-workflow
38 lines
1.2 KiB
Go
38 lines
1.2 KiB
Go
// mcp_bridge.go 实现 mcp.OrchestratorBridge:把 request_subtask MCP 工具的调用转译到
|
|
// 本包 Service.RequestSubtask。放在 orchestrator 包内(orchestrator 已 import mcp 间接
|
|
// 无需,故这里只 import mcp 接口),避免 mcp → orchestrator 的循环依赖。
|
|
package orchestrator
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/google/uuid"
|
|
|
|
"github.com/yan1h/agent-coding-workflow/internal/mcp"
|
|
"github.com/yan1h/agent-coding-workflow/internal/project"
|
|
)
|
|
|
|
// MCPBridge 适配 Service 到 mcp.OrchestratorBridge。
|
|
type MCPBridge struct {
|
|
svc Service
|
|
}
|
|
|
|
// NewMCPBridge 构造桥接适配器,由 app.go 装配 mcp.ServerDeps 时调用。
|
|
func NewMCPBridge(svc Service) *MCPBridge { return &MCPBridge{svc: svc} }
|
|
|
|
var _ mcp.OrchestratorBridge = (*MCPBridge)(nil)
|
|
|
|
// RequestSubtask 透传到 Service.RequestSubtask;返回新建子 step 的 id 字符串。
|
|
func (b *MCPBridge) RequestSubtask(ctx context.Context, parentACPSessionID uuid.UUID,
|
|
phase string, prompt string, agentKindID *uuid.UUID) (string, error) {
|
|
step, err := b.svc.RequestSubtask(ctx, parentACPSessionID, SubtaskInput{
|
|
Phase: project.Phase(phase),
|
|
Prompt: prompt,
|
|
AgentKindID: agentKindID,
|
|
})
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return step.ID.String(), nil
|
|
}
|