{
  "$id": "https://comitiva.dev/schema/Block.json",
  "title": "Block",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "oneOf": [
    {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "const": "text"
        },
        "text": {
          "type": "string"
        }
      },
      "required": [
        "type",
        "text"
      ]
    },
    {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "const": "image"
        },
        "source": {
          "oneOf": [
            {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "const": "base64"
                },
                "mediaType": {
                  "type": "string"
                },
                "data": {
                  "type": "string"
                }
              },
              "required": [
                "kind",
                "mediaType",
                "data"
              ]
            },
            {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "const": "file"
                },
                "path": {
                  "type": "string"
                },
                "mediaType": {
                  "type": "string"
                }
              },
              "required": [
                "kind",
                "path"
              ]
            }
          ]
        },
        "name": {
          "type": "string"
        }
      },
      "required": [
        "type",
        "source"
      ]
    },
    {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "const": "document"
        },
        "name": {
          "type": "string"
        },
        "mediaType": {
          "type": "string"
        },
        "source": {
          "oneOf": [
            {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "const": "base64"
                },
                "mediaType": {
                  "type": "string"
                },
                "data": {
                  "type": "string"
                }
              },
              "required": [
                "kind",
                "mediaType",
                "data"
              ]
            },
            {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "const": "file"
                },
                "path": {
                  "type": "string"
                },
                "mediaType": {
                  "type": "string"
                }
              },
              "required": [
                "kind",
                "path"
              ]
            }
          ]
        }
      },
      "required": [
        "type",
        "name",
        "mediaType",
        "source"
      ]
    },
    {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "const": "tool_use"
        },
        "id": {
          "type": "string"
        },
        "toolServerId": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "input": {},
        "signature": {
          "type": "string"
        }
      },
      "required": [
        "type",
        "id",
        "toolServerId",
        "name",
        "input"
      ]
    },
    {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "const": "tool_result"
        },
        "toolUseId": {
          "type": "string"
        },
        "content": {
          "type": "array",
          "items": {
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "const": "text"
                  },
                  "text": {
                    "type": "string"
                  }
                },
                "required": [
                  "type",
                  "text"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "const": "image"
                  },
                  "source": {
                    "oneOf": [
                      {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "const": "base64"
                          },
                          "mediaType": {
                            "type": "string"
                          },
                          "data": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "kind",
                          "mediaType",
                          "data"
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "const": "file"
                          },
                          "path": {
                            "type": "string"
                          },
                          "mediaType": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "kind",
                          "path"
                        ]
                      }
                    ]
                  },
                  "name": {
                    "type": "string"
                  }
                },
                "required": [
                  "type",
                  "source"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "const": "document"
                  },
                  "name": {
                    "type": "string"
                  },
                  "mediaType": {
                    "type": "string"
                  },
                  "source": {
                    "oneOf": [
                      {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "const": "base64"
                          },
                          "mediaType": {
                            "type": "string"
                          },
                          "data": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "kind",
                          "mediaType",
                          "data"
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "const": "file"
                          },
                          "path": {
                            "type": "string"
                          },
                          "mediaType": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "kind",
                          "path"
                        ]
                      }
                    ]
                  }
                },
                "required": [
                  "type",
                  "name",
                  "mediaType",
                  "source"
                ]
              }
            ]
          }
        },
        "isError": {
          "type": "boolean"
        },
        "durationMs": {
          "type": "number",
          "minimum": 0
        }
      },
      "required": [
        "type",
        "toolUseId",
        "content",
        "isError"
      ]
    }
  ]
}
