{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "schemaVersion": {
      "type": "string",
      "const": "hay.bundle/1"
    },
    "manifest": {
      "type": "object",
      "properties": {
        "schemaVersion": {
          "type": "string",
          "const": "hay.app/1"
        },
        "id": {
          "type": "string",
          "maxLength": 80,
          "pattern": "^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)+$"
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 80
        },
        "version": {
          "type": "string",
          "pattern": "^\\d+\\.\\d+\\.\\d+$"
        },
        "description": {
          "type": "string",
          "minLength": 1,
          "maxLength": 500
        },
        "author": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100
        },
        "entrypoint": {
          "type": "string",
          "const": "index.html"
        },
        "icon": {
          "type": "string",
          "maxLength": 40
        },
        "color": {
          "type": "string",
          "pattern": "^#[0-9a-fA-F]{6}$"
        },
        "capabilities": {
          "maxItems": 10,
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "storage",
              "files.read",
              "models.invoke",
              "browser.read",
              "github.read",
              "github.private.read",
              "coding.read",
              "coding.run",
              "coding.commit",
              "browser.control"
            ]
          }
        },
        "views": {
          "minItems": 1,
          "maxItems": 12,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "maxLength": 60,
                "pattern": "^[a-z][a-z0-9-]*$"
              },
              "title": {
                "type": "string",
                "minLength": 1,
                "maxLength": 80
              },
              "description": {
                "type": "string",
                "maxLength": 250
              }
            },
            "required": [
              "id",
              "title",
              "description"
            ],
            "additionalProperties": false
          }
        },
        "intents": {
          "maxItems": 16,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "maxLength": 60,
                "pattern": "^[a-z][a-z0-9-]*$"
              },
              "label": {
                "type": "string",
                "minLength": 1,
                "maxLength": 100
              },
              "prompt": {
                "type": "string",
                "maxLength": 2000
              },
              "viewId": {
                "type": "string",
                "maxLength": 60
              }
            },
            "required": [
              "id",
              "label",
              "prompt",
              "viewId"
            ],
            "additionalProperties": false
          }
        },
        "defaultTask": {
          "type": "object",
          "properties": {
            "title": {
              "type": "string",
              "minLength": 1,
              "maxLength": 150
            },
            "viewId": {
              "type": "string",
              "maxLength": 60
            }
          },
          "required": [
            "title"
          ],
          "additionalProperties": false
        },
        "agent": {
          "type": "object",
          "properties": {
            "instructions": {
              "type": "string",
              "minLength": 1,
              "maxLength": 6000
            }
          },
          "required": [
            "instructions"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "schemaVersion",
        "id",
        "name",
        "version",
        "description",
        "author",
        "entrypoint",
        "icon",
        "color",
        "capabilities",
        "views",
        "intents"
      ],
      "additionalProperties": false
    },
    "html": {
      "type": "string",
      "minLength": 1,
      "maxLength": 1000000
    },
    "initialData": {
      "type": "object",
      "properties": {
        "state": {
          "type": "object",
          "propertyNames": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "additionalProperties": {
            "$ref": "#/$defs/__schema0"
          }
        },
        "documents": {
          "maxItems": 100,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "maxLength": 100,
                "pattern": "^[A-Za-z0-9_-]+$"
              },
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 255
              },
              "text": {
                "type": "string",
                "maxLength": 1000000
              }
            },
            "required": [
              "id",
              "name",
              "text"
            ],
            "additionalProperties": false
          }
        }
      },
      "additionalProperties": false
    }
  },
  "required": [
    "schemaVersion",
    "manifest",
    "html"
  ],
  "additionalProperties": false,
  "$defs": {
    "__schema0": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "number"
        },
        {
          "type": "boolean"
        },
        {
          "type": "null"
        },
        {
          "type": "array",
          "items": {
            "$ref": "#/$defs/__schema0"
          }
        },
        {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {
            "$ref": "#/$defs/__schema0"
          }
        }
      ]
    }
  }
}
