{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://stefilcoder.ledgecode.com/code-as-usual-registry/v1/distribution-registry-v1.schema.json",
  "title": "Code as Usual maintained distribution registry",
  "type": "object",
  "additionalProperties": false,
  "required": ["format", "formatVersion", "registryVersion", "publishedAt", "runtimePackageCatalogHref", "assets", "terminalAdapters", "terminalAdapterCompatibilities"],
  "properties": {
    "format": {"const": "code-as-usual.distribution-registry"},
    "formatVersion": {"const": 1},
    "registryVersion": {"type": "integer", "minimum": 1},
    "publishedAt": {"type": "string", "format": "date-time"},
    "runtimePackageCatalogHref": {"$ref": "#/$defs/href"},
    "assets": {
      "type": "array",
      "minItems": 1,
      "maxItems": 200,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["href", "sha256"],
        "properties": {
          "href": {"$ref": "#/$defs/href"},
          "sha256": {"type": "string", "pattern": "^[0-9a-f]{64}$"}
        }
      }
    },
    "terminalAdapters": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["adapterKey", "adapterVersion", "providerProgram", "installationMode", "protocolVersion", "artifactDigest", "artifactHref", "ownedPath", "launchCommand", "neutralEventTypes"],
        "properties": {
          "adapterKey": {"type": "string", "pattern": "^[a-z0-9][a-z0-9-]{0,79}$"},
          "adapterVersion": {"type": "string", "minLength": 1, "maxLength": 80},
          "providerProgram": {"type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,119}$"},
          "installationMode": {"const": "CODEX_PROFILE"},
          "protocolVersion": {"type": "integer", "minimum": 1},
          "artifactDigest": {"type": "string", "pattern": "^sha256:[0-9a-f]{64}$"},
          "artifactHref": {"$ref": "#/$defs/href"},
          "ownedPath": {"type": "string", "pattern": "^/home/session/\\.codex/[A-Za-z0-9._-]+\\.config\\.toml$"},
          "launchCommand": {"type": "string", "minLength": 1, "maxLength": 240},
          "neutralEventTypes": {
            "type": "array",
            "minItems": 1,
            "uniqueItems": true,
            "items": {"type": "string", "pattern": "^[A-Z][A-Z0-9_]{0,79}$"}
          }
        }
      }
    },
    "terminalAdapterCompatibilities": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["adapterKey", "adapterVersion", "artifactDigest", "providerVersionRule"],
        "properties": {
          "adapterKey": {"type": "string", "pattern": "^[a-z0-9][a-z0-9-]{0,79}$"},
          "adapterVersion": {"type": "string", "minLength": 1, "maxLength": 80},
          "artifactDigest": {"type": "string", "pattern": "^sha256:[0-9a-f]{64}$"},
          "providerVersionRule": {"type": "string", "minLength": 1, "maxLength": 240}
        }
      }
    }
  },
  "$defs": {
    "href": {
      "type": "string",
      "minLength": 1,
      "maxLength": 500,
      "pattern": "^(?!/)(?!.*(?:^|/)\\.\\.(?:/|$))[A-Za-z0-9._/-]+$"
    }
  }
}
