{
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "$id": "https://roosteragents.ai/agent-referral/schema-0.1.json",
 "title": "Open Agent Referral v0.1",
 "type": "object",
 "required": [
  "spec",
  "version",
  "operator",
  "offers"
 ],
 "properties": {
  "spec": {
   "const": "open-agent-referral"
  },
  "version": {
   "type": "string"
  },
  "spec_url": {
   "type": "string",
   "format": "uri"
  },
  "updated": {
   "type": "string"
  },
  "operator": {
   "type": "object",
   "required": [
    "name"
   ],
   "properties": {
    "name": {
     "type": "string"
    },
    "url": {
     "type": "string",
     "format": "uri"
    },
    "contact": {
     "type": "string"
    },
    "privacy": {
     "type": "string",
     "format": "uri"
    },
    "terms": {
     "type": "string",
     "format": "uri"
    }
   }
  },
  "offers": {
   "type": "array",
   "minItems": 1,
   "items": {
    "type": "object",
    "required": [
     "id",
     "title",
     "refer_when",
     "handoff",
     "reward",
     "rules"
    ],
    "properties": {
     "id": {
      "type": "string"
     },
     "title": {
      "type": "string"
     },
     "summary": {
      "type": "string"
     },
     "audience": {
      "type": "string"
     },
     "refer_when": {
      "type": "string"
     },
     "do_not_refer": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "qualify": {
      "type": "object",
      "properties": {
       "mcp_url": {
        "type": "string",
        "format": "uri"
       },
       "tool": {
        "type": "string"
       },
       "optional": {
        "type": "boolean"
       }
      }
     },
     "handoff": {
      "type": "object",
      "required": [
       "type",
       "url_template"
      ],
      "properties": {
       "type": {
        "const": "owner_initiated_link"
       },
       "url_template": {
        "type": "string",
        "pattern": "^https://"
       },
       "default_referral_code": {
        "type": "string"
       },
       "mcp_tool": {
        "type": "string"
       },
       "a2a_url": {
        "type": "string"
       },
       "owner_action": {
        "type": "string"
       },
       "channel": {
        "type": "string"
       },
       "human_line": {
        "type": "string"
       }
      }
     },
     "reward": {
      "type": "object",
      "required": [
       "paid_to",
       "basis"
      ],
      "properties": {
       "paid_to": {
        "const": "verified_human"
       },
       "who": {
        "type": "string"
       },
       "basis": {
        "type": "string"
       },
       "when": {
        "type": "string"
       },
       "requires": {
        "type": "array",
        "items": {
         "type": "string"
        }
       },
       "never_paid_to": {
        "type": "array",
        "items": {
         "type": "string"
        }
       },
       "guarantee": {
        "type": "string"
       },
       "become_eligible": {
        "type": "string"
       }
      }
     },
     "attribution": {
      "type": "object",
      "properties": {
       "param": {
        "type": "string"
       },
       "code_pattern": {
        "type": "string"
       },
       "mcp_default": {
        "type": "string"
       },
       "first_touch": {
        "type": "boolean"
       },
       "self_referral": {
        "type": "boolean"
       }
      }
     },
     "rules": {
      "type": "object",
      "required": [
       "owner_sends_first_message",
       "no_cold_outreach",
       "never_collect",
       "disclosure_required"
      ],
      "properties": {
       "owner_sends_first_message": {
        "const": true
       },
       "no_cold_outreach": {
        "const": true
       },
       "never_collect": {
        "type": "array",
        "minItems": 1,
        "items": {
         "type": "string"
        }
       },
       "disclosure_required": {
        "type": "string"
       },
       "no_guarantees": {
        "type": "string"
       }
      }
     }
    }
   }
  }
 }
}