{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://ensomniac.github.io/codex-ui/plan.schema.json",
  "title": "codex-ui action plan v1",
  "type": "object",
  "required": [
    "schema_version",
    "target",
    "actions"
  ],
  "additionalProperties": false,
  "properties": {
    "schema_version": {
      "const": 1
    },
    "target": {
      "type": "object",
      "properties": {
        "window_id": {
          "type": "integer"
        },
        "app": {
          "type": "string"
        },
        "title": {
          "type": "string"
        },
        "chrome_url": {
          "type": "string"
        },
        "frontmost": {
          "type": "boolean"
        },
        "occurrence": {
          "type": "integer",
          "minimum": 1
        }
      },
      "additionalProperties": false
    },
    "actions": {
      "type": "array",
      "minItems": 1,
      "items": {
        "oneOf": [
          {
            "type": "object",
            "required": [
              "type",
              "name"
            ],
            "properties": {
              "type": {
                "const": "press"
              },
              "name": {
                "type": "string"
              },
              "role": {
                "type": "string"
              },
              "contains": {
                "type": "boolean"
              },
              "occurrence": {
                "type": "integer",
                "minimum": 1
              }
            },
            "additionalProperties": false
          },
          {
            "type": "object",
            "required": [
              "type",
              "text"
            ],
            "properties": {
              "type": {
                "const": "click_text"
              },
              "text": {
                "type": "string"
              },
              "role": {
                "type": "string"
              },
              "contains": {
                "type": "boolean"
              },
              "occurrence": {
                "type": "integer",
                "minimum": 1
              }
            },
            "additionalProperties": false
          },
          {
            "type": "object",
            "required": [
              "type",
              "at"
            ],
            "properties": {
              "type": {
                "const": "click"
              },
              "at": {
                "type": "array",
                "items": {
                  "type": "number"
                },
                "minItems": 2,
                "maxItems": 2
              },
              "count": {
                "type": "integer",
                "minimum": 1
              },
              "button": {
                "enum": [
                  "left",
                  "right"
                ]
              }
            },
            "additionalProperties": false
          },
          {
            "type": "object",
            "required": [
              "type",
              "at"
            ],
            "properties": {
              "type": {
                "const": "move"
              },
              "at": {
                "type": "array",
                "items": {
                  "type": "number"
                },
                "minItems": 2,
                "maxItems": 2
              },
              "duration": {
                "type": "number",
                "minimum": 0
              }
            },
            "additionalProperties": false
          },
          {
            "type": "object",
            "required": [
              "type",
              "from",
              "to"
            ],
            "properties": {
              "type": {
                "const": "drag"
              },
              "from": {
                "type": "array",
                "items": {
                  "type": "number"
                },
                "minItems": 2,
                "maxItems": 2
              },
              "to": {
                "type": "array",
                "items": {
                  "type": "number"
                },
                "minItems": 2,
                "maxItems": 2
              },
              "duration": {
                "type": "number",
                "minimum": 0
              }
            },
            "additionalProperties": false
          },
          {
            "type": "object",
            "required": [
              "type",
              "delta_y"
            ],
            "properties": {
              "type": {
                "const": "scroll"
              },
              "at": {
                "type": "array",
                "items": {
                  "type": "number"
                },
                "minItems": 2,
                "maxItems": 2
              },
              "delta_x": {
                "type": "number"
              },
              "delta_y": {
                "type": "number"
              }
            },
            "additionalProperties": false
          },
          {
            "type": "object",
            "required": [
              "type",
              "text"
            ],
            "properties": {
              "type": {
                "const": "type"
              },
              "text": {
                "type": "string"
              }
            },
            "additionalProperties": false
          },
          {
            "type": "object",
            "required": [
              "type",
              "chord"
            ],
            "properties": {
              "type": {
                "const": "key"
              },
              "chord": {
                "type": "string"
              }
            },
            "additionalProperties": false
          },
          {
            "type": "object",
            "required": [
              "type"
            ],
            "properties": {
              "type": {
                "const": "wait"
              },
              "seconds": {
                "type": "number",
                "minimum": 0
              }
            },
            "additionalProperties": false
          },
          {
            "type": "object",
            "required": [
              "type"
            ],
            "properties": {
              "type": {
                "const": "capture"
              },
              "label": {
                "type": "string"
              }
            },
            "additionalProperties": false
          },
          {
            "type": "object",
            "required": [
              "type"
            ],
            "properties": {
              "type": {
                "const": "window_set"
              },
              "position": {
                "type": "array",
                "items": {
                  "type": "number"
                },
                "minItems": 2,
                "maxItems": 2
              },
              "size": {
                "type": "array",
                "items": {
                  "type": "number"
                },
                "minItems": 2,
                "maxItems": 2
              },
              "bounds": {
                "type": "array",
                "items": {
                  "type": "number"
                },
                "minItems": 4,
                "maxItems": 4
              },
              "preset": {
                "enum": [
                  "maximize",
                  "left-half",
                  "right-half",
                  "top-half",
                  "bottom-half",
                  "top-left",
                  "top-right",
                  "bottom-left",
                  "bottom-right",
                  "center"
                ]
              },
              "display": {
                "type": "integer",
                "minimum": 1
              },
              "margin": {
                "type": "number"
              },
              "allow_partial": {
                "type": "boolean"
              },
              "allow_constrained": {
                "type": "boolean"
              }
            },
            "additionalProperties": false
          }
        ]
      }
    }
  }
}
