{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.erlensuite.com/agentes/catalogo.schema.json",
  "title": "Erlen Suite public agent discovery catalogue",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "$schema",
    "schemaVersion",
    "id",
    "purpose",
    "scope",
    "documentation",
    "products"
  ],
  "properties": {
    "$schema": {
      "$ref": "#/$defs/url"
    },
    "schemaVersion": {
      "const": "1.0.0"
    },
    "id": {
      "const": "erlen-suite"
    },
    "purpose": {
      "const": "discovery"
    },
    "scope": {
      "const": "partial"
    },
    "documentation": {
      "$ref": "#/$defs/url"
    },
    "products": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/product"
      }
    }
  },
  "$defs": {
    "url": {
      "type": "string",
      "format": "uri",
      "pattern": "^https://"
    },
    "strings": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      }
    },
    "availability": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "execution",
        "machineCallableApi",
        "remoteService"
      ],
      "properties": {
        "execution": {
          "enum": [
            "local-mcp",
            "existing-user-interface"
          ]
        },
        "machineCallableApi": {
          "type": "boolean"
        },
        "remoteService": {
          "const": false
        },
        "transport": {
          "const": "stdio"
        },
        "requiresLocalInstallation": {
          "const": true
        },
        "requiresSourceAccess": {
          "const": true
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "execution": {
                "const": "local-mcp"
              }
            }
          },
          "then": {
            "required": [
              "transport",
              "requiresLocalInstallation",
              "requiresSourceAccess"
            ],
            "properties": {
              "machineCallableApi": {
                "const": true
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "execution": {
                "const": "existing-user-interface"
              }
            }
          },
          "then": {
            "properties": {
              "machineCallableApi": {
                "const": false
              }
            }
          }
        }
      ]
    },
    "capability": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "summary"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "summary": {
          "type": "string",
          "minLength": 1
        },
        "tools": {
          "$ref": "#/$defs/strings"
        }
      }
    },
    "product": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "name",
        "version",
        "status",
        "documentation",
        "userInterface",
        "sourceMetadata",
        "requiresHumanReview",
        "availability",
        "capabilities",
        "formats",
        "limits"
      ],
      "properties": {
        "id": {
          "enum": [
            "slides",
            "ftir"
          ]
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "version": {
          "type": "string",
          "pattern": "^\\d+\\.\\d+\\.\\d+(?:[-+][\\w.-]+)?$"
        },
        "status": {
          "enum": [
            "alpha",
            "beta",
            "stable",
            "available"
          ]
        },
        "documentation": {
          "$ref": "#/$defs/url"
        },
        "userInterface": {
          "$ref": "#/$defs/url"
        },
        "sourceMetadata": {
          "$ref": "#/$defs/url"
        },
        "requiresHumanReview": {
          "const": true
        },
        "availability": {
          "$ref": "#/$defs/availability"
        },
        "capabilities": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/capability"
          }
        },
        "formats": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "scope",
            "inputs",
            "outputs"
          ],
          "properties": {
            "scope": {
              "const": "partial"
            },
            "inputs": {
              "$ref": "#/$defs/strings"
            },
            "outputs": {
              "$ref": "#/$defs/strings"
            }
          }
        },
        "limits": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "interface": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "protocol",
            "schemaDiscovery",
            "command",
            "args",
            "workspaceEnvironment"
          ],
          "properties": {
            "protocol": {
              "const": "MCP"
            },
            "schemaDiscovery": {
              "const": "tools/list"
            },
            "command": {
              "const": "node"
            },
            "args": {
              "$ref": "#/$defs/strings"
            },
            "workspaceEnvironment": {
              "const": "ERLEN_SLIDES_DIR"
            }
          }
        },
        "discovery": {
          "$ref": "#/$defs/url"
        },
        "contract": {
          "type": "object",
          "required": [
            "appId",
            "contractVersion",
            "scope",
            "availability",
            "privacy",
            "capabilities"
          ],
          "properties": {
            "appId": {
              "const": "ftir"
            },
            "contractVersion": {
              "const": "1.0.0"
            },
            "scope": {
              "const": "partial"
            }
          }
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "id": {
                "const": "slides"
              }
            }
          },
          "then": {
            "required": [
              "interface"
            ],
            "properties": {
              "availability": {
                "properties": {
                  "execution": {
                    "const": "local-mcp"
                  }
                }
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "id": {
                "const": "ftir"
              }
            }
          },
          "then": {
            "required": [
              "discovery",
              "contract"
            ],
            "properties": {
              "availability": {
                "properties": {
                  "execution": {
                    "const": "existing-user-interface"
                  }
                }
              }
            }
          }
        }
      ]
    }
  }
}
