{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://opencradle.ai/schemas/team.v1.json",
  "title": "Cradle team manifest v1",
  "description": "One team of agents: captain (triage), checker, 1–5 leads with 0–5 members each, 0–5 shared executors. SPEC-57.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema",
    "name",
    "title",
    "captain",
    "checker",
    "leads"
  ],
  "properties": {
    "schema": {
      "const": "cradle.team/v1"
    },
    "name": {
      "type": "string",
      "pattern": "^[a-z0-9-]{1,64}$",
      "description": "Team slug, unique in the cradle (teams.slug)."
    },
    "title": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120,
      "description": "teams.name"
    },
    "description": {
      "type": "string",
      "maxLength": 2000,
      "description": "teams.description"
    },
    "captain": {
      "$ref": "#/$defs/captain"
    },
    "checker": {
      "$ref": "#/$defs/checker"
    },
    "leads": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/lead"
      },
      "minItems": 1,
      "maxItems": 5
    },
    "shared": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/shared"
      },
      "maxItems": 5,
      "default": [],
      "description": "D22: executors any lead may delegate to (reports_to = null)."
    },
    "requires": {
      "$ref": "#/$defs/requires"
    }
  },
  "$defs": {
    "trigger": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "cron",
        "instruction"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z0-9-]{1,64}$"
        },
        "cron": {
          "type": "string",
          "pattern": "^[0-9*/,\\-]+( [0-9*/,\\-]+){4}$",
          "description": "Five-field cron expression."
        },
        "tz": {
          "type": "string",
          "pattern": "^[A-Za-z_]+(/[A-Za-z0-9_+\\-]+)*$",
          "default": "UTC",
          "description": "IANA time zone."
        },
        "instruction": {
          "type": "string",
          "minLength": 1,
          "maxLength": 2000
        }
      }
    },
    "captain": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "title",
        "prompt"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z0-9-]{1,64}$",
          "description": "Stable key of the agent inside the team (agents.key)."
        },
        "title": {
          "type": "string",
          "minLength": 1,
          "maxLength": 120,
          "description": "Display name (agents.name)."
        },
        "badge": {
          "type": "string",
          "minLength": 1,
          "maxLength": 3,
          "description": "Optional 1–3 characters for the canvas. Not stored in v1."
        },
        "prompt": {
          "type": "string",
          "minLength": 1,
          "maxLength": 32000,
          "description": "System prompt (agents.system_prompt)."
        },
        "category": {
          "type": "string",
          "enum": [
            "coding",
            "business",
            "marketing",
            "seo",
            "general",
            "other"
          ],
          "default": "general",
          "description": "Triage category (agents.role)."
        },
        "model": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200,
          "description": "Model alias = models.catalog_id. Absent: the team bindings place the agent by `requirement`."
        },
        "requirement": {
          "type": "string",
          "enum": [
            "general",
            "coding",
            "reasoning"
          ],
          "default": "general",
          "description": "What the agent requires of a model (agents.model_requirement)."
        },
        "temperature": {
          "type": "number",
          "minimum": 0,
          "maximum": 1.5,
          "default": 0.7
        },
        "tags": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[a-z0-9-]{1,64}$"
          },
          "uniqueItems": true,
          "default": [],
          "description": "Routing tags from the skills directory (agents.skills). Unknown tags are created as custom."
        },
        "skills": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[a-z0-9-]{1,64}@\\d+\\.\\d+\\.\\d+$"
          },
          "uniqueItems": true,
          "default": [],
          "description": "Skill packages `id@semver` (agents.skill_refs)."
        },
        "policies": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[a-z0-9-]{1,64}@\\d+\\.\\d+\\.\\d+$"
          },
          "uniqueItems": true,
          "default": [],
          "description": "Policies `id@semver` (agents.policy_refs)."
        },
        "tools": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[a-z0-9]+(\\.[a-z0-9_-]+)+$"
          },
          "uniqueItems": true,
          "default": [],
          "description": "Built-in tool ids, e.g. `web.search` (agents.tool_ids). Unknown ids block the import."
        },
        "knowledgeBases": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "uniqueItems": true,
          "default": [],
          "sorted": true,
          "description": "Knowledge base names of the team (a set: canonical form sorts it). Missing ones are reported as needsBinding."
        },
        "mcpServers": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "uniqueItems": true,
          "default": [],
          "sorted": true,
          "description": "MCP server names of the cradle (a set: canonical form sorts it). Missing ones are reported as needsBinding."
        },
        "grounding": {
          "type": "string",
          "enum": [
            "off",
            "soft",
            "strict"
          ],
          "default": "soft",
          "description": "agents.grounding_mode; a policy with `grounding` overrides it."
        },
        "enabled": {
          "type": "boolean",
          "default": true
        }
      }
    },
    "checker": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "title",
        "prompt"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z0-9-]{1,64}$",
          "description": "Stable key of the agent inside the team (agents.key)."
        },
        "title": {
          "type": "string",
          "minLength": 1,
          "maxLength": 120,
          "description": "Display name (agents.name)."
        },
        "badge": {
          "type": "string",
          "minLength": 1,
          "maxLength": 3,
          "description": "Optional 1–3 characters for the canvas. Not stored in v1."
        },
        "prompt": {
          "type": "string",
          "minLength": 1,
          "maxLength": 32000,
          "description": "System prompt (agents.system_prompt)."
        },
        "category": {
          "type": "string",
          "enum": [
            "coding",
            "business",
            "marketing",
            "seo",
            "general",
            "other"
          ],
          "default": "general",
          "description": "Triage category (agents.role)."
        },
        "model": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200,
          "description": "Model alias = models.catalog_id. Absent: the team bindings place the agent by `requirement`."
        },
        "requirement": {
          "type": "string",
          "enum": [
            "general",
            "coding",
            "reasoning"
          ],
          "default": "general",
          "description": "What the agent requires of a model (agents.model_requirement)."
        },
        "temperature": {
          "type": "number",
          "minimum": 0,
          "maximum": 1.5,
          "default": 0.7
        },
        "tags": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[a-z0-9-]{1,64}$"
          },
          "uniqueItems": true,
          "default": [],
          "description": "Routing tags from the skills directory (agents.skills). Unknown tags are created as custom."
        },
        "skills": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[a-z0-9-]{1,64}@\\d+\\.\\d+\\.\\d+$"
          },
          "uniqueItems": true,
          "default": [],
          "description": "Skill packages `id@semver` (agents.skill_refs)."
        },
        "policies": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[a-z0-9-]{1,64}@\\d+\\.\\d+\\.\\d+$"
          },
          "uniqueItems": true,
          "default": [],
          "description": "Policies `id@semver` (agents.policy_refs)."
        },
        "tools": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[a-z0-9]+(\\.[a-z0-9_-]+)+$"
          },
          "uniqueItems": true,
          "default": [],
          "description": "Built-in tool ids, e.g. `web.search` (agents.tool_ids). Unknown ids block the import."
        },
        "knowledgeBases": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "uniqueItems": true,
          "default": [],
          "sorted": true,
          "description": "Knowledge base names of the team (a set: canonical form sorts it). Missing ones are reported as needsBinding."
        },
        "mcpServers": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "uniqueItems": true,
          "default": [],
          "sorted": true,
          "description": "MCP server names of the cradle (a set: canonical form sorts it). Missing ones are reported as needsBinding."
        },
        "grounding": {
          "type": "string",
          "enum": [
            "off",
            "soft",
            "strict"
          ],
          "default": "soft",
          "description": "agents.grounding_mode; a policy with `grounding` overrides it."
        },
        "enabled": {
          "type": "boolean",
          "default": true
        },
        "onReject": {
          "type": "string",
          "enum": [
            "return-to-lead"
          ],
          "default": "return-to-lead"
        }
      }
    },
    "lead": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "title",
        "prompt"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z0-9-]{1,64}$",
          "description": "Stable key of the agent inside the team (agents.key)."
        },
        "title": {
          "type": "string",
          "minLength": 1,
          "maxLength": 120,
          "description": "Display name (agents.name)."
        },
        "badge": {
          "type": "string",
          "minLength": 1,
          "maxLength": 3,
          "description": "Optional 1–3 characters for the canvas. Not stored in v1."
        },
        "prompt": {
          "type": "string",
          "minLength": 1,
          "maxLength": 32000,
          "description": "System prompt (agents.system_prompt)."
        },
        "category": {
          "type": "string",
          "enum": [
            "coding",
            "business",
            "marketing",
            "seo",
            "general",
            "other"
          ],
          "default": "general",
          "description": "Triage category (agents.role)."
        },
        "model": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200,
          "description": "Model alias = models.catalog_id. Absent: the team bindings place the agent by `requirement`."
        },
        "requirement": {
          "type": "string",
          "enum": [
            "general",
            "coding",
            "reasoning"
          ],
          "default": "general",
          "description": "What the agent requires of a model (agents.model_requirement)."
        },
        "temperature": {
          "type": "number",
          "minimum": 0,
          "maximum": 1.5,
          "default": 0.7
        },
        "tags": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[a-z0-9-]{1,64}$"
          },
          "uniqueItems": true,
          "default": [],
          "description": "Routing tags from the skills directory (agents.skills). Unknown tags are created as custom."
        },
        "skills": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[a-z0-9-]{1,64}@\\d+\\.\\d+\\.\\d+$"
          },
          "uniqueItems": true,
          "default": [],
          "description": "Skill packages `id@semver` (agents.skill_refs)."
        },
        "policies": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[a-z0-9-]{1,64}@\\d+\\.\\d+\\.\\d+$"
          },
          "uniqueItems": true,
          "default": [],
          "description": "Policies `id@semver` (agents.policy_refs)."
        },
        "tools": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[a-z0-9]+(\\.[a-z0-9_-]+)+$"
          },
          "uniqueItems": true,
          "default": [],
          "description": "Built-in tool ids, e.g. `web.search` (agents.tool_ids). Unknown ids block the import."
        },
        "knowledgeBases": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "uniqueItems": true,
          "default": [],
          "sorted": true,
          "description": "Knowledge base names of the team (a set: canonical form sorts it). Missing ones are reported as needsBinding."
        },
        "mcpServers": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "uniqueItems": true,
          "default": [],
          "sorted": true,
          "description": "MCP server names of the cradle (a set: canonical form sorts it). Missing ones are reported as needsBinding."
        },
        "grounding": {
          "type": "string",
          "enum": [
            "off",
            "soft",
            "strict"
          ],
          "default": "soft",
          "description": "agents.grounding_mode; a policy with `grounding` overrides it."
        },
        "enabled": {
          "type": "boolean",
          "default": true
        },
        "sources": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "telegram",
              "telegram:private",
              "telegram:group",
              "widget",
              "api",
              "mcp-server"
            ]
          },
          "uniqueItems": true,
          "description": "D23: which inbound sources this lead accepts. Absent = any; [] = none (triggers and tasks only)."
        },
        "triggers": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/trigger"
          },
          "maxItems": 5,
          "default": [],
          "description": "D24: stored and shown, not executed in v1."
        },
        "members": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/member"
          },
          "maxItems": 5,
          "default": []
        }
      }
    },
    "member": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "title",
        "prompt"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z0-9-]{1,64}$",
          "description": "Stable key of the agent inside the team (agents.key)."
        },
        "title": {
          "type": "string",
          "minLength": 1,
          "maxLength": 120,
          "description": "Display name (agents.name)."
        },
        "badge": {
          "type": "string",
          "minLength": 1,
          "maxLength": 3,
          "description": "Optional 1–3 characters for the canvas. Not stored in v1."
        },
        "prompt": {
          "type": "string",
          "minLength": 1,
          "maxLength": 32000,
          "description": "System prompt (agents.system_prompt)."
        },
        "category": {
          "type": "string",
          "enum": [
            "coding",
            "business",
            "marketing",
            "seo",
            "general",
            "other"
          ],
          "default": "general",
          "description": "Triage category (agents.role)."
        },
        "model": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200,
          "description": "Model alias = models.catalog_id. Absent: the team bindings place the agent by `requirement`."
        },
        "requirement": {
          "type": "string",
          "enum": [
            "general",
            "coding",
            "reasoning"
          ],
          "default": "general",
          "description": "What the agent requires of a model (agents.model_requirement)."
        },
        "temperature": {
          "type": "number",
          "minimum": 0,
          "maximum": 1.5,
          "default": 0.7
        },
        "tags": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[a-z0-9-]{1,64}$"
          },
          "uniqueItems": true,
          "default": [],
          "description": "Routing tags from the skills directory (agents.skills). Unknown tags are created as custom."
        },
        "skills": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[a-z0-9-]{1,64}@\\d+\\.\\d+\\.\\d+$"
          },
          "uniqueItems": true,
          "default": [],
          "description": "Skill packages `id@semver` (agents.skill_refs)."
        },
        "policies": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[a-z0-9-]{1,64}@\\d+\\.\\d+\\.\\d+$"
          },
          "uniqueItems": true,
          "default": [],
          "description": "Policies `id@semver` (agents.policy_refs)."
        },
        "tools": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[a-z0-9]+(\\.[a-z0-9_-]+)+$"
          },
          "uniqueItems": true,
          "default": [],
          "description": "Built-in tool ids, e.g. `web.search` (agents.tool_ids). Unknown ids block the import."
        },
        "knowledgeBases": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "uniqueItems": true,
          "default": [],
          "sorted": true,
          "description": "Knowledge base names of the team (a set: canonical form sorts it). Missing ones are reported as needsBinding."
        },
        "mcpServers": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "uniqueItems": true,
          "default": [],
          "sorted": true,
          "description": "MCP server names of the cradle (a set: canonical form sorts it). Missing ones are reported as needsBinding."
        },
        "grounding": {
          "type": "string",
          "enum": [
            "off",
            "soft",
            "strict"
          ],
          "default": "soft",
          "description": "agents.grounding_mode; a policy with `grounding` overrides it."
        },
        "enabled": {
          "type": "boolean",
          "default": true
        },
        "execution": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "kind",
            "repository",
            "baseBranch"
          ],
          "properties": {
            "kind": {
              "const": "external"
            },
            "repository": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+$",
              "description": "GitHub repository `owner/name`; must be in the team code_repositories to be dispatched to."
            },
            "baseBranch": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200,
              "description": "Branch the pull request goes into."
            }
          },
          "description": "SPEC-66 D1: absent = the agent runs on a model of the cradle. `external` = the task goes to an external code agent (code.dispatch)."
        }
      }
    },
    "shared": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "title",
        "prompt"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z0-9-]{1,64}$",
          "description": "Stable key of the agent inside the team (agents.key)."
        },
        "title": {
          "type": "string",
          "minLength": 1,
          "maxLength": 120,
          "description": "Display name (agents.name)."
        },
        "badge": {
          "type": "string",
          "minLength": 1,
          "maxLength": 3,
          "description": "Optional 1–3 characters for the canvas. Not stored in v1."
        },
        "prompt": {
          "type": "string",
          "minLength": 1,
          "maxLength": 32000,
          "description": "System prompt (agents.system_prompt)."
        },
        "category": {
          "type": "string",
          "enum": [
            "coding",
            "business",
            "marketing",
            "seo",
            "general",
            "other"
          ],
          "default": "general",
          "description": "Triage category (agents.role)."
        },
        "model": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200,
          "description": "Model alias = models.catalog_id. Absent: the team bindings place the agent by `requirement`."
        },
        "requirement": {
          "type": "string",
          "enum": [
            "general",
            "coding",
            "reasoning"
          ],
          "default": "general",
          "description": "What the agent requires of a model (agents.model_requirement)."
        },
        "temperature": {
          "type": "number",
          "minimum": 0,
          "maximum": 1.5,
          "default": 0.7
        },
        "tags": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[a-z0-9-]{1,64}$"
          },
          "uniqueItems": true,
          "default": [],
          "description": "Routing tags from the skills directory (agents.skills). Unknown tags are created as custom."
        },
        "skills": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[a-z0-9-]{1,64}@\\d+\\.\\d+\\.\\d+$"
          },
          "uniqueItems": true,
          "default": [],
          "description": "Skill packages `id@semver` (agents.skill_refs)."
        },
        "policies": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[a-z0-9-]{1,64}@\\d+\\.\\d+\\.\\d+$"
          },
          "uniqueItems": true,
          "default": [],
          "description": "Policies `id@semver` (agents.policy_refs)."
        },
        "tools": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[a-z0-9]+(\\.[a-z0-9_-]+)+$"
          },
          "uniqueItems": true,
          "default": [],
          "description": "Built-in tool ids, e.g. `web.search` (agents.tool_ids). Unknown ids block the import."
        },
        "knowledgeBases": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "uniqueItems": true,
          "default": [],
          "sorted": true,
          "description": "Knowledge base names of the team (a set: canonical form sorts it). Missing ones are reported as needsBinding."
        },
        "mcpServers": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "uniqueItems": true,
          "default": [],
          "sorted": true,
          "description": "MCP server names of the cradle (a set: canonical form sorts it). Missing ones are reported as needsBinding."
        },
        "grounding": {
          "type": "string",
          "enum": [
            "off",
            "soft",
            "strict"
          ],
          "default": "soft",
          "description": "agents.grounding_mode; a policy with `grounding` overrides it."
        },
        "enabled": {
          "type": "boolean",
          "default": true
        },
        "triggers": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/trigger"
          },
          "maxItems": 5,
          "default": [],
          "description": "D24: stored and shown, not executed in v1."
        },
        "execution": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "kind",
            "repository",
            "baseBranch"
          ],
          "properties": {
            "kind": {
              "const": "external"
            },
            "repository": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+$",
              "description": "GitHub repository `owner/name`; must be in the team code_repositories to be dispatched to."
            },
            "baseBranch": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200,
              "description": "Branch the pull request goes into."
            }
          },
          "description": "SPEC-66 D1: absent = the agent runs on a model of the cradle. `external` = the task goes to an external code agent (code.dispatch)."
        }
      }
    },
    "requires": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "channels": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "telegram",
              "widget",
              "api",
              "mcp-server"
            ]
          },
          "uniqueItems": true,
          "default": []
        },
        "mcpServers": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "uniqueItems": true,
          "default": [],
          "sorted": true
        },
        "knowledgeBases": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "uniqueItems": true,
          "default": [],
          "sorted": true
        },
        "ontologies": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[a-z0-9-]+(@[a-z0-9.-]+)?$"
          },
          "uniqueItems": true,
          "default": [],
          "description": "Always [] in v1: no domain packs to point at yet."
        }
      },
      "default": {}
    }
  }
}
