{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://agentweb.us/.well-known/setup-session.schema.json",
  "title": "AgentWeb Setup Session",
  "type": "object",
  "required": [
    "setup_session_id",
    "business_domain",
    "requested_package",
    "requested_scopes",
    "payment_state",
    "status",
    "created_at",
    "expires_at"
  ],
  "properties": {
    "setup_session_id": { "type": "string" },
    "requesting_agent": {
      "type": "object",
      "properties": {
        "agent_id": { "type": "string" },
        "agent_name": { "type": "string" },
        "agent_provider": { "type": "string" },
        "agent_protocol": { "type": "string", "enum": ["a2a", "mcp", "openapi", "direct_api", "unknown"] }
      }
    },
    "principal_type": { "type": "string", "enum": ["business", "user", "agent", "enterprise_account", "unknown"] },
    "principal_id": { "type": "string" },
    "business_domain": { "type": "string" },
    "requested_package": {
      "type": "string",
      "enum": [
        "readiness_scan",
        "discoverability_fix",
        "starter_action_map",
        "growth_action_bundle",
        "end_to_end_agent_ready_business",
        "enterprise_agent_discovery_program"
      ]
    },
    "requested_scopes": {
      "type": "array",
      "items": { "$ref": "#/$defs/permission_scope" }
    },
    "approved_scopes": {
      "type": "array",
      "items": { "$ref": "#/$defs/permission_scope" }
    },
    "budget_limit": {
      "type": "object",
      "properties": {
        "amount": { "type": "number" },
        "currency": { "type": "string" },
        "expires_at": { "type": "string", "format": "date-time" }
      }
    },
    "payment_state": {
      "type": "string",
      "enum": ["not_required", "quote_required", "awaiting_payment", "paid", "failed", "refunded", "cancelled"]
    },
    "payment_artifact_id": { "type": "string" },
    "permission_artifact_id": { "type": "string" },
    "work_order_id": { "type": "string" },
    "status": {
      "type": "string",
      "enum": [
        "quoted",
        "awaiting_authority",
        "awaiting_payment",
        "paid",
        "scoped",
        "installing",
        "verification_pending",
        "verified",
        "blocked",
        "cancelled"
      ]
    },
    "created_at": { "type": "string", "format": "date-time" },
    "expires_at": { "type": "string", "format": "date-time" },
    "verification_artifact_id": { "type": "string" }
  },
  "$defs": {
    "permission_scope": {
      "type": "string",
      "enum": [
        "scan.public_site",
        "read.public_metadata",
        "generate.business_profile",
        "generate.agent_card",
        "generate.llms_txt",
        "generate.openapi",
        "generate.mcp_manifest",
        "generate.a2a_card",
        "generate.action_map_draft",
        "verify.public_deploy",
        "create.setup_session",
        "request.repo_connection",
        "write.repo_branch",
        "submit.business_action",
        "initiate.payment"
      ]
    }
  }
}
