{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/hashgraph-online/skill-publish/main/schemas/skill.schema.json",
  "title": "Hashgraph Online Skill Manifest",
  "description": "Manifest for Registry Broker skill packages published to the HOL skills registry.",
  "type": "object",
  "additionalProperties": false,
  "$defs": {
    "scriptPermission": {
      "type": "object",
      "additionalProperties": false,
      "required": ["network", "filesystem"],
      "properties": {
        "network": {
          "type": "boolean"
        },
        "filesystem": {
          "type": "string",
          "enum": ["read-only", "read-write"]
        }
      }
    },
    "scriptPermissionsMap": {
      "type": "object",
      "propertyNames": {
        "type": "string",
        "pattern": "^scripts/.+"
      },
      "additionalProperties": {
        "$ref": "#/$defs/scriptPermission"
      }
    }
  },
  "required": ["name", "version", "description", "homepage", "skill", "api"],
  "properties": {
    "$schema": {
      "type": "string",
      "format": "uri"
    },
    "name": {
      "type": "string",
      "minLength": 1
    },
    "version": {
      "type": "string",
      "minLength": 1
    },
    "description": {
      "type": "string",
      "minLength": 1
    },
    "homepage": {
      "type": "string",
      "format": "uri"
    },
    "author": {
      "type": "string",
      "minLength": 1
    },
    "license": {
      "type": "string",
      "minLength": 1
    },
    "repository": {
      "type": "object",
      "additionalProperties": false,
      "required": ["type", "url"],
      "properties": {
        "type": {
          "type": "string",
          "minLength": 1
        },
        "url": {
          "type": "string",
          "format": "uri"
        }
      }
    },
    "keywords": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      }
    },
    "skill": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "name",
        "category",
        "api_base",
        "protocols",
        "capabilities",
        "files"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "emoji": {
          "type": "string",
          "minLength": 1
        },
        "category": {
          "type": "string",
          "minLength": 1
        },
        "api_base": {
          "type": "string",
          "format": "uri"
        },
        "protocols": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "capabilities": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "files": {
          "type": "object",
          "additionalProperties": false,
          "required": ["skill", "metadata", "docs"],
          "properties": {
            "skill": {
              "type": "string",
              "format": "uri"
            },
            "metadata": {
              "type": "string",
              "format": "uri"
            },
            "llms": {
              "type": "string",
              "format": "uri"
            },
            "docs": {
              "type": "string",
              "format": "uri"
            }
          }
        }
      }
    },
    "api": {
      "type": "object",
      "additionalProperties": false,
      "required": ["base_url", "authentication", "endpoints"],
      "properties": {
        "base_url": {
          "type": "string",
          "format": "uri"
        },
        "authentication": {
          "type": "object",
          "additionalProperties": false,
          "required": ["type", "header"],
          "properties": {
            "type": {
              "type": "string",
              "minLength": 1
            },
            "header": {
              "type": "string",
              "minLength": 1
            },
            "format": {
              "type": "string"
            }
          }
        },
        "endpoints": {
          "type": "object",
          "additionalProperties": {
            "type": "string",
            "minLength": 1
          }
        },
        "rate_limits": {
          "type": "object",
          "additionalProperties": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    },
    "integrations": {
      "type": "object",
      "additionalProperties": {
        "type": "object",
        "additionalProperties": true
      }
    },
    "permissions": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "scripts": {
          "$ref": "#/$defs/scriptPermissionsMap"
        }
      }
    },
    "scriptPermissions": {
      "$ref": "#/$defs/scriptPermissionsMap"
    },
    "stats": {
      "type": "object",
      "additionalProperties": true
    }
  }
}
