{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://schemas.kiket.dev/agent.json",
  "title": "Kiket Agent Definition",
  "description": "Defines an AI agent with context, prompts, and safety constraints.",
  "type": "object",
  "required": [
    "model_version",
    "agent"
  ],
  "properties": {
    "model_version": {
      "type": "string",
      "const": "1.0"
    },
    "agent": {
      "type": "object",
      "required": [
        "name"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z0-9_-]+$"
        },
        "slug": {
          "type": "string"
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "description": {
          "type": "string"
        },
        "capabilities": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "anyOf": [
        {
          "required": [
            "id"
          ]
        },
        {
          "required": [
            "slug"
          ]
        }
      ],
      "additionalProperties": false
    },
    "model": {
      "type": "object",
      "properties": {
        "provider": {
          "type": "string",
          "enum": [
            "vertex_ai",
            "mistral",
            "openai"
          ],
          "default": "vertex_ai"
        },
        "name": {
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "context": {
      "type": "object",
      "properties": {
        "include": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Context sources: project_issues, team_capacity, sprint_history, documents, code, etc."
        }
      },
      "additionalProperties": false
    },
    "inputs": {
      "type": "array",
      "items": {
        "oneOf": [
          {
            "type": "string"
          },
          {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "id": {
                "type": "string"
              },
              "type": {
                "type": "string",
                "default": "string"
              },
              "description": {
                "type": "string"
              }
            }
          }
        ]
      }
    },
    "outputs": {
      "type": "array",
      "items": {
        "oneOf": [
          {
            "type": "string"
          },
          {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "id": {
                "type": "string"
              },
              "type": {
                "type": "string",
                "default": "string"
              },
              "description": {
                "type": "string"
              }
            }
          }
        ]
      }
    },
    "prompts": {
      "type": "object",
      "additionalProperties": {
        "type": "object",
        "properties": {
          "body": {
            "type": "string"
          },
          "response_schema": {
            "type": "object"
          }
        }
      }
    },
    "tools": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "default": "http"
          },
          "config": {
            "type": "object"
          }
        }
      }
    },
    "safety": {
      "type": "object",
      "properties": {
        "require_approval": {
          "type": "boolean",
          "default": false
        },
        "max_tokens": {
          "type": "integer",
          "minimum": 1
        },
        "rate_limit": {
          "type": "integer",
          "minimum": 0
        },
        "allowed_actions": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false
}
