{
  "components": {
    "parameters": {},
    "schemas": {
      "AgentAction": {
        "properties": {
          "agentId": {
            "description": "Агент, который просит разрешения",
            "format": "uuid",
            "type": "string"
          },
          "arguments": {
            "additionalProperties": true,
            "description": "Параметры действия",
            "type": "object"
          },
          "closedReason": {
            "description": "Почему запрос снят: superseded, expired или stopped",
            "type": [
              "string",
              "null"
            ]
          },
          "conversationId": {
            "description": "Беседа, в которой агент просил разрешения",
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "description": "Когда агент попросил, ISO 8601",
            "type": "string"
          },
          "decidedAt": {
            "description": "Когда принято решение, ISO 8601",
            "type": [
              "string",
              "null"
            ]
          },
          "decidedVia": {
            "description": "Где принято решение: chat, inbox или telegram",
            "type": [
              "string",
              "null"
            ]
          },
          "decision": {
            "description": "once — разрешено один раз, always — всегда",
            "enum": [
              "once",
              "always",
              null
            ],
            "type": [
              "string",
              "null"
            ]
          },
          "domain": {
            "description": "Раздел инструментов",
            "type": "string"
          },
          "effect": {
            "description": "read — чтение, write — изменение, irreversible — необратимое действие",
            "type": "string"
          },
          "expiresAt": {
            "description": "До какого момента ждёт решения, ISO 8601",
            "type": "string"
          },
          "id": {
            "description": "Идентификатор запроса",
            "format": "uuid",
            "type": "string"
          },
          "message": {
            "description": "Что агент собирается сделать",
            "type": "string"
          },
          "sectionTitle": {
            "description": "Название раздела",
            "type": [
              "string",
              "null"
            ]
          },
          "state": {
            "description": "pending — ждёт решения, approved — разрешено, used — выполнено после разрешения, rejected — отклонено, expired — срок решения истёк, closed — снято",
            "enum": [
              "pending",
              "approved",
              "rejected",
              "expired",
              "closed",
              "used"
            ],
            "type": "string"
          },
          "tool": {
            "description": "Инструмент",
            "type": "string"
          },
          "toolTitle": {
            "description": "Название действия",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "id",
          "agentId",
          "domain",
          "tool",
          "toolTitle",
          "sectionTitle",
          "effect",
          "message",
          "arguments",
          "state",
          "decision",
          "decidedVia",
          "decidedAt",
          "closedReason",
          "conversationId",
          "expiresAt",
          "createdAt"
        ],
        "type": "object"
      },
      "AgentActionDecision": {
        "properties": {
          "always": {
            "default": false,
            "description": "true — разрешать это действие всегда",
            "type": "boolean"
          },
          "approve": {
            "description": "true — разрешить, false — отклонить",
            "type": "boolean"
          }
        },
        "required": [
          "approve"
        ],
        "type": "object"
      },
      "AgentActivityStats": {
        "properties": {
          "days": {
            "description": "Запуски по дням",
            "items": {
              "properties": {
                "agentId": {
                  "description": "Агент",
                  "format": "uuid",
                  "type": "string"
                },
                "assisted": {
                  "description": "Запуски вместе с людьми",
                  "type": "integer"
                },
                "autonomous": {
                  "description": "Запуски без участия людей",
                  "type": "integer"
                },
                "day": {
                  "description": "День в часовом поясе запроса, YYYY-MM-DD",
                  "type": "string"
                }
              },
              "required": [
                "agentId",
                "day",
                "autonomous",
                "assisted"
              ],
              "type": "object"
            },
            "type": "array"
          },
          "domains": {
            "description": "Действия по разделам",
            "items": {
              "properties": {
                "agentId": {
                  "description": "Агент",
                  "format": "uuid",
                  "type": "string"
                },
                "calls": {
                  "description": "Число действий",
                  "type": "integer"
                },
                "domain": {
                  "description": "Раздел, в котором агент выполнял действия",
                  "type": "string"
                }
              },
              "required": [
                "agentId",
                "domain",
                "calls"
              ],
              "type": "object"
            },
            "type": "array"
          },
          "previousSince": {
            "description": "Начало такого же предыдущего периода, ISO 8601; дни включают и его",
            "type": "string"
          },
          "since": {
            "description": "Начало периода, ISO 8601",
            "type": "string"
          }
        },
        "required": [
          "since",
          "previousSince",
          "days",
          "domains"
        ],
        "type": "object"
      },
      "AgentJournalEvent": {
        "properties": {
          "agentId": {
            "description": "Агент",
            "format": "uuid",
            "type": "string"
          },
          "at": {
            "description": "Когда, ISO 8601",
            "type": "string"
          },
          "domain": {
            "description": "Раздел действия",
            "type": [
              "string",
              "null"
            ]
          },
          "effect": {
            "description": "Характер действия",
            "enum": [
              "read",
              "write",
              "irreversible",
              null
            ],
            "type": [
              "string",
              "null"
            ]
          },
          "id": {
            "description": "Идентификатор события",
            "type": "string"
          },
          "kind": {
            "description": "action — действие агента, failed — запуск завершился неудачей",
            "enum": [
              "action",
              "failed"
            ],
            "type": "string"
          },
          "origin": {
            "description": "Откуда был запуск",
            "type": "string"
          },
          "runId": {
            "description": "Запуск",
            "format": "uuid",
            "type": "string"
          },
          "subject": {
            "description": "С чем, например название документа",
            "type": [
              "string",
              "null"
            ]
          },
          "text": {
            "description": "Что сделано, в прошедшем времени",
            "type": "string"
          },
          "tool": {
            "description": "Инструмент",
            "type": [
              "string",
              "null"
            ]
          },
          "userId": {
            "description": "Пользователь, от имени которого работал агент",
            "format": "uuid",
            "type": "string"
          }
        },
        "required": [
          "id",
          "kind",
          "agentId",
          "userId",
          "runId",
          "at",
          "domain",
          "tool",
          "effect",
          "text",
          "subject",
          "origin"
        ],
        "type": "object"
      },
      "AgentJournalPage": {
        "properties": {
          "events": {
            "description": "События, новые первыми",
            "items": {
              "$ref": "#/components/schemas/AgentJournalEvent"
            },
            "type": "array"
          },
          "nextBefore": {
            "description": "Курсор следующей страницы",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "events",
          "nextBefore"
        ],
        "type": "object"
      },
      "AgentRun": {
        "properties": {
          "conversationId": {
            "description": "Беседа, в которой был запуск",
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "description": "Когда создан, ISO 8601",
            "type": "string"
          },
          "failure": {
            "description": "Причина неудачи: quota, access, unavailable, chain_lost или error",
            "type": [
              "string",
              "null"
            ]
          },
          "finishedAt": {
            "description": "Когда закончился, ISO 8601",
            "type": [
              "string",
              "null"
            ]
          },
          "id": {
            "description": "Идентификатор запуска",
            "format": "uuid",
            "type": "string"
          },
          "inputTokens": {
            "description": "Токены запроса",
            "type": "integer"
          },
          "origin": {
            "description": "Откуда запуск: chat, telegram, council, critique или schedule",
            "type": "string"
          },
          "output": {
            "description": "Ответ агента",
            "type": "string"
          },
          "outputTokens": {
            "description": "Токены ответа",
            "type": "integer"
          },
          "startedAt": {
            "description": "Когда начался, ISO 8601",
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "description": "Состояние: queued, running, completed, failed, cancelled или interrupted",
            "type": "string"
          },
          "title": {
            "description": "Запрос, с которого начался запуск",
            "type": "string"
          },
          "toolCalls": {
            "description": "Сколько инструментов вызвал агент",
            "type": "integer"
          }
        },
        "required": [
          "id",
          "origin",
          "status",
          "failure",
          "title",
          "output",
          "conversationId",
          "toolCalls",
          "inputTokens",
          "outputTokens",
          "createdAt",
          "startedAt",
          "finishedAt"
        ],
        "type": "object"
      },
      "AgentRunTool": {
        "properties": {
          "callId": {
            "description": "Идентификатор вызова",
            "type": "string"
          },
          "finishedAt": {
            "description": "Когда закончен, ISO 8601",
            "type": [
              "string",
              "null"
            ]
          },
          "label": {
            "description": "Что делал агент",
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "description": "Инструмент",
            "type": "string"
          },
          "params": {
            "description": "Параметры вызова"
          },
          "result": {
            "description": "Результат вызова"
          },
          "startedAt": {
            "description": "Когда начат, ISO 8601",
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "description": "Состояние вызова: pending, completed или failed",
            "type": "string"
          }
        },
        "required": [
          "callId",
          "name",
          "label",
          "status",
          "startedAt",
          "finishedAt"
        ],
        "type": "object"
      },
      "AgentTrustSuggestion": {
        "properties": {
          "agentId": {
            "description": "Агент",
            "format": "uuid",
            "type": "string"
          },
          "approvals": {
            "description": "Разрешений, на которых основана подсказка",
            "type": "integer"
          },
          "createdAt": {
            "description": "Когда предложена, ISO 8601",
            "type": "string"
          },
          "decidedAt": {
            "description": "Когда решена, ISO 8601",
            "type": [
              "string",
              "null"
            ]
          },
          "domain": {
            "description": "Раздел инструментов; null для promote",
            "type": [
              "string",
              "null"
            ]
          },
          "id": {
            "description": "Идентификатор подсказки",
            "format": "uuid",
            "type": "string"
          },
          "kind": {
            "description": "allow — разрешить действие без вопросов, deny — запретить, promote — снять испытательный уровень",
            "enum": [
              "allow",
              "deny",
              "promote"
            ],
            "type": "string"
          },
          "rejections": {
            "description": "Отказов, на которых основана подсказка",
            "type": "integer"
          },
          "sectionTitle": {
            "description": "Название раздела",
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "description": "open — ждёт решения, accepted — принята, dismissed — отклонена",
            "enum": [
              "open",
              "accepted",
              "dismissed"
            ],
            "type": "string"
          },
          "tool": {
            "description": "Инструмент; null для promote",
            "type": [
              "string",
              "null"
            ]
          },
          "toolTitle": {
            "description": "Название действия",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "id",
          "agentId",
          "kind",
          "domain",
          "tool",
          "toolTitle",
          "sectionTitle",
          "approvals",
          "rejections",
          "status",
          "createdAt",
          "decidedAt"
        ],
        "type": "object"
      },
      "ProblemDetails": {
        "description": "Ошибка в формате Problem Details (RFC 9457)",
        "properties": {
          "code": {
            "description": "Стабильный машиночитаемый код ошибки",
            "type": "string"
          },
          "detail": {
            "description": "Пояснение для человека",
            "type": "string"
          },
          "errors": {
            "description": "Ошибки валидации по полям",
            "items": {
              "properties": {
                "name": {
                  "description": "Имя поля",
                  "type": "string"
                },
                "pointer": {
                  "description": "JSON Pointer на поле",
                  "type": "string"
                },
                "reason": {
                  "description": "Причина",
                  "type": "string"
                },
                "rule": {
                  "description": "Нарушенное правило",
                  "type": "string"
                }
              },
              "required": [
                "reason"
              ],
              "type": "object"
            },
            "type": "array"
          },
          "instance": {
            "description": "Путь запроса, в котором возникла ошибка",
            "type": "string"
          },
          "request_id": {
            "description": "Идентификатор запроса для обращения в поддержку",
            "type": "string"
          },
          "status": {
            "description": "HTTP-статус",
            "type": "integer"
          },
          "title": {
            "description": "Краткое описание",
            "type": "string"
          },
          "trace_id": {
            "description": "Идентификатор трассы",
            "type": "string"
          },
          "type": {
            "description": "URI типа ошибки, ведёт на описание в документации",
            "format": "uri",
            "type": "string"
          }
        },
        "required": [
          "type",
          "title",
          "status",
          "code"
        ],
        "type": "object"
      }
    },
    "securitySchemes": {
      "dpop": {
        "bearerFormat": "JWT",
        "description": "Access token, привязанный к ключу клиента по RFC 9449: заголовок `Authorization: DPoP <token>` и заголовок `DPoP` с доказательством для каждого запроса. Сервер выдаёт `DPoP-Nonce`, который клиент включает в доказательство.",
        "scheme": "dpop",
        "type": "http"
      },
      "mutualTLS": {
        "description": "Access token, привязанный к клиентскому сертификату по RFC 8705: заголовок `Authorization: Bearer <token>` поверх mTLS-соединения тем же сертификатом.",
        "type": "mutualTLS"
      }
    }
  },
  "info": {
    "description": "HTTP-поверхность realtime-сервиса: AI-беседы, файлы AI-чата, администрирование агентов.",
    "title": "LegalStack Collaboration API",
    "version": "1.0.0"
  },
  "openapi": "3.1.0",
  "paths": {
    "/ws/api/agent-actions": {
      "get": {
        "description": "Действия, которые агенты просили разрешить текущему пользователю: ожидающие решения или вся история решений, новые первыми.",
        "operationId": "get_ws_api_agent-actions",
        "parameters": [
          {
            "description": "pending — ждут решения, all — вся история",
            "in": "query",
            "name": "state",
            "required": false,
            "schema": {
              "default": "pending",
              "description": "pending — ждут решения, all — вся история",
              "enum": [
                "pending",
                "all"
              ],
              "type": "string"
            }
          },
          {
            "description": "Показать запросы, созданные раньше этого момента, ISO 8601",
            "in": "query",
            "name": "before",
            "required": false,
            "schema": {
              "description": "Показать запросы, созданные раньше этого момента, ISO 8601",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "actions": {
                      "description": "Запросы, новые первыми",
                      "items": {
                        "$ref": "#/components/schemas/AgentAction"
                      },
                      "type": "array"
                    }
                  },
                  "required": [
                    "actions"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Запросы"
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Некорректный запрос: не прошла валидация параметров или тела"
          },
          "401": {
            "description": "Не авторизован"
          },
          "403": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Недостаточно прав или scope"
          }
        },
        "security": [
          {
            "dpop": []
          }
        ],
        "summary": "Запросы агентов на действия",
        "tags": [
          "collaboration:agents"
        ]
      }
    },
    "/ws/api/agent-actions/grants": {
      "get": {
        "description": "Действия, которые текущий пользователь разрешил агентам выполнять без вопросов.",
        "operationId": "get_ws_api_agent-actions_grants",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "grants": {
                      "description": "Действия, которые агенты выполняют без вопросов",
                      "items": {
                        "properties": {
                          "agentId": {
                            "description": "Агент",
                            "format": "uuid",
                            "type": "string"
                          },
                          "createdAt": {
                            "description": "Когда разрешено, ISO 8601",
                            "type": "string"
                          },
                          "domain": {
                            "description": "Раздел инструментов",
                            "type": "string"
                          },
                          "id": {
                            "description": "Идентификатор разрешения",
                            "format": "uuid",
                            "type": "string"
                          },
                          "sectionTitle": {
                            "description": "Название раздела",
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "tool": {
                            "description": "Инструмент",
                            "type": "string"
                          },
                          "toolTitle": {
                            "description": "Название действия",
                            "type": [
                              "string",
                              "null"
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "agentId",
                          "domain",
                          "tool",
                          "toolTitle",
                          "sectionTitle",
                          "createdAt"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    }
                  },
                  "required": [
                    "grants"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Разрешения"
          },
          "401": {
            "description": "Не авторизован"
          },
          "403": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Недостаточно прав или scope"
          }
        },
        "security": [
          {
            "dpop": []
          }
        ],
        "summary": "Постоянные разрешения",
        "tags": [
          "collaboration:agents"
        ]
      }
    },
    "/ws/api/agent-actions/grants/{grantId}": {
      "delete": {
        "description": "Агент снова будет спрашивать перед этим действием.",
        "operationId": "delete_ws_api_agent-actions_grants_grantId",
        "parameters": [
          {
            "description": "Идентификатор разрешения",
            "in": "path",
            "name": "grantId",
            "required": true,
            "schema": {
              "description": "Идентификатор разрешения",
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Разрешение отозвано"
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Некорректный запрос: не прошла валидация параметров или тела"
          },
          "401": {
            "description": "Не авторизован"
          },
          "403": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Недостаточно прав или scope"
          },
          "404": {
            "description": "Разрешение не найдено"
          }
        },
        "security": [
          {
            "dpop": []
          }
        ],
        "summary": "Отозвать постоянное разрешение",
        "tags": [
          "collaboration:agents"
        ]
      }
    },
    "/ws/api/agent-actions/{actionId}/decision": {
      "post": {
        "description": "Разрешает действие один раз или всегда либо отклоняет его. Если запрос пришёл из беседы, агент продолжает работу в ней с учётом решения.",
        "operationId": "post_ws_api_agent-actions_actionId_decision",
        "parameters": [
          {
            "description": "Идентификатор запроса",
            "in": "path",
            "name": "actionId",
            "required": true,
            "schema": {
              "description": "Идентификатор запроса",
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AgentActionDecision"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "conversationId": {
                      "description": "Беседа, где агент продолжает работу",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "outcome": {
                      "description": "continued — агент продолжает работу в беседе с учётом решения",
                      "enum": [
                        "continued",
                        "approved",
                        "rejected",
                        "expired"
                      ],
                      "type": "string"
                    },
                    "runId": {
                      "description": "Ответ агента, который начался после решения",
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "outcome",
                    "conversationId",
                    "runId"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Итог"
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Некорректный запрос: не прошла валидация параметров или тела"
          },
          "401": {
            "description": "Не авторизован"
          },
          "403": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Недостаточно прав или scope"
          },
          "404": {
            "description": "Запрос не найден"
          },
          "409": {
            "description": "Агент сейчас отвечает в этой беседе"
          }
        },
        "security": [
          {
            "dpop": []
          }
        ],
        "summary": "Решение по запросу агента",
        "tags": [
          "collaboration:agents"
        ]
      }
    },
    "/ws/api/agent-activity/journal": {
      "get": {
        "description": "Действия агентов и неудачные запуски за последние 90 дней, новые первыми. По агентам под управлением пользователя показываются действия для всей команды, по остальным только свои.",
        "operationId": "get_ws_api_agent-activity_journal",
        "parameters": [
          {
            "description": "Агенты, чьи действия нужны",
            "in": "query",
            "name": "agent",
            "required": true,
            "schema": {
              "anyOf": [
                {
                  "format": "uuid",
                  "type": "string"
                },
                {
                  "items": {
                    "format": "uuid",
                    "type": "string"
                  },
                  "maxItems": 50,
                  "type": "array"
                }
              ],
              "description": "Агенты, чьи действия нужны"
            }
          },
          {
            "description": "Показать события раньше этого момента, ISO 8601",
            "in": "query",
            "name": "before",
            "required": false,
            "schema": {
              "description": "Показать события раньше этого момента, ISO 8601",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentJournalPage"
                }
              }
            },
            "description": "События"
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Некорректный запрос: не прошла валидация параметров или тела"
          },
          "401": {
            "description": "Не авторизован"
          },
          "403": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Недостаточно прав или scope"
          }
        },
        "security": [
          {
            "dpop": []
          }
        ],
        "summary": "Журнал действий агентов",
        "tags": [
          "collaboration:agents"
        ]
      }
    },
    "/ws/api/agent-activity/stats": {
      "get": {
        "description": "Запуски по дням: сами (по расписанию, задачам и проверкам) и с людьми (чат, Telegram, консилиумы), а также разделы, в которых агенты работали. По агентам под управлением пользователя учитываются запуски всей команды, по остальным только свои.",
        "operationId": "get_ws_api_agent-activity_stats",
        "parameters": [
          {
            "description": "Агенты, по которым нужна статистика",
            "in": "query",
            "name": "agent",
            "required": true,
            "schema": {
              "anyOf": [
                {
                  "format": "uuid",
                  "type": "string"
                },
                {
                  "items": {
                    "format": "uuid",
                    "type": "string"
                  },
                  "maxItems": 50,
                  "type": "array"
                }
              ],
              "description": "Агенты, по которым нужна статистика"
            }
          },
          {
            "description": "Период: неделя, 30 дней, квартал или год; для года сравнение с прошлым периодом не считается",
            "in": "query",
            "name": "period",
            "required": false,
            "schema": {
              "default": "month",
              "description": "Период: неделя, 30 дней, квартал или год; для года сравнение с прошлым периодом не считается",
              "enum": [
                "week",
                "month",
                "quarter",
                "year"
              ],
              "type": "string"
            }
          },
          {
            "description": "true — только собственные запуски пользователя",
            "in": "query",
            "name": "mine",
            "required": false,
            "schema": {
              "description": "true — только собственные запуски пользователя",
              "enum": [
                "true",
                "false"
              ],
              "type": "string"
            }
          },
          {
            "description": "Часовой пояс для разбивки по дням, IANA",
            "in": "query",
            "name": "tz",
            "required": false,
            "schema": {
              "description": "Часовой пояс для разбивки по дням, IANA",
              "maxLength": 64,
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentActivityStats"
                }
              }
            },
            "description": "Статистика"
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Некорректный запрос: не прошла валидация параметров или тела"
          },
          "401": {
            "description": "Не авторизован"
          },
          "403": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Недостаточно прав или scope"
          }
        },
        "security": [
          {
            "dpop": []
          }
        ],
        "summary": "Статистика запусков агентов",
        "tags": [
          "collaboration:agents"
        ]
      }
    },
    "/ws/api/agent-presets": {
      "get": {
        "description": "Роли, которые можно выбрать агенту при создании и в настройках.",
        "operationId": "get_ws_api_agent-presets",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "defaultPresetId": {
                      "description": "Пресет по умолчанию",
                      "type": "string"
                    },
                    "presets": {
                      "description": "Пресеты",
                      "items": {
                        "properties": {
                          "description": {
                            "description": "Описание",
                            "type": "string"
                          },
                          "icon": {
                            "description": "Иконка",
                            "type": "string"
                          },
                          "id": {
                            "description": "Идентификатор пресета",
                            "type": "string"
                          },
                          "isDefault": {
                            "description": "Пресет по умолчанию",
                            "type": "boolean"
                          },
                          "label": {
                            "description": "Название",
                            "type": "string"
                          },
                          "model": {
                            "description": "Модель",
                            "type": "string"
                          },
                          "skills": {
                            "description": "Навыки",
                            "items": {
                              "type": "string"
                            },
                            "type": "array"
                          }
                        },
                        "required": [
                          "id",
                          "label",
                          "description",
                          "icon",
                          "isDefault",
                          "model",
                          "skills"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    }
                  },
                  "required": [
                    "defaultPresetId",
                    "presets"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Роли"
          },
          "401": {
            "description": "Не авторизован"
          },
          "403": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Недостаточно прав или scope"
          }
        },
        "security": [
          {
            "dpop": []
          }
        ],
        "summary": "Роли агентов",
        "tags": [
          "collaboration:agents"
        ]
      }
    },
    "/ws/api/agent-schedules": {
      "get": {
        "description": "Задания пользователя по расписанию у всех перечисленных агентов, которыми он может управлять, и задания, переданные ему от ушедших сотрудников.",
        "operationId": "get_ws_api_agent-schedules",
        "parameters": [
          {
            "description": "Агенты, чьи задания нужны",
            "in": "query",
            "name": "agent",
            "required": true,
            "schema": {
              "anyOf": [
                {
                  "format": "uuid",
                  "type": "string"
                },
                {
                  "items": {
                    "format": "uuid",
                    "type": "string"
                  },
                  "maxItems": 50,
                  "type": "array"
                }
              ],
              "description": "Агенты, чьи задания нужны"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "handovers": {
                      "description": "Задания, переданные вам от ушедших сотрудников",
                      "items": {
                        "properties": {
                          "agentId": {
                            "description": "Идентификатор агента",
                            "type": "string"
                          },
                          "channels": {
                            "description": "Куда присылать результат",
                            "items": {
                              "description": "chat — беседа задания, telegram — привязанный Telegram, email — почта автора",
                              "enum": [
                                "chat",
                                "telegram",
                                "email"
                              ],
                              "type": "string"
                            },
                            "type": "array"
                          },
                          "createdAt": {
                            "description": "Когда передано, ISO 8601",
                            "type": "string"
                          },
                          "endsOn": {
                            "description": "Последний день работы; null — без окончания",
                            "pattern": "^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2})?$",
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "fromName": {
                            "description": "Имя бывшего автора",
                            "type": "string"
                          },
                          "fromUserId": {
                            "description": "Кто вёл задание раньше",
                            "type": "string"
                          },
                          "id": {
                            "description": "Идентификатор переданного задания",
                            "type": "string"
                          },
                          "name": {
                            "description": "Название",
                            "type": "string"
                          },
                          "prompt": {
                            "description": "Что делает агент",
                            "type": "string"
                          },
                          "repeatTimes": {
                            "description": "Число повторов; null — без ограничения",
                            "type": [
                              "integer",
                              "null"
                            ]
                          },
                          "schedule": {
                            "description": "Расписание",
                            "type": "string"
                          },
                          "startsOn": {
                            "description": "Дата начала; null — сразу",
                            "pattern": "^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2})?$",
                            "type": [
                              "string",
                              "null"
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "agentId",
                          "fromUserId",
                          "fromName",
                          "name",
                          "prompt",
                          "schedule",
                          "channels",
                          "createdAt",
                          "startsOn",
                          "endsOn",
                          "repeatTimes"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "schedules": {
                      "description": "Задания пользователя",
                      "items": {
                        "properties": {
                          "agentId": {
                            "description": "Идентификатор агента",
                            "type": "string"
                          },
                          "channels": {
                            "description": "Куда присылать результат",
                            "items": {
                              "description": "chat — беседа задания, telegram — привязанный Telegram, email — почта автора",
                              "enum": [
                                "chat",
                                "telegram",
                                "email"
                              ],
                              "type": "string"
                            },
                            "type": "array"
                          },
                          "conversationId": {
                            "description": "Беседа, куда приходят результаты",
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "createdAt": {
                            "description": "Создано, ISO 8601",
                            "type": "string"
                          },
                          "endsOn": {
                            "description": "Последний день работы; null — без окончания",
                            "pattern": "^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2})?$",
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "hold": {
                            "description": "Остановка администратором; null — не остановлено",
                            "properties": {
                              "at": {
                                "description": "Когда, ISO 8601",
                                "type": "string"
                              },
                              "byUserId": {
                                "description": "Кто остановил",
                                "type": "string"
                              },
                              "reason": {
                                "description": "Причина",
                                "type": "string"
                              }
                            },
                            "required": [
                              "byUserId",
                              "at",
                              "reason"
                            ],
                            "type": [
                              "object",
                              "null"
                            ]
                          },
                          "id": {
                            "description": "Идентификатор задания",
                            "type": "string"
                          },
                          "lastFailed": {
                            "description": "Последний запуск завершился ошибкой",
                            "type": "boolean"
                          },
                          "lastRunAt": {
                            "description": "Последний запуск, ISO 8601",
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "name": {
                            "description": "Название",
                            "type": "string"
                          },
                          "nextRunAt": {
                            "description": "Следующий запуск, ISO 8601",
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "origin": {
                            "description": "Где создано: chat — в чате, telegram — в Telegram, panel — в разделе «Агенты», agent — агентом",
                            "enum": [
                              "chat",
                              "telegram",
                              "panel",
                              "agent"
                            ],
                            "type": "string"
                          },
                          "overlap": {
                            "description": "Если к очередному запуску предыдущий ещё идёт: skip — пропустить очередной запуск, queue — выполнить его сразу после текущего, replace — остановить текущий и начать новый",
                            "enum": [
                              "skip",
                              "queue",
                              "replace"
                            ],
                            "type": "string"
                          },
                          "prompt": {
                            "description": "Что делает агент",
                            "type": "string"
                          },
                          "quotaPaused": {
                            "description": "Приостановлено, пока исчерпан месячный лимит работы агента; продолжится автоматически",
                            "type": "boolean"
                          },
                          "repeatDone": {
                            "description": "Сколько раз задание уже выполнено",
                            "type": "integer"
                          },
                          "repeatTimes": {
                            "description": "Число повторов; null — без ограничения",
                            "type": [
                              "integer",
                              "null"
                            ]
                          },
                          "schedule": {
                            "description": "Расписание: выражение cron, every Nm или дата однократного запуска",
                            "type": "string"
                          },
                          "startsOn": {
                            "description": "Дата начала; null — сразу",
                            "pattern": "^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2})?$",
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "state": {
                            "description": "active — работает по расписанию, paused — на паузе, running — выполняется прямо сейчас, finished — запусков больше не будет",
                            "enum": [
                              "active",
                              "paused",
                              "running",
                              "finished"
                            ],
                            "type": "string"
                          },
                          "upcoming": {
                            "description": "Ближайшие запуски",
                            "items": {
                              "properties": {
                                "at": {
                                  "description": "Время запуска, ISO 8601",
                                  "type": "string"
                                },
                                "label": {
                                  "description": "Время запуска по-русски в часовом поясе команды",
                                  "type": "string"
                                }
                              },
                              "required": [
                                "at",
                                "label"
                              ],
                              "type": "object"
                            },
                            "type": "array"
                          },
                          "userId": {
                            "description": "Автор задания",
                            "type": "string"
                          },
                          "waiting": {
                            "description": "Ждёт даты начала",
                            "type": "boolean"
                          },
                          "webhook": {
                            "description": "Включён ли вебхук, по которому внешняя система запускает задание вне расписания",
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "id",
                          "agentId",
                          "userId",
                          "name",
                          "prompt",
                          "schedule",
                          "state",
                          "nextRunAt",
                          "lastRunAt",
                          "lastFailed",
                          "origin",
                          "conversationId",
                          "channels",
                          "hold",
                          "quotaPaused",
                          "webhook",
                          "overlap",
                          "createdAt",
                          "startsOn",
                          "endsOn",
                          "repeatTimes",
                          "repeatDone",
                          "waiting",
                          "upcoming"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    }
                  },
                  "required": [
                    "schedules",
                    "handovers"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Задания"
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Некорректный запрос: не прошла валидация параметров или тела"
          },
          "401": {
            "description": "Не авторизован"
          },
          "403": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Недостаточно прав или scope"
          }
        },
        "security": [
          {
            "dpop": []
          }
        ],
        "summary": "Мои задания агентов",
        "tags": [
          "collaboration:agents"
        ]
      }
    },
    "/ws/api/agents/{agentId}/memory": {
      "get": {
        "description": "Память личного профиля агента вызывающего пользователя.",
        "operationId": "get_ws_api_agents_agentId_memory",
        "parameters": [
          {
            "description": "Идентификатор агента",
            "in": "path",
            "name": "agentId",
            "required": true,
            "schema": {
              "description": "Идентификатор агента",
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "items": {
                      "description": "Записи памяти агента",
                      "items": {
                        "properties": {
                          "id": {
                            "description": "Идентификатор записи памяти",
                            "type": "string"
                          },
                          "kind": {
                            "description": "about — сведения о собеседнике, fact — запомненный факт, note — рабочая заметка агента",
                            "enum": [
                              "about",
                              "fact",
                              "note"
                            ],
                            "type": "string"
                          },
                          "text": {
                            "description": "Что агент запомнил",
                            "type": "string"
                          },
                          "updatedAt": {
                            "description": "Когда запись обновлена, ISO 8601",
                            "type": [
                              "string",
                              "null"
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "kind",
                          "text",
                          "updatedAt"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    }
                  },
                  "required": [
                    "items"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Записи памяти"
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Некорректный запрос: не прошла валидация параметров или тела"
          },
          "401": {
            "description": "Не авторизован"
          },
          "403": {
            "description": "Недостаточно прав на агента"
          }
        },
        "security": [
          {
            "dpop": []
          }
        ],
        "summary": "Что агент помнит обо мне",
        "tags": [
          "collaboration:agents"
        ]
      }
    },
    "/ws/api/agents/{agentId}/memory/forget": {
      "post": {
        "description": "Удаляет выбранные записи или всю память личного профиля агента вызывающего пользователя.",
        "operationId": "post_ws_api_agents_agentId_memory_forget",
        "parameters": [
          {
            "description": "Идентификатор агента",
            "in": "path",
            "name": "agentId",
            "required": true,
            "schema": {
              "description": "Идентификатор агента",
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "all": {
                    "default": false,
                    "description": "true — забыть всё",
                    "type": "boolean"
                  },
                  "ids": {
                    "default": [],
                    "description": "Записи, которые нужно забыть",
                    "items": {
                      "maxLength": 80,
                      "minLength": 1,
                      "type": "string"
                    },
                    "maxItems": 500,
                    "type": "array"
                  }
                },
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "forgotten": {
                      "description": "Сколько записей забыто",
                      "type": "integer"
                    }
                  },
                  "required": [
                    "forgotten"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Итог"
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Некорректный запрос: не прошла валидация параметров или тела"
          },
          "401": {
            "description": "Не авторизован"
          },
          "403": {
            "description": "Недостаточно прав на агента"
          }
        },
        "security": [
          {
            "dpop": []
          }
        ],
        "summary": "Забыть записи памяти",
        "tags": [
          "collaboration:agents"
        ]
      }
    },
    "/ws/api/agents/{agentId}/own-files": {
      "delete": {
        "operationId": "delete_ws_api_agents_agentId_own-files",
        "parameters": [
          {
            "description": "Идентификатор агента",
            "in": "path",
            "name": "agentId",
            "required": true,
            "schema": {
              "description": "Идентификатор агента",
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "description": "Путь к файлу",
            "in": "query",
            "name": "path",
            "required": true,
            "schema": {
              "description": "Путь к файлу",
              "maxLength": 1024,
              "minLength": 1,
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Файл удалён"
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Некорректный запрос: не прошла валидация параметров или тела"
          },
          "401": {
            "description": "Не авторизован"
          },
          "403": {
            "description": "Недостаточно прав на агента"
          },
          "404": {
            "description": "Файл не найден"
          }
        },
        "security": [
          {
            "dpop": []
          }
        ],
        "summary": "Удалить свой файл у агента",
        "tags": [
          "collaboration:agents"
        ]
      },
      "get": {
        "description": "Вложения из чата и файлы, которые агент скачал или подготовил в личном профиле. Скачать файл можно через /ws/api/files/workspace.",
        "operationId": "get_ws_api_agents_agentId_own-files",
        "parameters": [
          {
            "description": "Идентификатор агента",
            "in": "path",
            "name": "agentId",
            "required": true,
            "schema": {
              "description": "Идентификатор агента",
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "files": {
                      "description": "Файлы",
                      "items": {
                        "properties": {
                          "path": {
                            "description": "Путь внутри рабочей папки агента",
                            "type": "string"
                          },
                          "size": {
                            "description": "Размер, байт",
                            "type": "integer"
                          },
                          "updatedAt": {
                            "description": "Когда изменён, ISO 8601",
                            "type": "string"
                          }
                        },
                        "required": [
                          "path",
                          "size",
                          "updatedAt"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "truncated": {
                      "description": "true — показаны не все файлы",
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "files",
                    "truncated"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Файлы"
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Некорректный запрос: не прошла валидация параметров или тела"
          },
          "401": {
            "description": "Не авторизован"
          },
          "403": {
            "description": "Недостаточно прав на агента"
          }
        },
        "security": [
          {
            "dpop": []
          }
        ],
        "summary": "Мои файлы у агента",
        "tags": [
          "collaboration:agents"
        ]
      }
    },
    "/ws/api/agents/{agentId}/profiles": {
      "get": {
        "description": "Доступно владельцу и администраторам команды. Показывает активность и объём профиля каждого сотрудника, но не содержимое памяти и файлов.",
        "operationId": "get_ws_api_agents_agentId_profiles",
        "parameters": [
          {
            "description": "Идентификатор агента",
            "in": "path",
            "name": "agentId",
            "required": true,
            "schema": {
              "description": "Идентификатор агента",
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "profiles": {
                      "description": "Профили сотрудников",
                      "items": {
                        "properties": {
                          "bytes": {
                            "description": "Объём файлов, байт",
                            "type": "integer"
                          },
                          "createdAt": {
                            "description": "Когда профиль создан, ISO 8601",
                            "type": "string"
                          },
                          "files": {
                            "description": "Файлов в рабочей папке",
                            "type": "integer"
                          },
                          "lastUsedAt": {
                            "description": "Последняя активность, ISO 8601",
                            "type": "string"
                          },
                          "memories": {
                            "description": "Записей в памяти агента",
                            "type": "integer"
                          },
                          "schedules": {
                            "description": "Заданий по расписанию",
                            "type": "integer"
                          },
                          "userId": {
                            "description": "Сотрудник",
                            "type": "string"
                          }
                        },
                        "required": [
                          "userId",
                          "createdAt",
                          "lastUsedAt",
                          "memories",
                          "files",
                          "bytes",
                          "schedules"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    }
                  },
                  "required": [
                    "profiles"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Профили"
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Некорректный запрос: не прошла валидация параметров или тела"
          },
          "401": {
            "description": "Не авторизован"
          },
          "403": {
            "description": "Недостаточно прав на агента"
          }
        },
        "security": [
          {
            "dpop": []
          }
        ],
        "summary": "Профили сотрудников у агента",
        "tags": [
          "collaboration:agents"
        ]
      }
    },
    "/ws/api/agents/{agentId}/profiles/{userId}/reset": {
      "post": {
        "description": "Доступно владельцу и администраторам команды. Агент забывает всё о сотруднике, его рабочие файлы, беседы агента и входы в личные кабинеты удаляются; переписка в чате и задания по расписанию сохраняются. Сотрудник получает уведомление.",
        "operationId": "post_ws_api_agents_agentId_profiles_userId_reset",
        "parameters": [
          {
            "description": "Идентификатор агента",
            "in": "path",
            "name": "agentId",
            "required": true,
            "schema": {
              "description": "Идентификатор агента",
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "description": "Сотрудник",
            "in": "path",
            "name": "userId",
            "required": true,
            "schema": {
              "description": "Сотрудник",
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Профиль сброшен"
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Некорректный запрос: не прошла валидация параметров или тела"
          },
          "401": {
            "description": "Не авторизован"
          },
          "403": {
            "description": "Недостаточно прав на агента"
          },
          "404": {
            "description": "У сотрудника нет профиля агента"
          },
          "409": {
            "description": "Сейчас выполняется задание сотрудника"
          }
        },
        "security": [
          {
            "dpop": []
          }
        ],
        "summary": "Сбросить профиль сотрудника",
        "tags": [
          "collaboration:agents"
        ]
      }
    },
    "/ws/api/agents/{agentId}/runs": {
      "get": {
        "description": "Запуски агента от имени вызывающего пользователя: ходы в чате и Telegram, консилиумы и возражения.",
        "operationId": "get_ws_api_agents_agentId_runs",
        "parameters": [
          {
            "description": "Идентификатор агента",
            "in": "path",
            "name": "agentId",
            "required": true,
            "schema": {
              "description": "Идентификатор агента",
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "description": "Показать запуски, созданные раньше этого момента",
            "in": "query",
            "name": "before",
            "required": false,
            "schema": {
              "description": "Показать запуски, созданные раньше этого момента",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "runs": {
                      "description": "Запуски, новые первыми",
                      "items": {
                        "$ref": "#/components/schemas/AgentRun"
                      },
                      "type": "array"
                    }
                  },
                  "required": [
                    "runs"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Запуски"
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Некорректный запрос: не прошла валидация параметров или тела"
          },
          "401": {
            "description": "Не авторизован"
          },
          "403": {
            "description": "Недостаточно прав на агента"
          }
        },
        "security": [
          {
            "dpop": []
          }
        ],
        "summary": "Журнал запусков агента",
        "tags": [
          "collaboration:agents"
        ]
      }
    },
    "/ws/api/agents/{agentId}/runs/{runId}": {
      "get": {
        "description": "Запрос, ответ, вызовы инструментов и расход токенов одного запуска.",
        "operationId": "get_ws_api_agents_agentId_runs_runId",
        "parameters": [
          {
            "description": "Идентификатор агента",
            "in": "path",
            "name": "agentId",
            "required": true,
            "schema": {
              "description": "Идентификатор агента",
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "description": "Идентификатор запуска",
            "in": "path",
            "name": "runId",
            "required": true,
            "schema": {
              "description": "Идентификатор запуска",
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "run": {
                      "$ref": "#/components/schemas/AgentRun"
                    },
                    "tools": {
                      "description": "Вызовы инструментов по порядку",
                      "items": {
                        "$ref": "#/components/schemas/AgentRunTool"
                      },
                      "type": "array"
                    }
                  },
                  "required": [
                    "run",
                    "tools"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Запуск"
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Некорректный запрос: не прошла валидация параметров или тела"
          },
          "401": {
            "description": "Не авторизован"
          },
          "403": {
            "description": "Недостаточно прав на агента"
          }
        },
        "security": [
          {
            "dpop": []
          }
        ],
        "summary": "Запуск агента",
        "tags": [
          "collaboration:agents"
        ]
      }
    },
    "/ws/api/agents/{agentId}/runs/{runId}/stop": {
      "post": {
        "description": "Агент прекращает работу, сделанное к этому моменту сохраняется.",
        "operationId": "post_ws_api_agents_agentId_runs_runId_stop",
        "parameters": [
          {
            "description": "Идентификатор агента",
            "in": "path",
            "name": "agentId",
            "required": true,
            "schema": {
              "description": "Идентификатор агента",
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "description": "Идентификатор запуска",
            "in": "path",
            "name": "runId",
            "required": true,
            "schema": {
              "description": "Идентификатор запуска",
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "run": {
                      "$ref": "#/components/schemas/AgentRun"
                    }
                  },
                  "required": [
                    "run"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Запуск"
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Некорректный запрос: не прошла валидация параметров или тела"
          },
          "401": {
            "description": "Не авторизован"
          },
          "403": {
            "description": "Недостаточно прав на агента"
          }
        },
        "security": [
          {
            "dpop": []
          }
        ],
        "summary": "Остановить запуск агента",
        "tags": [
          "collaboration:agents"
        ]
      }
    },
    "/ws/api/agents/{agentId}/schedule-handovers": {
      "get": {
        "description": "Задания ушедших сотрудников, переданные вам как преемнику. Они не выполняются, пока вы их не включите.",
        "operationId": "get_ws_api_agents_agentId_schedule-handovers",
        "parameters": [
          {
            "description": "Идентификатор агента",
            "in": "path",
            "name": "agentId",
            "required": true,
            "schema": {
              "description": "Идентификатор агента",
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "handovers": {
                      "description": "Задания, переданные вам от ушедших сотрудников",
                      "items": {
                        "properties": {
                          "agentId": {
                            "description": "Идентификатор агента",
                            "type": "string"
                          },
                          "channels": {
                            "description": "Куда присылать результат",
                            "items": {
                              "description": "chat — беседа задания, telegram — привязанный Telegram, email — почта автора",
                              "enum": [
                                "chat",
                                "telegram",
                                "email"
                              ],
                              "type": "string"
                            },
                            "type": "array"
                          },
                          "createdAt": {
                            "description": "Когда передано, ISO 8601",
                            "type": "string"
                          },
                          "endsOn": {
                            "description": "Последний день работы; null — без окончания",
                            "pattern": "^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2})?$",
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "fromName": {
                            "description": "Имя бывшего автора",
                            "type": "string"
                          },
                          "fromUserId": {
                            "description": "Кто вёл задание раньше",
                            "type": "string"
                          },
                          "id": {
                            "description": "Идентификатор переданного задания",
                            "type": "string"
                          },
                          "name": {
                            "description": "Название",
                            "type": "string"
                          },
                          "prompt": {
                            "description": "Что делает агент",
                            "type": "string"
                          },
                          "repeatTimes": {
                            "description": "Число повторов; null — без ограничения",
                            "type": [
                              "integer",
                              "null"
                            ]
                          },
                          "schedule": {
                            "description": "Расписание",
                            "type": "string"
                          },
                          "startsOn": {
                            "description": "Дата начала; null — сразу",
                            "pattern": "^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2})?$",
                            "type": [
                              "string",
                              "null"
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "agentId",
                          "fromUserId",
                          "fromName",
                          "name",
                          "prompt",
                          "schedule",
                          "channels",
                          "createdAt",
                          "startsOn",
                          "endsOn",
                          "repeatTimes"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    }
                  },
                  "required": [
                    "handovers"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Переданные задания"
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Некорректный запрос: не прошла валидация параметров или тела"
          },
          "401": {
            "description": "Не авторизован"
          },
          "403": {
            "description": "Недостаточно прав на агента"
          }
        },
        "security": [
          {
            "dpop": []
          }
        ],
        "summary": "Задания, переданные мне",
        "tags": [
          "collaboration:agents"
        ]
      }
    },
    "/ws/api/agents/{agentId}/schedule-handovers/{handoverId}": {
      "delete": {
        "operationId": "delete_ws_api_agents_agentId_schedule-handovers_handoverId",
        "parameters": [
          {
            "description": "Идентификатор агента",
            "in": "path",
            "name": "agentId",
            "required": true,
            "schema": {
              "description": "Идентификатор агента",
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "description": "Переданное задание",
            "in": "path",
            "name": "handoverId",
            "required": true,
            "schema": {
              "description": "Переданное задание",
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Задание удалено"
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Некорректный запрос: не прошла валидация параметров или тела"
          },
          "401": {
            "description": "Не авторизован"
          },
          "403": {
            "description": "Недостаточно прав на агента"
          }
        },
        "security": [
          {
            "dpop": []
          }
        ],
        "summary": "Отказаться от переданного задания",
        "tags": [
          "collaboration:agents"
        ]
      }
    },
    "/ws/api/agents/{agentId}/schedule-handovers/{handoverId}/accept": {
      "post": {
        "description": "Задание создаётся в вашем профиле агента и выполняется от вашего имени.",
        "operationId": "post_ws_api_agents_agentId_schedule-handovers_handoverId_accept",
        "parameters": [
          {
            "description": "Идентификатор агента",
            "in": "path",
            "name": "agentId",
            "required": true,
            "schema": {
              "description": "Идентификатор агента",
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "description": "Переданное задание",
            "in": "path",
            "name": "handoverId",
            "required": true,
            "schema": {
              "description": "Переданное задание",
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "agentId": {
                      "description": "Идентификатор агента",
                      "type": "string"
                    },
                    "channels": {
                      "description": "Куда присылать результат",
                      "items": {
                        "description": "chat — беседа задания, telegram — привязанный Telegram, email — почта автора",
                        "enum": [
                          "chat",
                          "telegram",
                          "email"
                        ],
                        "type": "string"
                      },
                      "type": "array"
                    },
                    "conversationId": {
                      "description": "Беседа, куда приходят результаты",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "createdAt": {
                      "description": "Создано, ISO 8601",
                      "type": "string"
                    },
                    "endsOn": {
                      "description": "Последний день работы; null — без окончания",
                      "pattern": "^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2})?$",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "hold": {
                      "description": "Остановка администратором; null — не остановлено",
                      "properties": {
                        "at": {
                          "description": "Когда, ISO 8601",
                          "type": "string"
                        },
                        "byUserId": {
                          "description": "Кто остановил",
                          "type": "string"
                        },
                        "reason": {
                          "description": "Причина",
                          "type": "string"
                        }
                      },
                      "required": [
                        "byUserId",
                        "at",
                        "reason"
                      ],
                      "type": [
                        "object",
                        "null"
                      ]
                    },
                    "id": {
                      "description": "Идентификатор задания",
                      "type": "string"
                    },
                    "lastFailed": {
                      "description": "Последний запуск завершился ошибкой",
                      "type": "boolean"
                    },
                    "lastRunAt": {
                      "description": "Последний запуск, ISO 8601",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "name": {
                      "description": "Название",
                      "type": "string"
                    },
                    "nextRunAt": {
                      "description": "Следующий запуск, ISO 8601",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "origin": {
                      "description": "Где создано: chat — в чате, telegram — в Telegram, panel — в разделе «Агенты», agent — агентом",
                      "enum": [
                        "chat",
                        "telegram",
                        "panel",
                        "agent"
                      ],
                      "type": "string"
                    },
                    "overlap": {
                      "description": "Если к очередному запуску предыдущий ещё идёт: skip — пропустить очередной запуск, queue — выполнить его сразу после текущего, replace — остановить текущий и начать новый",
                      "enum": [
                        "skip",
                        "queue",
                        "replace"
                      ],
                      "type": "string"
                    },
                    "prompt": {
                      "description": "Что делает агент",
                      "type": "string"
                    },
                    "quotaPaused": {
                      "description": "Приостановлено, пока исчерпан месячный лимит работы агента; продолжится автоматически",
                      "type": "boolean"
                    },
                    "repeatDone": {
                      "description": "Сколько раз задание уже выполнено",
                      "type": "integer"
                    },
                    "repeatTimes": {
                      "description": "Число повторов; null — без ограничения",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "schedule": {
                      "description": "Расписание: выражение cron, every Nm или дата однократного запуска",
                      "type": "string"
                    },
                    "startsOn": {
                      "description": "Дата начала; null — сразу",
                      "pattern": "^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2})?$",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "state": {
                      "description": "active — работает по расписанию, paused — на паузе, running — выполняется прямо сейчас, finished — запусков больше не будет",
                      "enum": [
                        "active",
                        "paused",
                        "running",
                        "finished"
                      ],
                      "type": "string"
                    },
                    "upcoming": {
                      "description": "Ближайшие запуски",
                      "items": {
                        "properties": {
                          "at": {
                            "description": "Время запуска, ISO 8601",
                            "type": "string"
                          },
                          "label": {
                            "description": "Время запуска по-русски в часовом поясе команды",
                            "type": "string"
                          }
                        },
                        "required": [
                          "at",
                          "label"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "userId": {
                      "description": "Автор задания",
                      "type": "string"
                    },
                    "waiting": {
                      "description": "Ждёт даты начала",
                      "type": "boolean"
                    },
                    "webhook": {
                      "description": "Включён ли вебхук, по которому внешняя система запускает задание вне расписания",
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "id",
                    "agentId",
                    "userId",
                    "name",
                    "prompt",
                    "schedule",
                    "state",
                    "nextRunAt",
                    "lastRunAt",
                    "lastFailed",
                    "origin",
                    "conversationId",
                    "channels",
                    "hold",
                    "quotaPaused",
                    "webhook",
                    "overlap",
                    "createdAt",
                    "startsOn",
                    "endsOn",
                    "repeatTimes",
                    "repeatDone",
                    "waiting",
                    "upcoming"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Включённое задание"
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Некорректный запрос: не прошла валидация параметров или тела"
          },
          "401": {
            "description": "Не авторизован"
          },
          "403": {
            "description": "Недостаточно прав на агента"
          }
        },
        "security": [
          {
            "dpop": []
          }
        ],
        "summary": "Включить переданное задание",
        "tags": [
          "collaboration:agents"
        ]
      }
    },
    "/ws/api/agents/{agentId}/schedules": {
      "get": {
        "description": "mine — задания пользователя; team — задания всех сотрудников, доступно администраторам и владельцу команды.",
        "operationId": "get_ws_api_agents_agentId_schedules",
        "parameters": [
          {
            "description": "Идентификатор агента",
            "in": "path",
            "name": "agentId",
            "required": true,
            "schema": {
              "description": "Идентификатор агента",
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "description": "mine — мои задания, team — задания всех сотрудников",
            "in": "query",
            "name": "scope",
            "required": false,
            "schema": {
              "default": "mine",
              "description": "mine — мои задания, team — задания всех сотрудников",
              "enum": [
                "mine",
                "team"
              ],
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "schedules": {
                      "description": "Задания",
                      "items": {
                        "properties": {
                          "agentId": {
                            "description": "Идентификатор агента",
                            "type": "string"
                          },
                          "channels": {
                            "description": "Куда присылать результат",
                            "items": {
                              "description": "chat — беседа задания, telegram — привязанный Telegram, email — почта автора",
                              "enum": [
                                "chat",
                                "telegram",
                                "email"
                              ],
                              "type": "string"
                            },
                            "type": "array"
                          },
                          "conversationId": {
                            "description": "Беседа, куда приходят результаты",
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "createdAt": {
                            "description": "Создано, ISO 8601",
                            "type": "string"
                          },
                          "endsOn": {
                            "description": "Последний день работы; null — без окончания",
                            "pattern": "^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2})?$",
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "hold": {
                            "description": "Остановка администратором; null — не остановлено",
                            "properties": {
                              "at": {
                                "description": "Когда, ISO 8601",
                                "type": "string"
                              },
                              "byUserId": {
                                "description": "Кто остановил",
                                "type": "string"
                              },
                              "reason": {
                                "description": "Причина",
                                "type": "string"
                              }
                            },
                            "required": [
                              "byUserId",
                              "at",
                              "reason"
                            ],
                            "type": [
                              "object",
                              "null"
                            ]
                          },
                          "id": {
                            "description": "Идентификатор задания",
                            "type": "string"
                          },
                          "lastFailed": {
                            "description": "Последний запуск завершился ошибкой",
                            "type": "boolean"
                          },
                          "lastRunAt": {
                            "description": "Последний запуск, ISO 8601",
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "name": {
                            "description": "Название",
                            "type": "string"
                          },
                          "nextRunAt": {
                            "description": "Следующий запуск, ISO 8601",
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "origin": {
                            "description": "Где создано: chat — в чате, telegram — в Telegram, panel — в разделе «Агенты», agent — агентом",
                            "enum": [
                              "chat",
                              "telegram",
                              "panel",
                              "agent"
                            ],
                            "type": "string"
                          },
                          "overlap": {
                            "description": "Если к очередному запуску предыдущий ещё идёт: skip — пропустить очередной запуск, queue — выполнить его сразу после текущего, replace — остановить текущий и начать новый",
                            "enum": [
                              "skip",
                              "queue",
                              "replace"
                            ],
                            "type": "string"
                          },
                          "prompt": {
                            "description": "Что делает агент",
                            "type": "string"
                          },
                          "quotaPaused": {
                            "description": "Приостановлено, пока исчерпан месячный лимит работы агента; продолжится автоматически",
                            "type": "boolean"
                          },
                          "repeatDone": {
                            "description": "Сколько раз задание уже выполнено",
                            "type": "integer"
                          },
                          "repeatTimes": {
                            "description": "Число повторов; null — без ограничения",
                            "type": [
                              "integer",
                              "null"
                            ]
                          },
                          "schedule": {
                            "description": "Расписание: выражение cron, every Nm или дата однократного запуска",
                            "type": "string"
                          },
                          "startsOn": {
                            "description": "Дата начала; null — сразу",
                            "pattern": "^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2})?$",
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "state": {
                            "description": "active — работает по расписанию, paused — на паузе, running — выполняется прямо сейчас, finished — запусков больше не будет",
                            "enum": [
                              "active",
                              "paused",
                              "running",
                              "finished"
                            ],
                            "type": "string"
                          },
                          "upcoming": {
                            "description": "Ближайшие запуски",
                            "items": {
                              "properties": {
                                "at": {
                                  "description": "Время запуска, ISO 8601",
                                  "type": "string"
                                },
                                "label": {
                                  "description": "Время запуска по-русски в часовом поясе команды",
                                  "type": "string"
                                }
                              },
                              "required": [
                                "at",
                                "label"
                              ],
                              "type": "object"
                            },
                            "type": "array"
                          },
                          "userId": {
                            "description": "Автор задания",
                            "type": "string"
                          },
                          "waiting": {
                            "description": "Ждёт даты начала",
                            "type": "boolean"
                          },
                          "webhook": {
                            "description": "Включён ли вебхук, по которому внешняя система запускает задание вне расписания",
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "id",
                          "agentId",
                          "userId",
                          "name",
                          "prompt",
                          "schedule",
                          "state",
                          "nextRunAt",
                          "lastRunAt",
                          "lastFailed",
                          "origin",
                          "conversationId",
                          "channels",
                          "hold",
                          "quotaPaused",
                          "webhook",
                          "overlap",
                          "createdAt",
                          "startsOn",
                          "endsOn",
                          "repeatTimes",
                          "repeatDone",
                          "waiting",
                          "upcoming"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    }
                  },
                  "required": [
                    "schedules"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Задания"
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Некорректный запрос: не прошла валидация параметров или тела"
          },
          "401": {
            "description": "Не авторизован"
          },
          "403": {
            "description": "Недостаточно прав на агента"
          }
        },
        "security": [
          {
            "dpop": []
          }
        ],
        "summary": "Задания агента по расписанию",
        "tags": [
          "collaboration:agents"
        ]
      },
      "post": {
        "operationId": "post_ws_api_agents_agentId_schedules",
        "parameters": [
          {
            "description": "Идентификатор агента",
            "in": "path",
            "name": "agentId",
            "required": true,
            "schema": {
              "description": "Идентификатор агента",
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "channels": {
                    "description": "Куда присылать результат",
                    "items": {
                      "description": "chat — беседа задания, telegram — привязанный Telegram, email — почта автора",
                      "enum": [
                        "chat",
                        "telegram",
                        "email"
                      ],
                      "type": "string"
                    },
                    "maxItems": 3,
                    "type": "array"
                  },
                  "endsOn": {
                    "default": null,
                    "description": "Последний день работы; null — без окончания",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2})?$",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "name": {
                    "description": "Название",
                    "maxLength": 200,
                    "minLength": 1,
                    "type": "string"
                  },
                  "overlap": {
                    "default": "skip",
                    "description": "Если к очередному запуску предыдущий ещё идёт: skip — пропустить очередной запуск, queue — выполнить его сразу после текущего, replace — остановить текущий и начать новый",
                    "enum": [
                      "skip",
                      "queue",
                      "replace"
                    ],
                    "type": "string"
                  },
                  "prompt": {
                    "description": "Что должен сделать агент",
                    "maxLength": 5000,
                    "minLength": 1,
                    "type": "string"
                  },
                  "repeat": {
                    "default": null,
                    "description": "Число повторов; null — без ограничения",
                    "maximum": 1000,
                    "minimum": 1,
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "schedule": {
                    "description": "Расписание",
                    "maxLength": 200,
                    "minLength": 1,
                    "type": "string"
                  },
                  "startsOn": {
                    "default": null,
                    "description": "Дата начала; null — сразу",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2})?$",
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "required": [
                  "name",
                  "schedule",
                  "prompt",
                  "channels"
                ],
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "agentId": {
                      "description": "Идентификатор агента",
                      "type": "string"
                    },
                    "channels": {
                      "description": "Куда присылать результат",
                      "items": {
                        "description": "chat — беседа задания, telegram — привязанный Telegram, email — почта автора",
                        "enum": [
                          "chat",
                          "telegram",
                          "email"
                        ],
                        "type": "string"
                      },
                      "type": "array"
                    },
                    "conversationId": {
                      "description": "Беседа, куда приходят результаты",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "createdAt": {
                      "description": "Создано, ISO 8601",
                      "type": "string"
                    },
                    "endsOn": {
                      "description": "Последний день работы; null — без окончания",
                      "pattern": "^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2})?$",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "hold": {
                      "description": "Остановка администратором; null — не остановлено",
                      "properties": {
                        "at": {
                          "description": "Когда, ISO 8601",
                          "type": "string"
                        },
                        "byUserId": {
                          "description": "Кто остановил",
                          "type": "string"
                        },
                        "reason": {
                          "description": "Причина",
                          "type": "string"
                        }
                      },
                      "required": [
                        "byUserId",
                        "at",
                        "reason"
                      ],
                      "type": [
                        "object",
                        "null"
                      ]
                    },
                    "id": {
                      "description": "Идентификатор задания",
                      "type": "string"
                    },
                    "lastFailed": {
                      "description": "Последний запуск завершился ошибкой",
                      "type": "boolean"
                    },
                    "lastRunAt": {
                      "description": "Последний запуск, ISO 8601",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "name": {
                      "description": "Название",
                      "type": "string"
                    },
                    "nextRunAt": {
                      "description": "Следующий запуск, ISO 8601",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "origin": {
                      "description": "Где создано: chat — в чате, telegram — в Telegram, panel — в разделе «Агенты», agent — агентом",
                      "enum": [
                        "chat",
                        "telegram",
                        "panel",
                        "agent"
                      ],
                      "type": "string"
                    },
                    "overlap": {
                      "description": "Если к очередному запуску предыдущий ещё идёт: skip — пропустить очередной запуск, queue — выполнить его сразу после текущего, replace — остановить текущий и начать новый",
                      "enum": [
                        "skip",
                        "queue",
                        "replace"
                      ],
                      "type": "string"
                    },
                    "prompt": {
                      "description": "Что делает агент",
                      "type": "string"
                    },
                    "quotaPaused": {
                      "description": "Приостановлено, пока исчерпан месячный лимит работы агента; продолжится автоматически",
                      "type": "boolean"
                    },
                    "repeatDone": {
                      "description": "Сколько раз задание уже выполнено",
                      "type": "integer"
                    },
                    "repeatTimes": {
                      "description": "Число повторов; null — без ограничения",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "schedule": {
                      "description": "Расписание: выражение cron, every Nm или дата однократного запуска",
                      "type": "string"
                    },
                    "startsOn": {
                      "description": "Дата начала; null — сразу",
                      "pattern": "^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2})?$",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "state": {
                      "description": "active — работает по расписанию, paused — на паузе, running — выполняется прямо сейчас, finished — запусков больше не будет",
                      "enum": [
                        "active",
                        "paused",
                        "running",
                        "finished"
                      ],
                      "type": "string"
                    },
                    "upcoming": {
                      "description": "Ближайшие запуски",
                      "items": {
                        "properties": {
                          "at": {
                            "description": "Время запуска, ISO 8601",
                            "type": "string"
                          },
                          "label": {
                            "description": "Время запуска по-русски в часовом поясе команды",
                            "type": "string"
                          }
                        },
                        "required": [
                          "at",
                          "label"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "userId": {
                      "description": "Автор задания",
                      "type": "string"
                    },
                    "waiting": {
                      "description": "Ждёт даты начала",
                      "type": "boolean"
                    },
                    "webhook": {
                      "description": "Включён ли вебхук, по которому внешняя система запускает задание вне расписания",
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "id",
                    "agentId",
                    "userId",
                    "name",
                    "prompt",
                    "schedule",
                    "state",
                    "nextRunAt",
                    "lastRunAt",
                    "lastFailed",
                    "origin",
                    "conversationId",
                    "channels",
                    "hold",
                    "quotaPaused",
                    "webhook",
                    "overlap",
                    "createdAt",
                    "startsOn",
                    "endsOn",
                    "repeatTimes",
                    "repeatDone",
                    "waiting",
                    "upcoming"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Созданное задание"
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Некорректный запрос: не прошла валидация параметров или тела"
          },
          "401": {
            "description": "Не авторизован"
          },
          "403": {
            "description": "Недостаточно прав на агента"
          }
        },
        "security": [
          {
            "dpop": []
          }
        ],
        "summary": "Создать задание агента по расписанию",
        "tags": [
          "collaboration:agents"
        ]
      }
    },
    "/ws/api/agents/{agentId}/schedules/{scheduleId}": {
      "delete": {
        "description": "Автор удаляет своё задание; администратор или владелец команды — любое задание команды.",
        "operationId": "delete_ws_api_agents_agentId_schedules_scheduleId",
        "parameters": [
          {
            "description": "Идентификатор агента",
            "in": "path",
            "name": "agentId",
            "required": true,
            "schema": {
              "description": "Идентификатор агента",
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "description": "Идентификатор задания",
            "in": "path",
            "name": "scheduleId",
            "required": true,
            "schema": {
              "description": "Идентификатор задания",
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "ok": {
                      "description": "Операция выполнена",
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "ok"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Задание удалено"
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Некорректный запрос: не прошла валидация параметров или тела"
          },
          "401": {
            "description": "Не авторизован"
          },
          "403": {
            "description": "Недостаточно прав на агента"
          }
        },
        "security": [
          {
            "dpop": []
          }
        ],
        "summary": "Удалить задание",
        "tags": [
          "collaboration:agents"
        ]
      },
      "patch": {
        "operationId": "patch_ws_api_agents_agentId_schedules_scheduleId",
        "parameters": [
          {
            "description": "Идентификатор агента",
            "in": "path",
            "name": "agentId",
            "required": true,
            "schema": {
              "description": "Идентификатор агента",
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "description": "Идентификатор задания",
            "in": "path",
            "name": "scheduleId",
            "required": true,
            "schema": {
              "description": "Идентификатор задания",
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "channels": {
                    "description": "Куда присылать результат",
                    "items": {
                      "description": "chat — беседа задания, telegram — привязанный Telegram, email — почта автора",
                      "enum": [
                        "chat",
                        "telegram",
                        "email"
                      ],
                      "type": "string"
                    },
                    "maxItems": 3,
                    "type": "array"
                  },
                  "endsOn": {
                    "description": "Последний день работы; null — без окончания",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2})?$",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "name": {
                    "description": "Название",
                    "maxLength": 200,
                    "minLength": 1,
                    "type": "string"
                  },
                  "overlap": {
                    "description": "Если к очередному запуску предыдущий ещё идёт: skip — пропустить очередной запуск, queue — выполнить его сразу после текущего, replace — остановить текущий и начать новый",
                    "enum": [
                      "skip",
                      "queue",
                      "replace"
                    ],
                    "type": "string"
                  },
                  "prompt": {
                    "description": "Что должен сделать агент",
                    "maxLength": 5000,
                    "minLength": 1,
                    "type": "string"
                  },
                  "repeat": {
                    "description": "Число повторов; null — без ограничения",
                    "maximum": 1000,
                    "minimum": 1,
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "schedule": {
                    "description": "Расписание",
                    "maxLength": 200,
                    "minLength": 1,
                    "type": "string"
                  },
                  "startsOn": {
                    "description": "Дата начала; null — сразу",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2})?$",
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "agentId": {
                      "description": "Идентификатор агента",
                      "type": "string"
                    },
                    "channels": {
                      "description": "Куда присылать результат",
                      "items": {
                        "description": "chat — беседа задания, telegram — привязанный Telegram, email — почта автора",
                        "enum": [
                          "chat",
                          "telegram",
                          "email"
                        ],
                        "type": "string"
                      },
                      "type": "array"
                    },
                    "conversationId": {
                      "description": "Беседа, куда приходят результаты",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "createdAt": {
                      "description": "Создано, ISO 8601",
                      "type": "string"
                    },
                    "endsOn": {
                      "description": "Последний день работы; null — без окончания",
                      "pattern": "^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2})?$",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "hold": {
                      "description": "Остановка администратором; null — не остановлено",
                      "properties": {
                        "at": {
                          "description": "Когда, ISO 8601",
                          "type": "string"
                        },
                        "byUserId": {
                          "description": "Кто остановил",
                          "type": "string"
                        },
                        "reason": {
                          "description": "Причина",
                          "type": "string"
                        }
                      },
                      "required": [
                        "byUserId",
                        "at",
                        "reason"
                      ],
                      "type": [
                        "object",
                        "null"
                      ]
                    },
                    "id": {
                      "description": "Идентификатор задания",
                      "type": "string"
                    },
                    "lastFailed": {
                      "description": "Последний запуск завершился ошибкой",
                      "type": "boolean"
                    },
                    "lastRunAt": {
                      "description": "Последний запуск, ISO 8601",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "name": {
                      "description": "Название",
                      "type": "string"
                    },
                    "nextRunAt": {
                      "description": "Следующий запуск, ISO 8601",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "origin": {
                      "description": "Где создано: chat — в чате, telegram — в Telegram, panel — в разделе «Агенты», agent — агентом",
                      "enum": [
                        "chat",
                        "telegram",
                        "panel",
                        "agent"
                      ],
                      "type": "string"
                    },
                    "overlap": {
                      "description": "Если к очередному запуску предыдущий ещё идёт: skip — пропустить очередной запуск, queue — выполнить его сразу после текущего, replace — остановить текущий и начать новый",
                      "enum": [
                        "skip",
                        "queue",
                        "replace"
                      ],
                      "type": "string"
                    },
                    "prompt": {
                      "description": "Что делает агент",
                      "type": "string"
                    },
                    "quotaPaused": {
                      "description": "Приостановлено, пока исчерпан месячный лимит работы агента; продолжится автоматически",
                      "type": "boolean"
                    },
                    "repeatDone": {
                      "description": "Сколько раз задание уже выполнено",
                      "type": "integer"
                    },
                    "repeatTimes": {
                      "description": "Число повторов; null — без ограничения",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "schedule": {
                      "description": "Расписание: выражение cron, every Nm или дата однократного запуска",
                      "type": "string"
                    },
                    "startsOn": {
                      "description": "Дата начала; null — сразу",
                      "pattern": "^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2})?$",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "state": {
                      "description": "active — работает по расписанию, paused — на паузе, running — выполняется прямо сейчас, finished — запусков больше не будет",
                      "enum": [
                        "active",
                        "paused",
                        "running",
                        "finished"
                      ],
                      "type": "string"
                    },
                    "upcoming": {
                      "description": "Ближайшие запуски",
                      "items": {
                        "properties": {
                          "at": {
                            "description": "Время запуска, ISO 8601",
                            "type": "string"
                          },
                          "label": {
                            "description": "Время запуска по-русски в часовом поясе команды",
                            "type": "string"
                          }
                        },
                        "required": [
                          "at",
                          "label"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "userId": {
                      "description": "Автор задания",
                      "type": "string"
                    },
                    "waiting": {
                      "description": "Ждёт даты начала",
                      "type": "boolean"
                    },
                    "webhook": {
                      "description": "Включён ли вебхук, по которому внешняя система запускает задание вне расписания",
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "id",
                    "agentId",
                    "userId",
                    "name",
                    "prompt",
                    "schedule",
                    "state",
                    "nextRunAt",
                    "lastRunAt",
                    "lastFailed",
                    "origin",
                    "conversationId",
                    "channels",
                    "hold",
                    "quotaPaused",
                    "webhook",
                    "overlap",
                    "createdAt",
                    "startsOn",
                    "endsOn",
                    "repeatTimes",
                    "repeatDone",
                    "waiting",
                    "upcoming"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Изменённое задание"
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Некорректный запрос: не прошла валидация параметров или тела"
          },
          "401": {
            "description": "Не авторизован"
          },
          "403": {
            "description": "Недостаточно прав на агента"
          }
        },
        "security": [
          {
            "dpop": []
          }
        ],
        "summary": "Изменить своё задание по расписанию",
        "tags": [
          "collaboration:agents"
        ]
      }
    },
    "/ws/api/agents/{agentId}/schedules/{scheduleId}/hold": {
      "post": {
        "description": "Доступно администраторам и владельцу команды. Задание останавливается, автор видит причину и получает сообщение; возобновить его может только администратор или владелец команды.",
        "operationId": "post_ws_api_agents_agentId_schedules_scheduleId_hold",
        "parameters": [
          {
            "description": "Идентификатор агента",
            "in": "path",
            "name": "agentId",
            "required": true,
            "schema": {
              "description": "Идентификатор агента",
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "description": "Идентификатор задания",
            "in": "path",
            "name": "scheduleId",
            "required": true,
            "schema": {
              "description": "Идентификатор задания",
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "reason": {
                    "description": "Причина остановки",
                    "maxLength": 500,
                    "minLength": 1,
                    "type": "string"
                  }
                },
                "required": [
                  "reason"
                ],
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "agentId": {
                      "description": "Идентификатор агента",
                      "type": "string"
                    },
                    "channels": {
                      "description": "Куда присылать результат",
                      "items": {
                        "description": "chat — беседа задания, telegram — привязанный Telegram, email — почта автора",
                        "enum": [
                          "chat",
                          "telegram",
                          "email"
                        ],
                        "type": "string"
                      },
                      "type": "array"
                    },
                    "conversationId": {
                      "description": "Беседа, куда приходят результаты",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "createdAt": {
                      "description": "Создано, ISO 8601",
                      "type": "string"
                    },
                    "endsOn": {
                      "description": "Последний день работы; null — без окончания",
                      "pattern": "^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2})?$",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "hold": {
                      "description": "Остановка администратором; null — не остановлено",
                      "properties": {
                        "at": {
                          "description": "Когда, ISO 8601",
                          "type": "string"
                        },
                        "byUserId": {
                          "description": "Кто остановил",
                          "type": "string"
                        },
                        "reason": {
                          "description": "Причина",
                          "type": "string"
                        }
                      },
                      "required": [
                        "byUserId",
                        "at",
                        "reason"
                      ],
                      "type": [
                        "object",
                        "null"
                      ]
                    },
                    "id": {
                      "description": "Идентификатор задания",
                      "type": "string"
                    },
                    "lastFailed": {
                      "description": "Последний запуск завершился ошибкой",
                      "type": "boolean"
                    },
                    "lastRunAt": {
                      "description": "Последний запуск, ISO 8601",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "name": {
                      "description": "Название",
                      "type": "string"
                    },
                    "nextRunAt": {
                      "description": "Следующий запуск, ISO 8601",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "origin": {
                      "description": "Где создано: chat — в чате, telegram — в Telegram, panel — в разделе «Агенты», agent — агентом",
                      "enum": [
                        "chat",
                        "telegram",
                        "panel",
                        "agent"
                      ],
                      "type": "string"
                    },
                    "overlap": {
                      "description": "Если к очередному запуску предыдущий ещё идёт: skip — пропустить очередной запуск, queue — выполнить его сразу после текущего, replace — остановить текущий и начать новый",
                      "enum": [
                        "skip",
                        "queue",
                        "replace"
                      ],
                      "type": "string"
                    },
                    "prompt": {
                      "description": "Что делает агент",
                      "type": "string"
                    },
                    "quotaPaused": {
                      "description": "Приостановлено, пока исчерпан месячный лимит работы агента; продолжится автоматически",
                      "type": "boolean"
                    },
                    "repeatDone": {
                      "description": "Сколько раз задание уже выполнено",
                      "type": "integer"
                    },
                    "repeatTimes": {
                      "description": "Число повторов; null — без ограничения",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "schedule": {
                      "description": "Расписание: выражение cron, every Nm или дата однократного запуска",
                      "type": "string"
                    },
                    "startsOn": {
                      "description": "Дата начала; null — сразу",
                      "pattern": "^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2})?$",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "state": {
                      "description": "active — работает по расписанию, paused — на паузе, running — выполняется прямо сейчас, finished — запусков больше не будет",
                      "enum": [
                        "active",
                        "paused",
                        "running",
                        "finished"
                      ],
                      "type": "string"
                    },
                    "upcoming": {
                      "description": "Ближайшие запуски",
                      "items": {
                        "properties": {
                          "at": {
                            "description": "Время запуска, ISO 8601",
                            "type": "string"
                          },
                          "label": {
                            "description": "Время запуска по-русски в часовом поясе команды",
                            "type": "string"
                          }
                        },
                        "required": [
                          "at",
                          "label"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "userId": {
                      "description": "Автор задания",
                      "type": "string"
                    },
                    "waiting": {
                      "description": "Ждёт даты начала",
                      "type": "boolean"
                    },
                    "webhook": {
                      "description": "Включён ли вебхук, по которому внешняя система запускает задание вне расписания",
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "id",
                    "agentId",
                    "userId",
                    "name",
                    "prompt",
                    "schedule",
                    "state",
                    "nextRunAt",
                    "lastRunAt",
                    "lastFailed",
                    "origin",
                    "conversationId",
                    "channels",
                    "hold",
                    "quotaPaused",
                    "webhook",
                    "overlap",
                    "createdAt",
                    "startsOn",
                    "endsOn",
                    "repeatTimes",
                    "repeatDone",
                    "waiting",
                    "upcoming"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Остановленное задание"
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Некорректный запрос: не прошла валидация параметров или тела"
          },
          "401": {
            "description": "Не авторизован"
          },
          "403": {
            "description": "Недостаточно прав на агента"
          }
        },
        "security": [
          {
            "dpop": []
          }
        ],
        "summary": "Остановить задание сотрудника",
        "tags": [
          "collaboration:agents"
        ]
      }
    },
    "/ws/api/agents/{agentId}/schedules/{scheduleId}/pause": {
      "post": {
        "operationId": "post_ws_api_agents_agentId_schedules_scheduleId_pause",
        "parameters": [
          {
            "description": "Идентификатор агента",
            "in": "path",
            "name": "agentId",
            "required": true,
            "schema": {
              "description": "Идентификатор агента",
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "description": "Идентификатор задания",
            "in": "path",
            "name": "scheduleId",
            "required": true,
            "schema": {
              "description": "Идентификатор задания",
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "agentId": {
                      "description": "Идентификатор агента",
                      "type": "string"
                    },
                    "channels": {
                      "description": "Куда присылать результат",
                      "items": {
                        "description": "chat — беседа задания, telegram — привязанный Telegram, email — почта автора",
                        "enum": [
                          "chat",
                          "telegram",
                          "email"
                        ],
                        "type": "string"
                      },
                      "type": "array"
                    },
                    "conversationId": {
                      "description": "Беседа, куда приходят результаты",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "createdAt": {
                      "description": "Создано, ISO 8601",
                      "type": "string"
                    },
                    "endsOn": {
                      "description": "Последний день работы; null — без окончания",
                      "pattern": "^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2})?$",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "hold": {
                      "description": "Остановка администратором; null — не остановлено",
                      "properties": {
                        "at": {
                          "description": "Когда, ISO 8601",
                          "type": "string"
                        },
                        "byUserId": {
                          "description": "Кто остановил",
                          "type": "string"
                        },
                        "reason": {
                          "description": "Причина",
                          "type": "string"
                        }
                      },
                      "required": [
                        "byUserId",
                        "at",
                        "reason"
                      ],
                      "type": [
                        "object",
                        "null"
                      ]
                    },
                    "id": {
                      "description": "Идентификатор задания",
                      "type": "string"
                    },
                    "lastFailed": {
                      "description": "Последний запуск завершился ошибкой",
                      "type": "boolean"
                    },
                    "lastRunAt": {
                      "description": "Последний запуск, ISO 8601",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "name": {
                      "description": "Название",
                      "type": "string"
                    },
                    "nextRunAt": {
                      "description": "Следующий запуск, ISO 8601",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "origin": {
                      "description": "Где создано: chat — в чате, telegram — в Telegram, panel — в разделе «Агенты», agent — агентом",
                      "enum": [
                        "chat",
                        "telegram",
                        "panel",
                        "agent"
                      ],
                      "type": "string"
                    },
                    "overlap": {
                      "description": "Если к очередному запуску предыдущий ещё идёт: skip — пропустить очередной запуск, queue — выполнить его сразу после текущего, replace — остановить текущий и начать новый",
                      "enum": [
                        "skip",
                        "queue",
                        "replace"
                      ],
                      "type": "string"
                    },
                    "prompt": {
                      "description": "Что делает агент",
                      "type": "string"
                    },
                    "quotaPaused": {
                      "description": "Приостановлено, пока исчерпан месячный лимит работы агента; продолжится автоматически",
                      "type": "boolean"
                    },
                    "repeatDone": {
                      "description": "Сколько раз задание уже выполнено",
                      "type": "integer"
                    },
                    "repeatTimes": {
                      "description": "Число повторов; null — без ограничения",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "schedule": {
                      "description": "Расписание: выражение cron, every Nm или дата однократного запуска",
                      "type": "string"
                    },
                    "startsOn": {
                      "description": "Дата начала; null — сразу",
                      "pattern": "^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2})?$",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "state": {
                      "description": "active — работает по расписанию, paused — на паузе, running — выполняется прямо сейчас, finished — запусков больше не будет",
                      "enum": [
                        "active",
                        "paused",
                        "running",
                        "finished"
                      ],
                      "type": "string"
                    },
                    "upcoming": {
                      "description": "Ближайшие запуски",
                      "items": {
                        "properties": {
                          "at": {
                            "description": "Время запуска, ISO 8601",
                            "type": "string"
                          },
                          "label": {
                            "description": "Время запуска по-русски в часовом поясе команды",
                            "type": "string"
                          }
                        },
                        "required": [
                          "at",
                          "label"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "userId": {
                      "description": "Автор задания",
                      "type": "string"
                    },
                    "waiting": {
                      "description": "Ждёт даты начала",
                      "type": "boolean"
                    },
                    "webhook": {
                      "description": "Включён ли вебхук, по которому внешняя система запускает задание вне расписания",
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "id",
                    "agentId",
                    "userId",
                    "name",
                    "prompt",
                    "schedule",
                    "state",
                    "nextRunAt",
                    "lastRunAt",
                    "lastFailed",
                    "origin",
                    "conversationId",
                    "channels",
                    "hold",
                    "quotaPaused",
                    "webhook",
                    "overlap",
                    "createdAt",
                    "startsOn",
                    "endsOn",
                    "repeatTimes",
                    "repeatDone",
                    "waiting",
                    "upcoming"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Задание"
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Некорректный запрос: не прошла валидация параметров или тела"
          },
          "401": {
            "description": "Не авторизован"
          },
          "403": {
            "description": "Недостаточно прав на агента"
          }
        },
        "security": [
          {
            "dpop": []
          }
        ],
        "summary": "Приостановить своё задание",
        "tags": [
          "collaboration:agents"
        ]
      }
    },
    "/ws/api/agents/{agentId}/schedules/{scheduleId}/release": {
      "post": {
        "description": "Доступно администраторам и владельцу команды.",
        "operationId": "post_ws_api_agents_agentId_schedules_scheduleId_release",
        "parameters": [
          {
            "description": "Идентификатор агента",
            "in": "path",
            "name": "agentId",
            "required": true,
            "schema": {
              "description": "Идентификатор агента",
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "description": "Идентификатор задания",
            "in": "path",
            "name": "scheduleId",
            "required": true,
            "schema": {
              "description": "Идентификатор задания",
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "agentId": {
                      "description": "Идентификатор агента",
                      "type": "string"
                    },
                    "channels": {
                      "description": "Куда присылать результат",
                      "items": {
                        "description": "chat — беседа задания, telegram — привязанный Telegram, email — почта автора",
                        "enum": [
                          "chat",
                          "telegram",
                          "email"
                        ],
                        "type": "string"
                      },
                      "type": "array"
                    },
                    "conversationId": {
                      "description": "Беседа, куда приходят результаты",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "createdAt": {
                      "description": "Создано, ISO 8601",
                      "type": "string"
                    },
                    "endsOn": {
                      "description": "Последний день работы; null — без окончания",
                      "pattern": "^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2})?$",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "hold": {
                      "description": "Остановка администратором; null — не остановлено",
                      "properties": {
                        "at": {
                          "description": "Когда, ISO 8601",
                          "type": "string"
                        },
                        "byUserId": {
                          "description": "Кто остановил",
                          "type": "string"
                        },
                        "reason": {
                          "description": "Причина",
                          "type": "string"
                        }
                      },
                      "required": [
                        "byUserId",
                        "at",
                        "reason"
                      ],
                      "type": [
                        "object",
                        "null"
                      ]
                    },
                    "id": {
                      "description": "Идентификатор задания",
                      "type": "string"
                    },
                    "lastFailed": {
                      "description": "Последний запуск завершился ошибкой",
                      "type": "boolean"
                    },
                    "lastRunAt": {
                      "description": "Последний запуск, ISO 8601",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "name": {
                      "description": "Название",
                      "type": "string"
                    },
                    "nextRunAt": {
                      "description": "Следующий запуск, ISO 8601",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "origin": {
                      "description": "Где создано: chat — в чате, telegram — в Telegram, panel — в разделе «Агенты», agent — агентом",
                      "enum": [
                        "chat",
                        "telegram",
                        "panel",
                        "agent"
                      ],
                      "type": "string"
                    },
                    "overlap": {
                      "description": "Если к очередному запуску предыдущий ещё идёт: skip — пропустить очередной запуск, queue — выполнить его сразу после текущего, replace — остановить текущий и начать новый",
                      "enum": [
                        "skip",
                        "queue",
                        "replace"
                      ],
                      "type": "string"
                    },
                    "prompt": {
                      "description": "Что делает агент",
                      "type": "string"
                    },
                    "quotaPaused": {
                      "description": "Приостановлено, пока исчерпан месячный лимит работы агента; продолжится автоматически",
                      "type": "boolean"
                    },
                    "repeatDone": {
                      "description": "Сколько раз задание уже выполнено",
                      "type": "integer"
                    },
                    "repeatTimes": {
                      "description": "Число повторов; null — без ограничения",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "schedule": {
                      "description": "Расписание: выражение cron, every Nm или дата однократного запуска",
                      "type": "string"
                    },
                    "startsOn": {
                      "description": "Дата начала; null — сразу",
                      "pattern": "^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2})?$",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "state": {
                      "description": "active — работает по расписанию, paused — на паузе, running — выполняется прямо сейчас, finished — запусков больше не будет",
                      "enum": [
                        "active",
                        "paused",
                        "running",
                        "finished"
                      ],
                      "type": "string"
                    },
                    "upcoming": {
                      "description": "Ближайшие запуски",
                      "items": {
                        "properties": {
                          "at": {
                            "description": "Время запуска, ISO 8601",
                            "type": "string"
                          },
                          "label": {
                            "description": "Время запуска по-русски в часовом поясе команды",
                            "type": "string"
                          }
                        },
                        "required": [
                          "at",
                          "label"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "userId": {
                      "description": "Автор задания",
                      "type": "string"
                    },
                    "waiting": {
                      "description": "Ждёт даты начала",
                      "type": "boolean"
                    },
                    "webhook": {
                      "description": "Включён ли вебхук, по которому внешняя система запускает задание вне расписания",
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "id",
                    "agentId",
                    "userId",
                    "name",
                    "prompt",
                    "schedule",
                    "state",
                    "nextRunAt",
                    "lastRunAt",
                    "lastFailed",
                    "origin",
                    "conversationId",
                    "channels",
                    "hold",
                    "quotaPaused",
                    "webhook",
                    "overlap",
                    "createdAt",
                    "startsOn",
                    "endsOn",
                    "repeatTimes",
                    "repeatDone",
                    "waiting",
                    "upcoming"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Задание"
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Некорректный запрос: не прошла валидация параметров или тела"
          },
          "401": {
            "description": "Не авторизован"
          },
          "403": {
            "description": "Недостаточно прав на агента"
          }
        },
        "security": [
          {
            "dpop": []
          }
        ],
        "summary": "Снять остановку задания",
        "tags": [
          "collaboration:agents"
        ]
      }
    },
    "/ws/api/agents/{agentId}/schedules/{scheduleId}/resume": {
      "post": {
        "operationId": "post_ws_api_agents_agentId_schedules_scheduleId_resume",
        "parameters": [
          {
            "description": "Идентификатор агента",
            "in": "path",
            "name": "agentId",
            "required": true,
            "schema": {
              "description": "Идентификатор агента",
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "description": "Идентификатор задания",
            "in": "path",
            "name": "scheduleId",
            "required": true,
            "schema": {
              "description": "Идентификатор задания",
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "agentId": {
                      "description": "Идентификатор агента",
                      "type": "string"
                    },
                    "channels": {
                      "description": "Куда присылать результат",
                      "items": {
                        "description": "chat — беседа задания, telegram — привязанный Telegram, email — почта автора",
                        "enum": [
                          "chat",
                          "telegram",
                          "email"
                        ],
                        "type": "string"
                      },
                      "type": "array"
                    },
                    "conversationId": {
                      "description": "Беседа, куда приходят результаты",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "createdAt": {
                      "description": "Создано, ISO 8601",
                      "type": "string"
                    },
                    "endsOn": {
                      "description": "Последний день работы; null — без окончания",
                      "pattern": "^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2})?$",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "hold": {
                      "description": "Остановка администратором; null — не остановлено",
                      "properties": {
                        "at": {
                          "description": "Когда, ISO 8601",
                          "type": "string"
                        },
                        "byUserId": {
                          "description": "Кто остановил",
                          "type": "string"
                        },
                        "reason": {
                          "description": "Причина",
                          "type": "string"
                        }
                      },
                      "required": [
                        "byUserId",
                        "at",
                        "reason"
                      ],
                      "type": [
                        "object",
                        "null"
                      ]
                    },
                    "id": {
                      "description": "Идентификатор задания",
                      "type": "string"
                    },
                    "lastFailed": {
                      "description": "Последний запуск завершился ошибкой",
                      "type": "boolean"
                    },
                    "lastRunAt": {
                      "description": "Последний запуск, ISO 8601",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "name": {
                      "description": "Название",
                      "type": "string"
                    },
                    "nextRunAt": {
                      "description": "Следующий запуск, ISO 8601",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "origin": {
                      "description": "Где создано: chat — в чате, telegram — в Telegram, panel — в разделе «Агенты», agent — агентом",
                      "enum": [
                        "chat",
                        "telegram",
                        "panel",
                        "agent"
                      ],
                      "type": "string"
                    },
                    "overlap": {
                      "description": "Если к очередному запуску предыдущий ещё идёт: skip — пропустить очередной запуск, queue — выполнить его сразу после текущего, replace — остановить текущий и начать новый",
                      "enum": [
                        "skip",
                        "queue",
                        "replace"
                      ],
                      "type": "string"
                    },
                    "prompt": {
                      "description": "Что делает агент",
                      "type": "string"
                    },
                    "quotaPaused": {
                      "description": "Приостановлено, пока исчерпан месячный лимит работы агента; продолжится автоматически",
                      "type": "boolean"
                    },
                    "repeatDone": {
                      "description": "Сколько раз задание уже выполнено",
                      "type": "integer"
                    },
                    "repeatTimes": {
                      "description": "Число повторов; null — без ограничения",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "schedule": {
                      "description": "Расписание: выражение cron, every Nm или дата однократного запуска",
                      "type": "string"
                    },
                    "startsOn": {
                      "description": "Дата начала; null — сразу",
                      "pattern": "^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2})?$",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "state": {
                      "description": "active — работает по расписанию, paused — на паузе, running — выполняется прямо сейчас, finished — запусков больше не будет",
                      "enum": [
                        "active",
                        "paused",
                        "running",
                        "finished"
                      ],
                      "type": "string"
                    },
                    "upcoming": {
                      "description": "Ближайшие запуски",
                      "items": {
                        "properties": {
                          "at": {
                            "description": "Время запуска, ISO 8601",
                            "type": "string"
                          },
                          "label": {
                            "description": "Время запуска по-русски в часовом поясе команды",
                            "type": "string"
                          }
                        },
                        "required": [
                          "at",
                          "label"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "userId": {
                      "description": "Автор задания",
                      "type": "string"
                    },
                    "waiting": {
                      "description": "Ждёт даты начала",
                      "type": "boolean"
                    },
                    "webhook": {
                      "description": "Включён ли вебхук, по которому внешняя система запускает задание вне расписания",
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "id",
                    "agentId",
                    "userId",
                    "name",
                    "prompt",
                    "schedule",
                    "state",
                    "nextRunAt",
                    "lastRunAt",
                    "lastFailed",
                    "origin",
                    "conversationId",
                    "channels",
                    "hold",
                    "quotaPaused",
                    "webhook",
                    "overlap",
                    "createdAt",
                    "startsOn",
                    "endsOn",
                    "repeatTimes",
                    "repeatDone",
                    "waiting",
                    "upcoming"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Задание"
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Некорректный запрос: не прошла валидация параметров или тела"
          },
          "401": {
            "description": "Не авторизован"
          },
          "403": {
            "description": "Недостаточно прав на агента"
          }
        },
        "security": [
          {
            "dpop": []
          }
        ],
        "summary": "Возобновить своё задание",
        "tags": [
          "collaboration:agents"
        ]
      }
    },
    "/ws/api/agents/{agentId}/schedules/{scheduleId}/run": {
      "post": {
        "operationId": "post_ws_api_agents_agentId_schedules_scheduleId_run",
        "parameters": [
          {
            "description": "Идентификатор агента",
            "in": "path",
            "name": "agentId",
            "required": true,
            "schema": {
              "description": "Идентификатор агента",
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "description": "Идентификатор задания",
            "in": "path",
            "name": "scheduleId",
            "required": true,
            "schema": {
              "description": "Идентификатор задания",
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "agentId": {
                      "description": "Идентификатор агента",
                      "type": "string"
                    },
                    "channels": {
                      "description": "Куда присылать результат",
                      "items": {
                        "description": "chat — беседа задания, telegram — привязанный Telegram, email — почта автора",
                        "enum": [
                          "chat",
                          "telegram",
                          "email"
                        ],
                        "type": "string"
                      },
                      "type": "array"
                    },
                    "conversationId": {
                      "description": "Беседа, куда приходят результаты",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "createdAt": {
                      "description": "Создано, ISO 8601",
                      "type": "string"
                    },
                    "endsOn": {
                      "description": "Последний день работы; null — без окончания",
                      "pattern": "^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2})?$",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "hold": {
                      "description": "Остановка администратором; null — не остановлено",
                      "properties": {
                        "at": {
                          "description": "Когда, ISO 8601",
                          "type": "string"
                        },
                        "byUserId": {
                          "description": "Кто остановил",
                          "type": "string"
                        },
                        "reason": {
                          "description": "Причина",
                          "type": "string"
                        }
                      },
                      "required": [
                        "byUserId",
                        "at",
                        "reason"
                      ],
                      "type": [
                        "object",
                        "null"
                      ]
                    },
                    "id": {
                      "description": "Идентификатор задания",
                      "type": "string"
                    },
                    "lastFailed": {
                      "description": "Последний запуск завершился ошибкой",
                      "type": "boolean"
                    },
                    "lastRunAt": {
                      "description": "Последний запуск, ISO 8601",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "name": {
                      "description": "Название",
                      "type": "string"
                    },
                    "nextRunAt": {
                      "description": "Следующий запуск, ISO 8601",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "origin": {
                      "description": "Где создано: chat — в чате, telegram — в Telegram, panel — в разделе «Агенты», agent — агентом",
                      "enum": [
                        "chat",
                        "telegram",
                        "panel",
                        "agent"
                      ],
                      "type": "string"
                    },
                    "overlap": {
                      "description": "Если к очередному запуску предыдущий ещё идёт: skip — пропустить очередной запуск, queue — выполнить его сразу после текущего, replace — остановить текущий и начать новый",
                      "enum": [
                        "skip",
                        "queue",
                        "replace"
                      ],
                      "type": "string"
                    },
                    "prompt": {
                      "description": "Что делает агент",
                      "type": "string"
                    },
                    "quotaPaused": {
                      "description": "Приостановлено, пока исчерпан месячный лимит работы агента; продолжится автоматически",
                      "type": "boolean"
                    },
                    "repeatDone": {
                      "description": "Сколько раз задание уже выполнено",
                      "type": "integer"
                    },
                    "repeatTimes": {
                      "description": "Число повторов; null — без ограничения",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "schedule": {
                      "description": "Расписание: выражение cron, every Nm или дата однократного запуска",
                      "type": "string"
                    },
                    "startsOn": {
                      "description": "Дата начала; null — сразу",
                      "pattern": "^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2})?$",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "state": {
                      "description": "active — работает по расписанию, paused — на паузе, running — выполняется прямо сейчас, finished — запусков больше не будет",
                      "enum": [
                        "active",
                        "paused",
                        "running",
                        "finished"
                      ],
                      "type": "string"
                    },
                    "upcoming": {
                      "description": "Ближайшие запуски",
                      "items": {
                        "properties": {
                          "at": {
                            "description": "Время запуска, ISO 8601",
                            "type": "string"
                          },
                          "label": {
                            "description": "Время запуска по-русски в часовом поясе команды",
                            "type": "string"
                          }
                        },
                        "required": [
                          "at",
                          "label"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "userId": {
                      "description": "Автор задания",
                      "type": "string"
                    },
                    "waiting": {
                      "description": "Ждёт даты начала",
                      "type": "boolean"
                    },
                    "webhook": {
                      "description": "Включён ли вебхук, по которому внешняя система запускает задание вне расписания",
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "id",
                    "agentId",
                    "userId",
                    "name",
                    "prompt",
                    "schedule",
                    "state",
                    "nextRunAt",
                    "lastRunAt",
                    "lastFailed",
                    "origin",
                    "conversationId",
                    "channels",
                    "hold",
                    "quotaPaused",
                    "webhook",
                    "overlap",
                    "createdAt",
                    "startsOn",
                    "endsOn",
                    "repeatTimes",
                    "repeatDone",
                    "waiting",
                    "upcoming"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Задание"
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Некорректный запрос: не прошла валидация параметров или тела"
          },
          "401": {
            "description": "Не авторизован"
          },
          "403": {
            "description": "Недостаточно прав на агента"
          }
        },
        "security": [
          {
            "dpop": []
          }
        ],
        "summary": "Запустить своё задание сейчас",
        "tags": [
          "collaboration:agents"
        ]
      }
    },
    "/ws/api/agents/{agentId}/schedules/{scheduleId}/runs": {
      "get": {
        "operationId": "get_ws_api_agents_agentId_schedules_scheduleId_runs",
        "parameters": [
          {
            "description": "Идентификатор агента",
            "in": "path",
            "name": "agentId",
            "required": true,
            "schema": {
              "description": "Идентификатор агента",
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "description": "Идентификатор задания",
            "in": "path",
            "name": "scheduleId",
            "required": true,
            "schema": {
              "description": "Идентификатор задания",
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "description": "Сколько запусков вернуть, до 50",
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 20,
              "description": "Сколько запусков вернуть, до 50",
              "maximum": 50,
              "minimum": 1,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "runs": {
                      "description": "Последние запуски",
                      "items": {
                        "properties": {
                          "awaitingDecision": {
                            "description": "Запуск ждёт решения автора по действиям",
                            "type": "boolean"
                          },
                          "content": {
                            "description": "Результат или причина неудачи",
                            "type": "string"
                          },
                          "finishedAt": {
                            "description": "Завершён, ISO 8601",
                            "type": "string"
                          },
                          "id": {
                            "description": "Идентификатор запуска",
                            "type": "string"
                          },
                          "outcome": {
                            "description": "reported — есть результат, silent — сообщать нечего, failed — не выполнено, stopped — остановлено",
                            "enum": [
                              "reported",
                              "silent",
                              "failed",
                              "stopped"
                            ],
                            "type": "string"
                          },
                          "runId": {
                            "description": "Запуск агента в журнале запусков",
                            "type": "string"
                          },
                          "trigger": {
                            "description": "schedule — по расписанию, manual — вручную, catchup — пропущенный запуск после восстановления лимита, webhook — по вебхуку",
                            "enum": [
                              "schedule",
                              "manual",
                              "catchup",
                              "webhook"
                            ],
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "finishedAt",
                          "outcome",
                          "content",
                          "awaitingDecision",
                          "runId",
                          "trigger"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    }
                  },
                  "required": [
                    "runs"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Запуски"
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Некорректный запрос: не прошла валидация параметров или тела"
          },
          "401": {
            "description": "Не авторизован"
          },
          "403": {
            "description": "Недостаточно прав на агента"
          }
        },
        "security": [
          {
            "dpop": []
          }
        ],
        "summary": "История запусков своего задания",
        "tags": [
          "collaboration:agents"
        ]
      }
    },
    "/ws/api/agents/{agentId}/schedules/{scheduleId}/webhook": {
      "post": {
        "description": "Вебхук позволяет внешней системе запускать задание вне расписания запросом по секретному адресу. При включении выпускается новый адрес, прежний перестаёт работать; адрес возвращается один раз. Доступно автору задания.",
        "operationId": "post_ws_api_agents_agentId_schedules_scheduleId_webhook",
        "parameters": [
          {
            "description": "Идентификатор агента",
            "in": "path",
            "name": "agentId",
            "required": true,
            "schema": {
              "description": "Идентификатор агента",
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "description": "Идентификатор задания",
            "in": "path",
            "name": "scheduleId",
            "required": true,
            "schema": {
              "description": "Идентификатор задания",
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "enabled": {
                    "description": "true — включить вебхук и выпустить новый адрес, false — отключить",
                    "type": "boolean"
                  }
                },
                "required": [
                  "enabled"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "schedule": {
                      "properties": {
                        "agentId": {
                          "description": "Идентификатор агента",
                          "type": "string"
                        },
                        "channels": {
                          "description": "Куда присылать результат",
                          "items": {
                            "description": "chat — беседа задания, telegram — привязанный Telegram, email — почта автора",
                            "enum": [
                              "chat",
                              "telegram",
                              "email"
                            ],
                            "type": "string"
                          },
                          "type": "array"
                        },
                        "conversationId": {
                          "description": "Беседа, куда приходят результаты",
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "createdAt": {
                          "description": "Создано, ISO 8601",
                          "type": "string"
                        },
                        "endsOn": {
                          "description": "Последний день работы; null — без окончания",
                          "pattern": "^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2})?$",
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "hold": {
                          "description": "Остановка администратором; null — не остановлено",
                          "properties": {
                            "at": {
                              "description": "Когда, ISO 8601",
                              "type": "string"
                            },
                            "byUserId": {
                              "description": "Кто остановил",
                              "type": "string"
                            },
                            "reason": {
                              "description": "Причина",
                              "type": "string"
                            }
                          },
                          "required": [
                            "byUserId",
                            "at",
                            "reason"
                          ],
                          "type": [
                            "object",
                            "null"
                          ]
                        },
                        "id": {
                          "description": "Идентификатор задания",
                          "type": "string"
                        },
                        "lastFailed": {
                          "description": "Последний запуск завершился ошибкой",
                          "type": "boolean"
                        },
                        "lastRunAt": {
                          "description": "Последний запуск, ISO 8601",
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "name": {
                          "description": "Название",
                          "type": "string"
                        },
                        "nextRunAt": {
                          "description": "Следующий запуск, ISO 8601",
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "origin": {
                          "description": "Где создано: chat — в чате, telegram — в Telegram, panel — в разделе «Агенты», agent — агентом",
                          "enum": [
                            "chat",
                            "telegram",
                            "panel",
                            "agent"
                          ],
                          "type": "string"
                        },
                        "overlap": {
                          "description": "Если к очередному запуску предыдущий ещё идёт: skip — пропустить очередной запуск, queue — выполнить его сразу после текущего, replace — остановить текущий и начать новый",
                          "enum": [
                            "skip",
                            "queue",
                            "replace"
                          ],
                          "type": "string"
                        },
                        "prompt": {
                          "description": "Что делает агент",
                          "type": "string"
                        },
                        "quotaPaused": {
                          "description": "Приостановлено, пока исчерпан месячный лимит работы агента; продолжится автоматически",
                          "type": "boolean"
                        },
                        "repeatDone": {
                          "description": "Сколько раз задание уже выполнено",
                          "type": "integer"
                        },
                        "repeatTimes": {
                          "description": "Число повторов; null — без ограничения",
                          "type": [
                            "integer",
                            "null"
                          ]
                        },
                        "schedule": {
                          "description": "Расписание: выражение cron, every Nm или дата однократного запуска",
                          "type": "string"
                        },
                        "startsOn": {
                          "description": "Дата начала; null — сразу",
                          "pattern": "^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2})?$",
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "state": {
                          "description": "active — работает по расписанию, paused — на паузе, running — выполняется прямо сейчас, finished — запусков больше не будет",
                          "enum": [
                            "active",
                            "paused",
                            "running",
                            "finished"
                          ],
                          "type": "string"
                        },
                        "upcoming": {
                          "description": "Ближайшие запуски",
                          "items": {
                            "properties": {
                              "at": {
                                "description": "Время запуска, ISO 8601",
                                "type": "string"
                              },
                              "label": {
                                "description": "Время запуска по-русски в часовом поясе команды",
                                "type": "string"
                              }
                            },
                            "required": [
                              "at",
                              "label"
                            ],
                            "type": "object"
                          },
                          "type": "array"
                        },
                        "userId": {
                          "description": "Автор задания",
                          "type": "string"
                        },
                        "waiting": {
                          "description": "Ждёт даты начала",
                          "type": "boolean"
                        },
                        "webhook": {
                          "description": "Включён ли вебхук, по которому внешняя система запускает задание вне расписания",
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "id",
                        "agentId",
                        "userId",
                        "name",
                        "prompt",
                        "schedule",
                        "state",
                        "nextRunAt",
                        "lastRunAt",
                        "lastFailed",
                        "origin",
                        "conversationId",
                        "channels",
                        "hold",
                        "quotaPaused",
                        "webhook",
                        "overlap",
                        "createdAt",
                        "startsOn",
                        "endsOn",
                        "repeatTimes",
                        "repeatDone",
                        "waiting",
                        "upcoming"
                      ],
                      "type": "object"
                    },
                    "url": {
                      "description": "Адрес вебхука; возвращается один раз при включении, при отключении — null",
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "schedule",
                    "url"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Задание и адрес вебхука"
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Некорректный запрос: не прошла валидация параметров или тела"
          },
          "401": {
            "description": "Не авторизован"
          },
          "403": {
            "description": "Недостаточно прав на агента"
          }
        },
        "security": [
          {
            "dpop": []
          }
        ],
        "summary": "Включить или отключить вебхук задания",
        "tags": [
          "collaboration:agents"
        ]
      }
    },
    "/ws/api/agents/{agentId}/tools": {
      "get": {
        "operationId": "get_ws_api_agents_agentId_tools",
        "parameters": [
          {
            "description": "Идентификатор агента",
            "in": "path",
            "name": "agentId",
            "required": true,
            "schema": {
              "description": "Идентификатор агента",
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "domains": {
                      "description": "Разделы инструментов",
                      "items": {
                        "properties": {
                          "id": {
                            "description": "Идентификатор раздела",
                            "type": "string"
                          },
                          "title": {
                            "description": "Название раздела",
                            "type": "string"
                          },
                          "tools": {
                            "description": "Инструменты раздела",
                            "items": {
                              "properties": {
                                "activity": {
                                  "description": "Подпись действия в процессе выполнения",
                                  "type": "string"
                                },
                                "effect": {
                                  "description": "read — только чтение, write — изменяет данные, irreversible — необратимое действие",
                                  "type": "string"
                                },
                                "name": {
                                  "description": "Имя инструмента внутри раздела",
                                  "type": "string"
                                },
                                "qualified": {
                                  "description": "Полное имя инструмента у агента",
                                  "type": "string"
                                },
                                "title": {
                                  "description": "Название действия",
                                  "type": "string"
                                }
                              },
                              "required": [
                                "name",
                                "qualified",
                                "title",
                                "activity",
                                "effect"
                              ],
                              "type": "object"
                            },
                            "type": "array"
                          }
                        },
                        "required": [
                          "id",
                          "title",
                          "tools"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "version": {
                      "description": "Версия каталога; пустая строка — каталог ещё не развёрнут",
                      "type": "string"
                    }
                  },
                  "required": [
                    "version",
                    "domains"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Разделы и инструменты агента с подписями для интерфейса"
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Некорректный запрос: не прошла валидация параметров или тела"
          },
          "401": {
            "description": "Не авторизован"
          },
          "403": {
            "description": "Недостаточно прав на агента"
          }
        },
        "security": [
          {
            "dpop": []
          }
        ],
        "summary": "Каталог инструментов агента",
        "tags": [
          "collaboration:agents"
        ]
      }
    },
    "/ws/api/agents/{agentId}/trust-suggestions": {
      "get": {
        "description": "Платформа следит за решениями людей по запросам агента: серия разрешений подряд предлагает разрешить действие без вопросов, серия отказов — запретить его, а испытательному агенту без отказов — обычный уровень доверия. Подсказка приходит куратору во входящие и видна здесь, пока по ней не принято решение.",
        "operationId": "get_ws_api_agents_agentId_trust-suggestions",
        "parameters": [
          {
            "description": "Идентификатор агента",
            "in": "path",
            "name": "agentId",
            "required": true,
            "schema": {
              "description": "Идентификатор агента",
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "suggestions": {
                      "description": "Открытые подсказки по доверию для агента",
                      "items": {
                        "$ref": "#/components/schemas/AgentTrustSuggestion"
                      },
                      "type": "array"
                    }
                  },
                  "required": [
                    "suggestions"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Подсказки"
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Некорректный запрос: не прошла валидация параметров или тела"
          },
          "401": {
            "description": "Не авторизован"
          },
          "403": {
            "description": "Недостаточно прав на агента"
          }
        },
        "security": [
          {
            "dpop": []
          }
        ],
        "summary": "Подсказки по доверию к агенту",
        "tags": [
          "collaboration:agents"
        ]
      }
    },
    "/ws/api/agents/{agentId}/trust-suggestions/{suggestionId}/decision": {
      "post": {
        "description": "Закрывает подсказку. Сами права агента меняет редактор настройками агента; принятая подсказка только фиксирует решение, отклонённая не повторяется месяц.",
        "operationId": "post_ws_api_agents_agentId_trust-suggestions_suggestionId_decision",
        "parameters": [
          {
            "description": "Идентификатор агента",
            "in": "path",
            "name": "agentId",
            "required": true,
            "schema": {
              "description": "Идентификатор агента",
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "description": "Идентификатор подсказки",
            "in": "path",
            "name": "suggestionId",
            "required": true,
            "schema": {
              "description": "Идентификатор подсказки",
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "accept": {
                    "description": "true — подсказка принята и права агента уже изменены, false — оставить как есть",
                    "type": "boolean"
                  }
                },
                "required": [
                  "accept"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentTrustSuggestion"
                }
              }
            },
            "description": "Подсказка"
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Некорректный запрос: не прошла валидация параметров или тела"
          },
          "401": {
            "description": "Не авторизован"
          },
          "403": {
            "description": "Недостаточно прав на агента"
          },
          "404": {
            "description": "Подсказка не найдена или уже решена"
          }
        },
        "security": [
          {
            "dpop": []
          }
        ],
        "summary": "Решение по подсказке о доверии",
        "tags": [
          "collaboration:agents"
        ]
      }
    },
    "/ws/api/ai/sessions": {
      "get": {
        "operationId": "get_ws_api_ai_sessions",
        "parameters": [
          {
            "description": "Максимум бесед в ответе, 1–50 (по умолчанию 30)",
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "description": "Максимум бесед в ответе, 1–50 (по умолчанию 30)",
              "type": "string"
            }
          },
          {
            "description": "Сколько самых свежих бесед пропустить (по умолчанию 0)",
            "in": "query",
            "name": "offset",
            "required": false,
            "schema": {
              "description": "Сколько самых свежих бесед пропустить (по умолчанию 0)",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "nextOffset": {
                      "description": "offset следующей страницы или null, если бесед больше нет",
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "sessions": {
                      "items": {
                        "properties": {
                          "agents": {
                            "description": "Агенты, которые отвечали в беседе",
                            "items": {
                              "type": "string"
                            },
                            "type": "array"
                          },
                          "conversationId": {
                            "description": "Идентификатор беседы",
                            "type": "string"
                          },
                          "createdAt": {
                            "description": "Создана, ISO 8601",
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "lead": {
                            "description": "Кому уходят сообщения без упоминаний: all — всем доступным агентам, иначе идентификатор агента",
                            "type": "string"
                          },
                          "preview": {
                            "description": "Последнее сообщение, до 200 символов",
                            "type": "string"
                          },
                          "sessionKey": {
                            "description": "Ключ сессии, совпадает с conversationId",
                            "type": "string"
                          },
                          "title": {
                            "description": "Заголовок беседы",
                            "type": "string"
                          },
                          "updatedAt": {
                            "description": "Обновлена, ISO 8601",
                            "type": [
                              "string",
                              "null"
                            ]
                          }
                        },
                        "required": [
                          "conversationId",
                          "sessionKey",
                          "lead",
                          "agents",
                          "title",
                          "preview",
                          "createdAt",
                          "updatedAt"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    }
                  },
                  "required": [
                    "sessions",
                    "nextOffset"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Страница бесед, от свежих к старым"
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Некорректный запрос: не прошла валидация параметров или тела"
          },
          "401": {
            "description": "Не авторизован"
          },
          "403": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Недостаточно прав или scope"
          }
        },
        "security": [
          {
            "dpop": []
          }
        ],
        "summary": "Список бесед пользователя с ассистентом",
        "tags": [
          "collaboration"
        ]
      }
    },
    "/ws/api/ai/sessions/{conversationId}": {
      "delete": {
        "operationId": "delete_ws_api_ai_sessions_conversationId",
        "parameters": [
          {
            "description": "Идентификатор беседы",
            "in": "path",
            "name": "conversationId",
            "required": true,
            "schema": {
              "description": "Идентификатор беседы",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "ok": {
                      "description": "Операция выполнена",
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "ok"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Результат удаления"
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Некорректный запрос: не прошла валидация параметров или тела"
          },
          "401": {
            "description": "Не авторизован"
          },
          "403": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Недостаточно прав или scope"
          }
        },
        "security": [
          {
            "dpop": []
          }
        ],
        "summary": "Удалить беседу с ассистентом",
        "tags": [
          "collaboration"
        ]
      },
      "get": {
        "operationId": "get_ws_api_ai_sessions_conversationId",
        "parameters": [
          {
            "description": "Идентификатор беседы",
            "in": "path",
            "name": "conversationId",
            "required": true,
            "schema": {
              "description": "Идентификатор беседы",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "agents": {
                      "description": "Агенты, которые отвечали в беседе",
                      "items": {
                        "properties": {
                          "id": {
                            "description": "Агент",
                            "type": "string"
                          },
                          "name": {
                            "description": "Имя агента",
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "name"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "confirmations": {
                      "description": "Действия, которые агент просил подтвердить в беседе",
                      "items": {
                        "properties": {
                          "agentId": {
                            "description": "Агент, который просит подтверждение",
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "id": {
                            "description": "Идентификатор подтверждения",
                            "type": "string"
                          },
                          "message": {
                            "description": "Что агент просит подтвердить",
                            "type": "string"
                          },
                          "status": {
                            "description": "pending — ждёт решения, approved — подтверждено, rejected — отклонено, expired — истекло, superseded — заменено новым запуском задания",
                            "enum": [
                              "pending",
                              "approved",
                              "rejected",
                              "expired",
                              "superseded"
                            ],
                            "type": "string"
                          },
                          "timestamp": {
                            "description": "Когда агент запросил подтверждение, ISO 8601",
                            "type": [
                              "string",
                              "null"
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "agentId",
                          "message",
                          "status",
                          "timestamp"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "conversationId": {
                      "description": "Идентификатор беседы",
                      "type": "string"
                    },
                    "councils": {
                      "description": "Консилиумы агентов в беседе",
                      "items": {
                        "properties": {
                          "chair": {
                            "description": "Председатель",
                            "type": "string"
                          },
                          "conversationId": {
                            "description": "Беседа",
                            "type": "string"
                          },
                          "createdAt": {
                            "description": "Запущен, ISO 8601",
                            "type": "string"
                          },
                          "decision": {
                            "description": "Проект решения председателя",
                            "properties": {
                              "status": {
                                "description": "pending — ждёт, running — готовится, done — готово, failed — не удалось, timeout — не успел",
                                "enum": [
                                  "pending",
                                  "running",
                                  "done",
                                  "failed",
                                  "timeout"
                                ],
                                "type": "string"
                              },
                              "text": {
                                "description": "Текст",
                                "type": "string"
                              }
                            },
                            "required": [
                              "status"
                            ],
                            "type": "object"
                          },
                          "id": {
                            "description": "Идентификатор консилиума",
                            "type": "string"
                          },
                          "letters": {
                            "additionalProperties": {
                              "type": "string",
                              "x-additionalPropertiesName": "agentId"
                            },
                            "description": "Буквы, под которыми позиции видели при взаимной проверке",
                            "type": "object"
                          },
                          "names": {
                            "additionalProperties": {
                              "type": "string",
                              "x-additionalPropertiesName": "agentId"
                            },
                            "description": "Имена агентов",
                            "type": "object"
                          },
                          "notice": {
                            "description": "Почему консилиум приостановлен",
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "origin": {
                            "description": "Где запущен",
                            "enum": [
                              "chat",
                              "telegram"
                            ],
                            "type": "string"
                          },
                          "participants": {
                            "description": "Участники",
                            "items": {
                              "type": "string"
                            },
                            "type": "array"
                          },
                          "positions": {
                            "additionalProperties": {
                              "properties": {
                                "status": {
                                  "description": "pending — ждёт, running — готовится, done — готово, failed — не удалось, timeout — не успел",
                                  "enum": [
                                    "pending",
                                    "running",
                                    "done",
                                    "failed",
                                    "timeout"
                                  ],
                                  "type": "string"
                                },
                                "text": {
                                  "description": "Текст",
                                  "type": "string"
                                }
                              },
                              "required": [
                                "status"
                              ],
                              "type": "object",
                              "x-additionalPropertiesName": "agentId"
                            },
                            "description": "Позиции участников",
                            "type": "object"
                          },
                          "question": {
                            "description": "Вопрос",
                            "type": "string"
                          },
                          "reviews": {
                            "additionalProperties": {
                              "properties": {
                                "status": {
                                  "description": "pending — ждёт, running — готовится, done — готово, failed — не удалось, timeout — не успел",
                                  "enum": [
                                    "pending",
                                    "running",
                                    "done",
                                    "failed",
                                    "timeout"
                                  ],
                                  "type": "string"
                                },
                                "text": {
                                  "description": "Текст",
                                  "type": "string"
                                }
                              },
                              "required": [
                                "status"
                              ],
                              "type": "object",
                              "x-additionalPropertiesName": "agentId"
                            },
                            "description": "Взаимная проверка",
                            "type": "object"
                          },
                          "stage": {
                            "description": "positions — позиции, reviews — взаимная проверка, decision — проект решения председателя, voting — голосование",
                            "enum": [
                              "positions",
                              "reviews",
                              "decision",
                              "voting"
                            ],
                            "type": "string"
                          },
                          "status": {
                            "description": "running — идёт, paused — приостановлен и может быть продолжен, done — завершён",
                            "enum": [
                              "running",
                              "paused",
                              "done"
                            ],
                            "type": "string"
                          },
                          "updatedAt": {
                            "description": "Обновлён, ISO 8601",
                            "type": "string"
                          },
                          "verdict": {
                            "description": "Итог голосования; null — консилиум не завершён",
                            "properties": {
                              "abstained": {
                                "description": "Не проголосовали",
                                "type": "integer"
                              },
                              "against": {
                                "description": "Голосов против",
                                "type": "integer"
                              },
                              "for": {
                                "description": "Голосов за",
                                "type": "integer"
                              },
                              "outcome": {
                                "description": "unanimous — единогласно, majority — большинством, rejected — решение не принято",
                                "enum": [
                                  "unanimous",
                                  "majority",
                                  "rejected"
                                ],
                                "type": "string"
                              }
                            },
                            "required": [
                              "outcome",
                              "for",
                              "against",
                              "abstained"
                            ],
                            "type": [
                              "object",
                              "null"
                            ]
                          },
                          "votes": {
                            "additionalProperties": {
                              "properties": {
                                "status": {
                                  "description": "pending — ждёт, running — готовится, done — готово, failed — не удалось, timeout — не успел",
                                  "enum": [
                                    "pending",
                                    "running",
                                    "done",
                                    "failed",
                                    "timeout"
                                  ],
                                  "type": "string"
                                },
                                "text": {
                                  "description": "Текст",
                                  "type": "string"
                                },
                                "vote": {
                                  "description": "for — за, against — против; нет — не проголосовал",
                                  "enum": [
                                    "for",
                                    "against"
                                  ],
                                  "type": "string"
                                }
                              },
                              "required": [
                                "status"
                              ],
                              "type": "object",
                              "x-additionalPropertiesName": "agentId"
                            },
                            "description": "Голоса участников; у голосовавших против текст — особое мнение",
                            "type": "object"
                          }
                        },
                        "required": [
                          "id",
                          "conversationId",
                          "question",
                          "chair",
                          "participants",
                          "names",
                          "letters",
                          "origin",
                          "status",
                          "stage",
                          "notice",
                          "positions",
                          "reviews",
                          "decision",
                          "votes",
                          "verdict",
                          "createdAt",
                          "updatedAt"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "entries": {
                      "description": "Лента беседы в порядке появления: сообщения, действия агентов, подтверждения и консилиумы",
                      "items": {
                        "oneOf": [
                          {
                            "properties": {
                              "agentId": {
                                "description": "Агент, который ответил; null — сообщение пользователя или платформы",
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "attachments": {
                                "description": "Вложения",
                                "items": {
                                  "properties": {
                                    "agentId": {
                                      "description": "Агент, в рабочей папке которого лежит файл",
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "mimeType": {
                                      "description": "MIME-тип",
                                      "type": "string"
                                    },
                                    "name": {
                                      "description": "Имя файла",
                                      "type": "string"
                                    },
                                    "path": {
                                      "description": "Путь в рабочей папке агента",
                                      "type": [
                                        "string",
                                        "null"
                                      ]
                                    },
                                    "size": {
                                      "description": "Размер в байтах",
                                      "type": "number"
                                    }
                                  },
                                  "required": [
                                    "name",
                                    "mimeType",
                                    "path",
                                    "agentId"
                                  ],
                                  "type": "object"
                                },
                                "type": "array"
                              },
                              "content": {
                                "description": "Текст сообщения",
                                "type": "string"
                              },
                              "id": {
                                "description": "Идентификатор сообщения; у ответа агента совпадает с идентификатором хода",
                                "type": "string"
                              },
                              "kind": {
                                "enum": [
                                  "message"
                                ],
                                "type": "string"
                              },
                              "purpose": {
                                "description": "Зачем агент ответил: возражения на другой ответ",
                                "properties": {
                                  "kind": {
                                    "description": "Возражения",
                                    "enum": [
                                      "critique"
                                    ],
                                    "type": "string"
                                  },
                                  "targetId": {
                                    "description": "Ответ или консилиум, на который возражают",
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "kind",
                                  "targetId"
                                ],
                                "type": "object"
                              },
                              "role": {
                                "description": "Автор: user, assistant или system",
                                "enum": [
                                  "user",
                                  "assistant",
                                  "system"
                                ],
                                "type": "string"
                              },
                              "timestamp": {
                                "description": "Время сообщения, ISO 8601",
                                "type": "string"
                              }
                            },
                            "required": [
                              "kind",
                              "id",
                              "role",
                              "content",
                              "agentId",
                              "timestamp"
                            ],
                            "type": "object"
                          },
                          {
                            "properties": {
                              "agentId": {
                                "description": "Агент, который выполнил действие",
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "at": {
                                "description": "Позиция в тексте ответа хода, на которой агент вызвал инструмент",
                                "type": "integer"
                              },
                              "effect": {
                                "description": "Характер действия: чтение или изменение",
                                "type": "string"
                              },
                              "id": {
                                "description": "Идентификатор записи о действии",
                                "type": "string"
                              },
                              "kind": {
                                "enum": [
                                  "tool"
                                ],
                                "type": "string"
                              },
                              "label": {
                                "description": "Подпись действия",
                                "type": "string"
                              },
                              "name": {
                                "description": "Инструмент",
                                "type": "string"
                              },
                              "params": {
                                "additionalProperties": true,
                                "description": "Параметры вызова",
                                "type": "object"
                              },
                              "result": {
                                "description": "Результат вызова"
                              },
                              "timestamp": {
                                "description": "Время выполнения, ISO 8601",
                                "type": "string"
                              },
                              "turnId": {
                                "description": "Ход агента, в котором выполнено действие",
                                "type": "string"
                              }
                            },
                            "required": [
                              "kind",
                              "id",
                              "agentId",
                              "name",
                              "params",
                              "timestamp"
                            ],
                            "type": "object"
                          },
                          {
                            "properties": {
                              "agentId": {
                                "description": "Агент, который просит подтверждение",
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "id": {
                                "description": "Идентификатор подтверждения",
                                "type": "string"
                              },
                              "kind": {
                                "enum": [
                                  "confirmation"
                                ],
                                "type": "string"
                              },
                              "message": {
                                "description": "Что агент просит подтвердить",
                                "type": "string"
                              },
                              "status": {
                                "description": "Текущее состояние подтверждения",
                                "enum": [
                                  "pending",
                                  "approved",
                                  "rejected",
                                  "expired",
                                  "superseded"
                                ],
                                "type": "string"
                              },
                              "timestamp": {
                                "description": "Когда агент запросил подтверждение, ISO 8601",
                                "type": "string"
                              }
                            },
                            "required": [
                              "kind",
                              "id",
                              "agentId",
                              "message",
                              "status",
                              "timestamp"
                            ],
                            "type": "object"
                          },
                          {
                            "properties": {
                              "id": {
                                "description": "Идентификатор консилиума",
                                "type": "string"
                              },
                              "kind": {
                                "enum": [
                                  "council"
                                ],
                                "type": "string"
                              },
                              "timestamp": {
                                "description": "Когда консилиум запущен, ISO 8601",
                                "type": "string"
                              }
                            },
                            "required": [
                              "kind",
                              "id",
                              "timestamp"
                            ],
                            "type": "object"
                          }
                        ]
                      },
                      "type": "array"
                    },
                    "lead": {
                      "description": "Кому уходят сообщения без упоминаний: all — всем доступным агентам, иначе идентификатор агента",
                      "type": "string"
                    },
                    "messages": {
                      "description": "Сообщения беседы",
                      "items": {
                        "properties": {
                          "agentId": {
                            "description": "Агент, который ответил; null — сообщение пользователя или платформы",
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "attachments": {
                            "description": "Вложения",
                            "items": {
                              "properties": {
                                "agentId": {
                                  "description": "Агент, в рабочей папке которого лежит файл",
                                  "type": [
                                    "string",
                                    "null"
                                  ]
                                },
                                "mimeType": {
                                  "description": "MIME-тип",
                                  "type": "string"
                                },
                                "name": {
                                  "description": "Имя файла",
                                  "type": "string"
                                },
                                "path": {
                                  "description": "Путь в рабочей папке агента",
                                  "type": [
                                    "string",
                                    "null"
                                  ]
                                },
                                "size": {
                                  "description": "Размер в байтах",
                                  "type": "number"
                                }
                              },
                              "required": [
                                "name",
                                "mimeType",
                                "path",
                                "agentId"
                              ],
                              "type": "object"
                            },
                            "type": "array"
                          },
                          "content": {
                            "description": "Текст сообщения",
                            "type": "string"
                          },
                          "id": {
                            "description": "Идентификатор сообщения",
                            "type": "string"
                          },
                          "purpose": {
                            "description": "Зачем агент ответил: возражения на другой ответ",
                            "properties": {
                              "kind": {
                                "description": "Возражения",
                                "enum": [
                                  "critique"
                                ],
                                "type": "string"
                              },
                              "targetId": {
                                "description": "Ответ или консилиум, на который возражают",
                                "type": "string"
                              }
                            },
                            "required": [
                              "kind",
                              "targetId"
                            ],
                            "type": "object"
                          },
                          "role": {
                            "description": "Автор: user, assistant или system",
                            "enum": [
                              "user",
                              "assistant",
                              "system"
                            ],
                            "type": "string"
                          },
                          "timestamp": {
                            "description": "Время сообщения, ISO 8601",
                            "type": [
                              "string",
                              "null"
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "role",
                          "content",
                          "agentId",
                          "timestamp"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "revision": {
                      "description": "Ревизия беседы; растёт на единицу при каждом изменении ленты",
                      "type": "integer"
                    },
                    "sessionKey": {
                      "description": "Ключ сессии, совпадает с conversationId",
                      "type": "string"
                    }
                  },
                  "required": [
                    "conversationId",
                    "sessionKey",
                    "lead",
                    "agents",
                    "messages",
                    "councils",
                    "confirmations",
                    "entries",
                    "revision"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Беседа с сообщениями"
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Некорректный запрос: не прошла валидация параметров или тела"
          },
          "401": {
            "description": "Не авторизован"
          },
          "403": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Недостаточно прав или scope"
          }
        },
        "security": [
          {
            "dpop": []
          }
        ],
        "summary": "История беседы с ассистентом",
        "tags": [
          "collaboration"
        ]
      },
      "patch": {
        "operationId": "patch_ws_api_ai_sessions_conversationId",
        "parameters": [
          {
            "description": "Идентификатор беседы",
            "in": "path",
            "name": "conversationId",
            "required": true,
            "schema": {
              "description": "Идентификатор беседы",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "title": {
                    "description": "Новое название беседы, до 80 символов",
                    "type": "string"
                  }
                },
                "required": [
                  "title"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "ok": {
                      "description": "Операция выполнена",
                      "type": "boolean"
                    },
                    "title": {
                      "description": "Сохранённое название беседы",
                      "type": "string"
                    }
                  },
                  "required": [
                    "ok",
                    "title"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Название сохранено"
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Некорректный запрос: не прошла валидация параметров или тела"
          },
          "401": {
            "description": "Не авторизован"
          },
          "403": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Недостаточно прав или scope"
          }
        },
        "security": [
          {
            "dpop": []
          }
        ],
        "summary": "Переименовать беседу с ассистентом",
        "tags": [
          "collaboration"
        ]
      }
    },
    "/ws/api/files/upload": {
      "post": {
        "description": "Принимает multipart/form-data с полем file (PDF/DOCX и др., до 25 МБ), извлекает текст и сохраняет файл в рабочую папку агента.",
        "operationId": "post_ws_api_files_upload",
        "parameters": [
          {
            "description": "Агент чата; по умолчанию основной агент команды",
            "in": "query",
            "name": "agentId",
            "required": false,
            "schema": {
              "description": "Агент чата; по умолчанию основной агент команды",
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "fileName": {
                      "type": "string"
                    },
                    "mimeType": {
                      "type": "string"
                    },
                    "savedPath": {
                      "description": "Путь в рабочей папке агента (null, если сохранить не удалось)",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "size": {
                      "type": "number"
                    },
                    "text": {
                      "description": "Извлечённый текст файла",
                      "type": "string"
                    }
                  },
                  "required": [
                    "fileName",
                    "mimeType",
                    "size",
                    "text",
                    "savedPath"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Извлечённый текст и путь сохранения"
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Некорректный запрос: не прошла валидация параметров или тела"
          },
          "401": {
            "description": "Не авторизован"
          },
          "403": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Недостаточно прав или scope"
          }
        },
        "security": [
          {
            "dpop": []
          }
        ],
        "summary": "Загрузить файл в чат с ассистентом",
        "tags": [
          "collaboration"
        ]
      }
    },
    "/ws/api/files/warm": {
      "post": {
        "operationId": "post_ws_api_files_warm",
        "parameters": [
          {
            "description": "Агент чата; по умолчанию основной агент команды",
            "in": "query",
            "name": "agentId",
            "required": false,
            "schema": {
              "description": "Агент чата; по умолчанию основной агент команды",
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Подготовка запущена"
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Некорректный запрос: не прошла валидация параметров или тела"
          },
          "401": {
            "description": "Не авторизован"
          },
          "403": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Недостаточно прав или scope"
          }
        },
        "security": [
          {
            "dpop": []
          }
        ],
        "summary": "Подготовить извлечение текста, пока пользователь выбирает файлы",
        "tags": [
          "collaboration"
        ]
      }
    },
    "/ws/api/files/workspace": {
      "get": {
        "description": "Читает файл внутри workspace агента команды по относительному пути (например Downloads/screenshot.png). Тип содержимого определяется по сигнатуре файла; небезопасные для встраивания типы отдаются вложением.",
        "operationId": "get_ws_api_files_workspace",
        "parameters": [
          {
            "description": "Агент чата; по умолчанию основной агент команды",
            "in": "query",
            "name": "agentId",
            "required": false,
            "schema": {
              "description": "Агент чата; по умолчанию основной агент команды",
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "description": "Путь внутри рабочей папки агента; допускается полный путь /home/agent/.hermes/workspace/…",
            "in": "query",
            "name": "path",
            "required": true,
            "schema": {
              "description": "Путь внутри рабочей папки агента; допускается полный путь /home/agent/.hermes/workspace/…",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/octet-stream": {
                "schema": {
                  "format": "binary",
                  "type": "string"
                }
              }
            },
            "description": "Содержимое файла"
          },
          "400": {
            "description": "Некорректный путь"
          },
          "401": {
            "description": "Не авторизован"
          },
          "403": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Недостаточно прав или scope"
          },
          "404": {
            "description": "Файл не найден"
          }
        },
        "security": [
          {
            "dpop": []
          }
        ],
        "summary": "Скачать файл из рабочей папки агента",
        "tags": [
          "collaboration"
        ]
      }
    },
    "/ws/api/hooks/agent-schedules/{scheduleId}/{token}": {
      "get": {
        "description": "Для систем, которые умеют только GET. Параметры запроса агент получает вместе с заданием.",
        "operationId": "get_ws_api_hooks_agent-schedules_scheduleId_token",
        "parameters": [
          {
            "description": "Идентификатор задания",
            "in": "path",
            "name": "scheduleId",
            "required": true,
            "schema": {
              "description": "Идентификатор задания",
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "description": "Секрет из адреса вебхука",
            "in": "path",
            "name": "token",
            "required": true,
            "schema": {
              "description": "Секрет из адреса вебхука",
              "maxLength": 128,
              "minLength": 1,
              "type": "string"
            }
          }
        ],
        "responses": {
          "202": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "accepted": {
                      "description": "Задание запущено",
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "accepted"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Задание запущено"
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Некорректный запрос: не прошла валидация параметров или тела"
          },
          "404": {
            "description": "Задание не найдено или секрет неверный"
          },
          "409": {
            "description": "Задание сейчас нельзя запустить: выполняется, на паузе, остановлено или завершено"
          },
          "429": {
            "description": "Слишком много запросов"
          }
        },
        "security": [],
        "summary": "Запустить задание агента по вебхуку (GET)",
        "tags": [
          "collaboration:agents"
        ]
      },
      "post": {
        "description": "Адрес выпускается при включении вебхука в задании. Тело запроса — до 32 КБ, агент получает его вместе с заданием. Такой запуск не уменьшает число оставшихся повторов; пока идёт запуск, повторный вызов отклоняется.",
        "operationId": "post_ws_api_hooks_agent-schedules_scheduleId_token",
        "parameters": [
          {
            "description": "Идентификатор задания",
            "in": "path",
            "name": "scheduleId",
            "required": true,
            "schema": {
              "description": "Идентификатор задания",
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "description": "Секрет из адреса вебхука",
            "in": "path",
            "name": "token",
            "required": true,
            "schema": {
              "description": "Секрет из адреса вебхука",
              "maxLength": 128,
              "minLength": 1,
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": true,
                "description": "Данные для агента: JSON-объект до 32 КБ, агент получает его вместе с заданием",
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "202": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "accepted": {
                      "description": "Задание запущено",
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "accepted"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Задание запущено"
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            },
            "description": "Некорректный запрос: не прошла валидация параметров или тела"
          },
          "404": {
            "description": "Задание не найдено или секрет неверный"
          },
          "409": {
            "description": "Задание сейчас нельзя запустить: выполняется, на паузе, остановлено или завершено"
          },
          "429": {
            "description": "Слишком много запросов"
          }
        },
        "security": [],
        "summary": "Запустить задание агента по вебхуку",
        "tags": [
          "collaboration:agents"
        ]
      }
    }
  },
  "servers": [
    {
      "description": "Публичный API LegalStack",
      "url": "https://api.legalstack.ru"
    }
  ],
  "tags": [
    {
      "description": "Беседы с ассистентом и файлы чата.",
      "name": "collaboration",
      "x-displayName": "Беседы с ассистентом"
    },
    {
      "description": "Настройка агентов команды: навыки, файлы, задачи по расписанию, пресеты.",
      "name": "collaboration:agents",
      "x-displayName": "Настройка агентов"
    }
  ],
  "webhooks": {}
}
