{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/agentnexus-app/json-schema/agentnexus-app-discovery-result-schema.json",
  "title": "DiscoveryResult",
  "x-generated": "2026-11-15",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/agentnexus-app-openapi.yml#/components/schemas/DiscoveryResult",
  "type": "object",
  "properties": {
    "need": {
      "type": "string"
    },
    "coverage": {
      "type": "string",
      "enum": [
        "exact",
        "partial",
        "none"
      ]
    },
    "count": {
      "type": "integer"
    },
    "uncovered": {
      "type": "boolean"
    },
    "note": {
      "type": "string"
    },
    "next_steps": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "matches": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/DiscoveryMatch"
      }
    }
  },
  "required": [
    "need",
    "coverage",
    "count",
    "matches",
    "uncovered"
  ],
  "$defs": {
    "CurrentHealth": {
      "type": "object",
      "description": "Live state from the latest probes, distinct from historical reliability.",
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "up",
            "degraded",
            "down",
            "unknown"
          ]
        },
        "reasons": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "checked_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        }
      },
      "required": [
        "status",
        "reasons"
      ]
    },
    "DiscoveryMatch": {
      "type": "object",
      "properties": {
        "slug": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "category": {
          "type": "string",
          "enum": [
            "api",
            "mcp",
            "cli"
          ]
        },
        "summary": {
          "type": "string"
        },
        "match_score": {
          "type": "number"
        },
        "matched_on": {
          "type": "string",
          "enum": [
            "capability",
            "fallback"
          ]
        },
        "capabilities": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "call": {
          "type": "object",
          "additionalProperties": true,
          "description": "endpoint, auth_mode, auth_params, formats, rate_limit, pricing, example, docs_url"
        },
        "trust": {
          "type": "object",
          "additionalProperties": true,
          "description": "Historical reliability: verified, reliability_score, uptime, samples, avg_latency_ms"
        },
        "current_health": {
          "$ref": "#/$defs/CurrentHealth"
        },
        "alternatives": {
          "type": "array",
          "description": "Only when current_health is down or degraded. Advisory, not guaranteed.",
          "items": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "required": [
        "slug",
        "name",
        "category",
        "call",
        "trust",
        "current_health"
      ]
    }
  }
}