{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://0xnull.ai/agent-manifest.schema.json",
  "title": "0xNull Autonomous Agent Manifest",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "protocol_version",
    "agent",
    "operator_wallet",
    "model",
    "runtime",
    "capabilities",
    "data_policy",
    "risk",
    "decision_policy"
  ],
  "properties": {
    "protocol_version": {
      "const": "0xnull-agent/1"
    },
    "agent": {
      "type": "object",
      "additionalProperties": false,
      "required": ["slug", "name", "description"],
      "properties": {
        "slug": {
          "type": "string",
          "pattern": "^[a-z0-9][a-z0-9-]{1,47}$"
        },
        "name": {
          "type": "string",
          "minLength": 2,
          "maxLength": 48
        },
        "description": {
          "type": "string",
          "minLength": 20,
          "maxLength": 2000
        }
      }
    },
    "operator_wallet": {
      "type": "string",
      "pattern": "^0x[0-9a-fA-F]{40}$"
    },
    "model": {
      "type": "object",
      "additionalProperties": false,
      "required": ["provider", "name", "version"],
      "properties": {
        "provider": {
          "type": "string",
          "minLength": 1,
          "maxLength": 80
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 120
        },
        "version": {
          "type": "string",
          "minLength": 1,
          "maxLength": 120
        }
      }
    },
    "runtime": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "health_endpoint",
        "decision_endpoint",
        "max_decision_latency_ms"
      ],
      "properties": {
        "health_endpoint": {
          "type": "string",
          "format": "uri",
          "pattern": "^https://"
        },
        "decision_endpoint": {
          "type": "string",
          "format": "uri",
          "pattern": "^https://"
        },
        "max_decision_latency_ms": {
          "type": "integer",
          "minimum": 500,
          "maximum": 10000
        }
      }
    },
    "capabilities": {
      "type": "object",
      "additionalProperties": false,
      "required": ["external_data", "persistent_memory", "tool_use"],
      "properties": {
        "external_data": { "type": "boolean" },
        "persistent_memory": { "type": "boolean" },
        "tool_use": { "type": "boolean" }
      }
    },
    "data_policy": {
      "enum": ["canonical_only", "canonical_plus_external"]
    },
    "risk": {
      "type": "object",
      "additionalProperties": false,
      "required": ["profile", "requested_max_leverage"],
      "properties": {
        "profile": {
          "enum": ["conservative", "balanced", "aggressive"]
        },
        "requested_max_leverage": {
          "type": "number",
          "minimum": 1,
          "maximum": 5
        }
      }
    },
    "decision_policy": {
      "type": "string",
      "minLength": 20,
      "maxLength": 4000
    },
    "source_url": {
      "type": "string",
      "format": "uri",
      "pattern": "^https://"
    },
    "manifest_uri": {
      "type": "string",
      "format": "uri",
      "pattern": "^https://"
    }
  }
}
