{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://agentprofile.org/schemas/0.0.1/profile.schema.json",
  "title": "Agent Profile 0.0.1",
  "description": "Manifest schema for one durable logical AI agent profile.",
  "type": "object",
  "required": ["$schema", "id", "name"],
  "properties": {
    "$schema": {
      "const": "https://agentprofile.org/schemas/0.0.1/profile.schema.json"
    },
    "id": {
      "$ref": "#/$defs/absoluteUri"
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 256
    },
    "version": {
      "type": "string",
      "minLength": 1,
      "maxLength": 64
    },
    "description": {
      "type": "string",
      "minLength": 1,
      "maxLength": 4096
    },
    "owner": {
      "type": "object",
      "required": ["name"],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "email": {
          "type": "string",
          "minLength": 3,
          "maxLength": 320,
          "pattern": "^[^@\\s]+@[^@\\s]+$"
        },
        "url": {
          "$ref": "#/$defs/absoluteUri"
        }
      },
      "additionalProperties": false
    },
    "contacts": {
      "type": "array",
      "maxItems": 64,
      "items": {
        "$ref": "#/$defs/absoluteUri"
      }
    },
    "identifiers": {
      "type": "array",
      "maxItems": 64,
      "items": {
        "type": "object",
        "required": ["type"],
        "properties": {
          "type": {
            "type": "string",
            "minLength": 1
          }
        },
        "allOf": [
          {
            "if": {
              "properties": {
                "type": {
                  "const": "issuer-subject"
                }
              }
            },
            "then": {
              "$ref": "#/$defs/issuerSubjectIdentifier"
            }
          },
          {
            "if": {
              "properties": {
                "type": {
                  "const": "uri"
                }
              }
            },
            "then": {
              "$ref": "#/$defs/uriIdentifier"
            }
          }
        ]
      }
    },
    "extensions": {
      "type": "object",
      "propertyNames": {
        "pattern": "^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)+$",
        "maxLength": 253
      },
      "additionalProperties": {
        "type": "object"
      }
    }
  },
  "$defs": {
    "absoluteUri": {
      "type": "string",
      "minLength": 1,
      "maxLength": 2048,
      "pattern": "^[A-Za-z][A-Za-z0-9+.-]*:\\S+$"
    },
    "issuerSubjectIdentifier": {
      "type": "object",
      "required": ["type", "issuer", "subject"],
      "properties": {
        "type": {
          "const": "issuer-subject"
        },
        "issuer": {
          "type": "string",
          "minLength": 1,
          "maxLength": 2048
        },
        "subject": {
          "type": "string",
          "minLength": 1,
          "maxLength": 1024
        }
      },
      "additionalProperties": false
    },
    "uriIdentifier": {
      "type": "object",
      "required": ["type", "value"],
      "properties": {
        "type": {
          "const": "uri"
        },
        "value": {
          "$ref": "#/$defs/absoluteUri"
        }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false
}
