{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "contract": {
      "type": "string",
      "const": "CapabilityRegistry"
    },
    "entries": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "manifest": {
            "type": "object",
            "properties": {
              "contract": {
                "type": "string",
                "const": "CapabilityManifest"
              },
              "id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "capabilityVersion": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "ownerRepo": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "kind": {
                "type": "string",
                "enum": [
                  "primitive",
                  "composite",
                  "view",
                  "professional-provider",
                  "tool",
                  "workflow"
                ]
              },
              "displayName": {
                "type": "string",
                "minLength": 1
              },
              "description": {
                "type": "string"
              },
              "ports": {
                "type": "object",
                "properties": {
                  "inputs": {
                    "default": [],
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 256
                        },
                        "schemaRef": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 256
                        },
                        "required": {
                          "default": false,
                          "type": "boolean"
                        },
                        "multiple": {
                          "default": false,
                          "type": "boolean"
                        },
                        "description": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "name",
                        "schemaRef",
                        "required",
                        "multiple"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "outputs": {
                    "default": [],
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 256
                        },
                        "schemaRef": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 256
                        },
                        "required": {
                          "default": false,
                          "type": "boolean"
                        },
                        "multiple": {
                          "default": false,
                          "type": "boolean"
                        },
                        "description": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "name",
                        "schemaRef",
                        "required",
                        "multiple"
                      ],
                      "additionalProperties": false
                    }
                  }
                },
                "required": [
                  "inputs",
                  "outputs"
                ],
                "additionalProperties": false
              },
              "runtime": {
                "type": "object",
                "properties": {
                  "providerBindings": {
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "providerRef": {
                          "type": "object",
                          "properties": {
                            "kind": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 256
                            },
                            "id": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 256
                            },
                            "version": {
                              "anyOf": [
                                {
                                  "type": "integer",
                                  "exclusiveMinimum": 0,
                                  "maximum": 9007199254740991
                                },
                                {
                                  "type": "string",
                                  "minLength": 1
                                }
                              ]
                            },
                            "ownerRepo": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 256
                            }
                          },
                          "required": [
                            "kind",
                            "id"
                          ],
                          "additionalProperties": false
                        },
                        "productContexts": {
                          "default": [],
                          "type": "array",
                          "items": {
                            "type": "string",
                            "enum": [
                              "studio",
                              "kernel"
                            ]
                          }
                        },
                        "priority": {
                          "default": 0,
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        }
                      },
                      "required": [
                        "providerRef",
                        "productContexts",
                        "priority"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "loading": {
                    "type": "string",
                    "enum": [
                      "eager",
                      "lazy",
                      "viewport",
                      "on-activation"
                    ]
                  },
                  "fallbackCapabilityRef": {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256
                      },
                      "id": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256
                      },
                      "version": {
                        "anyOf": [
                          {
                            "type": "integer",
                            "exclusiveMinimum": 0,
                            "maximum": 9007199254740991
                          },
                          {
                            "type": "string",
                            "minLength": 1
                          }
                        ]
                      },
                      "ownerRepo": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256
                      }
                    },
                    "required": [
                      "kind",
                      "id"
                    ],
                    "additionalProperties": false
                  },
                  "stateOwner": {
                    "type": "string",
                    "enum": [
                      "host",
                      "provider",
                      "external"
                    ]
                  },
                  "stateSchemaRef": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  },
                  "sideEffects": {
                    "default": [],
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "network",
                        "storage",
                        "navigation",
                        "clipboard",
                        "worker",
                        "websocket"
                      ]
                    }
                  }
                },
                "required": [
                  "providerBindings",
                  "loading",
                  "stateOwner",
                  "sideEffects"
                ],
                "additionalProperties": false
              },
              "placement": {
                "type": "object",
                "properties": {
                  "surfaces": {
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 256
                    }
                  },
                  "slots": {
                    "default": [],
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 256
                    }
                  },
                  "variants": {
                    "default": [],
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 256
                    }
                  },
                  "tokenRefs": {
                    "default": [],
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 256
                    }
                  }
                },
                "required": [
                  "surfaces",
                  "slots",
                  "variants",
                  "tokenRefs"
                ],
                "additionalProperties": false
              },
              "accessibility": {
                "type": "object",
                "properties": {
                  "keyboardModel": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  },
                  "focusModel": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  },
                  "labelContract": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  }
                },
                "required": [
                  "keyboardModel",
                  "focusModel",
                  "labelContract"
                ],
                "additionalProperties": false
              },
              "observability": {
                "type": "object",
                "properties": {
                  "eventNamespace": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  },
                  "metrics": {
                    "default": [],
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 256
                    }
                  },
                  "evidenceRefs": {
                    "default": [],
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 256
                    }
                  },
                  "performanceBudgetMs": {
                    "type": "number",
                    "exclusiveMinimum": 0
                  }
                },
                "required": [
                  "eventNamespace",
                  "metrics",
                  "evidenceRefs"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "contract",
              "id",
              "capabilityVersion",
              "ownerRepo",
              "kind",
              "displayName",
              "ports",
              "runtime",
              "placement",
              "accessibility",
              "observability"
            ],
            "additionalProperties": false
          },
          "sources": {
            "minItems": 1,
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "sourceType": {
                  "type": "string",
                  "enum": [
                    "tool-manifest",
                    "plugin-manifest",
                    "openapi",
                    "workflow",
                    "comfyui",
                    "design-view-provider"
                  ]
                },
                "sourceId": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 256
                },
                "ownerRepo": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 256
                }
              },
              "required": [
                "sourceType",
                "sourceId",
                "ownerRepo"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "manifest",
          "sources"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "contract",
    "entries"
  ],
  "additionalProperties": false,
  "$id": "https://schemas.infmonkeys.com/contracts/capability-registry.schema.json",
  "title": "capability-registry"
}
