# Schema for assign_task_to_agent MCP tool
# Validates agent task assignment requests
{
  tool_name = "assign_task_to_agent",

  description = "Assign a task to an agent by role",

  parameters = {
    # Agent role - must be valid role
    role
      | String
      | doc "Agent role"
      | std.string.NonEmpty
      | std.enum.TaggedUnion
      | [| 'developer, 'reviewer, 'architect, 'tester, 'documenter, 'devops, 'monitor, 'security |],

    # Task title
    task_title
      | String
      | doc "Task title (3-500 chars)"
      | std.string.NonEmpty
      | std.string.length.min 3
      | std.string.length.max 500,

    # Task description
    task_description
      | String
      | doc "Task description (detailed requirements)"
      | std.string.NonEmpty
      | std.string.length.min 10,

    # Optional priority (0-100)
    priority
      | Number
      | doc "Task priority (0-100, default: 50)"
      | std.number.between 0 100
      | default = 50,

    # Optional context (JSON string)
    context
      | String
      | doc "Additional context as JSON string (optional)"
      | default = "{}",
  },

  # Validation contracts
  contracts = {
    # Context must be valid JSON if provided
    context_is_json = fun params =>
      if params.context == "{}" then
        true
      else
        # Simple JSON validation - starts with { or [
        std.string.is_match "^[\\{\\[]" params.context,
  },
}
