{
  "openapi": "3.1.0",
  "info": {
    "title": "Keko engine",
    "description": "Threads, majors, approvals, changes, review, terminals and devices. Send `Authorization: Bearer <token>` on every request and WebSocket upgrade except the public ones.",
    "version": "1.0.0"
  },
  "security": [
    {
      "bearer": []
    }
  ],
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "JsonValue": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "number"
          },
          {
            "type": "boolean"
          },
          {
            "type": "null"
          },
          {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/JsonValue"
            }
          },
          {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {
              "$ref": "#/components/schemas/JsonValue"
            },
            "examples": [
              {}
            ]
          }
        ]
      }
    }
  },
  "paths": {
    "/v1/health": {
      "get": {
        "tags": [
          "engine"
        ],
        "summary": "Whether the engine is up",
        "operationId": "getHealth",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "const": true
                    }
                  },
                  "required": [
                    "ok"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/v1/openapi.json": {
      "get": {
        "tags": [
          "engine"
        ],
        "summary": "This API as an OpenAPI 3.1 document",
        "operationId": "getOpenapiJson",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {},
                  "additionalProperties": true
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/v1/me": {
      "get": {
        "tags": [
          "engine"
        ],
        "summary": "Who the token belongs to",
        "operationId": "getMe",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "user": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "name"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "user"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/v1/export": {
      "get": {
        "tags": [
          "engine"
        ],
        "summary": "Everything this engine keeps about you, for your data export: threads and majors with their transcripts, devices and machines (no secrets), streamed, as one JSON document or (`format=lines`) one record a line; a few an hour",
        "operationId": "getExport",
        "parameters": [
          {
            "name": "format",
            "in": "query",
            "required": false,
            "schema": {
              "default": "json",
              "type": "string",
              "enum": [
                "json",
                "lines"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string",
                      "const": "keko.engine-export"
                    },
                    "version": {
                      "type": "number",
                      "const": 1
                    },
                    "exportedAt": {
                      "type": "string"
                    },
                    "threads": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {},
                        "additionalProperties": true
                      }
                    },
                    "majors": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {},
                        "additionalProperties": true
                      }
                    }
                  },
                  "required": [
                    "kind",
                    "version",
                    "exportedAt",
                    "threads",
                    "majors"
                  ],
                  "additionalProperties": true
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/v1/models": {
      "get": {
        "tags": [
          "engine"
        ],
        "summary": "Models threads can run on",
        "operationId": "getModels",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "models": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "provider": {
                            "type": "string"
                          },
                          "id": {
                            "type": "string"
                          },
                          "label": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "provider",
                          "id",
                          "label"
                        ],
                        "additionalProperties": true
                      }
                    }
                  },
                  "required": [
                    "models"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/v1/sidebar": {
      "get": {
        "tags": [
          "events"
        ],
        "summary": "Everything a sidebar shows, with the cursor to follow `WS /v1/events` from",
        "operationId": "getSidebar",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "const": "snapshot"
                    },
                    "cursor": {
                      "type": "string"
                    },
                    "threads": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id"
                        ],
                        "additionalProperties": true
                      }
                    },
                    "majors": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id"
                        ],
                        "additionalProperties": true
                      }
                    },
                    "devices": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id"
                        ],
                        "additionalProperties": true
                      }
                    },
                    "machines": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id"
                        ],
                        "additionalProperties": true
                      }
                    }
                  },
                  "required": [
                    "type",
                    "cursor",
                    "threads",
                    "majors",
                    "devices",
                    "machines"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/v1/dock/keys": {
      "get": {
        "tags": [
          "devices"
        ],
        "summary": "The keys the engine signs requests to docks with; a dock pins them when it pairs",
        "operationId": "getDockKeys",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "keys": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64
                          },
                          "publicKey": {
                            "type": "string",
                            "pattern": "^[\\w-]{43}$"
                          },
                          "endorsedBy": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 64
                              },
                              "signature": {
                                "type": "string",
                                "pattern": "^[\\w-]{86}$"
                              }
                            },
                            "required": [
                              "id",
                              "signature"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "id",
                          "publicKey"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "keys"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/v1/devices": {
      "get": {
        "tags": [
          "devices"
        ],
        "summary": "Your devices",
        "operationId": "getDevices",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "devices": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "online": {
                            "type": "boolean"
                          },
                          "kind": {
                            "type": "string",
                            "const": "cloud"
                          },
                          "hostname": {
                            "type": "string"
                          },
                          "os": {
                            "type": "string"
                          },
                          "arch": {
                            "type": "string"
                          },
                          "info": {
                            "type": "object",
                            "properties": {
                              "name": {
                                "type": "string"
                              },
                              "hostname": {
                                "type": "string"
                              },
                              "os": {
                                "type": "string"
                              },
                              "arch": {
                                "type": "string"
                              },
                              "folders": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              "home": {
                                "type": "string"
                              },
                              "version": {
                                "type": "string"
                              },
                              "hardware": {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "laptop",
                                      "desktop",
                                      "server"
                                    ]
                                  },
                                  "model": {
                                    "type": "string",
                                    "maxLength": 200
                                  },
                                  "chip": {
                                    "type": "string",
                                    "maxLength": 200
                                  },
                                  "cores": {
                                    "type": "integer",
                                    "exclusiveMinimum": 0,
                                    "maximum": 9007199254740991
                                  },
                                  "memoryBytes": {
                                    "type": "number",
                                    "exclusiveMinimum": 0
                                  },
                                  "system": {
                                    "type": "string",
                                    "maxLength": 200
                                  }
                                },
                                "additionalProperties": false
                              },
                              "capabilities": {
                                "type": "object",
                                "properties": {
                                  "arch": {
                                    "type": "string",
                                    "maxLength": 40
                                  },
                                  "git": {
                                    "type": "string",
                                    "maxLength": 120
                                  },
                                  "gh": {
                                    "type": "string",
                                    "maxLength": 120
                                  },
                                  "node": {
                                    "type": "string",
                                    "maxLength": 120
                                  },
                                  "bun": {
                                    "type": "string",
                                    "maxLength": 120
                                  },
                                  "python": {
                                    "type": "string",
                                    "maxLength": 120
                                  },
                                  "docker": {
                                    "type": "string",
                                    "maxLength": 120
                                  },
                                  "browser": {
                                    "type": "string",
                                    "maxLength": 120
                                  },
                                  "desktop": {
                                    "type": "string",
                                    "maxLength": 40
                                  },
                                  "desktopPort": {
                                    "type": "integer",
                                    "minimum": 1,
                                    "maximum": 65535
                                  },
                                  "computer": {
                                    "minItems": 1,
                                    "maxItems": 4,
                                    "type": "array",
                                    "items": {
                                      "type": "string",
                                      "maxLength": 500
                                    }
                                  },
                                  "recording": {
                                    "type": "string",
                                    "maxLength": 120
                                  },
                                  "previews": {
                                    "type": "boolean"
                                  },
                                  "diskFreeBytes": {
                                    "type": "number",
                                    "minimum": 0
                                  },
                                  "memoryFreeBytes": {
                                    "type": "number",
                                    "minimum": 0
                                  },
                                  "memoryLimitBytes": {
                                    "type": "number",
                                    "minimum": 0
                                  }
                                },
                                "required": [
                                  "arch"
                                ],
                                "additionalProperties": false
                              },
                              "gitCredentials": {
                                "type": "string",
                                "const": "own"
                              },
                              "app": {
                                "type": "string",
                                "const": "mac"
                              },
                              "variables": {
                                "type": "boolean"
                              }
                            },
                            "required": [
                              "name",
                              "os",
                              "arch",
                              "folders",
                              "home",
                              "version"
                            ],
                            "additionalProperties": false
                          },
                          "lastSeenAt": {
                            "type": "number"
                          },
                          "createdAt": {
                            "type": "number"
                          },
                          "maxThreads": {
                            "type": "integer",
                            "exclusiveMinimum": 0,
                            "maximum": 9007199254740991
                          },
                          "userId": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "online",
                          "userId"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "devices"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "devices"
        ],
        "summary": "Pairs a device; the token is shown once",
        "operationId": "postDevices",
        "parameters": [],
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "device": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "online": {
                          "type": "boolean"
                        },
                        "kind": {
                          "type": "string",
                          "const": "cloud"
                        },
                        "hostname": {
                          "type": "string"
                        },
                        "os": {
                          "type": "string"
                        },
                        "arch": {
                          "type": "string"
                        },
                        "info": {
                          "type": "object",
                          "properties": {
                            "name": {
                              "type": "string"
                            },
                            "hostname": {
                              "type": "string"
                            },
                            "os": {
                              "type": "string"
                            },
                            "arch": {
                              "type": "string"
                            },
                            "folders": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "home": {
                              "type": "string"
                            },
                            "version": {
                              "type": "string"
                            },
                            "hardware": {
                              "type": "object",
                              "properties": {
                                "type": {
                                  "type": "string",
                                  "enum": [
                                    "laptop",
                                    "desktop",
                                    "server"
                                  ]
                                },
                                "model": {
                                  "type": "string",
                                  "maxLength": 200
                                },
                                "chip": {
                                  "type": "string",
                                  "maxLength": 200
                                },
                                "cores": {
                                  "type": "integer",
                                  "exclusiveMinimum": 0,
                                  "maximum": 9007199254740991
                                },
                                "memoryBytes": {
                                  "type": "number",
                                  "exclusiveMinimum": 0
                                },
                                "system": {
                                  "type": "string",
                                  "maxLength": 200
                                }
                              },
                              "additionalProperties": false
                            },
                            "capabilities": {
                              "type": "object",
                              "properties": {
                                "arch": {
                                  "type": "string",
                                  "maxLength": 40
                                },
                                "git": {
                                  "type": "string",
                                  "maxLength": 120
                                },
                                "gh": {
                                  "type": "string",
                                  "maxLength": 120
                                },
                                "node": {
                                  "type": "string",
                                  "maxLength": 120
                                },
                                "bun": {
                                  "type": "string",
                                  "maxLength": 120
                                },
                                "python": {
                                  "type": "string",
                                  "maxLength": 120
                                },
                                "docker": {
                                  "type": "string",
                                  "maxLength": 120
                                },
                                "browser": {
                                  "type": "string",
                                  "maxLength": 120
                                },
                                "desktop": {
                                  "type": "string",
                                  "maxLength": 40
                                },
                                "desktopPort": {
                                  "type": "integer",
                                  "minimum": 1,
                                  "maximum": 65535
                                },
                                "computer": {
                                  "minItems": 1,
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "string",
                                    "maxLength": 500
                                  }
                                },
                                "recording": {
                                  "type": "string",
                                  "maxLength": 120
                                },
                                "previews": {
                                  "type": "boolean"
                                },
                                "diskFreeBytes": {
                                  "type": "number",
                                  "minimum": 0
                                },
                                "memoryFreeBytes": {
                                  "type": "number",
                                  "minimum": 0
                                },
                                "memoryLimitBytes": {
                                  "type": "number",
                                  "minimum": 0
                                }
                              },
                              "required": [
                                "arch"
                              ],
                              "additionalProperties": false
                            },
                            "gitCredentials": {
                              "type": "string",
                              "const": "own"
                            },
                            "app": {
                              "type": "string",
                              "const": "mac"
                            },
                            "variables": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "name",
                            "os",
                            "arch",
                            "folders",
                            "home",
                            "version"
                          ],
                          "additionalProperties": false
                        },
                        "lastSeenAt": {
                          "type": "number"
                        },
                        "createdAt": {
                          "type": "number"
                        },
                        "maxThreads": {
                          "type": "integer",
                          "exclusiveMinimum": 0,
                          "maximum": 9007199254740991
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "online"
                      ],
                      "additionalProperties": false
                    },
                    "pairingToken": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "device",
                    "pairingToken"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "default": "",
                    "type": "string"
                  },
                  "hostname": {
                    "type": "string",
                    "maxLength": 255
                  },
                  "os": {
                    "type": "string",
                    "maxLength": 32
                  },
                  "arch": {
                    "type": "string",
                    "maxLength": 32
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        }
      }
    },
    "/v1/devices/{deviceId}/pairing": {
      "post": {
        "tags": [
          "devices"
        ],
        "summary": "A new pairing token for one of your devices, shown once; its old token stops working (a Mac pairs as the same device after signing out)",
        "operationId": "postDevicesByDeviceIdPairing",
        "parameters": [
          {
            "name": "deviceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "device": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "online": {
                          "type": "boolean"
                        },
                        "kind": {
                          "type": "string",
                          "const": "cloud"
                        },
                        "hostname": {
                          "type": "string"
                        },
                        "os": {
                          "type": "string"
                        },
                        "arch": {
                          "type": "string"
                        },
                        "info": {
                          "type": "object",
                          "properties": {
                            "name": {
                              "type": "string"
                            },
                            "hostname": {
                              "type": "string"
                            },
                            "os": {
                              "type": "string"
                            },
                            "arch": {
                              "type": "string"
                            },
                            "folders": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "home": {
                              "type": "string"
                            },
                            "version": {
                              "type": "string"
                            },
                            "hardware": {
                              "type": "object",
                              "properties": {
                                "type": {
                                  "type": "string",
                                  "enum": [
                                    "laptop",
                                    "desktop",
                                    "server"
                                  ]
                                },
                                "model": {
                                  "type": "string",
                                  "maxLength": 200
                                },
                                "chip": {
                                  "type": "string",
                                  "maxLength": 200
                                },
                                "cores": {
                                  "type": "integer",
                                  "exclusiveMinimum": 0,
                                  "maximum": 9007199254740991
                                },
                                "memoryBytes": {
                                  "type": "number",
                                  "exclusiveMinimum": 0
                                },
                                "system": {
                                  "type": "string",
                                  "maxLength": 200
                                }
                              },
                              "additionalProperties": false
                            },
                            "capabilities": {
                              "type": "object",
                              "properties": {
                                "arch": {
                                  "type": "string",
                                  "maxLength": 40
                                },
                                "git": {
                                  "type": "string",
                                  "maxLength": 120
                                },
                                "gh": {
                                  "type": "string",
                                  "maxLength": 120
                                },
                                "node": {
                                  "type": "string",
                                  "maxLength": 120
                                },
                                "bun": {
                                  "type": "string",
                                  "maxLength": 120
                                },
                                "python": {
                                  "type": "string",
                                  "maxLength": 120
                                },
                                "docker": {
                                  "type": "string",
                                  "maxLength": 120
                                },
                                "browser": {
                                  "type": "string",
                                  "maxLength": 120
                                },
                                "desktop": {
                                  "type": "string",
                                  "maxLength": 40
                                },
                                "desktopPort": {
                                  "type": "integer",
                                  "minimum": 1,
                                  "maximum": 65535
                                },
                                "computer": {
                                  "minItems": 1,
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "string",
                                    "maxLength": 500
                                  }
                                },
                                "recording": {
                                  "type": "string",
                                  "maxLength": 120
                                },
                                "previews": {
                                  "type": "boolean"
                                },
                                "diskFreeBytes": {
                                  "type": "number",
                                  "minimum": 0
                                },
                                "memoryFreeBytes": {
                                  "type": "number",
                                  "minimum": 0
                                },
                                "memoryLimitBytes": {
                                  "type": "number",
                                  "minimum": 0
                                }
                              },
                              "required": [
                                "arch"
                              ],
                              "additionalProperties": false
                            },
                            "gitCredentials": {
                              "type": "string",
                              "const": "own"
                            },
                            "app": {
                              "type": "string",
                              "const": "mac"
                            },
                            "variables": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "name",
                            "os",
                            "arch",
                            "folders",
                            "home",
                            "version"
                          ],
                          "additionalProperties": false
                        },
                        "lastSeenAt": {
                          "type": "number"
                        },
                        "createdAt": {
                          "type": "number"
                        },
                        "maxThreads": {
                          "type": "integer",
                          "exclusiveMinimum": 0,
                          "maximum": 9007199254740991
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "online"
                      ],
                      "additionalProperties": false
                    },
                    "pairingToken": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "device",
                    "pairingToken"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/v1/devices/{deviceId}": {
      "patch": {
        "tags": [
          "devices"
        ],
        "summary": "Changes one of your devices: its name (from then on its dock’s name doesn’t replace yours) and how many threads may work on it at once",
        "operationId": "patchDevicesByDeviceId",
        "parameters": [
          {
            "name": "deviceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "device": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "online": {
                          "type": "boolean"
                        },
                        "kind": {
                          "type": "string",
                          "const": "cloud"
                        },
                        "hostname": {
                          "type": "string"
                        },
                        "os": {
                          "type": "string"
                        },
                        "arch": {
                          "type": "string"
                        },
                        "info": {
                          "type": "object",
                          "properties": {
                            "name": {
                              "type": "string"
                            },
                            "hostname": {
                              "type": "string"
                            },
                            "os": {
                              "type": "string"
                            },
                            "arch": {
                              "type": "string"
                            },
                            "folders": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "home": {
                              "type": "string"
                            },
                            "version": {
                              "type": "string"
                            },
                            "hardware": {
                              "type": "object",
                              "properties": {
                                "type": {
                                  "type": "string",
                                  "enum": [
                                    "laptop",
                                    "desktop",
                                    "server"
                                  ]
                                },
                                "model": {
                                  "type": "string",
                                  "maxLength": 200
                                },
                                "chip": {
                                  "type": "string",
                                  "maxLength": 200
                                },
                                "cores": {
                                  "type": "integer",
                                  "exclusiveMinimum": 0,
                                  "maximum": 9007199254740991
                                },
                                "memoryBytes": {
                                  "type": "number",
                                  "exclusiveMinimum": 0
                                },
                                "system": {
                                  "type": "string",
                                  "maxLength": 200
                                }
                              },
                              "additionalProperties": false
                            },
                            "capabilities": {
                              "type": "object",
                              "properties": {
                                "arch": {
                                  "type": "string",
                                  "maxLength": 40
                                },
                                "git": {
                                  "type": "string",
                                  "maxLength": 120
                                },
                                "gh": {
                                  "type": "string",
                                  "maxLength": 120
                                },
                                "node": {
                                  "type": "string",
                                  "maxLength": 120
                                },
                                "bun": {
                                  "type": "string",
                                  "maxLength": 120
                                },
                                "python": {
                                  "type": "string",
                                  "maxLength": 120
                                },
                                "docker": {
                                  "type": "string",
                                  "maxLength": 120
                                },
                                "browser": {
                                  "type": "string",
                                  "maxLength": 120
                                },
                                "desktop": {
                                  "type": "string",
                                  "maxLength": 40
                                },
                                "desktopPort": {
                                  "type": "integer",
                                  "minimum": 1,
                                  "maximum": 65535
                                },
                                "computer": {
                                  "minItems": 1,
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "string",
                                    "maxLength": 500
                                  }
                                },
                                "recording": {
                                  "type": "string",
                                  "maxLength": 120
                                },
                                "previews": {
                                  "type": "boolean"
                                },
                                "diskFreeBytes": {
                                  "type": "number",
                                  "minimum": 0
                                },
                                "memoryFreeBytes": {
                                  "type": "number",
                                  "minimum": 0
                                },
                                "memoryLimitBytes": {
                                  "type": "number",
                                  "minimum": 0
                                }
                              },
                              "required": [
                                "arch"
                              ],
                              "additionalProperties": false
                            },
                            "gitCredentials": {
                              "type": "string",
                              "const": "own"
                            },
                            "app": {
                              "type": "string",
                              "const": "mac"
                            },
                            "variables": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "name",
                            "os",
                            "arch",
                            "folders",
                            "home",
                            "version"
                          ],
                          "additionalProperties": false
                        },
                        "lastSeenAt": {
                          "type": "number"
                        },
                        "createdAt": {
                          "type": "number"
                        },
                        "maxThreads": {
                          "type": "integer",
                          "exclusiveMinimum": 0,
                          "maximum": 9007199254740991
                        },
                        "userId": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "online",
                        "userId"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "device"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 80
                  },
                  "maxThreads": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 64
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "devices"
        ],
        "summary": "Removes one of your devices: its pairing token stops working and its dock is disconnected",
        "operationId": "deleteDevicesByDeviceId",
        "parameters": [
          {
            "name": "deviceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "const": true
                    }
                  },
                  "required": [
                    "ok"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/v1/cloud/status": {
      "get": {
        "tags": [
          "devices"
        ],
        "summary": "Whether Keko Cloud can start your new threads now, why not, and the server they’d go to instead",
        "operationId": "getCloudStatus",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "available": {
                      "type": "boolean"
                    },
                    "outage": {
                      "type": "object",
                      "properties": {
                        "reason": {
                          "type": "string",
                          "enum": [
                            "starts",
                            "hours",
                            "plan",
                            "outage"
                          ]
                        },
                        "message": {
                          "type": "string"
                        },
                        "until": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "reason",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "fallback": {
                      "type": "object",
                      "properties": {
                        "mode": {
                          "type": "string",
                          "enum": [
                            "ask",
                            "server",
                            "wait"
                          ]
                        },
                        "deviceId": {
                          "type": "string",
                          "minLength": 1
                        }
                      },
                      "required": [
                        "mode"
                      ],
                      "additionalProperties": false
                    },
                    "suggestedDeviceId": {
                      "type": "string"
                    },
                    "waiting": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "projectName": {
                            "type": "string"
                          },
                          "createdAt": {
                            "type": "number"
                          },
                          "model": {
                            "type": "object",
                            "properties": {
                              "provider": {
                                "type": "string"
                              },
                              "id": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "provider",
                              "id"
                            ],
                            "additionalProperties": false
                          },
                          "permissionMode": {
                            "type": "string",
                            "enum": [
                              "ask",
                              "auto"
                            ]
                          },
                          "ownerId": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          },
                          "until": {
                            "type": "number"
                          },
                          "firstMessage": {
                            "type": "string"
                          },
                          "failed": {
                            "type": "string"
                          },
                          "starting": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "id",
                          "title",
                          "projectName",
                          "createdAt",
                          "model",
                          "permissionMode",
                          "ownerId",
                          "message",
                          "firstMessage"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "available",
                    "fallback",
                    "waiting"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/v1/cloud/fallback": {
      "put": {
        "tags": [
          "devices"
        ],
        "summary": "Where your new cloud threads go when Keko Cloud is out of starts or hours: ask, one of your servers, or wait",
        "operationId": "putCloudFallback",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "available": {
                      "type": "boolean"
                    },
                    "outage": {
                      "type": "object",
                      "properties": {
                        "reason": {
                          "type": "string",
                          "enum": [
                            "starts",
                            "hours",
                            "plan",
                            "outage"
                          ]
                        },
                        "message": {
                          "type": "string"
                        },
                        "until": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "reason",
                        "message"
                      ],
                      "additionalProperties": false
                    },
                    "fallback": {
                      "type": "object",
                      "properties": {
                        "mode": {
                          "type": "string",
                          "enum": [
                            "ask",
                            "server",
                            "wait"
                          ]
                        },
                        "deviceId": {
                          "type": "string",
                          "minLength": 1
                        }
                      },
                      "required": [
                        "mode"
                      ],
                      "additionalProperties": false
                    },
                    "suggestedDeviceId": {
                      "type": "string"
                    },
                    "waiting": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "projectName": {
                            "type": "string"
                          },
                          "createdAt": {
                            "type": "number"
                          },
                          "model": {
                            "type": "object",
                            "properties": {
                              "provider": {
                                "type": "string"
                              },
                              "id": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "provider",
                              "id"
                            ],
                            "additionalProperties": false
                          },
                          "permissionMode": {
                            "type": "string",
                            "enum": [
                              "ask",
                              "auto"
                            ]
                          },
                          "ownerId": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          },
                          "until": {
                            "type": "number"
                          },
                          "firstMessage": {
                            "type": "string"
                          },
                          "failed": {
                            "type": "string"
                          },
                          "starting": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "id",
                          "title",
                          "projectName",
                          "createdAt",
                          "model",
                          "permissionMode",
                          "ownerId",
                          "message",
                          "firstMessage"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "available",
                    "fallback",
                    "waiting"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "mode": {
                    "type": "string",
                    "enum": [
                      "ask",
                      "server",
                      "wait"
                    ]
                  },
                  "deviceId": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "required": [
                  "mode"
                ]
              }
            }
          }
        }
      }
    },
    "/v1/cloud/waiting/{threadId}": {
      "delete": {
        "tags": [
          "threads"
        ],
        "summary": "Stops a thread waiting for Keko Cloud; it’s forgotten",
        "operationId": "deleteCloudWaitingByThreadId",
        "parameters": [
          {
            "name": "threadId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "const": true
                    }
                  },
                  "required": [
                    "ok"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/v1/cloud/waiting/{threadId}/start": {
      "post": {
        "tags": [
          "threads"
        ],
        "summary": "Starts a thread waiting for Keko Cloud on one of your servers now, with a note saying why",
        "operationId": "postCloudWaitingByThreadIdStart",
        "parameters": [
          {
            "name": "threadId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "thread": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "title": {
                          "type": "string"
                        },
                        "projectPath": {
                          "type": "string"
                        },
                        "worktreePath": {
                          "type": "string"
                        },
                        "branch": {
                          "type": "string"
                        },
                        "baseBranch": {
                          "type": "string"
                        },
                        "device": {
                          "type": "string"
                        },
                        "model": {
                          "type": "object",
                          "properties": {
                            "provider": {
                              "type": "string"
                            },
                            "id": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "provider",
                            "id"
                          ],
                          "additionalProperties": false
                        },
                        "createdAt": {
                          "type": "number"
                        },
                        "state": {
                          "type": "string",
                          "enum": [
                            "setting-up",
                            "working",
                            "idle",
                            "failed",
                            "stopped"
                          ]
                        },
                        "cost": {
                          "type": "number"
                        },
                        "setup": {
                          "type": "object",
                          "properties": {
                            "status": {
                              "type": "string",
                              "enum": [
                                "running",
                                "done",
                                "failed"
                              ]
                            },
                            "problems": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            }
                          },
                          "required": [
                            "status",
                            "problems"
                          ],
                          "additionalProperties": true
                        },
                        "deviceName": {
                          "type": "string"
                        },
                        "deviceOnline": {
                          "type": "boolean"
                        },
                        "machineId": {
                          "type": "string"
                        },
                        "machineState": {
                          "type": "string",
                          "enum": [
                            "creating",
                            "starting",
                            "running",
                            "stopping",
                            "stopped",
                            "cleared",
                            "failed",
                            "destroyed"
                          ]
                        },
                        "projectId": {
                          "type": "string"
                        },
                        "needsYou": {
                          "type": "boolean"
                        },
                        "question": {
                          "type": "string"
                        },
                        "statusLine": {
                          "type": "string"
                        },
                        "waitingForDevice": {
                          "type": "object",
                          "properties": {
                            "deviceId": {
                              "type": "string"
                            },
                            "since": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "deviceId",
                            "since"
                          ],
                          "additionalProperties": false
                        },
                        "waitingForCloud": {
                          "type": "object",
                          "properties": {
                            "message": {
                              "type": "string"
                            },
                            "until": {
                              "type": "number"
                            },
                            "firstMessage": {
                              "type": "string"
                            },
                            "failed": {
                              "type": "string"
                            },
                            "starting": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "message",
                            "firstMessage"
                          ],
                          "additionalProperties": false
                        },
                        "request": {
                          "type": "object",
                          "properties": {
                            "callId": {
                              "type": "string"
                            },
                            "title": {
                              "type": "string"
                            },
                            "command": {
                              "type": "boolean"
                            },
                            "ask": {
                              "type": "object",
                              "properties": {
                                "options": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                }
                              },
                              "required": [
                                "options"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "callId",
                            "title",
                            "command"
                          ],
                          "additionalProperties": true
                        },
                        "majorId": {
                          "type": "string"
                        },
                        "userId": {
                          "type": "string"
                        },
                        "unread": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "id",
                        "title",
                        "projectPath",
                        "worktreePath",
                        "branch",
                        "baseBranch",
                        "device",
                        "model",
                        "createdAt",
                        "state",
                        "cost",
                        "setup",
                        "deviceName",
                        "deviceOnline",
                        "userId",
                        "unread"
                      ],
                      "additionalProperties": true
                    }
                  },
                  "required": [
                    "thread"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "deviceId": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "required": [
                  "deviceId"
                ]
              }
            }
          }
        }
      }
    },
    "/v1/threads": {
      "get": {
        "tags": [
          "threads"
        ],
        "summary": "Your threads, newest first",
        "operationId": "getThreads",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "threads": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "projectPath": {
                            "type": "string"
                          },
                          "worktreePath": {
                            "type": "string"
                          },
                          "branch": {
                            "type": "string"
                          },
                          "baseBranch": {
                            "type": "string"
                          },
                          "device": {
                            "type": "string"
                          },
                          "model": {
                            "type": "object",
                            "properties": {
                              "provider": {
                                "type": "string"
                              },
                              "id": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "provider",
                              "id"
                            ],
                            "additionalProperties": false
                          },
                          "createdAt": {
                            "type": "number"
                          },
                          "state": {
                            "type": "string",
                            "enum": [
                              "setting-up",
                              "working",
                              "idle",
                              "failed",
                              "stopped"
                            ]
                          },
                          "cost": {
                            "type": "number"
                          },
                          "setup": {
                            "type": "object",
                            "properties": {
                              "status": {
                                "type": "string",
                                "enum": [
                                  "running",
                                  "done",
                                  "failed"
                                ]
                              },
                              "problems": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              }
                            },
                            "required": [
                              "status",
                              "problems"
                            ],
                            "additionalProperties": true
                          },
                          "deviceName": {
                            "type": "string"
                          },
                          "deviceOnline": {
                            "type": "boolean"
                          },
                          "machineId": {
                            "type": "string"
                          },
                          "machineState": {
                            "type": "string",
                            "enum": [
                              "creating",
                              "starting",
                              "running",
                              "stopping",
                              "stopped",
                              "cleared",
                              "failed",
                              "destroyed"
                            ]
                          },
                          "projectId": {
                            "type": "string"
                          },
                          "needsYou": {
                            "type": "boolean"
                          },
                          "question": {
                            "type": "string"
                          },
                          "statusLine": {
                            "type": "string"
                          },
                          "waitingForDevice": {
                            "type": "object",
                            "properties": {
                              "deviceId": {
                                "type": "string"
                              },
                              "since": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "deviceId",
                              "since"
                            ],
                            "additionalProperties": false
                          },
                          "waitingForCloud": {
                            "type": "object",
                            "properties": {
                              "message": {
                                "type": "string"
                              },
                              "until": {
                                "type": "number"
                              },
                              "firstMessage": {
                                "type": "string"
                              },
                              "failed": {
                                "type": "string"
                              },
                              "starting": {
                                "type": "boolean"
                              }
                            },
                            "required": [
                              "message",
                              "firstMessage"
                            ],
                            "additionalProperties": false
                          },
                          "request": {
                            "type": "object",
                            "properties": {
                              "callId": {
                                "type": "string"
                              },
                              "title": {
                                "type": "string"
                              },
                              "command": {
                                "type": "boolean"
                              },
                              "ask": {
                                "type": "object",
                                "properties": {
                                  "options": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  }
                                },
                                "required": [
                                  "options"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "callId",
                              "title",
                              "command"
                            ],
                            "additionalProperties": true
                          },
                          "majorId": {
                            "type": "string"
                          },
                          "userId": {
                            "type": "string"
                          },
                          "unread": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "id",
                          "title",
                          "projectPath",
                          "worktreePath",
                          "branch",
                          "baseBranch",
                          "device",
                          "model",
                          "createdAt",
                          "state",
                          "cost",
                          "setup",
                          "deviceName",
                          "deviceOnline",
                          "userId",
                          "unread"
                        ],
                        "additionalProperties": true
                      }
                    }
                  },
                  "required": [
                    "threads"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "threads"
        ],
        "summary": "Starts a thread on a device (or `cloud`)",
        "operationId": "postThreads",
        "parameters": [],
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "thread": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "title": {
                          "type": "string"
                        },
                        "projectPath": {
                          "type": "string"
                        },
                        "worktreePath": {
                          "type": "string"
                        },
                        "branch": {
                          "type": "string"
                        },
                        "baseBranch": {
                          "type": "string"
                        },
                        "device": {
                          "type": "string"
                        },
                        "model": {
                          "type": "object",
                          "properties": {
                            "provider": {
                              "type": "string"
                            },
                            "id": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "provider",
                            "id"
                          ],
                          "additionalProperties": false
                        },
                        "createdAt": {
                          "type": "number"
                        },
                        "state": {
                          "type": "string",
                          "enum": [
                            "setting-up",
                            "working",
                            "idle",
                            "failed",
                            "stopped"
                          ]
                        },
                        "cost": {
                          "type": "number"
                        },
                        "setup": {
                          "type": "object",
                          "properties": {
                            "status": {
                              "type": "string",
                              "enum": [
                                "running",
                                "done",
                                "failed"
                              ]
                            },
                            "problems": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            }
                          },
                          "required": [
                            "status",
                            "problems"
                          ],
                          "additionalProperties": true
                        },
                        "deviceName": {
                          "type": "string"
                        },
                        "deviceOnline": {
                          "type": "boolean"
                        },
                        "machineId": {
                          "type": "string"
                        },
                        "machineState": {
                          "type": "string",
                          "enum": [
                            "creating",
                            "starting",
                            "running",
                            "stopping",
                            "stopped",
                            "cleared",
                            "failed",
                            "destroyed"
                          ]
                        },
                        "projectId": {
                          "type": "string"
                        },
                        "needsYou": {
                          "type": "boolean"
                        },
                        "question": {
                          "type": "string"
                        },
                        "statusLine": {
                          "type": "string"
                        },
                        "waitingForDevice": {
                          "type": "object",
                          "properties": {
                            "deviceId": {
                              "type": "string"
                            },
                            "since": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "deviceId",
                            "since"
                          ],
                          "additionalProperties": false
                        },
                        "waitingForCloud": {
                          "type": "object",
                          "properties": {
                            "message": {
                              "type": "string"
                            },
                            "until": {
                              "type": "number"
                            },
                            "firstMessage": {
                              "type": "string"
                            },
                            "failed": {
                              "type": "string"
                            },
                            "starting": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "message",
                            "firstMessage"
                          ],
                          "additionalProperties": false
                        },
                        "request": {
                          "type": "object",
                          "properties": {
                            "callId": {
                              "type": "string"
                            },
                            "title": {
                              "type": "string"
                            },
                            "command": {
                              "type": "boolean"
                            },
                            "ask": {
                              "type": "object",
                              "properties": {
                                "options": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                }
                              },
                              "required": [
                                "options"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "callId",
                            "title",
                            "command"
                          ],
                          "additionalProperties": true
                        },
                        "majorId": {
                          "type": "string"
                        },
                        "userId": {
                          "type": "string"
                        },
                        "unread": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "id",
                        "title",
                        "projectPath",
                        "worktreePath",
                        "branch",
                        "baseBranch",
                        "device",
                        "model",
                        "createdAt",
                        "state",
                        "cost",
                        "setup",
                        "deviceName",
                        "deviceOnline",
                        "userId",
                        "unread"
                      ],
                      "additionalProperties": true
                    }
                  },
                  "required": [
                    "thread"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "deviceId": {
                    "default": "",
                    "type": "string"
                  },
                  "path": {
                    "type": "string"
                  },
                  "project": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "minLength": 1
                      },
                      "repoUrl": {
                        "type": "string",
                        "minLength": 1
                      },
                      "branch": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "id",
                      "repoUrl"
                    ]
                  },
                  "insteadOfCloud": {
                    "type": "boolean"
                  },
                  "firstMessage": {
                    "default": "",
                    "type": "string"
                  },
                  "model": {
                    "default": {
                      "provider": "",
                      "id": ""
                    },
                    "type": "object",
                    "properties": {
                      "provider": {
                        "type": "string"
                      },
                      "id": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "provider",
                      "id"
                    ]
                  },
                  "title": {
                    "type": "string"
                  },
                  "permissionMode": {
                    "type": "string",
                    "enum": [
                      "ask",
                      "auto"
                    ]
                  },
                  "baseBranch": {
                    "type": "string"
                  },
                  "requestId": {
                    "type": "string"
                  },
                  "allowSecret": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "deviceId",
                  "firstMessage",
                  "model"
                ]
              }
            }
          }
        }
      }
    },
    "/v1/threads/{threadId}": {
      "get": {
        "tags": [
          "threads"
        ],
        "summary": "One thread",
        "operationId": "getThreadsByThreadId",
        "parameters": [
          {
            "name": "threadId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "thread": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "title": {
                          "type": "string"
                        },
                        "projectPath": {
                          "type": "string"
                        },
                        "worktreePath": {
                          "type": "string"
                        },
                        "branch": {
                          "type": "string"
                        },
                        "baseBranch": {
                          "type": "string"
                        },
                        "device": {
                          "type": "string"
                        },
                        "model": {
                          "type": "object",
                          "properties": {
                            "provider": {
                              "type": "string"
                            },
                            "id": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "provider",
                            "id"
                          ],
                          "additionalProperties": false
                        },
                        "createdAt": {
                          "type": "number"
                        },
                        "state": {
                          "type": "string",
                          "enum": [
                            "setting-up",
                            "working",
                            "idle",
                            "failed",
                            "stopped"
                          ]
                        },
                        "cost": {
                          "type": "number"
                        },
                        "setup": {
                          "type": "object",
                          "properties": {
                            "status": {
                              "type": "string",
                              "enum": [
                                "running",
                                "done",
                                "failed"
                              ]
                            },
                            "problems": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            }
                          },
                          "required": [
                            "status",
                            "problems"
                          ],
                          "additionalProperties": true
                        },
                        "deviceName": {
                          "type": "string"
                        },
                        "deviceOnline": {
                          "type": "boolean"
                        },
                        "machineId": {
                          "type": "string"
                        },
                        "machineState": {
                          "type": "string",
                          "enum": [
                            "creating",
                            "starting",
                            "running",
                            "stopping",
                            "stopped",
                            "cleared",
                            "failed",
                            "destroyed"
                          ]
                        },
                        "projectId": {
                          "type": "string"
                        },
                        "needsYou": {
                          "type": "boolean"
                        },
                        "question": {
                          "type": "string"
                        },
                        "statusLine": {
                          "type": "string"
                        },
                        "waitingForDevice": {
                          "type": "object",
                          "properties": {
                            "deviceId": {
                              "type": "string"
                            },
                            "since": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "deviceId",
                            "since"
                          ],
                          "additionalProperties": false
                        },
                        "waitingForCloud": {
                          "type": "object",
                          "properties": {
                            "message": {
                              "type": "string"
                            },
                            "until": {
                              "type": "number"
                            },
                            "firstMessage": {
                              "type": "string"
                            },
                            "failed": {
                              "type": "string"
                            },
                            "starting": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "message",
                            "firstMessage"
                          ],
                          "additionalProperties": false
                        },
                        "request": {
                          "type": "object",
                          "properties": {
                            "callId": {
                              "type": "string"
                            },
                            "title": {
                              "type": "string"
                            },
                            "command": {
                              "type": "boolean"
                            },
                            "ask": {
                              "type": "object",
                              "properties": {
                                "options": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                }
                              },
                              "required": [
                                "options"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "callId",
                            "title",
                            "command"
                          ],
                          "additionalProperties": true
                        },
                        "majorId": {
                          "type": "string"
                        },
                        "userId": {
                          "type": "string"
                        },
                        "unread": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "id",
                        "title",
                        "projectPath",
                        "worktreePath",
                        "branch",
                        "baseBranch",
                        "device",
                        "model",
                        "createdAt",
                        "state",
                        "cost",
                        "setup",
                        "deviceName",
                        "deviceOnline",
                        "userId",
                        "unread"
                      ],
                      "additionalProperties": true
                    }
                  },
                  "required": [
                    "thread"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "threads"
        ],
        "summary": "Renames, archives, pins, or changes its model or permission mode",
        "operationId": "patchThreadsByThreadId",
        "parameters": [
          {
            "name": "threadId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "thread": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "title": {
                          "type": "string"
                        },
                        "projectPath": {
                          "type": "string"
                        },
                        "worktreePath": {
                          "type": "string"
                        },
                        "branch": {
                          "type": "string"
                        },
                        "baseBranch": {
                          "type": "string"
                        },
                        "device": {
                          "type": "string"
                        },
                        "model": {
                          "type": "object",
                          "properties": {
                            "provider": {
                              "type": "string"
                            },
                            "id": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "provider",
                            "id"
                          ],
                          "additionalProperties": false
                        },
                        "createdAt": {
                          "type": "number"
                        },
                        "state": {
                          "type": "string",
                          "enum": [
                            "setting-up",
                            "working",
                            "idle",
                            "failed",
                            "stopped"
                          ]
                        },
                        "cost": {
                          "type": "number"
                        },
                        "setup": {
                          "type": "object",
                          "properties": {
                            "status": {
                              "type": "string",
                              "enum": [
                                "running",
                                "done",
                                "failed"
                              ]
                            },
                            "problems": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            }
                          },
                          "required": [
                            "status",
                            "problems"
                          ],
                          "additionalProperties": true
                        },
                        "deviceName": {
                          "type": "string"
                        },
                        "deviceOnline": {
                          "type": "boolean"
                        },
                        "machineId": {
                          "type": "string"
                        },
                        "machineState": {
                          "type": "string",
                          "enum": [
                            "creating",
                            "starting",
                            "running",
                            "stopping",
                            "stopped",
                            "cleared",
                            "failed",
                            "destroyed"
                          ]
                        },
                        "projectId": {
                          "type": "string"
                        },
                        "needsYou": {
                          "type": "boolean"
                        },
                        "question": {
                          "type": "string"
                        },
                        "statusLine": {
                          "type": "string"
                        },
                        "waitingForDevice": {
                          "type": "object",
                          "properties": {
                            "deviceId": {
                              "type": "string"
                            },
                            "since": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "deviceId",
                            "since"
                          ],
                          "additionalProperties": false
                        },
                        "waitingForCloud": {
                          "type": "object",
                          "properties": {
                            "message": {
                              "type": "string"
                            },
                            "until": {
                              "type": "number"
                            },
                            "firstMessage": {
                              "type": "string"
                            },
                            "failed": {
                              "type": "string"
                            },
                            "starting": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "message",
                            "firstMessage"
                          ],
                          "additionalProperties": false
                        },
                        "request": {
                          "type": "object",
                          "properties": {
                            "callId": {
                              "type": "string"
                            },
                            "title": {
                              "type": "string"
                            },
                            "command": {
                              "type": "boolean"
                            },
                            "ask": {
                              "type": "object",
                              "properties": {
                                "options": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                }
                              },
                              "required": [
                                "options"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "callId",
                            "title",
                            "command"
                          ],
                          "additionalProperties": true
                        },
                        "majorId": {
                          "type": "string"
                        },
                        "userId": {
                          "type": "string"
                        },
                        "unread": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "id",
                        "title",
                        "projectPath",
                        "worktreePath",
                        "branch",
                        "baseBranch",
                        "device",
                        "model",
                        "createdAt",
                        "state",
                        "cost",
                        "setup",
                        "deviceName",
                        "deviceOnline",
                        "userId",
                        "unread"
                      ],
                      "additionalProperties": true
                    }
                  },
                  "required": [
                    "thread"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "title": {
                    "type": "string"
                  },
                  "archived": {
                    "type": "boolean"
                  },
                  "pinned": {
                    "type": "boolean"
                  },
                  "permissionMode": {
                    "type": "string",
                    "enum": [
                      "ask",
                      "auto"
                    ]
                  },
                  "model": {
                    "type": "object",
                    "properties": {
                      "provider": {
                        "type": "string"
                      },
                      "id": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "provider",
                      "id"
                    ]
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/threads/{threadId}/messages": {
      "post": {
        "tags": [
          "threads"
        ],
        "summary": "Sends a message: steer, queue or interrupt",
        "operationId": "postThreadsByThreadIdMessages",
        "parameters": [
          {
            "name": "threadId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "submissionId": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "submissionId"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "text": {
                    "default": "",
                    "type": "string"
                  },
                  "mode": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "steer",
                          "queue",
                          "interrupt"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "requestId": {
                    "type": "string"
                  },
                  "allowSecret": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "text"
                ]
              }
            }
          }
        }
      }
    },
    "/v1/threads/{threadId}/stop": {
      "post": {
        "tags": [
          "threads"
        ],
        "summary": "Stops the run (a thread or a major)",
        "operationId": "postThreadsByThreadIdStop",
        "parameters": [
          {
            "name": "threadId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "const": true
                    }
                  },
                  "required": [
                    "ok"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/v1/threads/{threadId}/read": {
      "post": {
        "tags": [
          "threads"
        ],
        "summary": "Marks it read (a thread or a major)",
        "operationId": "postThreadsByThreadIdRead",
        "parameters": [
          {
            "name": "threadId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "const": true
                    }
                  },
                  "required": [
                    "ok"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/v1/threads/{threadId}/entries": {
      "get": {
        "tags": [
          "threads"
        ],
        "summary": "A page of the transcript (a thread or a major)",
        "operationId": "getThreadsByThreadIdEntries",
        "parameters": [
          {
            "name": "threadId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "minEntryId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^\\d+$"
            }
          },
          {
            "name": "maxEntryId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^\\d+$"
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "ascending",
                "descending"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^\\d+$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "readOnly": true,
                      "type": "array",
                      "items": {}
                    },
                    "next": {}
                  },
                  "required": [
                    "items"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/v1/threads/{threadId}/preview": {
      "get": {
        "tags": [
          "threads"
        ],
        "summary": "A URL for a port on a Keko Cloud thread’s machine",
        "operationId": "getThreadsByThreadIdPreview",
        "parameters": [
          {
            "name": "threadId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "port",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^\\d+$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "url"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/v1/approvals": {
      "get": {
        "tags": [
          "approvals"
        ],
        "summary": "Requests waiting for you, across your threads",
        "operationId": "getApprovals",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "approvals": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "callId": {
                            "type": "string"
                          },
                          "tool": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "command": {
                            "type": "boolean"
                          },
                          "description": {
                            "type": "string"
                          },
                          "question": {
                            "type": "string"
                          },
                          "grants": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "kind": {
                                  "type": "string",
                                  "enum": [
                                    "command",
                                    "group"
                                  ]
                                },
                                "label": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "kind",
                                "label"
                              ],
                              "additionalProperties": true
                            }
                          },
                          "requestedAt": {
                            "type": "number"
                          },
                          "ask": {
                            "type": "object",
                            "properties": {
                              "options": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              }
                            },
                            "required": [
                              "options"
                            ],
                            "additionalProperties": false
                          },
                          "threadId": {
                            "type": "string"
                          },
                          "threadTitle": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "callId",
                          "tool",
                          "title",
                          "command",
                          "description",
                          "question",
                          "grants",
                          "requestedAt",
                          "threadId",
                          "threadTitle"
                        ],
                        "additionalProperties": true
                      }
                    }
                  },
                  "required": [
                    "approvals"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/v1/threads/{threadId}/approvals": {
      "get": {
        "tags": [
          "approvals"
        ],
        "summary": "One thread’s requests waiting for you",
        "operationId": "getThreadsByThreadIdApprovals",
        "parameters": [
          {
            "name": "threadId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "approvals": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "callId": {
                            "type": "string"
                          },
                          "tool": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "command": {
                            "type": "boolean"
                          },
                          "description": {
                            "type": "string"
                          },
                          "question": {
                            "type": "string"
                          },
                          "grants": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "kind": {
                                  "type": "string",
                                  "enum": [
                                    "command",
                                    "group"
                                  ]
                                },
                                "label": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "kind",
                                "label"
                              ],
                              "additionalProperties": true
                            }
                          },
                          "requestedAt": {
                            "type": "number"
                          },
                          "ask": {
                            "type": "object",
                            "properties": {
                              "options": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              }
                            },
                            "required": [
                              "options"
                            ],
                            "additionalProperties": false
                          },
                          "threadId": {
                            "type": "string"
                          },
                          "threadTitle": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "callId",
                          "tool",
                          "title",
                          "command",
                          "description",
                          "question",
                          "grants",
                          "requestedAt",
                          "threadId",
                          "threadTitle"
                        ],
                        "additionalProperties": true
                      }
                    }
                  },
                  "required": [
                    "approvals"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/v1/threads/{threadId}/approvals/{callId}": {
      "post": {
        "tags": [
          "approvals"
        ],
        "summary": "Answers a request: allow (optionally always), or deny with what to do instead",
        "operationId": "postThreadsByThreadIdApprovalsByCallId",
        "parameters": [
          {
            "name": "threadId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "callId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "const": true
                    }
                  },
                  "required": [
                    "ok"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "allow": {
                    "type": "boolean"
                  },
                  "always": {
                    "oneOf": [
                      {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "const": "command"
                          },
                          "command": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "kind",
                          "command"
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "const": "group"
                          },
                          "group": {
                            "type": "string",
                            "enum": [
                              "add-package",
                              "pull-request",
                              "push-branch",
                              "publish",
                              "network",
                              "database-read",
                              "system",
                              "connected-service",
                              "desktop"
                            ]
                          }
                        },
                        "required": [
                          "kind",
                          "group"
                        ]
                      }
                    ]
                  },
                  "redirect": {
                    "type": "string"
                  },
                  "by": {
                    "type": "string"
                  },
                  "reply": {
                    "type": "string"
                  },
                  "allowSecret": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "allow"
                ]
              }
            }
          }
        }
      }
    },
    "/v1/threads/{threadId}/plan": {
      "post": {
        "tags": [
          "approvals"
        ],
        "summary": "Approves, edits or rejects the plan `/plan` made",
        "operationId": "postThreadsByThreadIdPlan",
        "parameters": [
          {
            "name": "threadId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "const": true
                    }
                  },
                  "required": [
                    "ok"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "action": {
                    "type": "string",
                    "enum": [
                      "approve",
                      "edit",
                      "reject"
                    ]
                  }
                },
                "required": [
                  "action"
                ]
              }
            }
          }
        }
      }
    },
    "/v1/threads/{threadId}/changes": {
      "get": {
        "tags": [
          "changes"
        ],
        "summary": "Turns and changed files: one turn’s (the last by default), all, or uncommitted",
        "operationId": "getThreadsByThreadIdChanges",
        "parameters": [
          {
            "name": "threadId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "scope",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "turn",
                "all",
                "uncommitted"
              ]
            }
          },
          {
            "name": "turn",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^\\d+$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "scope": {
                      "type": "object",
                      "properties": {
                        "kind": {
                          "type": "string",
                          "enum": [
                            "turn",
                            "all",
                            "uncommitted"
                          ]
                        },
                        "turn": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "kind"
                      ],
                      "additionalProperties": true
                    },
                    "turn": {
                      "type": "number"
                    },
                    "from": {
                      "type": "string"
                    },
                    "to": {
                      "type": "string"
                    },
                    "files": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "path": {
                            "type": "string"
                          },
                          "oldPath": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "added",
                              "modified",
                              "deleted",
                              "renamed",
                              "type-changed"
                            ]
                          },
                          "added": {
                            "type": "number"
                          },
                          "removed": {
                            "type": "number"
                          },
                          "binary": {
                            "type": "boolean"
                          },
                          "hash": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "path",
                          "status",
                          "added",
                          "removed",
                          "binary",
                          "hash"
                        ],
                        "additionalProperties": true
                      }
                    },
                    "added": {
                      "type": "number"
                    },
                    "removed": {
                      "type": "number"
                    },
                    "branch": {
                      "type": "string"
                    },
                    "baseBranch": {
                      "type": "string"
                    },
                    "turns": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "turn": {
                            "type": "number"
                          },
                          "checkpoint": {
                            "type": "number"
                          },
                          "at": {
                            "type": "number"
                          }
                        },
                        "required": [
                          "turn",
                          "checkpoint",
                          "at"
                        ],
                        "additionalProperties": true
                      }
                    },
                    "empty": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "scope",
                    "from",
                    "to",
                    "files",
                    "added",
                    "removed",
                    "branch",
                    "baseBranch",
                    "turns"
                  ],
                  "additionalProperties": true
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/v1/threads/{threadId}/diff": {
      "get": {
        "tags": [
          "changes"
        ],
        "summary": "One file’s diff between two trees of a change set",
        "operationId": "getThreadsByThreadIdDiff",
        "parameters": [
          {
            "name": "threadId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "path",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "oldPath",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "force",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "0",
                "1",
                "true",
                "false"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "path": {
                      "type": "string"
                    },
                    "binary": {
                      "type": "boolean"
                    },
                    "lines": {
                      "type": "number"
                    },
                    "tooLarge": {
                      "type": "boolean"
                    },
                    "text": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "path",
                    "binary",
                    "lines",
                    "text"
                  ],
                  "additionalProperties": true
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/v1/threads/{threadId}/restore": {
      "post": {
        "tags": [
          "changes"
        ],
        "summary": "Puts the worktree back to a checkpoint; `backup` undoes it",
        "operationId": "postThreadsByThreadIdRestore",
        "parameters": [
          {
            "name": "threadId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "backup": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "backup"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "checkpoint": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  }
                },
                "required": [
                  "checkpoint"
                ]
              }
            }
          }
        }
      }
    },
    "/v1/threads/{threadId}/review": {
      "get": {
        "tags": [
          "review"
        ],
        "summary": "GitHub sign-in, the pull request and the branch",
        "operationId": "getThreadsByThreadIdReview",
        "parameters": [
          {
            "name": "threadId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "fresh",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "0",
                "1",
                "true",
                "false"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "github": {
                      "type": "object",
                      "properties": {
                        "state": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "state"
                      ],
                      "additionalProperties": true
                    },
                    "pr": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "number": {
                              "type": "number"
                            },
                            "url": {
                              "type": "string"
                            },
                            "title": {
                              "type": "string"
                            },
                            "status": {
                              "type": "string"
                            },
                            "checks": {
                              "type": "string"
                            },
                            "review": {
                              "type": "string"
                            },
                            "mergeable": {
                              "type": [
                                "boolean",
                                "null"
                              ]
                            },
                            "mergeState": {
                              "type": "string"
                            },
                            "checkedAt": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "number",
                            "url",
                            "title",
                            "status",
                            "checks",
                            "review",
                            "mergeable",
                            "mergeState",
                            "checkedAt"
                          ],
                          "additionalProperties": true
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "local": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "uncommitted": {
                              "type": "number"
                            },
                            "unpushed": {
                              "type": "number"
                            },
                            "ahead": {
                              "type": "number"
                            },
                            "pushed": {
                              "type": "boolean"
                            },
                            "remote": {
                              "type": [
                                "string",
                                "null"
                              ]
                            }
                          },
                          "required": [
                            "uncommitted",
                            "unpushed",
                            "ahead",
                            "pushed",
                            "remote"
                          ],
                          "additionalProperties": true
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "github",
                    "pr",
                    "local"
                  ],
                  "additionalProperties": true
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/v1/threads/{threadId}/review/pull-request": {
      "post": {
        "tags": [
          "review"
        ],
        "summary": "Commits, pushes and opens the pull request (or updates the open one)",
        "operationId": "postThreadsByThreadIdReviewPullRequest",
        "parameters": [
          {
            "name": "threadId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "pr": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "number": {
                              "type": "number"
                            },
                            "url": {
                              "type": "string"
                            },
                            "title": {
                              "type": "string"
                            },
                            "status": {
                              "type": "string"
                            },
                            "checks": {
                              "type": "string"
                            },
                            "review": {
                              "type": "string"
                            },
                            "mergeable": {
                              "type": [
                                "boolean",
                                "null"
                              ]
                            },
                            "mergeState": {
                              "type": "string"
                            },
                            "checkedAt": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "number",
                            "url",
                            "title",
                            "status",
                            "checks",
                            "review",
                            "mergeable",
                            "mergeState",
                            "checkedAt"
                          ],
                          "additionalProperties": true
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "pr"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "draft": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "review"
        ],
        "summary": "Commits and pushes new work to the open pull request",
        "operationId": "putThreadsByThreadIdReviewPullRequest",
        "parameters": [
          {
            "name": "threadId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "pr": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "number": {
                              "type": "number"
                            },
                            "url": {
                              "type": "string"
                            },
                            "title": {
                              "type": "string"
                            },
                            "status": {
                              "type": "string"
                            },
                            "checks": {
                              "type": "string"
                            },
                            "review": {
                              "type": "string"
                            },
                            "mergeable": {
                              "type": [
                                "boolean",
                                "null"
                              ]
                            },
                            "mergeState": {
                              "type": "string"
                            },
                            "checkedAt": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "number",
                            "url",
                            "title",
                            "status",
                            "checks",
                            "review",
                            "mergeable",
                            "mergeState",
                            "checkedAt"
                          ],
                          "additionalProperties": true
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "pr"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/v1/threads/{threadId}/review/refresh": {
      "post": {
        "tags": [
          "review"
        ],
        "summary": "Reads the pull request from GitHub now",
        "operationId": "postThreadsByThreadIdReviewRefresh",
        "parameters": [
          {
            "name": "threadId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "pr": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "number": {
                              "type": "number"
                            },
                            "url": {
                              "type": "string"
                            },
                            "title": {
                              "type": "string"
                            },
                            "status": {
                              "type": "string"
                            },
                            "checks": {
                              "type": "string"
                            },
                            "review": {
                              "type": "string"
                            },
                            "mergeable": {
                              "type": [
                                "boolean",
                                "null"
                              ]
                            },
                            "mergeState": {
                              "type": "string"
                            },
                            "checkedAt": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "number",
                            "url",
                            "title",
                            "status",
                            "checks",
                            "review",
                            "mergeable",
                            "mergeState",
                            "checkedAt"
                          ],
                          "additionalProperties": true
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "pr"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/v1/threads/{threadId}/review/merge": {
      "post": {
        "tags": [
          "review"
        ],
        "summary": "Merges the pull request (squash by default)",
        "operationId": "postThreadsByThreadIdReviewMerge",
        "parameters": [
          {
            "name": "threadId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "pr": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "number": {
                              "type": "number"
                            },
                            "url": {
                              "type": "string"
                            },
                            "title": {
                              "type": "string"
                            },
                            "status": {
                              "type": "string"
                            },
                            "checks": {
                              "type": "string"
                            },
                            "review": {
                              "type": "string"
                            },
                            "mergeable": {
                              "type": [
                                "boolean",
                                "null"
                              ]
                            },
                            "mergeState": {
                              "type": "string"
                            },
                            "checkedAt": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "number",
                            "url",
                            "title",
                            "status",
                            "checks",
                            "review",
                            "mergeable",
                            "mergeState",
                            "checkedAt"
                          ],
                          "additionalProperties": true
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "pr"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "method": {
                    "type": "string",
                    "enum": [
                      "squash",
                      "merge",
                      "rebase"
                    ]
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/threads/{threadId}/review/fix": {
      "post": {
        "tags": [
          "review"
        ],
        "summary": "Sends the failing checks and their logs to the thread",
        "operationId": "postThreadsByThreadIdReviewFix",
        "parameters": [
          {
            "name": "threadId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "const": true
                    }
                  },
                  "required": [
                    "ok"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/v1/threads/{threadId}/review/comments": {
      "post": {
        "tags": [
          "review"
        ],
        "summary": "Ask for changes: line comments, sent as one message (queued while it works)",
        "operationId": "postThreadsByThreadIdReviewComments",
        "parameters": [
          {
            "name": "threadId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "submissionId": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "submissionId"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "comments": {
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "path": {
                          "type": "string"
                        },
                        "side": {
                          "type": "string",
                          "enum": [
                            "new",
                            "old"
                          ]
                        },
                        "line": {
                          "type": "integer",
                          "exclusiveMinimum": 0,
                          "maximum": 9007199254740991
                        },
                        "endLine": {
                          "type": "integer",
                          "exclusiveMinimum": 0,
                          "maximum": 9007199254740991
                        },
                        "quote": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "text": {
                          "type": "string",
                          "minLength": 1
                        }
                      },
                      "required": [
                        "path",
                        "line",
                        "text"
                      ]
                    }
                  },
                  "requestId": {
                    "type": "string"
                  }
                },
                "required": [
                  "comments"
                ]
              }
            }
          }
        }
      }
    },
    "/v1/threads/{threadId}/terminals": {
      "get": {
        "tags": [
          "terminals"
        ],
        "summary": "A thread’s terminals",
        "operationId": "getThreadsByThreadIdTerminals",
        "parameters": [
          {
            "name": "threadId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "threadId": {
                      "type": "string"
                    },
                    "terminals": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "threadId": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "idle",
                              "running",
                              "exited"
                            ]
                          },
                          "foreground": {
                            "type": "string"
                          },
                          "exitCode": {
                            "type": "number"
                          }
                        },
                        "required": [
                          "id",
                          "threadId",
                          "title",
                          "status"
                        ],
                        "additionalProperties": true
                      }
                    },
                    "localUrls": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "threadId",
                    "terminals",
                    "localUrls"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "terminals"
        ],
        "summary": "Opens a terminal in the worktree; follow it on `WS /v1/terminals/{terminalId}`",
        "operationId": "postThreadsByThreadIdTerminals",
        "parameters": [
          {
            "name": "threadId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "terminal": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "threadId": {
                          "type": "string"
                        },
                        "title": {
                          "type": "string"
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "idle",
                            "running",
                            "exited"
                          ]
                        },
                        "foreground": {
                          "type": "string"
                        },
                        "exitCode": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "id",
                        "threadId",
                        "title",
                        "status"
                      ],
                      "additionalProperties": true
                    }
                  },
                  "required": [
                    "terminal"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "cols": {
                    "type": "integer",
                    "exclusiveMinimum": 0,
                    "maximum": 9007199254740991
                  },
                  "rows": {
                    "type": "integer",
                    "exclusiveMinimum": 0,
                    "maximum": 9007199254740991
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/terminals/{terminalId}": {
      "delete": {
        "tags": [
          "terminals"
        ],
        "summary": "Closes a terminal",
        "operationId": "deleteTerminalsByTerminalId",
        "parameters": [
          {
            "name": "terminalId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "const": true
                    }
                  },
                  "required": [
                    "ok"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "terminals"
        ],
        "summary": "A terminal: its output so far, then output as it comes (WebSocket)",
        "description": "Send `write` (keystrokes), `resize` and `close`. Several clients can follow one terminal at once.",
        "operationId": "socketTerminalsByTerminalId",
        "parameters": [
          {
            "name": "terminalId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "101": {
            "description": "Switches to a WebSocket"
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "x-websocket": {
          "sends": {
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "const": "attached"
                  },
                  "info": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "threadId": {
                        "type": "string"
                      },
                      "title": {
                        "type": "string"
                      },
                      "status": {
                        "type": "string",
                        "enum": [
                          "idle",
                          "running",
                          "exited"
                        ]
                      },
                      "foreground": {
                        "type": "string"
                      },
                      "exitCode": {
                        "type": "number"
                      }
                    },
                    "required": [
                      "id",
                      "threadId",
                      "title",
                      "status"
                    ],
                    "additionalProperties": true
                  },
                  "buffer": {
                    "type": "string"
                  }
                },
                "required": [
                  "type",
                  "info",
                  "buffer"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "const": "data"
                  },
                  "data": {
                    "type": "string"
                  }
                },
                "required": [
                  "type",
                  "data"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "const": "info"
                  },
                  "info": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "threadId": {
                        "type": "string"
                      },
                      "title": {
                        "type": "string"
                      },
                      "status": {
                        "type": "string",
                        "enum": [
                          "idle",
                          "running",
                          "exited"
                        ]
                      },
                      "foreground": {
                        "type": "string"
                      },
                      "exitCode": {
                        "type": "number"
                      }
                    },
                    "required": [
                      "id",
                      "threadId",
                      "title",
                      "status"
                    ],
                    "additionalProperties": true
                  }
                },
                "required": [
                  "type",
                  "info"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "const": "error"
                  },
                  "message": {
                    "type": "string"
                  }
                },
                "required": [
                  "type",
                  "message"
                ],
                "additionalProperties": false
              }
            ]
          },
          "receives": {
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "const": "write"
                  },
                  "data": {
                    "type": "string"
                  }
                },
                "required": [
                  "type",
                  "data"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "const": "resize"
                  },
                  "cols": {
                    "type": "number"
                  },
                  "rows": {
                    "type": "number"
                  }
                },
                "required": [
                  "type",
                  "cols",
                  "rows"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "const": "close"
                  }
                },
                "required": [
                  "type"
                ]
              }
            ]
          }
        }
      }
    },
    "/v1/majors": {
      "get": {
        "tags": [
          "majors"
        ],
        "summary": "Your majors",
        "operationId": "getMajors",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "majors": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "portrait": {
                            "type": "object",
                            "properties": {
                              "ant": {
                                "type": "string",
                                "enum": [
                                  "builder",
                                  "inspector",
                                  "scout",
                                  "engineer",
                                  "medic",
                                  "night-shift",
                                  "navigator",
                                  "dispatcher",
                                  "thinker",
                                  "rookie",
                                  "veteran",
                                  "royal-guard"
                                ]
                              },
                              "background": {
                                "type": "string",
                                "enum": [
                                  "sand",
                                  "sage",
                                  "sky",
                                  "lilac",
                                  "blush",
                                  "mint",
                                  "butter",
                                  "stone"
                                ]
                              }
                            },
                            "required": [
                              "ant",
                              "background"
                            ],
                            "additionalProperties": false
                          },
                          "projectPaths": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "device": {
                            "type": "string"
                          },
                          "model": {
                            "type": "object",
                            "properties": {
                              "provider": {
                                "type": "string"
                              },
                              "id": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "provider",
                              "id"
                            ],
                            "additionalProperties": false
                          },
                          "maxCrew": {
                            "type": "number"
                          },
                          "createdAt": {
                            "type": "number"
                          },
                          "archived": {
                            "type": "boolean"
                          },
                          "pinned": {
                            "type": "boolean"
                          },
                          "state": {
                            "type": "string",
                            "enum": [
                              "setting-up",
                              "working",
                              "idle",
                              "failed",
                              "stopped"
                            ]
                          },
                          "statusLine": {
                            "type": "string"
                          },
                          "lastActivityAt": {
                            "type": "number"
                          },
                          "cost": {
                            "type": "number"
                          },
                          "needsYou": {
                            "type": "boolean"
                          },
                          "question": {
                            "type": "string"
                          },
                          "rules": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string"
                                },
                                "kind": {
                                  "type": "string",
                                  "enum": [
                                    "allow",
                                    "ask",
                                    "instruction"
                                  ]
                                },
                                "text": {
                                  "type": "string"
                                },
                                "label": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "id",
                                "kind",
                                "text",
                                "label"
                              ],
                              "additionalProperties": true
                            }
                          },
                          "notes": {
                            "type": "string"
                          },
                          "upNext": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string"
                                },
                                "projectPath": {
                                  "type": "string"
                                },
                                "title": {
                                  "type": "string"
                                },
                                "instructions": {
                                  "type": "string"
                                },
                                "addedAt": {
                                  "type": "number"
                                },
                                "addedBy": {
                                  "type": "string",
                                  "enum": [
                                    "major",
                                    "you"
                                  ]
                                }
                              },
                              "required": [
                                "id",
                                "projectPath",
                                "title",
                                "instructions",
                                "addedAt",
                                "addedBy"
                              ],
                              "additionalProperties": true
                            }
                          },
                          "userId": {
                            "type": "string"
                          },
                          "unread": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "portrait",
                          "projectPaths",
                          "device",
                          "model",
                          "maxCrew",
                          "createdAt",
                          "archived",
                          "pinned",
                          "state",
                          "statusLine",
                          "lastActivityAt",
                          "cost",
                          "needsYou",
                          "rules",
                          "notes",
                          "upNext",
                          "userId",
                          "unread"
                        ],
                        "additionalProperties": true
                      }
                    }
                  },
                  "required": [
                    "majors"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "majors"
        ],
        "summary": "Starts a major on a device, over projects in folders it allows",
        "operationId": "postMajors",
        "parameters": [],
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "major": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "portrait": {
                          "type": "object",
                          "properties": {
                            "ant": {
                              "type": "string",
                              "enum": [
                                "builder",
                                "inspector",
                                "scout",
                                "engineer",
                                "medic",
                                "night-shift",
                                "navigator",
                                "dispatcher",
                                "thinker",
                                "rookie",
                                "veteran",
                                "royal-guard"
                              ]
                            },
                            "background": {
                              "type": "string",
                              "enum": [
                                "sand",
                                "sage",
                                "sky",
                                "lilac",
                                "blush",
                                "mint",
                                "butter",
                                "stone"
                              ]
                            }
                          },
                          "required": [
                            "ant",
                            "background"
                          ],
                          "additionalProperties": false
                        },
                        "projectPaths": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "device": {
                          "type": "string"
                        },
                        "model": {
                          "type": "object",
                          "properties": {
                            "provider": {
                              "type": "string"
                            },
                            "id": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "provider",
                            "id"
                          ],
                          "additionalProperties": false
                        },
                        "maxCrew": {
                          "type": "number"
                        },
                        "createdAt": {
                          "type": "number"
                        },
                        "archived": {
                          "type": "boolean"
                        },
                        "pinned": {
                          "type": "boolean"
                        },
                        "state": {
                          "type": "string",
                          "enum": [
                            "setting-up",
                            "working",
                            "idle",
                            "failed",
                            "stopped"
                          ]
                        },
                        "statusLine": {
                          "type": "string"
                        },
                        "lastActivityAt": {
                          "type": "number"
                        },
                        "cost": {
                          "type": "number"
                        },
                        "needsYou": {
                          "type": "boolean"
                        },
                        "question": {
                          "type": "string"
                        },
                        "rules": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "kind": {
                                "type": "string",
                                "enum": [
                                  "allow",
                                  "ask",
                                  "instruction"
                                ]
                              },
                              "text": {
                                "type": "string"
                              },
                              "label": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "id",
                              "kind",
                              "text",
                              "label"
                            ],
                            "additionalProperties": true
                          }
                        },
                        "notes": {
                          "type": "string"
                        },
                        "upNext": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "projectPath": {
                                "type": "string"
                              },
                              "title": {
                                "type": "string"
                              },
                              "instructions": {
                                "type": "string"
                              },
                              "addedAt": {
                                "type": "number"
                              },
                              "addedBy": {
                                "type": "string",
                                "enum": [
                                  "major",
                                  "you"
                                ]
                              }
                            },
                            "required": [
                              "id",
                              "projectPath",
                              "title",
                              "instructions",
                              "addedAt",
                              "addedBy"
                            ],
                            "additionalProperties": true
                          }
                        },
                        "userId": {
                          "type": "string"
                        },
                        "unread": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "portrait",
                        "projectPaths",
                        "device",
                        "model",
                        "maxCrew",
                        "createdAt",
                        "archived",
                        "pinned",
                        "state",
                        "statusLine",
                        "lastActivityAt",
                        "cost",
                        "needsYou",
                        "rules",
                        "notes",
                        "upNext",
                        "userId",
                        "unread"
                      ],
                      "additionalProperties": true
                    }
                  },
                  "required": [
                    "major"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1
                  },
                  "portrait": {
                    "default": null,
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "ant": {
                            "type": "string",
                            "enum": [
                              "builder",
                              "inspector",
                              "scout",
                              "engineer",
                              "medic",
                              "night-shift",
                              "navigator",
                              "dispatcher",
                              "thinker",
                              "rookie",
                              "veteran",
                              "royal-guard"
                            ]
                          },
                          "background": {
                            "type": "string",
                            "enum": [
                              "sand",
                              "sage",
                              "sky",
                              "lilac",
                              "blush",
                              "mint",
                              "butter",
                              "stone"
                            ]
                          }
                        },
                        "required": [
                          "ant",
                          "background"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "deviceId": {
                    "type": "string"
                  },
                  "projectPaths": {
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "model": {
                    "type": "object",
                    "properties": {
                      "provider": {
                        "type": "string"
                      },
                      "id": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "provider",
                      "id"
                    ]
                  },
                  "firstMessage": {
                    "type": "string",
                    "minLength": 1
                  },
                  "maxCrew": {
                    "type": "integer",
                    "exclusiveMinimum": 0,
                    "maximum": 9007199254740991
                  }
                },
                "required": [
                  "name",
                  "projectPaths",
                  "model",
                  "firstMessage"
                ]
              }
            }
          }
        }
      }
    },
    "/v1/majors/{majorId}": {
      "get": {
        "tags": [
          "majors"
        ],
        "summary": "One major",
        "operationId": "getMajorsByMajorId",
        "parameters": [
          {
            "name": "majorId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "major": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "portrait": {
                          "type": "object",
                          "properties": {
                            "ant": {
                              "type": "string",
                              "enum": [
                                "builder",
                                "inspector",
                                "scout",
                                "engineer",
                                "medic",
                                "night-shift",
                                "navigator",
                                "dispatcher",
                                "thinker",
                                "rookie",
                                "veteran",
                                "royal-guard"
                              ]
                            },
                            "background": {
                              "type": "string",
                              "enum": [
                                "sand",
                                "sage",
                                "sky",
                                "lilac",
                                "blush",
                                "mint",
                                "butter",
                                "stone"
                              ]
                            }
                          },
                          "required": [
                            "ant",
                            "background"
                          ],
                          "additionalProperties": false
                        },
                        "projectPaths": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "device": {
                          "type": "string"
                        },
                        "model": {
                          "type": "object",
                          "properties": {
                            "provider": {
                              "type": "string"
                            },
                            "id": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "provider",
                            "id"
                          ],
                          "additionalProperties": false
                        },
                        "maxCrew": {
                          "type": "number"
                        },
                        "createdAt": {
                          "type": "number"
                        },
                        "archived": {
                          "type": "boolean"
                        },
                        "pinned": {
                          "type": "boolean"
                        },
                        "state": {
                          "type": "string",
                          "enum": [
                            "setting-up",
                            "working",
                            "idle",
                            "failed",
                            "stopped"
                          ]
                        },
                        "statusLine": {
                          "type": "string"
                        },
                        "lastActivityAt": {
                          "type": "number"
                        },
                        "cost": {
                          "type": "number"
                        },
                        "needsYou": {
                          "type": "boolean"
                        },
                        "question": {
                          "type": "string"
                        },
                        "rules": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "kind": {
                                "type": "string",
                                "enum": [
                                  "allow",
                                  "ask",
                                  "instruction"
                                ]
                              },
                              "text": {
                                "type": "string"
                              },
                              "label": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "id",
                              "kind",
                              "text",
                              "label"
                            ],
                            "additionalProperties": true
                          }
                        },
                        "notes": {
                          "type": "string"
                        },
                        "upNext": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "projectPath": {
                                "type": "string"
                              },
                              "title": {
                                "type": "string"
                              },
                              "instructions": {
                                "type": "string"
                              },
                              "addedAt": {
                                "type": "number"
                              },
                              "addedBy": {
                                "type": "string",
                                "enum": [
                                  "major",
                                  "you"
                                ]
                              }
                            },
                            "required": [
                              "id",
                              "projectPath",
                              "title",
                              "instructions",
                              "addedAt",
                              "addedBy"
                            ],
                            "additionalProperties": true
                          }
                        },
                        "userId": {
                          "type": "string"
                        },
                        "unread": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "portrait",
                        "projectPaths",
                        "device",
                        "model",
                        "maxCrew",
                        "createdAt",
                        "archived",
                        "pinned",
                        "state",
                        "statusLine",
                        "lastActivityAt",
                        "cost",
                        "needsYou",
                        "rules",
                        "notes",
                        "upNext",
                        "userId",
                        "unread"
                      ],
                      "additionalProperties": true
                    }
                  },
                  "required": [
                    "major"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "majors"
        ],
        "summary": "Renames, archives, pins, or changes its model, crew size or projects",
        "operationId": "patchMajorsByMajorId",
        "parameters": [
          {
            "name": "majorId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "major": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "portrait": {
                          "type": "object",
                          "properties": {
                            "ant": {
                              "type": "string",
                              "enum": [
                                "builder",
                                "inspector",
                                "scout",
                                "engineer",
                                "medic",
                                "night-shift",
                                "navigator",
                                "dispatcher",
                                "thinker",
                                "rookie",
                                "veteran",
                                "royal-guard"
                              ]
                            },
                            "background": {
                              "type": "string",
                              "enum": [
                                "sand",
                                "sage",
                                "sky",
                                "lilac",
                                "blush",
                                "mint",
                                "butter",
                                "stone"
                              ]
                            }
                          },
                          "required": [
                            "ant",
                            "background"
                          ],
                          "additionalProperties": false
                        },
                        "projectPaths": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "device": {
                          "type": "string"
                        },
                        "model": {
                          "type": "object",
                          "properties": {
                            "provider": {
                              "type": "string"
                            },
                            "id": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "provider",
                            "id"
                          ],
                          "additionalProperties": false
                        },
                        "maxCrew": {
                          "type": "number"
                        },
                        "createdAt": {
                          "type": "number"
                        },
                        "archived": {
                          "type": "boolean"
                        },
                        "pinned": {
                          "type": "boolean"
                        },
                        "state": {
                          "type": "string",
                          "enum": [
                            "setting-up",
                            "working",
                            "idle",
                            "failed",
                            "stopped"
                          ]
                        },
                        "statusLine": {
                          "type": "string"
                        },
                        "lastActivityAt": {
                          "type": "number"
                        },
                        "cost": {
                          "type": "number"
                        },
                        "needsYou": {
                          "type": "boolean"
                        },
                        "question": {
                          "type": "string"
                        },
                        "rules": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "kind": {
                                "type": "string",
                                "enum": [
                                  "allow",
                                  "ask",
                                  "instruction"
                                ]
                              },
                              "text": {
                                "type": "string"
                              },
                              "label": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "id",
                              "kind",
                              "text",
                              "label"
                            ],
                            "additionalProperties": true
                          }
                        },
                        "notes": {
                          "type": "string"
                        },
                        "upNext": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "projectPath": {
                                "type": "string"
                              },
                              "title": {
                                "type": "string"
                              },
                              "instructions": {
                                "type": "string"
                              },
                              "addedAt": {
                                "type": "number"
                              },
                              "addedBy": {
                                "type": "string",
                                "enum": [
                                  "major",
                                  "you"
                                ]
                              }
                            },
                            "required": [
                              "id",
                              "projectPath",
                              "title",
                              "instructions",
                              "addedAt",
                              "addedBy"
                            ],
                            "additionalProperties": true
                          }
                        },
                        "userId": {
                          "type": "string"
                        },
                        "unread": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "portrait",
                        "projectPaths",
                        "device",
                        "model",
                        "maxCrew",
                        "createdAt",
                        "archived",
                        "pinned",
                        "state",
                        "statusLine",
                        "lastActivityAt",
                        "cost",
                        "needsYou",
                        "rules",
                        "notes",
                        "upNext",
                        "userId",
                        "unread"
                      ],
                      "additionalProperties": true
                    }
                  },
                  "required": [
                    "major"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "portrait": {
                    "default": null,
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "ant": {
                            "type": "string",
                            "enum": [
                              "builder",
                              "inspector",
                              "scout",
                              "engineer",
                              "medic",
                              "night-shift",
                              "navigator",
                              "dispatcher",
                              "thinker",
                              "rookie",
                              "veteran",
                              "royal-guard"
                            ]
                          },
                          "background": {
                            "type": "string",
                            "enum": [
                              "sand",
                              "sage",
                              "sky",
                              "lilac",
                              "blush",
                              "mint",
                              "butter",
                              "stone"
                            ]
                          }
                        },
                        "required": [
                          "ant",
                          "background"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "archived": {
                    "type": "boolean"
                  },
                  "pinned": {
                    "type": "boolean"
                  },
                  "maxCrew": {
                    "type": "integer",
                    "exclusiveMinimum": 0,
                    "maximum": 9007199254740991
                  },
                  "model": {
                    "type": "object",
                    "properties": {
                      "provider": {
                        "type": "string"
                      },
                      "id": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "provider",
                      "id"
                    ]
                  },
                  "projectPaths": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/majors/{majorId}/messages": {
      "post": {
        "tags": [
          "majors"
        ],
        "summary": "A message to the major’s chat",
        "operationId": "postMajorsByMajorIdMessages",
        "parameters": [
          {
            "name": "majorId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "submissionId": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "submissionId"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "text": {
                    "default": "",
                    "type": "string"
                  },
                  "mode": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "steer",
                          "queue",
                          "interrupt"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "requestId": {
                    "type": "string"
                  },
                  "allowSecret": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "text"
                ]
              }
            }
          }
        }
      }
    },
    "/v1/majors/{majorId}/crew": {
      "get": {
        "tags": [
          "majors"
        ],
        "summary": "Its crew’s threads",
        "operationId": "getMajorsByMajorIdCrew",
        "parameters": [
          {
            "name": "majorId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "threads": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "projectPath": {
                            "type": "string"
                          },
                          "worktreePath": {
                            "type": "string"
                          },
                          "branch": {
                            "type": "string"
                          },
                          "baseBranch": {
                            "type": "string"
                          },
                          "device": {
                            "type": "string"
                          },
                          "model": {
                            "type": "object",
                            "properties": {
                              "provider": {
                                "type": "string"
                              },
                              "id": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "provider",
                              "id"
                            ],
                            "additionalProperties": false
                          },
                          "createdAt": {
                            "type": "number"
                          },
                          "state": {
                            "type": "string",
                            "enum": [
                              "setting-up",
                              "working",
                              "idle",
                              "failed",
                              "stopped"
                            ]
                          },
                          "cost": {
                            "type": "number"
                          },
                          "setup": {
                            "type": "object",
                            "properties": {
                              "status": {
                                "type": "string",
                                "enum": [
                                  "running",
                                  "done",
                                  "failed"
                                ]
                              },
                              "problems": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              }
                            },
                            "required": [
                              "status",
                              "problems"
                            ],
                            "additionalProperties": true
                          },
                          "deviceName": {
                            "type": "string"
                          },
                          "deviceOnline": {
                            "type": "boolean"
                          },
                          "machineId": {
                            "type": "string"
                          },
                          "machineState": {
                            "type": "string",
                            "enum": [
                              "creating",
                              "starting",
                              "running",
                              "stopping",
                              "stopped",
                              "cleared",
                              "failed",
                              "destroyed"
                            ]
                          },
                          "projectId": {
                            "type": "string"
                          },
                          "needsYou": {
                            "type": "boolean"
                          },
                          "question": {
                            "type": "string"
                          },
                          "statusLine": {
                            "type": "string"
                          },
                          "waitingForDevice": {
                            "type": "object",
                            "properties": {
                              "deviceId": {
                                "type": "string"
                              },
                              "since": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "deviceId",
                              "since"
                            ],
                            "additionalProperties": false
                          },
                          "waitingForCloud": {
                            "type": "object",
                            "properties": {
                              "message": {
                                "type": "string"
                              },
                              "until": {
                                "type": "number"
                              },
                              "firstMessage": {
                                "type": "string"
                              },
                              "failed": {
                                "type": "string"
                              },
                              "starting": {
                                "type": "boolean"
                              }
                            },
                            "required": [
                              "message",
                              "firstMessage"
                            ],
                            "additionalProperties": false
                          },
                          "request": {
                            "type": "object",
                            "properties": {
                              "callId": {
                                "type": "string"
                              },
                              "title": {
                                "type": "string"
                              },
                              "command": {
                                "type": "boolean"
                              },
                              "ask": {
                                "type": "object",
                                "properties": {
                                  "options": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  }
                                },
                                "required": [
                                  "options"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": [
                              "callId",
                              "title",
                              "command"
                            ],
                            "additionalProperties": true
                          },
                          "majorId": {
                            "type": "string"
                          },
                          "userId": {
                            "type": "string"
                          },
                          "unread": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "id",
                          "title",
                          "projectPath",
                          "worktreePath",
                          "branch",
                          "baseBranch",
                          "device",
                          "model",
                          "createdAt",
                          "state",
                          "cost",
                          "setup",
                          "deviceName",
                          "deviceOnline",
                          "userId",
                          "unread"
                        ],
                        "additionalProperties": true
                      }
                    }
                  },
                  "required": [
                    "threads"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/v1/majors/{majorId}/rules": {
      "post": {
        "tags": [
          "majors"
        ],
        "summary": "Adds a rule in your words",
        "operationId": "postMajorsByMajorIdRules",
        "parameters": [
          {
            "name": "majorId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "major": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "portrait": {
                          "type": "object",
                          "properties": {
                            "ant": {
                              "type": "string",
                              "enum": [
                                "builder",
                                "inspector",
                                "scout",
                                "engineer",
                                "medic",
                                "night-shift",
                                "navigator",
                                "dispatcher",
                                "thinker",
                                "rookie",
                                "veteran",
                                "royal-guard"
                              ]
                            },
                            "background": {
                              "type": "string",
                              "enum": [
                                "sand",
                                "sage",
                                "sky",
                                "lilac",
                                "blush",
                                "mint",
                                "butter",
                                "stone"
                              ]
                            }
                          },
                          "required": [
                            "ant",
                            "background"
                          ],
                          "additionalProperties": false
                        },
                        "projectPaths": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "device": {
                          "type": "string"
                        },
                        "model": {
                          "type": "object",
                          "properties": {
                            "provider": {
                              "type": "string"
                            },
                            "id": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "provider",
                            "id"
                          ],
                          "additionalProperties": false
                        },
                        "maxCrew": {
                          "type": "number"
                        },
                        "createdAt": {
                          "type": "number"
                        },
                        "archived": {
                          "type": "boolean"
                        },
                        "pinned": {
                          "type": "boolean"
                        },
                        "state": {
                          "type": "string",
                          "enum": [
                            "setting-up",
                            "working",
                            "idle",
                            "failed",
                            "stopped"
                          ]
                        },
                        "statusLine": {
                          "type": "string"
                        },
                        "lastActivityAt": {
                          "type": "number"
                        },
                        "cost": {
                          "type": "number"
                        },
                        "needsYou": {
                          "type": "boolean"
                        },
                        "question": {
                          "type": "string"
                        },
                        "rules": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "kind": {
                                "type": "string",
                                "enum": [
                                  "allow",
                                  "ask",
                                  "instruction"
                                ]
                              },
                              "text": {
                                "type": "string"
                              },
                              "label": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "id",
                              "kind",
                              "text",
                              "label"
                            ],
                            "additionalProperties": true
                          }
                        },
                        "notes": {
                          "type": "string"
                        },
                        "upNext": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "projectPath": {
                                "type": "string"
                              },
                              "title": {
                                "type": "string"
                              },
                              "instructions": {
                                "type": "string"
                              },
                              "addedAt": {
                                "type": "number"
                              },
                              "addedBy": {
                                "type": "string",
                                "enum": [
                                  "major",
                                  "you"
                                ]
                              }
                            },
                            "required": [
                              "id",
                              "projectPath",
                              "title",
                              "instructions",
                              "addedAt",
                              "addedBy"
                            ],
                            "additionalProperties": true
                          }
                        },
                        "userId": {
                          "type": "string"
                        },
                        "unread": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "portrait",
                        "projectPaths",
                        "device",
                        "model",
                        "maxCrew",
                        "createdAt",
                        "archived",
                        "pinned",
                        "state",
                        "statusLine",
                        "lastActivityAt",
                        "cost",
                        "needsYou",
                        "rules",
                        "notes",
                        "upNext",
                        "userId",
                        "unread"
                      ],
                      "additionalProperties": true
                    }
                  },
                  "required": [
                    "major"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "text": {
                    "type": "string",
                    "minLength": 1
                  },
                  "kind": {
                    "type": "string",
                    "enum": [
                      "allow",
                      "ask",
                      "instruction"
                    ]
                  }
                },
                "required": [
                  "text"
                ]
              }
            }
          }
        }
      }
    },
    "/v1/majors/{majorId}/rules/{ruleId}": {
      "delete": {
        "tags": [
          "majors"
        ],
        "summary": "Removes a rule",
        "operationId": "deleteMajorsByMajorIdRulesByRuleId",
        "parameters": [
          {
            "name": "majorId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "ruleId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "major": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "portrait": {
                          "type": "object",
                          "properties": {
                            "ant": {
                              "type": "string",
                              "enum": [
                                "builder",
                                "inspector",
                                "scout",
                                "engineer",
                                "medic",
                                "night-shift",
                                "navigator",
                                "dispatcher",
                                "thinker",
                                "rookie",
                                "veteran",
                                "royal-guard"
                              ]
                            },
                            "background": {
                              "type": "string",
                              "enum": [
                                "sand",
                                "sage",
                                "sky",
                                "lilac",
                                "blush",
                                "mint",
                                "butter",
                                "stone"
                              ]
                            }
                          },
                          "required": [
                            "ant",
                            "background"
                          ],
                          "additionalProperties": false
                        },
                        "projectPaths": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "device": {
                          "type": "string"
                        },
                        "model": {
                          "type": "object",
                          "properties": {
                            "provider": {
                              "type": "string"
                            },
                            "id": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "provider",
                            "id"
                          ],
                          "additionalProperties": false
                        },
                        "maxCrew": {
                          "type": "number"
                        },
                        "createdAt": {
                          "type": "number"
                        },
                        "archived": {
                          "type": "boolean"
                        },
                        "pinned": {
                          "type": "boolean"
                        },
                        "state": {
                          "type": "string",
                          "enum": [
                            "setting-up",
                            "working",
                            "idle",
                            "failed",
                            "stopped"
                          ]
                        },
                        "statusLine": {
                          "type": "string"
                        },
                        "lastActivityAt": {
                          "type": "number"
                        },
                        "cost": {
                          "type": "number"
                        },
                        "needsYou": {
                          "type": "boolean"
                        },
                        "question": {
                          "type": "string"
                        },
                        "rules": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "kind": {
                                "type": "string",
                                "enum": [
                                  "allow",
                                  "ask",
                                  "instruction"
                                ]
                              },
                              "text": {
                                "type": "string"
                              },
                              "label": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "id",
                              "kind",
                              "text",
                              "label"
                            ],
                            "additionalProperties": true
                          }
                        },
                        "notes": {
                          "type": "string"
                        },
                        "upNext": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "projectPath": {
                                "type": "string"
                              },
                              "title": {
                                "type": "string"
                              },
                              "instructions": {
                                "type": "string"
                              },
                              "addedAt": {
                                "type": "number"
                              },
                              "addedBy": {
                                "type": "string",
                                "enum": [
                                  "major",
                                  "you"
                                ]
                              }
                            },
                            "required": [
                              "id",
                              "projectPath",
                              "title",
                              "instructions",
                              "addedAt",
                              "addedBy"
                            ],
                            "additionalProperties": true
                          }
                        },
                        "userId": {
                          "type": "string"
                        },
                        "unread": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "portrait",
                        "projectPaths",
                        "device",
                        "model",
                        "maxCrew",
                        "createdAt",
                        "archived",
                        "pinned",
                        "state",
                        "statusLine",
                        "lastActivityAt",
                        "cost",
                        "needsYou",
                        "rules",
                        "notes",
                        "upNext",
                        "userId",
                        "unread"
                      ],
                      "additionalProperties": true
                    }
                  },
                  "required": [
                    "major"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/v1/majors/{majorId}/notes": {
      "put": {
        "tags": [
          "majors"
        ],
        "summary": "Replaces its notes",
        "operationId": "putMajorsByMajorIdNotes",
        "parameters": [
          {
            "name": "majorId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "major": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "portrait": {
                          "type": "object",
                          "properties": {
                            "ant": {
                              "type": "string",
                              "enum": [
                                "builder",
                                "inspector",
                                "scout",
                                "engineer",
                                "medic",
                                "night-shift",
                                "navigator",
                                "dispatcher",
                                "thinker",
                                "rookie",
                                "veteran",
                                "royal-guard"
                              ]
                            },
                            "background": {
                              "type": "string",
                              "enum": [
                                "sand",
                                "sage",
                                "sky",
                                "lilac",
                                "blush",
                                "mint",
                                "butter",
                                "stone"
                              ]
                            }
                          },
                          "required": [
                            "ant",
                            "background"
                          ],
                          "additionalProperties": false
                        },
                        "projectPaths": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "device": {
                          "type": "string"
                        },
                        "model": {
                          "type": "object",
                          "properties": {
                            "provider": {
                              "type": "string"
                            },
                            "id": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "provider",
                            "id"
                          ],
                          "additionalProperties": false
                        },
                        "maxCrew": {
                          "type": "number"
                        },
                        "createdAt": {
                          "type": "number"
                        },
                        "archived": {
                          "type": "boolean"
                        },
                        "pinned": {
                          "type": "boolean"
                        },
                        "state": {
                          "type": "string",
                          "enum": [
                            "setting-up",
                            "working",
                            "idle",
                            "failed",
                            "stopped"
                          ]
                        },
                        "statusLine": {
                          "type": "string"
                        },
                        "lastActivityAt": {
                          "type": "number"
                        },
                        "cost": {
                          "type": "number"
                        },
                        "needsYou": {
                          "type": "boolean"
                        },
                        "question": {
                          "type": "string"
                        },
                        "rules": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "kind": {
                                "type": "string",
                                "enum": [
                                  "allow",
                                  "ask",
                                  "instruction"
                                ]
                              },
                              "text": {
                                "type": "string"
                              },
                              "label": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "id",
                              "kind",
                              "text",
                              "label"
                            ],
                            "additionalProperties": true
                          }
                        },
                        "notes": {
                          "type": "string"
                        },
                        "upNext": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "projectPath": {
                                "type": "string"
                              },
                              "title": {
                                "type": "string"
                              },
                              "instructions": {
                                "type": "string"
                              },
                              "addedAt": {
                                "type": "number"
                              },
                              "addedBy": {
                                "type": "string",
                                "enum": [
                                  "major",
                                  "you"
                                ]
                              }
                            },
                            "required": [
                              "id",
                              "projectPath",
                              "title",
                              "instructions",
                              "addedAt",
                              "addedBy"
                            ],
                            "additionalProperties": true
                          }
                        },
                        "userId": {
                          "type": "string"
                        },
                        "unread": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "portrait",
                        "projectPaths",
                        "device",
                        "model",
                        "maxCrew",
                        "createdAt",
                        "archived",
                        "pinned",
                        "state",
                        "statusLine",
                        "lastActivityAt",
                        "cost",
                        "needsYou",
                        "rules",
                        "notes",
                        "upNext",
                        "userId",
                        "unread"
                      ],
                      "additionalProperties": true
                    }
                  },
                  "required": [
                    "major"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "notes": {
                    "type": "string"
                  }
                },
                "required": [
                  "notes"
                ]
              }
            }
          }
        }
      }
    },
    "/v1/machines": {
      "get": {
        "tags": [
          "cloud"
        ],
        "summary": "Your machines",
        "operationId": "getMachines",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "machines": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "provider": {
                            "type": "string"
                          },
                          "providerId": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "key": {
                            "type": "string"
                          },
                          "purpose": {
                            "type": "string",
                            "enum": [
                              "thread",
                              "prewarm",
                              "snapshot"
                            ]
                          },
                          "projectId": {
                            "type": "string"
                          },
                          "userId": {
                            "type": "string"
                          },
                          "snapshot": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "image": {
                            "type": "string"
                          },
                          "deviceId": {
                            "type": "string"
                          },
                          "state": {
                            "type": "string",
                            "enum": [
                              "creating",
                              "starting",
                              "running",
                              "stopping",
                              "stopped",
                              "cleared",
                              "failed",
                              "destroyed"
                            ]
                          },
                          "size": {
                            "type": "string",
                            "enum": [
                              "small",
                              "default",
                              "large",
                              "xlarge"
                            ]
                          },
                          "region": {
                            "type": "string"
                          },
                          "threadIds": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "leaseUntil": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "lastAgentActivityAt": {
                            "type": "number"
                          },
                          "lastHumanActivityAt": {
                            "type": "number"
                          },
                          "createdAt": {
                            "type": "number"
                          },
                          "updatedAt": {
                            "type": "number"
                          },
                          "stoppedAt": {
                            "type": "number"
                          },
                          "clearedAt": {
                            "type": "number"
                          },
                          "prewarmedUntil": {
                            "type": "number"
                          },
                          "automatic": {
                            "type": "boolean"
                          },
                          "error": {
                            "type": "string"
                          },
                          "status": {
                            "type": "object",
                            "properties": {
                              "phase": {
                                "type": "string",
                                "enum": [
                                  "starting",
                                  "restoring",
                                  "running",
                                  "reconnecting",
                                  "stopping",
                                  "stopped",
                                  "cleared",
                                  "failed"
                                ]
                              },
                              "label": {
                                "type": "string"
                              },
                              "percent": {
                                "type": "number"
                              },
                              "reason": {
                                "type": "string"
                              },
                              "at": {
                                "type": "number"
                              },
                              "source": {
                                "type": "string",
                                "enum": [
                                  "engine",
                                  "webhook"
                                ]
                              }
                            },
                            "required": [
                              "phase",
                              "label",
                              "at",
                              "source"
                            ],
                            "additionalProperties": false
                          },
                          "previews": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "port": {
                                  "type": "number"
                                },
                                "name": {
                                  "default": "",
                                  "type": "string"
                                },
                                "url": {
                                  "type": "string"
                                },
                                "access": {
                                  "type": "string",
                                  "enum": [
                                    "private",
                                    "public"
                                  ]
                                },
                                "state": {
                                  "type": "string",
                                  "enum": [
                                    "live",
                                    "closed"
                                  ]
                                },
                                "firstSeenAt": {
                                  "type": "number"
                                },
                                "lastSeenAt": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "port",
                                "name",
                                "url",
                                "access",
                                "state",
                                "firstSeenAt",
                                "lastSeenAt"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "tunnels": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string"
                                },
                                "threadId": {
                                  "type": "string"
                                },
                                "fromDeviceId": {
                                  "type": "string"
                                },
                                "localPort": {
                                  "type": "number"
                                },
                                "remotePort": {
                                  "type": "number"
                                },
                                "state": {
                                  "type": "string",
                                  "enum": [
                                    "requested",
                                    "approved",
                                    "closed"
                                  ]
                                },
                                "requestedAt": {
                                  "type": "number"
                                },
                                "approvedAt": {
                                  "type": "number"
                                },
                                "error": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "id",
                                "threadId",
                                "fromDeviceId",
                                "localPort",
                                "remotePort",
                                "state",
                                "requestedAt"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "mirror": {
                            "type": "object",
                            "properties": {
                              "at": {
                                "type": "number"
                              },
                              "terminals": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "title": {
                                      "type": "string"
                                    },
                                    "status": {
                                      "type": "string"
                                    },
                                    "tail": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "title",
                                    "status",
                                    "tail"
                                  ],
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "at",
                              "terminals"
                            ],
                            "additionalProperties": false
                          },
                          "forkedFrom": {
                            "type": "object",
                            "properties": {
                              "threadId": {
                                "type": "string"
                              },
                              "machineId": {
                                "type": "string"
                              },
                              "turn": {
                                "type": "number"
                              },
                              "entryId": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "threadId",
                              "machineId",
                              "turn",
                              "entryId"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "id",
                          "provider",
                          "providerId",
                          "key",
                          "purpose",
                          "snapshot",
                          "image",
                          "deviceId",
                          "state",
                          "size",
                          "threadIds",
                          "leaseUntil",
                          "lastAgentActivityAt",
                          "lastHumanActivityAt",
                          "createdAt",
                          "updatedAt"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "machines"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/v1/machines/settings": {
      "get": {
        "tags": [
          "cloud"
        ],
        "summary": "Idle rule, lease and prewarm settings",
        "operationId": "getMachinesSettings",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "settings": {
                      "type": "object",
                      "properties": {
                        "agentIdleMs": {
                          "type": "number"
                        },
                        "humanIdleMs": {
                          "type": "number"
                        },
                        "leaseSeconds": {
                          "type": "number"
                        },
                        "renewBelowMs": {
                          "type": "number"
                        },
                        "tickMs": {
                          "type": "number"
                        },
                        "size": {
                          "type": "string",
                          "enum": [
                            "small",
                            "default",
                            "large",
                            "xlarge"
                          ]
                        },
                        "region": {
                          "type": "string"
                        },
                        "prewarmTtlMs": {
                          "type": "number"
                        },
                        "maxPrewarmed": {
                          "type": "number"
                        },
                        "bootTimeoutMs": {
                          "type": "number"
                        },
                        "autoSnapshot": {
                          "type": "boolean"
                        },
                        "clearAfterDays": {
                          "type": "number"
                        },
                        "stopGraceMs": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "agentIdleMs",
                        "humanIdleMs",
                        "leaseSeconds",
                        "renewBelowMs",
                        "tickMs",
                        "size",
                        "prewarmTtlMs",
                        "maxPrewarmed",
                        "bootTimeoutMs",
                        "autoSnapshot",
                        "clearAfterDays",
                        "stopGraceMs"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "settings"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "cloud"
        ],
        "summary": "Changes the settings (the engine’s operator only: they apply to everyone’s machines)",
        "operationId": "patchMachinesSettings",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "settings": {
                      "type": "object",
                      "properties": {
                        "agentIdleMs": {
                          "type": "number"
                        },
                        "humanIdleMs": {
                          "type": "number"
                        },
                        "leaseSeconds": {
                          "type": "number"
                        },
                        "renewBelowMs": {
                          "type": "number"
                        },
                        "tickMs": {
                          "type": "number"
                        },
                        "size": {
                          "type": "string",
                          "enum": [
                            "small",
                            "default",
                            "large",
                            "xlarge"
                          ]
                        },
                        "region": {
                          "type": "string"
                        },
                        "prewarmTtlMs": {
                          "type": "number"
                        },
                        "maxPrewarmed": {
                          "type": "number"
                        },
                        "bootTimeoutMs": {
                          "type": "number"
                        },
                        "autoSnapshot": {
                          "type": "boolean"
                        },
                        "clearAfterDays": {
                          "type": "number"
                        },
                        "stopGraceMs": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "agentIdleMs",
                        "humanIdleMs",
                        "leaseSeconds",
                        "renewBelowMs",
                        "tickMs",
                        "size",
                        "prewarmTtlMs",
                        "maxPrewarmed",
                        "bootTimeoutMs",
                        "autoSnapshot",
                        "clearAfterDays",
                        "stopGraceMs"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "settings"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "agentIdleMs": {
                    "type": "number",
                    "exclusiveMinimum": 0
                  },
                  "humanIdleMs": {
                    "type": "number",
                    "exclusiveMinimum": 0
                  },
                  "leaseSeconds": {
                    "type": "number",
                    "exclusiveMinimum": 0
                  },
                  "renewBelowMs": {
                    "type": "number",
                    "exclusiveMinimum": 0
                  },
                  "tickMs": {
                    "type": "number",
                    "exclusiveMinimum": 0
                  },
                  "size": {
                    "type": "string",
                    "enum": [
                      "small",
                      "default",
                      "large",
                      "xlarge"
                    ]
                  },
                  "prewarmTtlMs": {
                    "type": "number",
                    "exclusiveMinimum": 0
                  },
                  "maxPrewarmed": {
                    "type": "number",
                    "minimum": 0
                  },
                  "bootTimeoutMs": {
                    "type": "number",
                    "exclusiveMinimum": 0
                  },
                  "autoSnapshot": {
                    "type": "boolean"
                  },
                  "clearAfterDays": {
                    "type": "number",
                    "minimum": 0
                  },
                  "stopGraceMs": {
                    "type": "number",
                    "minimum": 0
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/machines/prewarm": {
      "post": {
        "tags": [
          "cloud"
        ],
        "summary": "Starts a machine for the project’s next thread (null when the budget is used)",
        "operationId": "postMachinesPrewarm",
        "parameters": [],
        "responses": {
          "202": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "machine": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "provider": {
                              "type": "string"
                            },
                            "providerId": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "key": {
                              "type": "string"
                            },
                            "purpose": {
                              "type": "string",
                              "enum": [
                                "thread",
                                "prewarm",
                                "snapshot"
                              ]
                            },
                            "projectId": {
                              "type": "string"
                            },
                            "userId": {
                              "type": "string"
                            },
                            "snapshot": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "image": {
                              "type": "string"
                            },
                            "deviceId": {
                              "type": "string"
                            },
                            "state": {
                              "type": "string",
                              "enum": [
                                "creating",
                                "starting",
                                "running",
                                "stopping",
                                "stopped",
                                "cleared",
                                "failed",
                                "destroyed"
                              ]
                            },
                            "size": {
                              "type": "string",
                              "enum": [
                                "small",
                                "default",
                                "large",
                                "xlarge"
                              ]
                            },
                            "region": {
                              "type": "string"
                            },
                            "threadIds": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "leaseUntil": {
                              "type": [
                                "number",
                                "null"
                              ]
                            },
                            "lastAgentActivityAt": {
                              "type": "number"
                            },
                            "lastHumanActivityAt": {
                              "type": "number"
                            },
                            "createdAt": {
                              "type": "number"
                            },
                            "updatedAt": {
                              "type": "number"
                            },
                            "stoppedAt": {
                              "type": "number"
                            },
                            "clearedAt": {
                              "type": "number"
                            },
                            "prewarmedUntil": {
                              "type": "number"
                            },
                            "automatic": {
                              "type": "boolean"
                            },
                            "error": {
                              "type": "string"
                            },
                            "status": {
                              "type": "object",
                              "properties": {
                                "phase": {
                                  "type": "string",
                                  "enum": [
                                    "starting",
                                    "restoring",
                                    "running",
                                    "reconnecting",
                                    "stopping",
                                    "stopped",
                                    "cleared",
                                    "failed"
                                  ]
                                },
                                "label": {
                                  "type": "string"
                                },
                                "percent": {
                                  "type": "number"
                                },
                                "reason": {
                                  "type": "string"
                                },
                                "at": {
                                  "type": "number"
                                },
                                "source": {
                                  "type": "string",
                                  "enum": [
                                    "engine",
                                    "webhook"
                                  ]
                                }
                              },
                              "required": [
                                "phase",
                                "label",
                                "at",
                                "source"
                              ],
                              "additionalProperties": false
                            },
                            "previews": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "port": {
                                    "type": "number"
                                  },
                                  "name": {
                                    "default": "",
                                    "type": "string"
                                  },
                                  "url": {
                                    "type": "string"
                                  },
                                  "access": {
                                    "type": "string",
                                    "enum": [
                                      "private",
                                      "public"
                                    ]
                                  },
                                  "state": {
                                    "type": "string",
                                    "enum": [
                                      "live",
                                      "closed"
                                    ]
                                  },
                                  "firstSeenAt": {
                                    "type": "number"
                                  },
                                  "lastSeenAt": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "port",
                                  "name",
                                  "url",
                                  "access",
                                  "state",
                                  "firstSeenAt",
                                  "lastSeenAt"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "tunnels": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string"
                                  },
                                  "threadId": {
                                    "type": "string"
                                  },
                                  "fromDeviceId": {
                                    "type": "string"
                                  },
                                  "localPort": {
                                    "type": "number"
                                  },
                                  "remotePort": {
                                    "type": "number"
                                  },
                                  "state": {
                                    "type": "string",
                                    "enum": [
                                      "requested",
                                      "approved",
                                      "closed"
                                    ]
                                  },
                                  "requestedAt": {
                                    "type": "number"
                                  },
                                  "approvedAt": {
                                    "type": "number"
                                  },
                                  "error": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "id",
                                  "threadId",
                                  "fromDeviceId",
                                  "localPort",
                                  "remotePort",
                                  "state",
                                  "requestedAt"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "mirror": {
                              "type": "object",
                              "properties": {
                                "at": {
                                  "type": "number"
                                },
                                "terminals": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "title": {
                                        "type": "string"
                                      },
                                      "status": {
                                        "type": "string"
                                      },
                                      "tail": {
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "title",
                                      "status",
                                      "tail"
                                    ],
                                    "additionalProperties": false
                                  }
                                }
                              },
                              "required": [
                                "at",
                                "terminals"
                              ],
                              "additionalProperties": false
                            },
                            "forkedFrom": {
                              "type": "object",
                              "properties": {
                                "threadId": {
                                  "type": "string"
                                },
                                "machineId": {
                                  "type": "string"
                                },
                                "turn": {
                                  "type": "number"
                                },
                                "entryId": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "threadId",
                                "machineId",
                                "turn",
                                "entryId"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "id",
                            "provider",
                            "providerId",
                            "key",
                            "purpose",
                            "snapshot",
                            "image",
                            "deviceId",
                            "state",
                            "size",
                            "threadIds",
                            "leaseUntil",
                            "lastAgentActivityAt",
                            "lastHumanActivityAt",
                            "createdAt",
                            "updatedAt"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "machine"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "projectId": {
                    "default": "",
                    "type": "string"
                  },
                  "repoUrl": {
                    "type": "string"
                  },
                  "branch": {
                    "type": "string"
                  },
                  "testBranch": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 255
                  }
                },
                "required": [
                  "projectId"
                ]
              }
            }
          }
        }
      }
    },
    "/v1/machines/{machineId}/stop": {
      "post": {
        "tags": [
          "cloud"
        ],
        "summary": "Stops a machine; its threads wake it again",
        "operationId": "postMachinesByMachineIdStop",
        "parameters": [
          {
            "name": "machineId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "machine": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "provider": {
                          "type": "string"
                        },
                        "providerId": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "key": {
                          "type": "string"
                        },
                        "purpose": {
                          "type": "string",
                          "enum": [
                            "thread",
                            "prewarm",
                            "snapshot"
                          ]
                        },
                        "projectId": {
                          "type": "string"
                        },
                        "userId": {
                          "type": "string"
                        },
                        "snapshot": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "image": {
                          "type": "string"
                        },
                        "deviceId": {
                          "type": "string"
                        },
                        "state": {
                          "type": "string",
                          "enum": [
                            "creating",
                            "starting",
                            "running",
                            "stopping",
                            "stopped",
                            "cleared",
                            "failed",
                            "destroyed"
                          ]
                        },
                        "size": {
                          "type": "string",
                          "enum": [
                            "small",
                            "default",
                            "large",
                            "xlarge"
                          ]
                        },
                        "region": {
                          "type": "string"
                        },
                        "threadIds": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "leaseUntil": {
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "lastAgentActivityAt": {
                          "type": "number"
                        },
                        "lastHumanActivityAt": {
                          "type": "number"
                        },
                        "createdAt": {
                          "type": "number"
                        },
                        "updatedAt": {
                          "type": "number"
                        },
                        "stoppedAt": {
                          "type": "number"
                        },
                        "clearedAt": {
                          "type": "number"
                        },
                        "prewarmedUntil": {
                          "type": "number"
                        },
                        "automatic": {
                          "type": "boolean"
                        },
                        "error": {
                          "type": "string"
                        },
                        "status": {
                          "type": "object",
                          "properties": {
                            "phase": {
                              "type": "string",
                              "enum": [
                                "starting",
                                "restoring",
                                "running",
                                "reconnecting",
                                "stopping",
                                "stopped",
                                "cleared",
                                "failed"
                              ]
                            },
                            "label": {
                              "type": "string"
                            },
                            "percent": {
                              "type": "number"
                            },
                            "reason": {
                              "type": "string"
                            },
                            "at": {
                              "type": "number"
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "engine",
                                "webhook"
                              ]
                            }
                          },
                          "required": [
                            "phase",
                            "label",
                            "at",
                            "source"
                          ],
                          "additionalProperties": false
                        },
                        "previews": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "port": {
                                "type": "number"
                              },
                              "name": {
                                "default": "",
                                "type": "string"
                              },
                              "url": {
                                "type": "string"
                              },
                              "access": {
                                "type": "string",
                                "enum": [
                                  "private",
                                  "public"
                                ]
                              },
                              "state": {
                                "type": "string",
                                "enum": [
                                  "live",
                                  "closed"
                                ]
                              },
                              "firstSeenAt": {
                                "type": "number"
                              },
                              "lastSeenAt": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "port",
                              "name",
                              "url",
                              "access",
                              "state",
                              "firstSeenAt",
                              "lastSeenAt"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "tunnels": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "threadId": {
                                "type": "string"
                              },
                              "fromDeviceId": {
                                "type": "string"
                              },
                              "localPort": {
                                "type": "number"
                              },
                              "remotePort": {
                                "type": "number"
                              },
                              "state": {
                                "type": "string",
                                "enum": [
                                  "requested",
                                  "approved",
                                  "closed"
                                ]
                              },
                              "requestedAt": {
                                "type": "number"
                              },
                              "approvedAt": {
                                "type": "number"
                              },
                              "error": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "id",
                              "threadId",
                              "fromDeviceId",
                              "localPort",
                              "remotePort",
                              "state",
                              "requestedAt"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "mirror": {
                          "type": "object",
                          "properties": {
                            "at": {
                              "type": "number"
                            },
                            "terminals": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "title": {
                                    "type": "string"
                                  },
                                  "status": {
                                    "type": "string"
                                  },
                                  "tail": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "title",
                                  "status",
                                  "tail"
                                ],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "at",
                            "terminals"
                          ],
                          "additionalProperties": false
                        },
                        "forkedFrom": {
                          "type": "object",
                          "properties": {
                            "threadId": {
                              "type": "string"
                            },
                            "machineId": {
                              "type": "string"
                            },
                            "turn": {
                              "type": "number"
                            },
                            "entryId": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "threadId",
                            "machineId",
                            "turn",
                            "entryId"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "required": [
                        "id",
                        "provider",
                        "providerId",
                        "key",
                        "purpose",
                        "snapshot",
                        "image",
                        "deviceId",
                        "state",
                        "size",
                        "threadIds",
                        "leaseUntil",
                        "lastAgentActivityAt",
                        "lastHumanActivityAt",
                        "createdAt",
                        "updatedAt"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "machine"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/v1/snapshots": {
      "get": {
        "tags": [
          "cloud"
        ],
        "summary": "Your project snapshots",
        "operationId": "getSnapshots",
        "parameters": [
          {
            "name": "projectId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "snapshots": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "userId": {
                            "type": "string"
                          },
                          "projectId": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "state": {
                            "type": "string",
                            "enum": [
                              "building",
                              "ready",
                              "failed"
                            ]
                          },
                          "fingerprint": {
                            "type": "object",
                            "properties": {
                              "lockfiles": {
                                "type": "string"
                              },
                              "setup": {
                                "type": "string"
                              },
                              "image": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "lockfiles",
                              "setup",
                              "image"
                            ],
                            "additionalProperties": false
                          },
                          "createdAt": {
                            "type": "number"
                          },
                          "readyAt": {
                            "type": "number"
                          },
                          "error": {
                            "type": "string"
                          },
                          "machineId": {
                            "type": "string"
                          },
                          "test": {
                            "type": "boolean"
                          },
                          "branch": {
                            "type": "string"
                          },
                          "source": {
                            "type": "string",
                            "enum": [
                              "file",
                              "detected",
                              "none"
                            ]
                          },
                          "setupCommit": {
                            "type": "string"
                          },
                          "setupError": {
                            "type": "string"
                          },
                          "logs": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "phase": {
                                  "type": "string",
                                  "enum": [
                                    "initialize",
                                    "refresh"
                                  ]
                                },
                                "command": {
                                  "type": "string"
                                },
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "done",
                                    "failed",
                                    "timed-out"
                                  ]
                                },
                                "code": {
                                  "type": [
                                    "number",
                                    "null"
                                  ]
                                },
                                "ms": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "string"
                                },
                                "failingLine": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "phase",
                                "command",
                                "status",
                                "code",
                                "ms",
                                "output"
                              ],
                              "additionalProperties": true
                            }
                          }
                        },
                        "required": [
                          "userId",
                          "projectId",
                          "name",
                          "state",
                          "createdAt"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "snapshots"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "cloud"
        ],
        "summary": "Starts a snapshot build for a project",
        "operationId": "postSnapshots",
        "parameters": [],
        "responses": {
          "202": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "snapshot": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "userId": {
                              "type": "string"
                            },
                            "projectId": {
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            },
                            "state": {
                              "type": "string",
                              "enum": [
                                "building",
                                "ready",
                                "failed"
                              ]
                            },
                            "fingerprint": {
                              "type": "object",
                              "properties": {
                                "lockfiles": {
                                  "type": "string"
                                },
                                "setup": {
                                  "type": "string"
                                },
                                "image": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "lockfiles",
                                "setup",
                                "image"
                              ],
                              "additionalProperties": false
                            },
                            "createdAt": {
                              "type": "number"
                            },
                            "readyAt": {
                              "type": "number"
                            },
                            "error": {
                              "type": "string"
                            },
                            "machineId": {
                              "type": "string"
                            },
                            "test": {
                              "type": "boolean"
                            },
                            "branch": {
                              "type": "string"
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "file",
                                "detected",
                                "none"
                              ]
                            },
                            "setupCommit": {
                              "type": "string"
                            },
                            "setupError": {
                              "type": "string"
                            },
                            "logs": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "phase": {
                                    "type": "string",
                                    "enum": [
                                      "initialize",
                                      "refresh"
                                    ]
                                  },
                                  "command": {
                                    "type": "string"
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "done",
                                      "failed",
                                      "timed-out"
                                    ]
                                  },
                                  "code": {
                                    "type": [
                                      "number",
                                      "null"
                                    ]
                                  },
                                  "ms": {
                                    "type": "number"
                                  },
                                  "output": {
                                    "type": "string"
                                  },
                                  "failingLine": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "phase",
                                  "command",
                                  "status",
                                  "code",
                                  "ms",
                                  "output"
                                ],
                                "additionalProperties": true
                              }
                            }
                          },
                          "required": [
                            "userId",
                            "projectId",
                            "name",
                            "state",
                            "createdAt"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "snapshot"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "projectId": {
                    "default": "",
                    "type": "string"
                  },
                  "repoUrl": {
                    "type": "string"
                  },
                  "branch": {
                    "type": "string"
                  },
                  "testBranch": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 255
                  }
                },
                "required": [
                  "projectId"
                ]
              }
            }
          }
        }
      }
    },
    "/v1/events": {
      "get": {
        "tags": [
          "events"
        ],
        "summary": "Your sidebar, live: threads, majors, devices and machines (WebSocket)",
        "description": "Sends a snapshot, then one message per change (whole records). Reconnect with `?cursor=` set to the last cursor you got: you get the changes you missed and `resumed`, or a new snapshot when the engine restarted or the cursor is too old. A snapshot replaces everything you had.",
        "operationId": "socketEvents",
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "101": {
            "description": "Switches to a WebSocket"
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "x-websocket": {
          "sends": {
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "const": "snapshot"
                  },
                  "cursor": {
                    "type": "string"
                  },
                  "threads": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id"
                      ],
                      "additionalProperties": true
                    }
                  },
                  "majors": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id"
                      ],
                      "additionalProperties": true
                    }
                  },
                  "devices": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id"
                      ],
                      "additionalProperties": true
                    }
                  },
                  "machines": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id"
                      ],
                      "additionalProperties": true
                    }
                  }
                },
                "required": [
                  "type",
                  "cursor",
                  "threads",
                  "majors",
                  "devices",
                  "machines"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "const": "resumed"
                  },
                  "cursor": {
                    "type": "string"
                  }
                },
                "required": [
                  "type",
                  "cursor"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "const": "upsert"
                  },
                  "cursor": {
                    "type": "string"
                  },
                  "entity": {
                    "type": "string",
                    "enum": [
                      "thread",
                      "major",
                      "device",
                      "machine"
                    ]
                  },
                  "id": {
                    "type": "string"
                  },
                  "value": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "id"
                    ],
                    "additionalProperties": true
                  }
                },
                "required": [
                  "type",
                  "cursor",
                  "entity",
                  "id",
                  "value"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "const": "remove"
                  },
                  "cursor": {
                    "type": "string"
                  },
                  "entity": {
                    "type": "string",
                    "enum": [
                      "thread",
                      "major",
                      "device",
                      "machine"
                    ]
                  },
                  "id": {
                    "type": "string"
                  }
                },
                "required": [
                  "type",
                  "cursor",
                  "entity",
                  "id"
                ],
                "additionalProperties": false
              }
            ]
          }
        }
      }
    },
    "/v1/threads/{threadId}/watch": {
      "get": {
        "tags": [
          "threads"
        ],
        "summary": "A thread’s (or major’s) transcript, live (WebSocket)",
        "description": "Sends pi-durable's conversation view, then each commit's Chord operations. `from`, `min` and `max` pick the window (`ConversationTranscript.resume`).",
        "operationId": "socketThreadsByThreadIdWatch",
        "parameters": [
          {
            "name": "threadId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "min",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "max",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "101": {
            "description": "Switches to a WebSocket"
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "x-websocket": {
          "sends": {
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "const": "view"
                  },
                  "value": {}
                },
                "required": [
                  "type",
                  "value"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "const": "ops"
                  },
                  "ops": {
                    "type": "array",
                    "items": {
                      "anyOf": [
                        {
                          "type": "array",
                          "prefixItems": [
                            {
                              "type": "string",
                              "const": "r"
                            },
                            {
                              "$ref": "#/components/schemas/JsonValue"
                            }
                          ],
                          "items": false,
                          "minItems": 2,
                          "maxItems": 2
                        },
                        {
                          "type": "array",
                          "prefixItems": [
                            {
                              "type": "string",
                              "const": "s"
                            },
                            {
                              "type": "array",
                              "prefixItems": [
                                {
                                  "type": [
                                    "string",
                                    "number"
                                  ]
                                }
                              ],
                              "items": {
                                "type": [
                                  "string",
                                  "number"
                                ]
                              },
                              "minItems": 1
                            },
                            {
                              "$ref": "#/components/schemas/JsonValue"
                            }
                          ],
                          "items": false,
                          "minItems": 3,
                          "maxItems": 3
                        },
                        {
                          "type": "array",
                          "prefixItems": [
                            {
                              "type": "string",
                              "const": "d"
                            },
                            {
                              "type": "array",
                              "prefixItems": [
                                {
                                  "type": [
                                    "string",
                                    "number"
                                  ]
                                }
                              ],
                              "items": {
                                "type": [
                                  "string",
                                  "number"
                                ]
                              },
                              "minItems": 1
                            }
                          ],
                          "items": false,
                          "minItems": 2,
                          "maxItems": 2
                        },
                        {
                          "type": "array",
                          "prefixItems": [
                            {
                              "type": "string",
                              "const": "a"
                            },
                            {
                              "type": "array",
                              "prefixItems": [
                                {
                                  "type": [
                                    "string",
                                    "number"
                                  ]
                                }
                              ],
                              "items": {
                                "type": [
                                  "string",
                                  "number"
                                ]
                              },
                              "minItems": 1
                            },
                            {
                              "type": "string"
                            }
                          ],
                          "items": false,
                          "minItems": 3,
                          "maxItems": 3
                        },
                        {
                          "type": "array",
                          "prefixItems": [
                            {
                              "type": "string",
                              "const": "t"
                            },
                            {
                              "type": "array",
                              "prefixItems": [
                                {
                                  "type": [
                                    "string",
                                    "number"
                                  ]
                                }
                              ],
                              "items": {
                                "type": [
                                  "string",
                                  "number"
                                ]
                              },
                              "minItems": 1
                            },
                            {
                              "type": "number"
                            }
                          ],
                          "items": false,
                          "minItems": 3,
                          "maxItems": 3
                        },
                        {
                          "type": "array",
                          "prefixItems": [
                            {
                              "type": "string",
                              "const": "p"
                            },
                            {
                              "type": "array",
                              "items": {
                                "type": [
                                  "string",
                                  "number"
                                ]
                              }
                            },
                            {
                              "type": "number"
                            },
                            {
                              "type": "number"
                            },
                            {
                              "type": "array",
                              "items": {
                                "$ref": "#/components/schemas/JsonValue"
                              }
                            }
                          ],
                          "items": false,
                          "minItems": 5,
                          "maxItems": 5
                        },
                        {
                          "type": "array",
                          "prefixItems": [
                            {
                              "type": "string",
                              "const": "m"
                            },
                            {
                              "type": "array",
                              "items": {
                                "type": [
                                  "string",
                                  "number"
                                ]
                              }
                            },
                            {
                              "type": "array",
                              "items": {
                                "type": "number"
                              }
                            }
                          ],
                          "items": false,
                          "minItems": 3,
                          "maxItems": 3
                        }
                      ]
                    }
                  }
                },
                "required": [
                  "type",
                  "ops"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "const": "error"
                  },
                  "message": {
                    "type": "string"
                  }
                },
                "required": [
                  "type",
                  "message"
                ],
                "additionalProperties": false
              }
            ]
          }
        }
      }
    },
    "/v1/host": {
      "get": {
        "tags": [
          "engine"
        ],
        "summary": "The thread host's own protocol (`@keko/core/protocol`), what the Mac app speaks (WebSocket)",
        "description": "Requests in, responses and every event out. Not scoped per user yet.",
        "operationId": "socketHost",
        "parameters": [],
        "responses": {
          "101": {
            "description": "Switches to a WebSocket"
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "x-websocket": {
          "sends": {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "response",
                  "event"
                ]
              }
            },
            "required": [
              "kind"
            ],
            "additionalProperties": true
          },
          "receives": {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "request"
              },
              "id": {
                "type": "string"
              },
              "type": {
                "type": "string"
              }
            },
            "required": [
              "kind",
              "id",
              "type"
            ],
            "additionalProperties": true
          }
        }
      }
    },
    "/v1/dock": {
      "get": {
        "tags": [
          "devices"
        ],
        "summary": "A dock's outbound connection, with its pairing token (`@keko/dock/wire`) (WebSocket)",
        "description": "Control messages as JSON text frames, channel bytes as binary frames (a u32 channel id, then the bytes). Closes with `DOCK_CLOSE` codes: 4003 refused, 4002 update required, 4000 violation, 1012 restarting. A token that matches no device gets a 401 with `x-keko-dock: refused`, on the upgrade and on a plain GET (which answers 426 for a good token); a removed device’s token also gets `x-keko-dock-reason: Device removed`.",
        "operationId": "socketDock",
        "parameters": [],
        "responses": {
          "101": {
            "description": "Switches to a WebSocket"
          },
          "default": {
            "description": "What went wrong",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "x-websocket": {
          "sends": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string"
              }
            },
            "required": [
              "type"
            ],
            "additionalProperties": true
          },
          "receives": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string"
              }
            },
            "required": [
              "type"
            ],
            "additionalProperties": true
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "engine",
      "x-displayName": "Engine"
    },
    {
      "name": "events",
      "x-displayName": "Events"
    },
    {
      "name": "devices",
      "x-displayName": "Devices"
    },
    {
      "name": "threads",
      "x-displayName": "Threads"
    },
    {
      "name": "approvals",
      "x-displayName": "Approvals"
    },
    {
      "name": "changes",
      "x-displayName": "Changes"
    },
    {
      "name": "review",
      "x-displayName": "Review"
    },
    {
      "name": "terminals",
      "x-displayName": "Terminals"
    },
    {
      "name": "majors",
      "x-displayName": "Majors"
    },
    {
      "name": "cloud",
      "x-displayName": "Keko Cloud"
    }
  ],
  "servers": [
    {
      "url": "https://engine.keko.run"
    }
  ]
}
