{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://humanisoffline.com/schemas/agent-request.v1.json",
  "title": "Agent Request Envelope v1",
  "oneOf": [
    {
      "title": "Encrypted envelope (API submission)",
      "type": "object",
      "required": [
        "schemaVersion",
        "cardSlug",
        "encryptedPayload",
        "encryption"
      ],
      "properties": {
        "schemaVersion": { "type": "integer", "const": 1 },
        "cardSlug": { "type": "string" },
        "publicKeyId": { "type": "string" },
        "encryptedPayload": { "type": "string" },
        "encryption": {
          "type": "object",
          "required": ["scheme", "nonce"],
          "properties": {
            "scheme": { "const": "sealed_box_v1" },
            "nonce": { "type": "string" }
          }
        }
      }
    },
    {
      "title": "Plaintext before encryption (client-side only)",
      "type": "object",
      "required": [
        "schemaVersion",
        "type",
        "title",
        "summary",
        "urgency",
        "riskLevel"
      ],
      "properties": {
        "schemaVersion": { "type": "integer", "const": 1 },
        "type": {
          "enum": ["inform", "collect", "authorize", "escalate", "result"]
        },
        "title": { "type": "string", "maxLength": 200 },
        "summary": { "type": "string", "maxLength": 2000 },
        "urgency": { "enum": ["low", "normal", "high", "critical"] },
        "riskLevel": { "enum": ["low", "medium", "high", "irreversible"] }
      }
    }
  ]
}
