{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://docs.b1m.ai/capabilities.schema.json",
  "title": "Beam capability registry",
  "description": "Beam's capabilities for AI agents, as data. The prose guide at /docs/agent is authoritative.",
  "type": "object",
  "required": ["schemaVersion", "updated", "about", "guide", "pricing", "rules", "interfaces", "operations", "capabilities", "connectors", "connections", "patterns", "notOffered"],
  "additionalProperties": false,
  "properties": {
    "$schema": { "type": "string" },
    "schemaVersion": { "const": 1 },
    "updated": { "type": "string", "format": "date" },
    "about": { "type": "string" },
    "guide": { "$ref": "#/$defs/docsLink" },
    "pricing": {
      "type": "object",
      "required": ["creditUsd", "docs", "note"],
      "additionalProperties": false,
      "properties": {
        "creditUsd": { "type": "number", "exclusiveMinimum": 0 },
        "docs": { "$ref": "#/$defs/docsLink" },
        "note": { "type": "string" }
      }
    },
    "rules": { "type": "array", "items": { "type": "string" }, "minItems": 1 },
    "interfaces": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["id", "name", "docs", "reachFor"],
        "additionalProperties": false,
        "properties": {
          "id": { "$ref": "#/$defs/identifier" },
          "name": { "type": "string" },
          "docs": { "$ref": "#/$defs/docsLink" },
          "reachFor": { "type": "string" }
        }
      }
    },
    "operations": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["id", "name", "availability"],
        "additionalProperties": false,
        "properties": {
          "id": { "type": "string", "pattern": "^[a-z]+(\\.[a-z-]+)+$" },
          "name": { "type": "string" },
          "availability": {
            "description": "One entry per interface id.",
            "type": "object",
            "additionalProperties": {
              "type": "object",
              "required": ["status"],
              "additionalProperties": false,
              "properties": {
                "status": { "enum": ["yes", "no", "partial"] },
                "note": { "type": "string" }
              }
            }
          }
        }
      }
    },
    "capabilities": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["id", "name", "guide", "does", "operations", "inputs", "outputs", "connectsTo", "requires", "trust", "cost", "limits", "docs"],
        "additionalProperties": false,
        "properties": {
          "id": { "$ref": "#/$defs/identifier" },
          "name": { "type": "string" },
          "guide": { "$ref": "#/$defs/docsLink" },
          "does": { "type": "string" },
          "operations": { "type": "array", "items": { "type": "string" } },
          "inputs": { "type": "string" },
          "steps": { "type": "array", "items": { "type": "string" } },
          "stages": { "type": "array", "items": { "type": "string" } },
          "channelKinds": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["kind", "carries", "receive"],
              "additionalProperties": false,
              "properties": {
                "kind": { "enum": ["message", "object", "stream", "datagram", "media"] },
                "carries": { "type": "string" },
                "receive": { "type": "string" }
              }
            }
          },
          "outputs": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["name", "delivery", "how"],
              "additionalProperties": false,
              "properties": {
                "name": { "type": "string" },
                "delivery": { "$ref": "#/$defs/delivery" },
                "how": { "type": "string" }
              }
            }
          },
          "connectsTo": { "type": "array", "items": { "$ref": "#/$defs/identifier" } },
          "requires": { "type": "array", "items": { "type": "string" } },
          "trust": { "type": "string" },
          "cost": {
            "type": "object",
            "required": ["credits"],
            "additionalProperties": false,
            "properties": { "credits": { "type": "string" }, "example": { "type": "string" } }
          },
          "limits": { "type": "array", "items": { "type": "string" } },
          "docs": { "type": "array", "items": { "$ref": "#/$defs/docsLink" } }
        }
      }
    },
    "connectors": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["id", "name", "source", "destination", "through", "notes", "docs"],
        "additionalProperties": false,
        "properties": {
          "id": { "$ref": "#/$defs/identifier" },
          "name": { "type": "string" },
          "source": { "enum": ["yes", "no"] },
          "destination": { "enum": ["yes", "no"] },
          "through": { "type": "array", "items": { "$ref": "#/$defs/identifier" } },
          "notes": { "type": "string" },
          "docs": { "$ref": "#/$defs/docsLink" }
        }
      }
    },
    "connections": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["output", "delivery", "how", "next", "glue"],
        "additionalProperties": false,
        "properties": {
          "output": { "type": "string" },
          "delivery": { "$ref": "#/$defs/delivery" },
          "how": { "type": "string" },
          "next": { "type": "string" },
          "glue": { "type": "string" }
        }
      }
    },
    "patterns": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["id", "name", "capabilities", "flow", "glue", "smallestProof"],
        "additionalProperties": false,
        "properties": {
          "id": { "type": "string", "pattern": "^[A-Z]$" },
          "name": { "type": "string" },
          "capabilities": { "type": "array", "items": { "$ref": "#/$defs/identifier" }, "minItems": 1 },
          "flow": { "type": "array", "items": { "type": "string" }, "minItems": 1 },
          "glue": { "type": "string" },
          "smallestProof": { "type": "string" }
        }
      }
    },
    "notOffered": { "type": "array", "items": { "type": "string" } }
  },
  "$defs": {
    "identifier": { "type": "string", "pattern": "^[a-z][a-z0-9-]*$" },
    "docsLink": { "type": "string", "pattern": "^/docs/[a-z0-9/-]*(#[a-z0-9-]+)?$|^/docs/agent$" },
    "delivery": { "enum": ["pushed", "read", "onchain"] }
  }
}
