{
  "name": "reply",
  "description": "Reply to the user. Every answer goes through this tool as SaleSys UI blocks.",
  "input_schema": {
    "type": "object",
    "properties": {
      "blocks": {
        "type": "array",
        "items": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "type": {
                  "const": "text"
                },
                "text": {
                  "type": "string",
                  "maxLength": 4000,
                  "description": "Markdown-lite: **bold**, *italic*, `code`, [link](https://...), \"- \" bullets, \"1. \" lists, blank line = paragraph"
                },
                "tone": {
                  "type": "string",
                  "enum": [
                    "normal",
                    "title",
                    "muted"
                  ]
                }
              },
              "required": [
                "type",
                "text"
              ],
              "additionalProperties": false,
              "description": "Plain answer text. Most replies start with one."
            },
            {
              "type": "object",
              "properties": {
                "type": {
                  "const": "notice"
                },
                "tone": {
                  "type": "string",
                  "enum": [
                    "info",
                    "good",
                    "warning",
                    "danger"
                  ]
                },
                "title": {
                  "type": "string",
                  "maxLength": 80
                },
                "text": {
                  "type": "string",
                  "maxLength": 600
                }
              },
              "required": [
                "type",
                "tone",
                "text"
              ],
              "additionalProperties": false,
              "description": "Highlighted message: confirmation (good), heads-up (warning), error (danger), tip (info)."
            },
            {
              "type": "object",
              "properties": {
                "type": {
                  "const": "buttons"
                },
                "buttons": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "pattern": "^[A-Za-z0-9_.-]{1,64}$"
                      },
                      "label": {
                        "type": "string",
                        "maxLength": 40
                      },
                      "icon": {
                        "type": "string",
                        "pattern": "^[a-z0-9-]{1,40}$",
                        "description": "FontAwesome 5 name without \"fa-\", e.g. \"phone\""
                      },
                      "weight": {
                        "type": "string",
                        "enum": [
                          "primary",
                          "normal",
                          "danger",
                          "simple"
                        ]
                      },
                      "url": {
                        "type": "string",
                        "maxLength": 500,
                        "description": "Opens a link instead of sending an action (https, mailto:, tel:)"
                      },
                      "confirm": {
                        "type": "boolean",
                        "description": "Require a second click. Use for anything that changes or deletes data."
                      },
                      "tooltip": {
                        "type": "string",
                        "maxLength": 120
                      }
                    },
                    "required": [
                      "id",
                      "label"
                    ],
                    "additionalProperties": false
                  },
                  "maxItems": 4
                }
              },
              "required": [
                "type",
                "buttons"
              ],
              "additionalProperties": false,
              "description": "Actions. Clicking sends {type:\"button\", id} back to you. At most one primary."
            },
            {
              "type": "object",
              "properties": {
                "type": {
                  "const": "choices"
                },
                "options": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "pattern": "^[A-Za-z0-9_.-]{1,64}$"
                      },
                      "label": {
                        "type": "string",
                        "maxLength": 60
                      },
                      "icon": {
                        "type": "string",
                        "pattern": "^[a-z0-9-]{1,40}$",
                        "description": "FontAwesome 5 name without \"fa-\", e.g. \"phone\""
                      }
                    },
                    "required": [
                      "id",
                      "label"
                    ],
                    "additionalProperties": false
                  },
                  "maxItems": 8
                },
                "multiple": {
                  "type": "boolean"
                },
                "submitLabel": {
                  "type": "string",
                  "maxLength": 30
                }
              },
              "required": [
                "type",
                "options"
              ],
              "additionalProperties": false,
              "description": "Quick replies. Single: one tap answers ({type:\"choice\", ids:[id]}). multiple: toggles + submit."
            },
            {
              "type": "object",
              "properties": {
                "type": {
                  "const": "list"
                },
                "selectable": {
                  "type": "boolean",
                  "description": "Clicking an item sends {type:\"select\", id}"
                },
                "items": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "pattern": "^[A-Za-z0-9_.-]{1,64}$"
                      },
                      "label": {
                        "type": "string",
                        "maxLength": 80
                      },
                      "description": {
                        "type": "string",
                        "maxLength": 160
                      },
                      "icon": {
                        "type": "string",
                        "pattern": "^[a-z0-9-]{1,40}$",
                        "description": "FontAwesome 5 name without \"fa-\", e.g. \"phone\""
                      },
                      "lines": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "maxLength": 120
                        },
                        "maxItems": 3,
                        "description": "Extra detail lines"
                      },
                      "badges": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "icon": {
                              "type": "string",
                              "pattern": "^[a-z0-9-]{1,40}$",
                              "description": "FontAwesome 5 name without \"fa-\", e.g. \"phone\""
                            },
                            "text": {
                              "type": "string",
                              "maxLength": 40
                            }
                          },
                          "required": [
                            "icon",
                            "text"
                          ],
                          "additionalProperties": false
                        },
                        "maxItems": 3
                      }
                    },
                    "required": [
                      "id",
                      "label"
                    ],
                    "additionalProperties": false
                  },
                  "maxItems": 30
                }
              },
              "required": [
                "type",
                "items"
              ],
              "additionalProperties": false,
              "description": "Records (contacts, orders, lists, users...). SaleSys SettingsList."
            },
            {
              "type": "object",
              "properties": {
                "type": {
                  "const": "form"
                },
                "id": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9_.-]{1,64}$"
                },
                "submitLabel": {
                  "type": "string",
                  "maxLength": 30
                },
                "fields": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "pattern": "^[A-Za-z0-9_.-]{1,64}$"
                      },
                      "label": {
                        "type": "string",
                        "maxLength": 60
                      },
                      "type": {
                        "type": "string",
                        "enum": [
                          "text",
                          "textarea",
                          "number",
                          "email",
                          "phone",
                          "date",
                          "time",
                          "select",
                          "switches",
                          "checkbox"
                        ]
                      },
                      "required": {
                        "type": "boolean"
                      },
                      "placeholder": {
                        "type": "string",
                        "maxLength": 80
                      },
                      "help": {
                        "type": "string",
                        "maxLength": 160
                      },
                      "value": {
                        "description": "Prefill: string, number, boolean (checkbox) or array of option values (switches)"
                      },
                      "options": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "value": {
                              "type": "string",
                              "maxLength": 80
                            },
                            "label": {
                              "type": "string",
                              "maxLength": 60
                            }
                          },
                          "required": [
                            "value",
                            "label"
                          ],
                          "additionalProperties": false
                        },
                        "maxItems": 20,
                        "description": "For select / switches"
                      }
                    },
                    "required": [
                      "id",
                      "label",
                      "type"
                    ],
                    "additionalProperties": false
                  },
                  "maxItems": 12
                }
              },
              "required": [
                "type",
                "id",
                "fields"
              ],
              "additionalProperties": false,
              "description": "Collect input. Submit sends {type:\"form\", id, values:{fieldId: value}}. Ask for what you need in one form, not field by field."
            },
            {
              "type": "object",
              "properties": {
                "type": {
                  "const": "details"
                },
                "title": {
                  "type": "string",
                  "maxLength": 80
                },
                "rows": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "label": {
                        "type": "string",
                        "maxLength": 40
                      },
                      "value": {
                        "type": "string",
                        "maxLength": 200
                      },
                      "icon": {
                        "type": "string",
                        "pattern": "^[a-z0-9-]{1,40}$",
                        "description": "FontAwesome 5 name without \"fa-\", e.g. \"phone\""
                      },
                      "tone": {
                        "type": "string",
                        "enum": [
                          "normal",
                          "primary",
                          "good",
                          "warning",
                          "danger",
                          "muted"
                        ]
                      }
                    },
                    "required": [
                      "label",
                      "value"
                    ],
                    "additionalProperties": false
                  },
                  "maxItems": 16
                }
              },
              "required": [
                "type",
                "rows"
              ],
              "additionalProperties": false,
              "description": "Key-value facts about one thing (an order, a contact)."
            },
            {
              "type": "object",
              "properties": {
                "type": {
                  "const": "stats"
                },
                "items": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "label": {
                        "type": "string",
                        "maxLength": 40
                      },
                      "value": {
                        "type": "string",
                        "maxLength": 24
                      },
                      "change": {
                        "type": "string",
                        "maxLength": 24,
                        "description": "e.g. \"+12%\""
                      },
                      "tone": {
                        "type": "string",
                        "enum": [
                          "normal",
                          "primary",
                          "good",
                          "warning",
                          "danger",
                          "muted"
                        ]
                      }
                    },
                    "required": [
                      "label",
                      "value"
                    ],
                    "additionalProperties": false
                  },
                  "maxItems": 6
                }
              },
              "required": [
                "type",
                "items"
              ],
              "additionalProperties": false,
              "description": "Big numbers (KPIs)."
            },
            {
              "type": "object",
              "properties": {
                "type": {
                  "const": "progress"
                },
                "items": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "label": {
                        "type": "string",
                        "maxLength": 60
                      },
                      "value": {
                        "type": "number"
                      },
                      "max": {
                        "type": "number"
                      },
                      "tone": {
                        "type": "string",
                        "enum": [
                          "normal",
                          "primary",
                          "good",
                          "warning",
                          "danger",
                          "muted"
                        ]
                      }
                    },
                    "required": [
                      "label",
                      "value"
                    ],
                    "additionalProperties": false
                  },
                  "maxItems": 8
                }
              },
              "required": [
                "type",
                "items"
              ],
              "additionalProperties": false,
              "description": "Progress toward goals. max defaults to 100."
            },
            {
              "type": "object",
              "properties": {
                "type": {
                  "const": "table"
                },
                "caption": {
                  "type": "string",
                  "maxLength": 80
                },
                "columns": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "maxLength": 40
                  },
                  "maxItems": 8
                },
                "rows": {
                  "type": "array",
                  "items": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "maxLength": 120
                    },
                    "maxItems": 8
                  },
                  "maxItems": 50
                }
              },
              "required": [
                "type",
                "columns",
                "rows"
              ],
              "additionalProperties": false,
              "description": "Compact tabular data. Prefer list for records the user acts on."
            }
          ]
        },
        "maxItems": 12,
        "description": "The reply, rendered top to bottom"
      }
    },
    "required": [
      "blocks"
    ],
    "additionalProperties": false
  }
}