{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://ketvia.com/schemas/kit-manifest/v1.json",
  "title": "Ketvia Kit manifest v1",
  "description": "A Kit manifest is a consent document: unknown keys are rejected, URLs are https, and tool schemas use a safe JSON Schema subset. Server-side checks (for example the safe-subset rules and cross-field references) go beyond what this schema expresses.",
  "type": "object",
  "properties": {
    "schemaVersion": {
      "type": "number",
      "const": 1
    },
    "slug": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9-]{1,39}$"
    },
    "version": {
      "type": "string",
      "pattern": "^(0|[1-9]\\d{0,3})\\.(0|[1-9]\\d{0,4})\\.(0|[1-9]\\d{0,5})$"
    },
    "displayName": {
      "type": "object",
      "properties": {
        "en": {
          "type": "string",
          "minLength": 1,
          "maxLength": 60
        },
        "tr": {
          "type": "string",
          "minLength": 1,
          "maxLength": 60
        }
      },
      "required": [
        "en"
      ],
      "additionalProperties": false
    },
    "description": {
      "type": "object",
      "properties": {
        "en": {
          "type": "string",
          "minLength": 1,
          "maxLength": 500
        },
        "tr": {
          "type": "string",
          "minLength": 1,
          "maxLength": 500
        }
      },
      "required": [
        "en"
      ],
      "additionalProperties": false
    },
    "developer": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 80
        },
        "url": {
          "type": "string",
          "minLength": 1,
          "maxLength": 2000
        },
        "supportEmail": {
          "type": "string",
          "maxLength": 254,
          "format": "email",
          "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
        }
      },
      "required": [
        "name",
        "url",
        "supportEmail"
      ],
      "additionalProperties": false
    },
    "privacyPolicyUrl": {
      "type": "string",
      "minLength": 1,
      "maxLength": 2000
    },
    "icon": {
      "type": "string",
      "minLength": 1,
      "maxLength": 2000
    },
    "categories": {
      "default": [],
      "maxItems": 5,
      "type": "array",
      "items": {
        "type": "string",
        "pattern": "^[a-z][a-z0-9-]{1,30}$"
      }
    },
    "locales": {
      "default": [
        "en"
      ],
      "minItems": 1,
      "maxItems": 2,
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "en",
          "tr"
        ]
      }
    },
    "bot": {
      "type": "object",
      "properties": {
        "displayName": {
          "type": "object",
          "properties": {
            "en": {
              "type": "string",
              "minLength": 1,
              "maxLength": 60
            },
            "tr": {
              "type": "string",
              "minLength": 1,
              "maxLength": 60
            }
          },
          "required": [
            "en"
          ],
          "additionalProperties": false
        },
        "scopes": {
          "default": [],
          "maxItems": 13,
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "conversations:read",
              "messages:read",
              "messages:write",
              "messages:write.ephemeral",
              "reactions:read",
              "reactions:write",
              "files:read",
              "files:write",
              "users:read",
              "users:read.email",
              "commands",
              "incoming-webhook",
              "assistant:tools"
            ]
          }
        }
      },
      "required": [
        "displayName"
      ],
      "additionalProperties": false
    },
    "userScopes": {
      "default": [],
      "maxItems": 10,
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "conversations:read",
          "messages:read",
          "messages:write",
          "reactions:read",
          "reactions:write",
          "files:read",
          "files:write",
          "users:read",
          "users:read.email",
          "runs:read"
        ]
      }
    },
    "externalAuth": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "const": "oauth2"
        },
        "authorizationUrl": {
          "type": "string",
          "minLength": 1,
          "maxLength": 2000
        },
        "tokenUrl": {
          "type": "string",
          "minLength": 1,
          "maxLength": 2000
        },
        "revocationUrl": {
          "type": "string",
          "minLength": 1,
          "maxLength": 2000
        },
        "resource": {
          "type": "string",
          "minLength": 1,
          "maxLength": 2000
        },
        "pkce": {
          "type": "string",
          "const": "S256"
        },
        "clientAuth": {
          "type": "string",
          "enum": [
            "client_secret_post",
            "client_secret_basic"
          ]
        },
        "requiredScopes": {
          "minItems": 1,
          "maxItems": 10,
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          }
        },
        "optionalScopes": {
          "default": [],
          "maxItems": 10,
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          }
        },
        "grantedBy": {
          "default": "admin",
          "type": "string",
          "enum": [
            "admin"
          ]
        },
        "displayName": {
          "type": "object",
          "properties": {
            "en": {
              "type": "string",
              "minLength": 1,
              "maxLength": 80
            },
            "tr": {
              "type": "string",
              "minLength": 1,
              "maxLength": 80
            }
          },
          "required": [
            "en"
          ],
          "additionalProperties": false
        },
        "scopeLabels": {
          "type": "object",
          "propertyNames": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "additionalProperties": {
            "type": "object",
            "properties": {
              "en": {
                "type": "string",
                "minLength": 1,
                "maxLength": 120
              },
              "tr": {
                "type": "string",
                "minLength": 1,
                "maxLength": 120
              }
            },
            "required": [
              "en"
            ],
            "additionalProperties": false
          }
        }
      },
      "required": [
        "type",
        "authorizationUrl",
        "tokenUrl",
        "pkce",
        "clientAuth",
        "requiredScopes",
        "displayName"
      ],
      "additionalProperties": false
    },
    "tools": {
      "type": "object",
      "properties": {
        "endpoint": {
          "type": "string",
          "minLength": 1,
          "maxLength": 2000
        },
        "auth": {
          "default": "signature",
          "type": "string",
          "enum": [
            "signature",
            "externalAuth"
          ]
        },
        "timezone": {
          "default": "UTC",
          "type": "string",
          "minLength": 1,
          "maxLength": 64
        },
        "rateLimitPerMinute": {
          "default": 60,
          "type": "integer",
          "minimum": 1,
          "maximum": 120
        },
        "planner": {
          "default": {
            "contextHints": []
          },
          "type": "object",
          "properties": {
            "rulesPack": {
              "type": "string",
              "pattern": "^[a-z0-9-]{1,40}$"
            },
            "contextHints": {
              "default": [],
              "maxItems": 5,
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "localDate"
                ]
              }
            }
          },
          "additionalProperties": false
        },
        "items": {
          "minItems": 1,
          "maxItems": 50,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "pattern": "^[a-z][a-z0-9_]{0,63}$"
              },
              "access": {
                "type": "string",
                "enum": [
                  "read",
                  "write"
                ]
              },
              "dataClass": {
                "type": "string",
                "enum": [
                  "aggregate",
                  "standard",
                  "personal",
                  "sensitive"
                ]
              },
              "requiredForVerification": {
                "default": false,
                "type": "boolean"
              },
              "requiresExternalScope": {
                "type": "string",
                "minLength": 1,
                "maxLength": 100
              },
              "displayName": {
                "type": "object",
                "properties": {
                  "en": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 80
                  },
                  "tr": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 80
                  }
                },
                "required": [
                  "en"
                ],
                "additionalProperties": false
              },
              "description": {
                "type": "object",
                "properties": {
                  "en": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 1000
                  },
                  "tr": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 1000
                  }
                },
                "required": [
                  "en"
                ],
                "additionalProperties": false
              },
              "inputSchema": {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {}
              },
              "inputConstraints": {
                "maxItems": 5,
                "type": "array",
                "items": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "kind": {
                          "type": "string",
                          "const": "dateRange"
                        },
                        "from": {
                          "type": "string",
                          "pattern": "^[A-Za-z_][A-Za-z0-9_]{0,63}$"
                        },
                        "to": {
                          "type": "string",
                          "pattern": "^[A-Za-z_][A-Za-z0-9_]{0,63}$"
                        },
                        "maxDays": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 366
                        }
                      },
                      "required": [
                        "kind",
                        "from",
                        "to",
                        "maxDays"
                      ],
                      "additionalProperties": false
                    }
                  ]
                }
              },
              "outputSchema": {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {}
              },
              "audience": {
                "default": "any",
                "type": "string",
                "enum": [
                  "any",
                  "private"
                ]
              },
              "card": {
                "type": "object",
                "properties": {
                  "title": {
                    "type": "object",
                    "properties": {
                      "en": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 80
                      },
                      "tr": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 80
                      }
                    },
                    "required": [
                      "en"
                    ],
                    "additionalProperties": false
                  },
                  "titleByEmphasis": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string",
                      "pattern": "^[A-Za-z][A-Za-z0-9_]{0,39}$"
                    },
                    "additionalProperties": {
                      "type": "object",
                      "properties": {
                        "en": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 80
                        },
                        "tr": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 80
                        }
                      },
                      "required": [
                        "en"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "localDateFrom": {
                    "type": "string",
                    "pattern": "^[A-Za-z_][A-Za-z0-9_]{0,63}$"
                  },
                  "metrics": {
                    "minItems": 1,
                    "maxItems": 10,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "key": {
                          "type": "string",
                          "pattern": "^[A-Za-z][A-Za-z0-9_]{0,39}$"
                        },
                        "path": {
                          "type": "string",
                          "pattern": "^[A-Za-z_][A-Za-z0-9_]{0,63}$"
                        },
                        "label": {
                          "type": "object",
                          "properties": {
                            "en": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 60
                            },
                            "tr": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 60
                            }
                          },
                          "required": [
                            "en"
                          ],
                          "additionalProperties": false
                        },
                        "format": {
                          "default": "integer",
                          "type": "string",
                          "enum": [
                            "integer",
                            "decimal",
                            "currency",
                            "percent"
                          ]
                        },
                        "currency": {
                          "type": "string",
                          "pattern": "^[A-Z]{3}$"
                        },
                        "currencyPath": {
                          "type": "string",
                          "pattern": "^[A-Za-z_][A-Za-z0-9_]{0,63}$"
                        },
                        "primary": {
                          "type": "boolean"
                        },
                        "phrase": {
                          "type": "object",
                          "properties": {
                            "en": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 120
                            },
                            "tr": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 120
                            }
                          },
                          "required": [
                            "en"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "required": [
                        "key",
                        "path",
                        "label"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "order": {
                    "maxItems": 10,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "pattern": "^[A-Za-z][A-Za-z0-9_]{0,39}$"
                    }
                  },
                  "maxMetrics": {
                    "default": 4,
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 4
                  },
                  "headline": {
                    "type": "object",
                    "properties": {
                      "en": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      "tr": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      }
                    },
                    "required": [
                      "en"
                    ],
                    "additionalProperties": false
                  },
                  "headlineWhenEqual": {
                    "type": "object",
                    "properties": {
                      "fields": {
                        "type": "array",
                        "prefixItems": [
                          {
                            "type": "string",
                            "pattern": "^[A-Za-z_][A-Za-z0-9_]{0,63}$"
                          },
                          {
                            "type": "string",
                            "pattern": "^[A-Za-z_][A-Za-z0-9_]{0,63}$"
                          }
                        ],
                        "items": false,
                        "minItems": 2,
                        "maxItems": 2
                      },
                      "text": {
                        "type": "object",
                        "properties": {
                          "en": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 200
                          },
                          "tr": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 200
                          }
                        },
                        "required": [
                          "en"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "required": [
                      "fields",
                      "text"
                    ],
                    "additionalProperties": false
                  },
                  "emphasisJoin": {
                    "type": "object",
                    "properties": {
                      "en": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 10
                      },
                      "tr": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 10
                      }
                    },
                    "required": [
                      "en"
                    ],
                    "additionalProperties": false
                  },
                  "definition": {
                    "type": "object",
                    "properties": {
                      "en": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 300
                      },
                      "tr": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 300
                      }
                    },
                    "required": [
                      "en"
                    ],
                    "additionalProperties": false
                  }
                },
                "required": [
                  "title",
                  "metrics",
                  "headline",
                  "definition"
                ],
                "additionalProperties": false
              },
              "preview": {
                "type": "string",
                "pattern": "^[a-z][a-z0-9_]{0,63}$"
              },
              "status": {
                "type": "string",
                "pattern": "^[a-z][a-z0-9_]{0,63}$"
              }
            },
            "required": [
              "name",
              "access",
              "dataClass",
              "displayName",
              "description",
              "inputSchema"
            ],
            "additionalProperties": false
          }
        }
      },
      "required": [
        "endpoint",
        "items"
      ],
      "additionalProperties": false
    },
    "failureCodes": {
      "default": {},
      "type": "object",
      "propertyNames": {
        "type": "string",
        "pattern": "^[a-z][a-z0-9_]{0,63}$"
      },
      "additionalProperties": {
        "type": "string",
        "enum": [
          "INSUFFICIENT_SCOPE",
          "RATE_LIMITED",
          "CONNECTOR_UNAVAILABLE",
          "SOURCE_TIMEOUT",
          "INVALID_RESULT"
        ]
      }
    },
    "events": {
      "type": "object",
      "properties": {
        "url": {
          "type": "string",
          "minLength": 1,
          "maxLength": 2000
        },
        "subscribe": {
          "minItems": 1,
          "maxItems": 30,
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "message.created",
              "message.updated",
              "message.deleted",
              "kit.mentioned",
              "reaction.added",
              "reaction.removed",
              "conversation.member_joined",
              "conversation.member_left",
              "conversation.created",
              "conversation.renamed",
              "conversation.archived",
              "file.shared",
              "kit.installed",
              "kit.uninstalled",
              "kit.tokens_revoked",
              "kit.scopes_changed",
              "approval.decided"
            ]
          }
        }
      },
      "required": [
        "url",
        "subscribe"
      ],
      "additionalProperties": false
    },
    "interactivity": {
      "type": "object",
      "properties": {
        "url": {
          "type": "string",
          "minLength": 1,
          "maxLength": 2000
        }
      },
      "required": [
        "url"
      ],
      "additionalProperties": false
    },
    "commands": {
      "maxItems": 25,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "command": {
            "type": "string",
            "pattern": "^\\/[a-z][a-z0-9_-]{1,31}$"
          },
          "url": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2000
          },
          "description": {
            "type": "object",
            "properties": {
              "en": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200
              },
              "tr": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200
              }
            },
            "required": [
              "en"
            ],
            "additionalProperties": false
          },
          "usageHint": {
            "type": "object",
            "properties": {
              "en": {
                "type": "string",
                "minLength": 1,
                "maxLength": 100
              },
              "tr": {
                "type": "string",
                "minLength": 1,
                "maxLength": 100
              }
            },
            "required": [
              "en"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "command",
          "url",
          "description"
        ],
        "additionalProperties": false
      }
    },
    "incomingWebhooks": {
      "type": "object",
      "properties": {
        "maxPerInstallation": {
          "type": "integer",
          "minimum": 1,
          "maximum": 20
        }
      },
      "required": [
        "maxPerInstallation"
      ],
      "additionalProperties": false
    },
    "oauth": {
      "type": "object",
      "properties": {
        "redirectUrls": {
          "minItems": 1,
          "maxItems": 10,
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2000
          }
        }
      },
      "required": [
        "redirectUrls"
      ],
      "additionalProperties": false
    },
    "distribution": {
      "type": "string",
      "enum": [
        "private",
        "unlisted",
        "directory"
      ]
    },
    "requestedModelDataPolicy": {
      "default": "none",
      "type": "string",
      "enum": [
        "none",
        "answer"
      ]
    }
  },
  "required": [
    "schemaVersion",
    "slug",
    "version",
    "displayName",
    "description",
    "developer",
    "privacyPolicyUrl",
    "bot",
    "distribution"
  ],
  "additionalProperties": false
}
