{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://docs.nylorun.com/schemas/agent-folder/v1/trigger-md.json",
  "title": "Nylorun agent folder: trigger frontmatter",
  "description": "The frontmatter of a trigger of an agent folder, triggers/<id>.md: exactly one of schedule, at and webhook, and the session; the body below it is the prompt",
  "type": "object",
  "properties": {
    "schedule": {
      "type": "string",
      "pattern": "^\\S+(\\s+\\S+){4}$",
      "description": "Five cron fields: minute hour day-of-month month day-of-week, in timezone"
    },
    "timezone": {
      "type": "string",
      "minLength": 1,
      "description": "The schedule's IANA time zone, such as Asia/Kolkata; UTC without one"
    },
    "at": {
      "type": "string",
      "format": "date-time",
      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$",
      "description": "One run, at an RFC 3339 time with an offset"
    },
    "webhook": {
      "type": "string",
      "enum": [
        "standard-webhooks"
      ],
      "description": "A webhook endpoint, verified with this signature scheme"
    },
    "session": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200,
      "description": "The session each run goes to: a session id, or new for a new one per run"
    }
  },
  "required": [
    "session"
  ],
  "additionalProperties": false,
  "oneOf": [
    {
      "required": [
        "schedule"
      ]
    },
    {
      "required": [
        "at"
      ],
      "properties": {
        "timezone": false
      }
    },
    {
      "required": [
        "webhook"
      ],
      "properties": {
        "timezone": false
      }
    }
  ]
}
