{
  "$ref": "#/definitions/rules-v1",
  "definitions": {
    "rules-v1": {
      "type": "object",
      "properties": {
        "v": {
          "type": "string",
          "const": "0.1"
        },
        "budget": {
          "type": "object",
          "properties": {
            "daily": {
              "type": "string"
            },
            "perCall": {
              "type": "string"
            },
            "currency": {
              "type": "string",
              "const": "USDC"
            }
          },
          "required": [
            "daily",
            "perCall",
            "currency"
          ],
          "additionalProperties": false
        },
        "hosts": {
          "type": "object",
          "properties": {
            "allow": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "deny": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          "additionalProperties": false
        },
        "priceCeiling": {
          "type": "string"
        },
        "triggers": {
          "type": "array",
          "items": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "const": "cron"
                  },
                  "expression": {
                    "type": "string"
                  }
                },
                "required": [
                  "type",
                  "expression"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "const": "webhook"
                  },
                  "path": {
                    "type": "string"
                  }
                },
                "required": [
                  "type",
                  "path"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "const": "interval"
                  },
                  "seconds": {
                    "type": "integer",
                    "exclusiveMinimum": 0
                  }
                },
                "required": [
                  "type",
                  "seconds"
                ],
                "additionalProperties": false
              }
            ]
          }
        },
        "stopOn": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "reason": {
                "type": "string"
              },
              "when": {
                "type": "string",
                "enum": [
                  "budget_exceeded",
                  "manual",
                  "error_streak"
                ]
              }
            },
            "required": [
              "reason",
              "when"
            ],
            "additionalProperties": false
          }
        }
      },
      "required": [
        "v",
        "budget",
        "hosts",
        "triggers"
      ],
      "additionalProperties": false
    }
  },
  "$schema": "http://json-schema.org/draft-07/schema#"
}