{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://chatsupporthq.com/schemas/agent-desk-0.2.json",
  "title": "Agent Desk discovery file",
  "description": "Published at https://<domain>/.well-known/agent-desk.json. Agent Desk spec v0.2 (draft). MIT License, Copyright (c) 2026 DishIs Technologies LLC.",
  "type": "object",
  "required": ["spec", "name", "domain", "mcp", "tools", "auth"],
  "properties": {
    "spec": {
      "type": "string",
      "pattern": "^agent-desk/[0-9]+\\.[0-9]+$",
      "description": "agent-desk/<major.minor>. Agents MUST ignore files with an unknown major version."
    },
    "name": { "type": "string", "minLength": 1, "maxLength": 200, "description": "Display name of the desk." },
    "domain": {
      "type": "string",
      "description": "The business domain. MUST equal the host the agent originally requested, even after a redirect.",
      "pattern": "^(?=.{1,253}$)([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\\.)+[a-z]{2,63}$"
    },
    "mcp": {
      "type": "object",
      "required": ["url", "transport"],
      "properties": {
        "url": { "type": "string", "format": "uri", "pattern": "^https://", "description": "Remote MCP endpoint. Any https origin." },
        "transport": { "const": "streamable-http", "description": "v0.2 supports streamable-http only." }
      }
    },
    "tools": {
      "type": "array",
      "uniqueItems": true,
      "items": { "enum": ["ask", "open_case", "case_status", "request_refund", "handoff_to_human"] },
      "allOf": [
        { "contains": { "const": "ask" } },
        { "contains": { "const": "handoff_to_human" } }
      ],
      "description": "Tools this desk offers. ask and handoff_to_human are always present."
    },
    "auth": {
      "type": "object",
      "required": ["agent_signature"],
      "properties": {
        "agent_signature": { "const": "web-bot-auth", "description": "Agent identity method accepted. Unsigned agents are still served as unverified." },
        "signature_required_for": {
          "type": "array",
          "uniqueItems": true,
          "default": [],
          "items": { "enum": ["ask", "open_case", "case_status", "request_refund"] },
          "description": "Tools that reject unsigned agents. handoff_to_human can never be listed."
        },
        "user_authorization": {
          "const": "one-time-code",
          "description": "Omitted when the desk has no customer lookup source and cannot verify customers."
        },
        "required_for": {
          "type": "array",
          "uniqueItems": true,
          "items": { "enum": ["open_case", "case_status", "request_refund"] },
          "description": "Tools that need a user authorization token. Never ask or handoff_to_human."
        },
        "endpoints": {
          "type": "object",
          "description": "Optional mirror HTTP endpoints for the authorization tools.",
          "properties": {
            "request_authorization": { "type": "string", "format": "uri", "pattern": "^https://" },
            "verify_authorization": { "type": "string", "format": "uri", "pattern": "^https://" }
          }
        }
      },
      "dependentRequired": { "required_for": ["user_authorization"] }
    },
    "posture": {
      "type": "object",
      "description": "The business's agent posture. Optional to publish; the server enforces it either way.",
      "properties": {
        "default": { "$ref": "#/$defs/posture", "default": "serve" },
        "unverified": { "$ref": "#/$defs/posture", "default": "tolerate" },
        "journeys": {
          "type": "object",
          "propertyNames": { "pattern": "^[a-z][a-z0-9_]{0,63}$" },
          "additionalProperties": { "$ref": "#/$defs/posture" }
        }
      }
    },
    "limits": {
      "type": "object",
      "description": "Public action limits. Server-side limits are authoritative.",
      "properties": {
        "request_refund": {
          "type": "object",
          "properties": {
            "max_amount": { "type": "number", "minimum": 0 },
            "currency": { "type": "string", "pattern": "^[A-Z]{3}$" },
            "per_user_per_30d": { "type": "integer", "minimum": 0 }
          },
          "dependentRequired": { "max_amount": ["currency"] }
        }
      }
    },
    "human": {
      "type": "object",
      "properties": {
        "available": { "type": "boolean" },
        "hours": { "type": "string", "maxLength": 200 }
      }
    },
    "languages": { "type": "array", "items": { "type": "string", "pattern": "^[a-z]{2,3}(-[A-Za-z0-9]{2,8})*$" } },
    "policy_url": { "type": "string", "format": "uri", "pattern": "^https://" },
    "contact": { "type": "string", "maxLength": 254 },
    "updated": { "type": "string", "format": "date-time" }
  },
  "$defs": {
    "posture": { "enum": ["block", "tolerate", "serve"] }
  }
}
