{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:aiwu:schema:workflow-pack:v1",
  "title": "AIWU Workflow Pack v1",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema", "id", "name", "version", "description", "requires", "risk", "workflows", "files"],
  "properties": {
    "schema": {"const": "aiwu.workflow-pack.v1"},
    "id": {"type": "string", "pattern": "^[a-z0-9]+(?:[.-][a-z0-9]+)*$", "maxLength": 128},
    "name": {"type": "string", "maxLength": 200},
    "version": {"type": "string", "pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(?:-[0-9A-Za-z.-]+)?(?:\\+[0-9A-Za-z.-]+)?$", "maxLength": 128},
    "description": {"type": "string", "maxLength": 4000},
    "requires": {
      "type": "array", "maxItems": 40,
      "items": {
        "type": "object", "additionalProperties": false, "required": ["kind", "id"],
        "properties": {
          "kind": {"enum": ["plugin", "account"]},
          "id": {"type": "string", "pattern": "^[a-z0-9][a-z0-9._/-]{1,190}$"},
          "version": {"type": "string", "pattern": "^(?:|(?:>=|<=|=|>|<)(?:0|[1-9][0-9]*)\\.(?:0|[1-9][0-9]*)\\.(?:0|[1-9][0-9]*))$"},
          "optional": {"type": "boolean"},
          "slot": {"type": "string", "pattern": "^[a-z0-9][a-z0-9_.-]{1,79}$"}
        },
        "allOf": [
          {
            "if": {"properties": {"kind": {"const": "account"}}, "required": ["kind"]},
            "then": {"required": ["slot"]}
          }
        ]
      }
    },
    "risk": {"type": "array", "maxItems": 40, "items": {"type": "string", "maxLength": 80}, "uniqueItems": true},
    "workflows": {
      "type": "array", "minItems": 1, "maxItems": 20,
      "items": {
        "type": "object", "additionalProperties": false, "required": ["id", "path"],
        "properties": {
          "id": {"type": "string", "pattern": "^[a-z0-9]+(?:[.-][a-z0-9]+)*$", "maxLength": 128},
          "path": {"type": "string", "pattern": "^workflows/[a-z0-9][a-z0-9.-]*\\.json$", "maxLength": 180}
        }
      }
    },
    "files": {
      "type": "array", "minItems": 1, "maxItems": 100,
      "items": {
        "type": "object", "additionalProperties": false, "required": ["path", "media_type", "size", "sha256"],
        "properties": {
          "path": {"type": "string", "maxLength": 180},
          "media_type": {"const": "application/json"},
          "size": {"type": "integer", "minimum": 0, "maximum": 10485760},
          "sha256": {"type": "string", "pattern": "^sha256:[a-f0-9]{64}$"}
        }
      }
    },
    "extensions": {"type": "object", "additionalProperties": false}
  }
}
