{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "provider": {
      "type": "string",
      "const": "webhook"
    },
    "key": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9_-]{0,63}$"
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 64
    },
    "description": {
      "type": "string",
      "minLength": 1,
      "maxLength": 1024
    },
    "harness": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9_-]{0,63}$"
    },
    "sandbox": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9_-]{0,63}$"
    },
    "agentId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 64,
      "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
    },
    "initialPrompt": {
      "type": "string",
      "minLength": 1,
      "maxLength": 65536
    },
    "enabled": {
      "default": true,
      "type": "boolean"
    },
    "guards": {
      "default": [],
      "maxItems": 10,
      "type": "array",
      "items": {
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "max_occurrences"
              },
              "enabled": {
                "default": true,
                "type": "boolean"
              },
              "limit": {
                "default": 3,
                "type": "integer",
                "minimum": 1,
                "maximum": 100
              },
              "scope": {
                "default": "subject",
                "type": "string",
                "enum": [
                  "repository",
                  "subject",
                  "commit",
                  "event"
                ]
              },
              "windowSeconds": {
                "type": "integer",
                "exclusiveMinimum": 0,
                "maximum": 31536000
              }
            },
            "required": [
              "type"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "cooldown"
              },
              "enabled": {
                "default": true,
                "type": "boolean"
              },
              "scope": {
                "type": "string",
                "enum": [
                  "repository",
                  "subject",
                  "commit",
                  "event"
                ]
              },
              "seconds": {
                "type": "integer",
                "exclusiveMinimum": 0,
                "maximum": 31536000
              }
            },
            "required": [
              "type",
              "scope",
              "seconds"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "max_concurrent"
              },
              "enabled": {
                "default": true,
                "type": "boolean"
              },
              "scope": {
                "type": "string",
                "enum": [
                  "repository",
                  "subject",
                  "commit",
                  "event"
                ]
              },
              "limit": {
                "type": "integer",
                "exclusiveMinimum": 0,
                "maximum": 100
              }
            },
            "required": [
              "type",
              "scope",
              "limit"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "deduplicate"
              },
              "enabled": {
                "default": true,
                "type": "boolean"
              },
              "scope": {
                "type": "string",
                "enum": [
                  "delivery",
                  "subject",
                  "commit",
                  "event"
                ]
              },
              "windowSeconds": {
                "type": "integer",
                "exclusiveMinimum": 0,
                "maximum": 31536000
              }
            },
            "required": [
              "type",
              "scope"
            ],
            "additionalProperties": false
          }
        ]
      }
    },
    "events": {
      "default": [],
      "maxItems": 32,
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 128
      }
    },
    "payloadFilter": {
      "type": "object",
      "propertyNames": {
        "type": "string"
      },
      "additionalProperties": {}
    }
  },
  "required": [
    "provider",
    "key",
    "name",
    "harness",
    "sandbox",
    "agentId",
    "initialPrompt"
  ],
  "additionalProperties": false
}
