{
  "$ref": "#/definitions/any-message",
  "definitions": {
    "any-message": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "v": {
              "type": "string",
              "pattern": "^\\d+\\.\\d+$"
            },
            "id": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "type": {
              "type": "string",
              "const": "error"
            },
            "ts": {
              "type": "integer",
              "exclusiveMinimum": 0
            },
            "sid": {
              "type": "string",
              "minLength": 16,
              "maxLength": 128
            },
            "replyTo": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "payload": {
              "type": "object",
              "properties": {
                "code": {
                  "type": "string",
                  "enum": [
                    "AUTH_EXPIRED",
                    "SCOPE_DENIED",
                    "RATE_LIMITED",
                    "NONCE_USED",
                    "SESSION_GONE",
                    "TURN_ABORTED",
                    "CONTEXT_TOO_LARGE",
                    "PAIR_DENIED",
                    "UNSUPPORTED",
                    "INTERNAL"
                  ]
                },
                "message": {
                  "type": "string",
                  "maxLength": 500
                },
                "retryable": {
                  "type": "boolean"
                },
                "details": {
                  "type": "object",
                  "additionalProperties": {}
                }
              },
              "required": [
                "code",
                "message",
                "retryable"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "v",
            "id",
            "type",
            "ts",
            "payload"
          ],
          "additionalProperties": true
        },
        {
          "type": "object",
          "properties": {
            "v": {
              "type": "string",
              "pattern": "^\\d+\\.\\d+$"
            },
            "id": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "type": {
              "type": "string",
              "const": "session.open"
            },
            "ts": {
              "type": "integer",
              "exclusiveMinimum": 0
            },
            "sid": {
              "type": "string",
              "minLength": 16,
              "maxLength": 128
            },
            "replyTo": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "payload": {
              "type": "object",
              "properties": {
                "capabilities": {
                  "type": "object",
                  "properties": {
                    "profiles": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "name": {
                            "type": "string",
                            "enum": [
                              "core",
                              "embed",
                              "companion",
                              "provider"
                            ]
                          },
                          "version": {
                            "type": "string",
                            "pattern": "^\\d+\\.\\d+$"
                          }
                        },
                        "required": [
                          "name",
                          "version"
                        ],
                        "additionalProperties": false
                      },
                      "minItems": 1
                    },
                    "stt": {
                      "type": "string",
                      "enum": [
                        "device",
                        "hub",
                        "none"
                      ],
                      "default": "none"
                    },
                    "tts": {
                      "type": "string",
                      "enum": [
                        "device",
                        "hub",
                        "none"
                      ],
                      "default": "none"
                    },
                    "locales": {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "minLength": 2,
                        "maxLength": 35
                      },
                      "default": []
                    },
                    "audio": {
                      "type": "boolean",
                      "default": false
                    },
                    "tools": {
                      "type": "boolean",
                      "default": false
                    }
                  },
                  "required": [
                    "profiles"
                  ],
                  "additionalProperties": false
                },
                "resumeKey": {
                  "type": "string",
                  "minLength": 16,
                  "maxLength": 256
                }
              },
              "required": [
                "capabilities"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "v",
            "id",
            "type",
            "ts",
            "payload"
          ],
          "additionalProperties": true
        },
        {
          "type": "object",
          "properties": {
            "v": {
              "type": "string",
              "pattern": "^\\d+\\.\\d+$"
            },
            "id": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "type": {
              "type": "string",
              "const": "session.linked"
            },
            "ts": {
              "type": "integer",
              "exclusiveMinimum": 0
            },
            "sid": {
              "type": "string",
              "minLength": 16,
              "maxLength": 128
            },
            "replyTo": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "payload": {
              "type": "object",
              "properties": {
                "sid": {
                  "type": "string"
                },
                "capabilities": {
                  "type": "object",
                  "properties": {
                    "profiles": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "name": {
                            "type": "string",
                            "enum": [
                              "core",
                              "embed",
                              "companion",
                              "provider"
                            ]
                          },
                          "version": {
                            "type": "string",
                            "pattern": "^\\d+\\.\\d+$"
                          }
                        },
                        "required": [
                          "name",
                          "version"
                        ],
                        "additionalProperties": false
                      },
                      "minItems": 1
                    },
                    "stt": {
                      "type": "string",
                      "enum": [
                        "device",
                        "hub",
                        "none"
                      ],
                      "default": "none"
                    },
                    "tts": {
                      "type": "string",
                      "enum": [
                        "device",
                        "hub",
                        "none"
                      ],
                      "default": "none"
                    },
                    "locales": {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "minLength": 2,
                        "maxLength": 35
                      },
                      "default": []
                    },
                    "audio": {
                      "type": "boolean",
                      "default": false
                    },
                    "tools": {
                      "type": "boolean",
                      "default": false
                    }
                  },
                  "required": [
                    "profiles"
                  ],
                  "additionalProperties": false
                },
                "tier": {
                  "type": "string",
                  "enum": [
                    "t0",
                    "t1",
                    "t2"
                  ]
                },
                "scopes": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "resumeKey": {
                  "type": "string"
                }
              },
              "required": [
                "sid",
                "capabilities",
                "tier",
                "scopes"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "v",
            "id",
            "type",
            "ts",
            "payload"
          ],
          "additionalProperties": true
        },
        {
          "type": "object",
          "properties": {
            "v": {
              "type": "string",
              "pattern": "^\\d+\\.\\d+$"
            },
            "id": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "type": {
              "type": "string",
              "const": "session.suspended"
            },
            "ts": {
              "type": "integer",
              "exclusiveMinimum": 0
            },
            "sid": {
              "type": "string",
              "minLength": 16,
              "maxLength": 128
            },
            "replyTo": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "payload": {
              "type": "object",
              "properties": {
                "peer": {
                  "type": "string",
                  "enum": [
                    "surface",
                    "companion"
                  ]
                },
                "graceMs": {
                  "type": "integer",
                  "exclusiveMinimum": 0
                }
              },
              "required": [
                "peer",
                "graceMs"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "v",
            "id",
            "type",
            "ts",
            "payload"
          ],
          "additionalProperties": true
        },
        {
          "type": "object",
          "properties": {
            "v": {
              "type": "string",
              "pattern": "^\\d+\\.\\d+$"
            },
            "id": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "type": {
              "type": "string",
              "const": "session.resumed"
            },
            "ts": {
              "type": "integer",
              "exclusiveMinimum": 0
            },
            "sid": {
              "type": "string",
              "minLength": 16,
              "maxLength": 128
            },
            "replyTo": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "payload": {
              "type": "object",
              "properties": {
                "peer": {
                  "type": "string",
                  "enum": [
                    "surface",
                    "companion"
                  ]
                }
              },
              "required": [
                "peer"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "v",
            "id",
            "type",
            "ts",
            "payload"
          ],
          "additionalProperties": true
        },
        {
          "type": "object",
          "properties": {
            "v": {
              "type": "string",
              "pattern": "^\\d+\\.\\d+$"
            },
            "id": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "type": {
              "type": "string",
              "const": "session.closed"
            },
            "ts": {
              "type": "integer",
              "exclusiveMinimum": 0
            },
            "sid": {
              "type": "string",
              "minLength": 16,
              "maxLength": 128
            },
            "replyTo": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "payload": {
              "type": "object",
              "properties": {
                "reason": {
                  "type": "string",
                  "enum": [
                    "surface_gone",
                    "revoked",
                    "ttl_idle",
                    "ttl_absolute",
                    "error",
                    "user"
                  ]
                }
              },
              "required": [
                "reason"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "v",
            "id",
            "type",
            "ts",
            "payload"
          ],
          "additionalProperties": true
        },
        {
          "type": "object",
          "properties": {
            "v": {
              "type": "string",
              "pattern": "^\\d+\\.\\d+$"
            },
            "id": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "type": {
              "type": "string",
              "const": "session.heartbeat"
            },
            "ts": {
              "type": "integer",
              "exclusiveMinimum": 0
            },
            "sid": {
              "type": "string",
              "minLength": 16,
              "maxLength": 128
            },
            "replyTo": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "payload": {
              "type": "object",
              "properties": {},
              "additionalProperties": true
            }
          },
          "required": [
            "v",
            "id",
            "type",
            "ts",
            "payload"
          ],
          "additionalProperties": true
        },
        {
          "type": "object",
          "properties": {
            "v": {
              "type": "string",
              "pattern": "^\\d+\\.\\d+$"
            },
            "id": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "type": {
              "type": "string",
              "const": "session.refresh"
            },
            "ts": {
              "type": "integer",
              "exclusiveMinimum": 0
            },
            "sid": {
              "type": "string",
              "minLength": 16,
              "maxLength": 128
            },
            "replyTo": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "payload": {
              "type": "object",
              "properties": {},
              "additionalProperties": true
            }
          },
          "required": [
            "v",
            "id",
            "type",
            "ts",
            "payload"
          ],
          "additionalProperties": true
        },
        {
          "type": "object",
          "properties": {
            "v": {
              "type": "string",
              "pattern": "^\\d+\\.\\d+$"
            },
            "id": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "type": {
              "type": "string",
              "const": "session.refreshed"
            },
            "ts": {
              "type": "integer",
              "exclusiveMinimum": 0
            },
            "sid": {
              "type": "string",
              "minLength": 16,
              "maxLength": 128
            },
            "replyTo": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "payload": {
              "type": "object",
              "properties": {
                "token": {
                  "type": "string",
                  "minLength": 20
                },
                "expiresIn": {
                  "type": "integer",
                  "exclusiveMinimum": 0
                }
              },
              "required": [
                "token",
                "expiresIn"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "v",
            "id",
            "type",
            "ts",
            "payload"
          ],
          "additionalProperties": true
        },
        {
          "type": "object",
          "properties": {
            "v": {
              "type": "string",
              "pattern": "^\\d+\\.\\d+$"
            },
            "id": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "type": {
              "type": "string",
              "const": "context.set"
            },
            "ts": {
              "type": "integer",
              "exclusiveMinimum": 0
            },
            "sid": {
              "type": "string",
              "minLength": 16,
              "maxLength": 128
            },
            "replyTo": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "payload": {
              "type": "object",
              "properties": {
                "rev": {
                  "type": "integer",
                  "minimum": 0
                },
                "url": {
                  "type": "string",
                  "maxLength": 2048
                },
                "resource": {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 64
                    },
                    "id": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 256
                    },
                    "title": {
                      "type": "string",
                      "maxLength": 500
                    }
                  },
                  "required": [
                    "kind",
                    "id"
                  ],
                  "additionalProperties": false
                },
                "selection": {
                  "type": "object",
                  "properties": {
                    "text": {
                      "type": "string",
                      "maxLength": 8192
                    },
                    "ref": {
                      "type": "string",
                      "maxLength": 512
                    }
                  },
                  "required": [
                    "text"
                  ],
                  "additionalProperties": false
                },
                "view": {
                  "type": "object",
                  "properties": {
                    "path": {
                      "type": "string",
                      "maxLength": 1024
                    }
                  },
                  "additionalProperties": false
                }
              },
              "required": [
                "rev"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "v",
            "id",
            "type",
            "ts",
            "payload"
          ],
          "additionalProperties": true
        },
        {
          "type": "object",
          "properties": {
            "v": {
              "type": "string",
              "pattern": "^\\d+\\.\\d+$"
            },
            "id": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "type": {
              "type": "string",
              "const": "turn.input"
            },
            "ts": {
              "type": "integer",
              "exclusiveMinimum": 0
            },
            "sid": {
              "type": "string",
              "minLength": 16,
              "maxLength": 128
            },
            "replyTo": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "payload": {
              "type": "object",
              "properties": {
                "turnId": {
                  "type": "string",
                  "minLength": 10,
                  "maxLength": 64
                },
                "text": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 8000
                },
                "audioRef": {
                  "type": "string",
                  "maxLength": 512
                },
                "lang": {
                  "type": "string",
                  "minLength": 2,
                  "maxLength": 35
                }
              },
              "required": [
                "turnId"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "v",
            "id",
            "type",
            "ts",
            "payload"
          ],
          "additionalProperties": true
        },
        {
          "type": "object",
          "properties": {
            "v": {
              "type": "string",
              "pattern": "^\\d+\\.\\d+$"
            },
            "id": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "type": {
              "type": "string",
              "const": "turn.delta"
            },
            "ts": {
              "type": "integer",
              "exclusiveMinimum": 0
            },
            "sid": {
              "type": "string",
              "minLength": 16,
              "maxLength": 128
            },
            "replyTo": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "payload": {
              "type": "object",
              "properties": {
                "turnId": {
                  "type": "string"
                },
                "text": {
                  "type": "string"
                }
              },
              "required": [
                "turnId",
                "text"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "v",
            "id",
            "type",
            "ts",
            "payload"
          ],
          "additionalProperties": true
        },
        {
          "type": "object",
          "properties": {
            "v": {
              "type": "string",
              "pattern": "^\\d+\\.\\d+$"
            },
            "id": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "type": {
              "type": "string",
              "const": "turn.citation"
            },
            "ts": {
              "type": "integer",
              "exclusiveMinimum": 0
            },
            "sid": {
              "type": "string",
              "minLength": 16,
              "maxLength": 128
            },
            "replyTo": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "payload": {
              "type": "object",
              "properties": {
                "turnId": {
                  "type": "string"
                },
                "index": {
                  "type": "integer",
                  "exclusiveMinimum": 0
                },
                "resource": {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string"
                    },
                    "id": {
                      "type": "string"
                    },
                    "title": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "kind",
                    "id"
                  ],
                  "additionalProperties": false
                },
                "quote": {
                  "type": "string",
                  "maxLength": 500
                }
              },
              "required": [
                "turnId",
                "index",
                "resource"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "v",
            "id",
            "type",
            "ts",
            "payload"
          ],
          "additionalProperties": true
        },
        {
          "type": "object",
          "properties": {
            "v": {
              "type": "string",
              "pattern": "^\\d+\\.\\d+$"
            },
            "id": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "type": {
              "type": "string",
              "const": "turn.done"
            },
            "ts": {
              "type": "integer",
              "exclusiveMinimum": 0
            },
            "sid": {
              "type": "string",
              "minLength": 16,
              "maxLength": 128
            },
            "replyTo": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "payload": {
              "type": "object",
              "properties": {
                "turnId": {
                  "type": "string"
                },
                "contextRev": {
                  "type": "integer",
                  "minimum": 0
                },
                "usage": {
                  "type": "object",
                  "properties": {
                    "inputTokens": {
                      "type": "integer"
                    },
                    "outputTokens": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "inputTokens",
                    "outputTokens"
                  ],
                  "additionalProperties": false
                }
              },
              "required": [
                "turnId"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "v",
            "id",
            "type",
            "ts",
            "payload"
          ],
          "additionalProperties": true
        },
        {
          "type": "object",
          "properties": {
            "v": {
              "type": "string",
              "pattern": "^\\d+\\.\\d+$"
            },
            "id": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "type": {
              "type": "string",
              "const": "turn.cancel"
            },
            "ts": {
              "type": "integer",
              "exclusiveMinimum": 0
            },
            "sid": {
              "type": "string",
              "minLength": 16,
              "maxLength": 128
            },
            "replyTo": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "payload": {
              "type": "object",
              "properties": {
                "turnId": {
                  "type": "string"
                }
              },
              "required": [
                "turnId"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "v",
            "id",
            "type",
            "ts",
            "payload"
          ],
          "additionalProperties": true
        },
        {
          "type": "object",
          "properties": {
            "v": {
              "type": "string",
              "pattern": "^\\d+\\.\\d+$"
            },
            "id": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "type": {
              "type": "string",
              "const": "turn.error"
            },
            "ts": {
              "type": "integer",
              "exclusiveMinimum": 0
            },
            "sid": {
              "type": "string",
              "minLength": 16,
              "maxLength": 128
            },
            "replyTo": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "payload": {
              "type": "object",
              "properties": {
                "turnId": {
                  "type": "string"
                },
                "code": {
                  "type": "string",
                  "enum": [
                    "TURN_ABORTED",
                    "RATE_LIMITED",
                    "SCOPE_DENIED",
                    "INTERNAL"
                  ]
                },
                "message": {
                  "type": "string",
                  "maxLength": 500
                }
              },
              "required": [
                "turnId",
                "code",
                "message"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "v",
            "id",
            "type",
            "ts",
            "payload"
          ],
          "additionalProperties": true
        },
        {
          "type": "object",
          "properties": {
            "v": {
              "type": "string",
              "pattern": "^\\d+\\.\\d+$"
            },
            "id": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "type": {
              "type": "string",
              "const": "tools.advertise"
            },
            "ts": {
              "type": "integer",
              "exclusiveMinimum": 0
            },
            "sid": {
              "type": "string",
              "minLength": 16,
              "maxLength": 128
            },
            "replyTo": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "payload": {
              "type": "object",
              "properties": {
                "tools": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 128,
                        "pattern": "^[a-z0-9_.:-]+$"
                      },
                      "description": {
                        "type": "string",
                        "maxLength": 1000
                      },
                      "inputSchema": {
                        "type": "object",
                        "additionalProperties": {}
                      },
                      "location": {
                        "type": "string",
                        "enum": [
                          "hub",
                          "surface"
                        ]
                      },
                      "write": {
                        "type": "boolean",
                        "default": false
                      }
                    },
                    "required": [
                      "name",
                      "description",
                      "inputSchema",
                      "location"
                    ],
                    "additionalProperties": false
                  },
                  "maxItems": 100
                }
              },
              "required": [
                "tools"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "v",
            "id",
            "type",
            "ts",
            "payload"
          ],
          "additionalProperties": true
        },
        {
          "type": "object",
          "properties": {
            "v": {
              "type": "string",
              "pattern": "^\\d+\\.\\d+$"
            },
            "id": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "type": {
              "type": "string",
              "const": "action.request"
            },
            "ts": {
              "type": "integer",
              "exclusiveMinimum": 0
            },
            "sid": {
              "type": "string",
              "minLength": 16,
              "maxLength": 128
            },
            "replyTo": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "payload": {
              "type": "object",
              "properties": {
                "actionId": {
                  "type": "string",
                  "minLength": 10,
                  "maxLength": 64
                },
                "tool": {
                  "type": "string"
                },
                "input": {
                  "type": "object",
                  "additionalProperties": {}
                },
                "turnId": {
                  "type": "string"
                }
              },
              "required": [
                "actionId",
                "tool",
                "input"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "v",
            "id",
            "type",
            "ts",
            "payload"
          ],
          "additionalProperties": true
        },
        {
          "type": "object",
          "properties": {
            "v": {
              "type": "string",
              "pattern": "^\\d+\\.\\d+$"
            },
            "id": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "type": {
              "type": "string",
              "const": "action.result"
            },
            "ts": {
              "type": "integer",
              "exclusiveMinimum": 0
            },
            "sid": {
              "type": "string",
              "minLength": 16,
              "maxLength": 128
            },
            "replyTo": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "payload": {
              "type": "object",
              "properties": {
                "actionId": {
                  "type": "string"
                },
                "ok": {
                  "type": "boolean"
                },
                "output": {},
                "error": {
                  "type": "string",
                  "maxLength": 500
                }
              },
              "required": [
                "actionId",
                "ok"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "v",
            "id",
            "type",
            "ts",
            "payload"
          ],
          "additionalProperties": true
        },
        {
          "type": "object",
          "properties": {
            "v": {
              "type": "string",
              "pattern": "^\\d+\\.\\d+$"
            },
            "id": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "type": {
              "type": "string",
              "const": "ui.request"
            },
            "ts": {
              "type": "integer",
              "exclusiveMinimum": 0
            },
            "sid": {
              "type": "string",
              "minLength": 16,
              "maxLength": 128
            },
            "replyTo": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "payload": {
              "type": "object",
              "properties": {
                "requestId": {
                  "type": "string",
                  "minLength": 10,
                  "maxLength": 64
                },
                "kind": {
                  "type": "string",
                  "enum": [
                    "confirm",
                    "choice",
                    "notice"
                  ]
                },
                "title": {
                  "type": "string",
                  "maxLength": 200
                },
                "body": {
                  "type": "string",
                  "maxLength": 2000
                },
                "options": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "maxLength": 64
                      },
                      "label": {
                        "type": "string",
                        "maxLength": 200
                      }
                    },
                    "required": [
                      "id",
                      "label"
                    ],
                    "additionalProperties": false
                  }
                },
                "expiresAt": {
                  "type": "integer",
                  "exclusiveMinimum": 0
                },
                "actionId": {
                  "type": "string"
                }
              },
              "required": [
                "requestId",
                "kind",
                "title",
                "expiresAt"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "v",
            "id",
            "type",
            "ts",
            "payload"
          ],
          "additionalProperties": true
        },
        {
          "type": "object",
          "properties": {
            "v": {
              "type": "string",
              "pattern": "^\\d+\\.\\d+$"
            },
            "id": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "type": {
              "type": "string",
              "const": "ui.response"
            },
            "ts": {
              "type": "integer",
              "exclusiveMinimum": 0
            },
            "sid": {
              "type": "string",
              "minLength": 16,
              "maxLength": 128
            },
            "replyTo": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "payload": {
              "type": "object",
              "properties": {
                "requestId": {
                  "type": "string"
                },
                "result": {
                  "type": "string",
                  "maxLength": 64
                },
                "peer": {
                  "type": "string",
                  "enum": [
                    "surface",
                    "companion"
                  ]
                }
              },
              "required": [
                "requestId",
                "result",
                "peer"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "v",
            "id",
            "type",
            "ts",
            "payload"
          ],
          "additionalProperties": true
        },
        {
          "type": "object",
          "properties": {
            "v": {
              "type": "string",
              "pattern": "^\\d+\\.\\d+$"
            },
            "id": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "type": {
              "type": "string",
              "const": "pair.approval_request"
            },
            "ts": {
              "type": "integer",
              "exclusiveMinimum": 0
            },
            "sid": {
              "type": "string",
              "minLength": 16,
              "maxLength": 128
            },
            "replyTo": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "payload": {
              "type": "object",
              "properties": {
                "claimId": {
                  "type": "string"
                },
                "device": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "platform": {
                      "type": "string"
                    },
                    "attested": {
                      "type": "boolean"
                    },
                    "firstSeen": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "name",
                    "platform",
                    "attested",
                    "firstSeen"
                  ],
                  "additionalProperties": false
                },
                "expiresAt": {
                  "type": "integer",
                  "exclusiveMinimum": 0
                }
              },
              "required": [
                "claimId",
                "device",
                "expiresAt"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "v",
            "id",
            "type",
            "ts",
            "payload"
          ],
          "additionalProperties": true
        },
        {
          "type": "object",
          "properties": {
            "v": {
              "type": "string",
              "pattern": "^\\d+\\.\\d+$"
            },
            "id": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "type": {
              "type": "string",
              "const": "pair.approval_response"
            },
            "ts": {
              "type": "integer",
              "exclusiveMinimum": 0
            },
            "sid": {
              "type": "string",
              "minLength": 16,
              "maxLength": 128
            },
            "replyTo": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "payload": {
              "type": "object",
              "properties": {
                "claimId": {
                  "type": "string"
                },
                "approved": {
                  "type": "boolean"
                }
              },
              "required": [
                "claimId",
                "approved"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "v",
            "id",
            "type",
            "ts",
            "payload"
          ],
          "additionalProperties": true
        },
        {
          "type": "object",
          "properties": {
            "v": {
              "type": "string",
              "pattern": "^\\d+\\.\\d+$"
            },
            "id": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "type": {
              "type": "string",
              "const": "pair.linked"
            },
            "ts": {
              "type": "integer",
              "exclusiveMinimum": 0
            },
            "sid": {
              "type": "string",
              "minLength": 16,
              "maxLength": 128
            },
            "replyTo": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "payload": {
              "type": "object",
              "properties": {
                "device": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "platform": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "name",
                    "platform"
                  ],
                  "additionalProperties": false
                },
                "scopes": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "tier": {
                  "type": "string",
                  "enum": [
                    "t0",
                    "t1",
                    "t2"
                  ]
                }
              },
              "required": [
                "device",
                "scopes",
                "tier"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "v",
            "id",
            "type",
            "ts",
            "payload"
          ],
          "additionalProperties": true
        },
        {
          "type": "object",
          "properties": {
            "v": {
              "type": "string",
              "pattern": "^\\d+\\.\\d+$"
            },
            "id": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "type": {
              "type": "string",
              "const": "pair.revoked"
            },
            "ts": {
              "type": "integer",
              "exclusiveMinimum": 0
            },
            "sid": {
              "type": "string",
              "minLength": 16,
              "maxLength": 128
            },
            "replyTo": {
              "type": "string",
              "minLength": 10,
              "maxLength": 64
            },
            "payload": {
              "type": "object",
              "properties": {
                "by": {
                  "type": "string",
                  "enum": [
                    "surface",
                    "hub",
                    "admin"
                  ]
                }
              },
              "required": [
                "by"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "v",
            "id",
            "type",
            "ts",
            "payload"
          ],
          "additionalProperties": true
        }
      ]
    }
  },
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://schwaizer.ch/ocp/schemas/1.0/any-message.json"
}
