diff options
Diffstat (limited to 'internal/executor/agentmcp.go')
| -rw-r--r-- | internal/executor/agentmcp.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/internal/executor/agentmcp.go b/internal/executor/agentmcp.go index c0088c5..a89c670 100644 --- a/internal/executor/agentmcp.go +++ b/internal/executor/agentmcp.go @@ -6,11 +6,13 @@ import ( "encoding/hex" "encoding/json" "errors" + "fmt" "net/http" "strings" "sync" "github.com/modelcontextprotocol/go-sdk/mcp" + "github.com/thepeterstone/claudomator/internal/role" ) // Registry maps per-task MCP bearer tokens to a built agent MCP server. A token @@ -79,6 +81,30 @@ type proposeEpicInput struct { StoryIDs []string `json:"story_ids" jsonschema:"the story IDs to group under this epic"` } +// proposeRoleConfigInput mirrors internal/role.RoleConfig's fields directly +// (same json tags) rather than defining a parallel shape, so the tool's +// input decodes straight into a role.RoleConfig with no field-by-field +// translation. See propose_role_config below. +type proposeRoleConfigInput struct { + Role string `json:"role" jsonschema:"the role name this config applies to (e.g. an existing role like builder, or a new one)"` + SystemPrompt string `json:"system_prompt,omitempty" jsonschema:"system prompt appended for tasks dispatched through this role"` + Tools []string `json:"tools,omitempty" jsonschema:"optional tool allowlist for this role"` + SandboxKind string `json:"sandbox_kind,omitempty" jsonschema:"optional sandbox kind for this role"` + DefaultBudgetUSD float64 `json:"default_budget_usd,omitempty" jsonschema:"optional estimated budget in USD, used when the scheduler considers escalating this role's tasks"` + EscalationLadder []role.Tier `json:"escalation_ladder,omitempty" jsonschema:"ordered list of escalation tiers; each has candidates (provider/model pairs), an optional selection_mode (round_robin|single), and max_retries"` +} + +func (in proposeRoleConfigInput) toRoleConfig() role.RoleConfig { + return role.RoleConfig{ + Role: in.Role, + SystemPrompt: in.SystemPrompt, + Tools: in.Tools, + SandboxKind: in.SandboxKind, + DefaultBudgetUSD: in.DefaultBudgetUSD, + EscalationLadder: in.EscalationLadder, + } +} + func textResult(text string) *mcp.CallToolResult { return &mcp.CallToolResult{Content: []mcp.Content{&mcp.TextContent{Text: text}}} } @@ -158,6 +184,17 @@ func newAgentServer(ch AgentChannel) *mcp.Server { return textResult("Proposed epic " + id), nil, nil }) + mcp.AddTool(s, &mcp.Tool{ + Name: "propose_role_config", + Description: "Propose a new draft configuration version for a role, after reflecting on what happened (e.g. during a story retro). Creates a new draft role_configs row for a human to review and activate via POST /api/roles/{role}/activate -- it never changes what is currently active.", + }, func(ctx context.Context, _ *mcp.CallToolRequest, in proposeRoleConfigInput) (*mcp.CallToolResult, any, error) { + version, err := ch.ProposeRoleConfig(ctx, in.toRoleConfig()) + if err != nil { + return nil, nil, err + } + return textResult(fmt.Sprintf("Proposed role config %s v%d (draft)", in.Role, version)), nil, nil + }) + return s } |
