{
  "openapi": "3.1.0",
  "jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
  "info": {
    "title": "Keyling 设备接口",
    "version": "1",
    "description": "键灵 Keyling 设备的 HTTP 接口（硬件层）。设备网页的「接口」页、官网接口参考与 docs/interfaces.md 的接口表都由这份定义生成：改接口先改这里，再重新生成。\n\n- 回复：成功 `{\"ok\":true,...}`；失败是 HTTP 状态码加 `{\"ok\":false,\"error\":\"<代码>\",\"message\":\"<说明>\"}`。程序以 `error` 为准，`message` 只给人看（中文，不随界面语言变）。各接口自己的错误码在 `x-errors`，所有接口都可能遇到的在 `components.x-errors`。\n- 鉴权：默认要 HMAC 签名（`stickHmac`，规则见那里）；写了 `security: []` 的接口开放。\n- `x-only`：`kernel` 只在内核（恢复固件回 404 `not_found`）；`prov` 只在配网期间。\n- `x-risk`：`keys` 会往电脑按键、动鼠标；`reboot` 会重启；`offline` 可能让设备离线；`data` 会改删数据。\n- `x-resp`：回复不是 JSON 时写 `text`、`binary` 或 `rgb565`（屏幕像素）。\n- 名字表（键名、修饰名、鼠标键、多媒体名）不分大小写（`x-case-insensitive`），枚举里是规范写法。键名分两层：设备认全表 `KeyName`，主机工具与 SDK 默认只认标准 87 键 `KeyName87`，扩展键 `KeyNameExtended`（F13–F24、NUMLOCK）只给自检与演练。\n- 按 UTF-8 字节限长的字段写 `x-max-bytes`（一个汉字 3 字节；`maxLength` 按字符数，只是必要条件）。\n- 二进制请求体的示例：`value` 是十六进制（时间线每条记录 12 位，空格隔开），`x-records` 是逐条的含义；带 `x-repeat: N` 时整段重复 N 次（如整屏纯色）。\n- 示例的查询参数：请求体示例对象里的 `x-query` 是这个示例的完整查询参数；没有请求体的接口用各参数的 `example`。\n- 双语：中文写在标准键 `summary` / `description` / `title`（标签是 `name`），英文写在同一对象 `x-en` 里的同名键。",
    "x-en": {
      "title": "Keyling device API",
      "description": "HTTP API of the Keyling device (hardware layer). The API page of the device web app, the API reference on the website and the endpoint tables in docs/interfaces.md are all generated from this definition: change an endpoint here first, then regenerate.\n\n- Replies: success is `{\"ok\":true,...}`; failure is an HTTP status plus `{\"ok\":false,\"error\":\"<code>\",\"message\":\"<text>\"}`. Programs go by `error`; `message` is for people (Chinese, independent of the UI language). Endpoint-specific error codes are in `x-errors`; codes any endpoint can return are in `components.x-errors`.\n- Auth: HMAC signing by default (`stickHmac`, see its rules); endpoints with `security: []` are open.\n- `x-only`: `kernel` means kernel only (the rescue firmware returns 404 `not_found`); `prov` means only during Wi-Fi setup.\n- `x-risk`: `keys` presses keys and moves the mouse on the computer; `reboot` restarts; `offline` may take the device offline; `data` changes or deletes data.\n- `x-resp`: replies that are not JSON are marked `text`, `binary` or `rgb565` (screen pixels).\n- Name tables (key, modifier, mouse button and media names) are case-insensitive (`x-case-insensitive`); enums list the canonical spelling. Key names come in two layers: the device accepts the full table `KeyName`; host tools and the SDK accept only the standard 87-key set `KeyName87` by default; extended keys `KeyNameExtended` (F13–F24, NUMLOCK) are for self-tests and drills only.\n- Fields limited in UTF-8 bytes carry `x-max-bytes` (a Chinese character is 3 bytes; `maxLength` counts characters and is only a necessary condition).\n- Examples of binary request bodies: `value` is hex (12 digits per timeline record, separated by spaces) and `x-records` spells out each record; `x-repeat: N` means the whole value repeats N times (e.g. a solid-colour screen).\n- Query parameters of examples: `x-query` on a request-body example holds that example's full query; endpoints without a request body use each parameter's `example`.\n- Languages: Chinese goes in the standard keys `summary` / `description` / `title` (`name` for tags); English goes in the same-named keys of `x-en` on the same object."
    },
    "license": {
      "name": "MIT",
      "identifier": "MIT"
    }
  },
  "servers": [
    {
      "url": "http://{device}",
      "description": "设备地址",
      "x-en": {
        "description": "Device address"
      },
      "variables": {
        "device": {
          "default": "192.168.1.20",
          "description": "设备的 IP（设备屏幕或 stick ls 可见）",
          "x-en": {
            "description": "Device IP (shown on the device screen or by stick ls)"
          }
        }
      }
    }
  ],
  "security": [
    {
      "stickHmac": []
    }
  ],
  "tags": [
    {
      "name": "设备",
      "x-id": "device",
      "x-en": {
        "name": "Device",
        "description": "Device info, status, logs, screen language, time zone, BOOT button events, identify and restart. info and nonce are open; the rest need signing"
      },
      "description": "设备信息、状态、日志、屏幕语言、时区、BOOT 键事件、找设备、重启。info 与 nonce 开放，其余要签名"
    },
    {
      "name": "Wi-Fi",
      "x-id": "wifi",
      "description": "记住的网络（最多 3 个）、换网络与忘记；配网期间热点上配网页用的 /prov/*（开放）。手机连上配网热点后，强制门户把没有路由的 GET 302 到配网页（不是接口）。Wi-Fi 密码只由人在配网页或设备网页「设置」里填，主机工具与 Agent 不经手",
      "x-en": {
        "name": "Wi-Fi",
        "description": "Saved networks (up to 3), switching and forgetting; during Wi-Fi setup, the open /prov/* endpoints used by the setup page on the hotspot. When a phone joins the setup hotspot, the captive portal redirects (302) GETs with no route to the setup page (not an endpoint). Only a person enters Wi-Fi passwords, on the setup page or in Settings of the device web app; host tools and agents never handle them"
      }
    },
    {
      "name": "配对",
      "x-id": "pair",
      "x-en": {
        "name": "Pairing",
        "description": "A browser, or an agent on a new computer, gets the pairing key over Wi-Fi: the device screen shows a 4-digit code; click BOOT to allow, double-click to deny. Kernel only; in the rescue firmware use the key command over USB serial"
      },
      "description": "浏览器或新电脑上的 Agent 经 Wi-Fi 领配对密钥：设备屏幕弹 4 位数字，人单击 BOOT 允许、双击拒绝。只在内核；恢复固件里用 USB 串口 key 命令"
    },
    {
      "name": "HID 键盘鼠标",
      "x-id": "hid",
      "description": "经 Wi-Fi 往插着的电脑发键盘、鼠标、多媒体键：先解锁（租约），再发动作或时间线；BOOT 键与 disarm 随时急停。另有 TF 卡上的时间线、监视页与 USB 模式",
      "x-en": {
        "name": "HID keyboard and mouse",
        "description": "Send keyboard, mouse and media input to the connected computer over Wi-Fi: arm first (a lease), then send actions or a timeline; the BOOT button and disarm stop it at any time. Also timelines on the microSD card, the monitor screen and the USB mode"
      }
    },
    {
      "name": "应用与宏",
      "x-id": "apps",
      "description": "设备上的 Lua 应用，同一时间只跑一个：列出、启动、停止、自启动、删除、发消息、读事件、在应用里跑代码。宏播放器是应用 macro，经 POST /v1/apps/msg 控制",
      "x-en": {
        "name": "Apps and macros",
        "description": "Lua apps on the device, one running at a time: list, start, stop, start on boot, delete, message, read events and run code in the app. The macro player is the app macro, controlled through POST /v1/apps/msg"
      }
    },
    {
      "name": "存储区文件",
      "x-id": "fs",
      "description": "设备存储区（littlefs）里的文件：应用 /apps/<id>/、应用数据 /data/<id>/、字库 /fonts/、设备网页 /www/。一次读写整个文件，≤ 2 MB",
      "x-en": {
        "name": "Storage files",
        "description": "Files in the device storage (littlefs): apps /apps/<id>/, app data /data/<id>/, fonts /fonts/, device web app /www/. Files are read and written whole, ≤ 2 MB"
      }
    },
    {
      "name": "TF 卡",
      "x-id": "sd",
      "description": "TF 卡（FAT）上的文件。按块读写，每个请求 ≤ 1 MB（主机 256 KB 一块），断了能续传。卡上原有的文件别动，自己的放 /stick/ 下",
      "x-en": {
        "name": "microSD card",
        "description": "Files on the microSD card (FAT). Read and written in chunks of ≤ 1 MB per request (256 KB on the host), resumable. Leave existing files on the card alone; put your own under /stick/"
      }
    },
    {
      "name": "屏幕",
      "x-id": "screen",
      "description": "截屏、界面对象树与整屏样张预览",
      "x-en": {
        "name": "Screen",
        "description": "Screenshots, the UI object tree and full-screen mockup previews"
      }
    },
    {
      "name": "更新与引导",
      "x-id": "ota",
      "description": "经 Wi-Fi 写签名固件、确认或回滚新内核、切引导分区、取崩溃转储。启动规则见 docs/interfaces.md 第 1 节",
      "x-en": {
        "name": "Updates and boot",
        "description": "Write signed firmware over Wi-Fi, confirm or roll back a new kernel, switch the boot partition, fetch the crash dump. Boot rules: docs/interfaces.md section 1"
      }
    },
    {
      "name": "调试与演练",
      "x-id": "debug",
      "description": "故障演练与界面调试：让设备断网、崩溃，或注入一条状态看界面。断网与崩溃只在演练时用（stick drill）",
      "x-en": {
        "name": "Debug and drills",
        "description": "Fault drills and UI debugging: make the device drop the network or crash, or inject a status to check the UI. Use dropping and crashing only in drills (stick drill)"
      }
    }
  ],
  "paths": {
    "/v1/info": {
      "get": {
        "tags": [
          "设备"
        ],
        "operationId": "get_v1_info",
        "summary": "设备信息：编号、固件、内存、Wi-Fi、OTA 槽、TF 卡、网页版本",
        "description": "开放，不用签名。主机靠它认出设备、固件与是否配对；恢复固件里没有只在内核的段",
        "x-en": {
          "summary": "Device info: ID, firmware, memory, Wi-Fi, OTA slots, microSD card, web app version",
          "description": "Open; no signing. Hosts use it to identify the device, its firmware and whether it is paired; the rescue firmware omits the kernel-only sections"
        },
        "security": [],
        "responses": {
          "200": {
            "description": "设备信息",
            "x-en": {
              "description": "Device info"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeviceInfo"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {}
      }
    },
    "/v1/nonce": {
      "get": {
        "tags": [
          "设备"
        ],
        "operationId": "get_v1_nonce",
        "summary": "取一次性 nonce（签名用，60 秒有效；鉴权过的回复头 X-Stick-Nonce 也会附送）",
        "description": "开放。每个 nonce 用一次作废、60 秒过期；设备最多存 16 个，满了挤掉最早的。用回复头附送的可省掉这一趟",
        "x-en": {
          "summary": "Get a one-time nonce for signing (valid 60 s; authenticated replies also carry X-Stick-Nonce)",
          "description": "Open. Each nonce is single use and expires in 60 s; the device keeps up to 16 and drops the oldest when full. Using the one from the reply header saves this round trip"
        },
        "security": [],
        "responses": {
          "200": {
            "description": "nonce",
            "x-en": {
              "description": "Nonce"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeviceNonce"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {}
      }
    },
    "/v1/status": {
      "get": {
        "tags": [
          "设备"
        ],
        "operationId": "get_v1_status",
        "summary": "状态总线快照：当前有哪些状态、事件",
        "description": "active 是当前开着的状态，recent 是最近的事件；屏幕、灯珠都按这些显示",
        "x-en": {
          "summary": "Status bus snapshot: current states and events",
          "description": "active lists the states that are on, recent the latest events; the screen and LED follow them"
        },
        "responses": {
          "200": {
            "description": "状态快照",
            "x-en": {
              "description": "Status snapshot"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeviceStatus"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {}
      }
    },
    "/v1/logs": {
      "get": {
        "tags": [
          "设备"
        ],
        "operationId": "get_v1_logs",
        "summary": "日志环",
        "description": "增量取：since 填上次的 next。boot 变了说明重启过，序号从 0 重来。每 300 毫秒轮询一次就是实时跟踪",
        "x-en": {
          "summary": "Log ring",
          "description": "Fetch incrementally: pass the last next as since. A new boot means the device restarted and numbering starts again at 0. Polling every 300 ms follows the log live"
        },
        "parameters": [
          {
            "name": "since",
            "in": "query",
            "required": false,
            "description": "从这个序号起（含），填上次的 next；省略取最后 max 行",
            "x-en": {
              "description": "Start at this sequence number (inclusive), the last next; omit for the last max lines"
            },
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          },
          {
            "name": "max",
            "in": "query",
            "required": false,
            "description": "最多几行",
            "x-en": {
              "description": "Max lines"
            },
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 200
            }
          }
        ],
        "responses": {
          "200": {
            "description": "日志",
            "x-en": {
              "description": "Logs"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeviceLogs"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {}
      }
    },
    "/v1/identify": {
      "post": {
        "tags": [
          "设备"
        ],
        "operationId": "post_v1_identify",
        "summary": "找设备：屏幕与灯珠提示 5 秒",
        "description": "用来认出是哪一台，不改任何设置；不要请求体",
        "x-en": {
          "summary": "Identify: screen and LED signal for 5 s",
          "description": "Shows which device this is and changes nothing; no request body"
        },
        "responses": {
          "200": {
            "description": "已提示",
            "x-en": {
              "description": "Signalled"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {}
      }
    },
    "/v1/reboot": {
      "post": {
        "tags": [
          "设备"
        ],
        "operationId": "post_v1_reboot",
        "summary": "回复后 0.5 秒重启",
        "description": "重启前先松开所有键。新内核待确认时重启等于回滚（引导程序回到上一版本）；不要请求体",
        "x-en": {
          "summary": "Restart 0.5 s after replying",
          "description": "Releases all keys first. Restarting a new kernel that awaits confirmation rolls it back (the bootloader returns to the previous version); no request body"
        },
        "x-risk": "reboot",
        "responses": {
          "200": {
            "description": "即将重启",
            "x-en": {
              "description": "Restarting"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {}
      }
    },
    "/v1/lang": {
      "get": {
        "tags": [
          "设备"
        ],
        "operationId": "get_v1_lang",
        "summary": "屏幕（系统界面）的语言：zh / en，chosen 表示有人选过",
        "description": "只管设备屏幕（系统界面）；应用的文字与回复里的 message 不随它变",
        "x-en": {
          "summary": "Screen (system UI) language: zh / en; chosen means someone picked it",
          "description": "Applies only to the device screen (system UI); app text and message in replies stay as they are"
        },
        "responses": {
          "200": {
            "description": "屏幕语言",
            "x-en": {
              "description": "Screen language"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeviceLang"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {}
      },
      "post": {
        "tags": [
          "设备"
        ],
        "operationId": "post_v1_lang",
        "summary": "设屏幕语言，存下并立即生效",
        "description": "存进设备，屏幕立即按新语言重建，不重启；回复同 GET。只管设备屏幕（系统界面）；应用的文字与回复里的 message 不随它变",
        "x-en": {
          "summary": "Set the screen language; saved and applied immediately",
          "description": "Saved on the device; the screen is rebuilt in the new language at once, without a restart. Replies like GET. Applies only to the device screen (system UI); app text and message in replies stay as they are"
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DeviceLangRequest"
              },
              "examples": {
                "to_en": {
                  "summary": "换成英文",
                  "x-en": {
                    "summary": "Switch to English"
                  },
                  "value": {
                    "lang": "en"
                  }
                },
                "to_zh": {
                  "summary": "换成中文",
                  "x-en": {
                    "summary": "Switch to Chinese"
                  },
                  "value": {
                    "lang": "zh"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "已保存，回当前语言",
            "x-en": {
              "description": "Saved; current language"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeviceLang"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "bad_lang": {
            "status": 400,
            "description": "lang 只能是 zh 或 en（请求体不是 JSON 也回这个）",
            "x-en": {
              "description": "lang must be zh or en (also returned when the body is not JSON)"
            },
            "example": "to_en"
          },
          "nvs": {
            "status": 500,
            "description": "存储写入失败。重试；仍失败看 stick logs",
            "x-en": {
              "description": "Saving failed. Retry; if it persists, check stick logs"
            }
          }
        }
      }
    },
    "/v1/time": {
      "get": {
        "tags": [
          "设备"
        ],
        "operationId": "get_v1_time",
        "summary": "时间与时区（POSIX TZ + IANA 名）",
        "description": "时钟经 SNTP 校时；时区决定 local、Lua 的 os.date 与屏幕上的时间",
        "x-en": {
          "summary": "Time and time zone (POSIX TZ + IANA name)",
          "description": "The clock syncs over SNTP; the time zone sets local, Lua os.date and the time on screen"
        },
        "x-only": "kernel",
        "responses": {
          "200": {
            "description": "时间与时区",
            "x-en": {
              "description": "Time and time zone"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeviceTime"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {}
      },
      "post": {
        "tags": [
          "设备"
        ],
        "operationId": "post_v1_time",
        "summary": "设时区，立即生效",
        "description": "存进设备并立即生效，回复同 GET。主机 stick tz 按本机时区填好两项",
        "x-en": {
          "summary": "Set the time zone; applied immediately",
          "description": "Saved on the device and applied at once; replies like GET. The host command stick tz fills both from the local time zone"
        },
        "x-only": "kernel",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DeviceTimeRequest"
              },
              "examples": {
                "sydney": {
                  "summary": "悉尼（带夏令时）",
                  "x-en": {
                    "summary": "Sydney (with daylight saving)"
                  },
                  "value": {
                    "tz": "AEST-10AEDT,M10.1.0,M4.1.0/3",
                    "zone": "Australia/Sydney"
                  }
                },
                "utc_only": {
                  "summary": "只给 tz",
                  "description": "zone 省略，存空串",
                  "x-en": {
                    "summary": "tz only",
                    "description": "zone omitted; stored empty"
                  },
                  "value": {
                    "tz": "UTC0"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "已保存，回当前时间与时区",
            "x-en": {
              "description": "Saved; current time and time zone"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeviceTime"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "bad_tz": {
            "status": 400,
            "description": "tz 要 1–63 字节、只许字母数字与 <>+-,.:/；zone ≤ 63 字节可打印 ASCII、不含空格",
            "x-en": {
              "description": "tz must be 1–63 bytes of letters, digits and <>+-,.:/; zone ≤ 63 bytes of printable ASCII without spaces"
            },
            "example": "sydney"
          },
          "nvs": {
            "status": 500,
            "description": "存储写入失败。重试；仍失败看 stick logs",
            "x-en": {
              "description": "Saving failed. Retry; if it persists, check stick logs"
            }
          }
        }
      }
    },
    "/v1/button": {
      "get": {
        "tags": [
          "设备"
        ],
        "operationId": "get_v1_button",
        "summary": "BOOT 键事件环（单击 / 双击 / 长按 / 按住，stop 标记急停）",
        "description": "增量取：since 填上次的 next。等配对时的单击、双击归系统，不进事件环",
        "x-en": {
          "summary": "BOOT button event ring (click / double-click / long press / hold; stop marks emergency stop)",
          "description": "Fetch incrementally: pass the last next as since. Clicks and double-clicks that answer a pairing request belong to the system and are not recorded"
        },
        "x-only": "kernel",
        "parameters": [
          {
            "name": "since",
            "in": "query",
            "required": false,
            "description": "只要这个序号之后的，填上次的 next",
            "x-en": {
              "description": "Only events after this sequence number, the last next"
            },
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          },
          {
            "name": "max",
            "in": "query",
            "required": false,
            "description": "最多几条（取最新的）",
            "x-en": {
              "description": "Max events (the latest ones)"
            },
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 32,
              "default": 32
            }
          }
        ],
        "responses": {
          "200": {
            "description": "BOOT 键事件",
            "x-en": {
              "description": "BOOT button events"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeviceButton"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {}
      }
    },
    "/v1/wifi": {
      "get": {
        "tags": [
          "Wi-Fi"
        ],
        "operationId": "get_v1_wifi",
        "summary": "记住的网络（最多 3 个，最近连上的在前，不含密码）与正连着的",
        "description": "只列名称、上次连上的时间与信道，从不回密码",
        "x-en": {
          "summary": "Saved networks (up to 3, most recent first, no passwords) and the current one",
          "description": "Lists names, last connection time and channel only; never returns passwords"
        },
        "responses": {
          "200": {
            "description": "记住的网络",
            "x-en": {
              "description": "Saved networks"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WifiList"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {}
      },
      "post": {
        "tags": [
          "Wi-Fi"
        ],
        "operationId": "post_v1_wifi",
        "summary": "设为候选、约 1.5 秒后断开当前网络去连它；连上才记住，连不上回到记住的网络",
        "description": "设备网页「设置」里由人填写后调用；主机工具与 Agent 不经手 Wi-Fi 密码，不调它。网络先当候选放在内存，回复后约 1.5 秒断开当前网络去连它，期间设备离线；连上、拿到 IP 才记住并排第一（满 3 个挤掉最久没用的），密码不对就丢掉，连不上回到记住的网络",
        "x-en": {
          "summary": "Set as candidate and switch to it in about 1.5 s; saved only once joined, otherwise returns to a saved network",
          "description": "Called by Settings in the device web app after a person enters the network; host tools and agents never handle Wi-Fi passwords and do not call it. The network is kept in memory as a candidate; about 1.5 s after replying the device leaves the current network to join it and is offline meanwhile. Only once it joins and gets an IP is it saved, first in the list (with 3 saved, the least recently used is dropped). A wrong password drops it; if it cannot connect, the device returns to a saved network"
        },
        "x-risk": "offline",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WifiSaveRequest"
              },
              "examples": {
                "add_network": {
                  "summary": "加一个要密码的网络",
                  "description": "密码是占位值，由人在网页上填",
                  "x-en": {
                    "summary": "Add a network with a password",
                    "description": "The password is a placeholder; a person types it in the web app"
                  },
                  "value": {
                    "ssid": "MyHome",
                    "pass": "<wifi-password>"
                  }
                },
                "open_network": {
                  "summary": "开放网络（不带密码）",
                  "x-en": {
                    "summary": "Open network (no password)"
                  },
                  "value": {
                    "ssid": "Cafe-Guest"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "已设为候选，即将切换",
            "x-en": {
              "description": "Candidate set; switching"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "bad_wifi": {
            "status": 400,
            "description": "ssid 不是 1–32 字节，密码不是空或 8–64 字节，或请求体不是 JSON 对象",
            "x-en": {
              "description": "ssid is not 1–32 bytes, the password is neither empty nor 8–64 bytes, or the body is not a JSON object"
            },
            "example": "add_network"
          }
        }
      }
    },
    "/v1/wifi/forget": {
      "post": {
        "tags": [
          "Wi-Fi"
        ],
        "operationId": "post_v1_wifi_forget",
        "summary": "忘记一个网络；不带 ssid = 全部清掉并进配网（设备离线，要人用手机重新配网）",
        "description": "带 ssid：只忘记这一个（同名候选一起丢掉），正连着的先连着，掉线后不再回来。不带：全部清掉、断开并进配网，设备离线，要人用手机连热点重新配网",
        "x-en": {
          "summary": "Forget a network; without ssid, clear all and enter Wi-Fi setup (device goes offline until set up from a phone)",
          "description": "With ssid: forget that one (and a candidate of the same name); if in use it stays connected but will not come back after a disconnect. Without: clear all, disconnect and enter Wi-Fi setup; the device is offline until a person sets it up from a phone via the hotspot"
        },
        "x-risk": "offline",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WifiForgetRequest"
              },
              "examples": {
                "forget_one": {
                  "summary": "忘记一个",
                  "x-en": {
                    "summary": "Forget one"
                  },
                  "value": {
                    "ssid": "OldHome"
                  }
                },
                "forget_all": {
                  "summary": "全部忘记并进配网",
                  "description": "设备随即离线",
                  "x-en": {
                    "summary": "Forget all and enter Wi-Fi setup",
                    "description": "The device goes offline at once"
                  },
                  "value": {}
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "已忘记",
            "x-en": {
              "description": "Forgotten"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "bad_args": {
            "status": 400,
            "description": "ssid 不是 1–32 字节的字符串，或请求体不是 JSON 对象",
            "x-en": {
              "description": "ssid is not a 1–32 byte string, or the body is not a JSON object"
            },
            "example": "forget_one"
          },
          "not_found": {
            "status": 404,
            "description": "没记住这个网络（名称区分大小写）。先 GET /v1/wifi 看名称",
            "x-en": {
              "description": "No saved network by that name (case-sensitive). Check names with GET /v1/wifi"
            }
          },
          "nvs": {
            "status": 500,
            "description": "存储写入失败。重试；仍失败看 stick logs",
            "x-en": {
              "description": "Saving failed. Retry; if it persists, check stick logs"
            }
          }
        }
      }
    },
    "/prov/status": {
      "get": {
        "tags": [
          "Wi-Fi"
        ],
        "operationId": "get_prov_status",
        "summary": "配网页轮询：候选网络的结果（只在配网期间）",
        "description": "配网页提交后每秒左右轮询一次，看候选连没连上；也带记住的网络与屏幕语言",
        "x-en": {
          "summary": "Setup page polling: candidate network result (Wi-Fi setup only)",
          "description": "The setup page polls about once a second after submitting, to see whether the candidate joined; also returns saved networks and the screen language"
        },
        "x-only": "prov",
        "security": [],
        "responses": {
          "200": {
            "description": "配网进度",
            "x-en": {
              "description": "Setup progress"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WifiProvStatus"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "not_found": {
            "status": 404,
            "description": "不在配网期间（热点关着）",
            "x-en": {
              "description": "Not in Wi-Fi setup (the hotspot is off)"
            }
          }
        }
      }
    },
    "/prov/scan": {
      "get": {
        "tags": [
          "Wi-Fi"
        ],
        "operationId": "get_prov_scan",
        "summary": "附近网络（只在配网期间）",
        "description": "当场扫描一次，扫完才回复",
        "x-en": {
          "summary": "Nearby networks (Wi-Fi setup only)",
          "description": "Scans once on the spot and replies when done"
        },
        "x-only": "prov",
        "security": [],
        "responses": {
          "200": {
            "description": "附近网络",
            "x-en": {
              "description": "Nearby networks"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WifiScanReply"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "scan_busy": {
            "status": 503,
            "description": "设备正在连接网络，扫描不了。稍后重试",
            "x-en": {
              "description": "The device is joining a network and cannot scan. Retry later"
            }
          },
          "not_found": {
            "status": 404,
            "description": "不在配网期间（热点关着）",
            "x-en": {
              "description": "Not in Wi-Fi setup (the hotspot is off)"
            }
          }
        }
      }
    },
    "/prov/wifi": {
      "post": {
        "tags": [
          "Wi-Fi"
        ],
        "operationId": "post_prov_wifi",
        "summary": "配网页提交（表单 ssid、pass；只在配网期间）",
        "description": "规则同 POST /v1/wifi：先当候选，回复后约 1.5 秒去连（热点跟着换信道，手机可能短暂掉线），连上才记住；之后轮询 GET /prov/status 看结果。密码由人在配网页上填",
        "x-en": {
          "summary": "Setup page submit (form ssid, pass; Wi-Fi setup only)",
          "description": "Same rules as POST /v1/wifi: kept as a candidate and joined about 1.5 s after replying (the hotspot follows the channel, so the phone may drop briefly), saved only once joined; then poll GET /prov/status for the result. A person types the password on the setup page"
        },
        "x-only": "prov",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/WifiSaveRequest"
              },
              "examples": {
                "add_network": {
                  "summary": "提交网络",
                  "description": "密码是占位值",
                  "x-en": {
                    "summary": "Submit a network",
                    "description": "The password is a placeholder"
                  },
                  "value": {
                    "ssid": "MyHome",
                    "pass": "<wifi-password>"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "已设为候选",
            "x-en": {
              "description": "Candidate set"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "bad_wifi": {
            "status": 400,
            "description": "缺 ssid，或 ssid 不是 1–32 字节，或密码不是空或 8–64 字节",
            "x-en": {
              "description": "ssid is missing or not 1–32 bytes, or the password is neither empty nor 8–64 bytes"
            },
            "example": "add_network"
          },
          "not_found": {
            "status": 404,
            "description": "不在配网期间（热点关着）",
            "x-en": {
              "description": "Not in Wi-Fi setup (the hotspot is off)"
            }
          }
        }
      }
    },
    "/prov/forget": {
      "post": {
        "tags": [
          "Wi-Fi"
        ],
        "operationId": "post_prov_forget",
        "summary": "配网页忘记一个网络（表单 ssid；只在配网期间）",
        "description": "忘记一个记住的网络（同名候选一起丢掉）；正连着的先连着",
        "x-en": {
          "summary": "Setup page forgets a network (form ssid; Wi-Fi setup only)",
          "description": "Forgets a saved network (and a candidate of the same name); if in use it stays connected"
        },
        "x-only": "prov",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/WifiProvForgetForm"
              },
              "examples": {
                "forget_one": {
                  "summary": "忘记一个",
                  "x-en": {
                    "summary": "Forget one"
                  },
                  "value": {
                    "ssid": "OldHome"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "已忘记",
            "x-en": {
              "description": "Forgotten"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "bad_args": {
            "status": 400,
            "description": "缺 ssid 或为空",
            "x-en": {
              "description": "ssid is missing or empty"
            },
            "example": "forget_one"
          },
          "not_found": {
            "status": 404,
            "description": "不在配网期间，或没记住这个网络",
            "x-en": {
              "description": "Not in Wi-Fi setup, or no saved network by that name"
            }
          },
          "nvs": {
            "status": 500,
            "description": "存储写入失败。重试；仍失败看 stick logs",
            "x-en": {
              "description": "Saving failed. Retry; if it persists, check stick logs"
            }
          }
        }
      }
    },
    "/prov/lang": {
      "post": {
        "tags": [
          "Wi-Fi"
        ],
        "operationId": "post_prov_lang",
        "summary": "配网页设屏幕语言（表单 lang=zh|en；只在配网期间）",
        "description": "同 POST /v1/lang：存进设备，屏幕立即换。配网页打开时没人选过语言（lang_chosen 为 false）就按手机语言设一次，右上角切换时也调",
        "x-en": {
          "summary": "Setup page sets the screen language (form lang=zh|en; Wi-Fi setup only)",
          "description": "Same as POST /v1/lang: saved on the device and the screen switches at once. When the setup page opens and nobody has chosen a language (lang_chosen is false), it sets one from the phone's language; the switch at the top right calls it too"
        },
        "x-only": "prov",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/WifiProvLangForm"
              },
              "examples": {
                "english": {
                  "summary": "英文",
                  "x-en": {
                    "summary": "English"
                  },
                  "value": {
                    "lang": "en"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "已设好",
            "x-en": {
              "description": "Set"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "bad_lang": {
            "status": 400,
            "description": "lang 只能是 zh 或 en",
            "x-en": {
              "description": "lang must be zh or en"
            },
            "example": "english"
          },
          "not_found": {
            "status": 404,
            "description": "不在配网期间（热点关着）",
            "x-en": {
              "description": "Not in Wi-Fi setup (the hotspot is off)"
            }
          },
          "nvs": {
            "status": 500,
            "description": "存储写入失败。重试；仍失败看 stick logs",
            "x-en": {
              "description": "Saving failed. Retry; if it persists, check stick logs"
            }
          }
        }
      }
    },
    "/prov/leave": {
      "post": {
        "tags": [
          "Wi-Fi"
        ],
        "operationId": "post_prov_leave",
        "summary": "退出配网：放弃候选，关热点、回记住的网络（只在配网期间）",
        "description": "清掉候选。已联网：约 1.5 秒后关热点；没联网：约 1.5 秒后去连记住的网络，连上再关热点（手机会掉线）。请求体忽略（配网页发空表单）",
        "x-en": {
          "summary": "Leave setup: drop the candidate, close the hotspot, return to a saved network (Wi-Fi setup only)",
          "description": "Drops the candidate. If online, closes the hotspot in about 1.5 s; if not, joins a saved network in about 1.5 s and closes the hotspot once connected (the phone drops). The body is ignored (the setup page sends an empty form)"
        },
        "x-only": "prov",
        "security": [],
        "responses": {
          "200": {
            "description": "正在退出配网",
            "x-en": {
              "description": "Leaving setup"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "not_found": {
            "status": 404,
            "description": "不在配网期间（热点关着）",
            "x-en": {
              "description": "Not in Wi-Fi setup (the hotspot is off)"
            }
          }
        }
      }
    },
    "/v1/pair": {
      "post": {
        "tags": [
          "配对"
        ],
        "operationId": "post_v1_pair",
        "summary": "申请配对：屏幕弹 4 位数字，人单击 BOOT 允许（30 秒）",
        "description": "开放，不用签名。同一时间只有一个请求在等。之后轮询 GET /v1/pair?id=；领到的是设备现有的密钥，没有才生成",
        "x-en": {
          "summary": "Request pairing: the screen shows a 4-digit code; click BOOT to allow (30 s)",
          "description": "Open; no signing. Only one request can wait at a time. Then poll GET /v1/pair?id=; you get the device's existing key, which is generated only if there is none"
        },
        "x-only": "kernel",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PairRequest"
              },
              "examples": {
                "browser": {
                  "summary": "浏览器",
                  "x-en": {
                    "summary": "Browser"
                  },
                  "value": {
                    "name": "Chrome · Windows"
                  }
                },
                "agent": {
                  "summary": "Agent",
                  "x-en": {
                    "summary": "Agent"
                  },
                  "value": {
                    "name": "Claude Code"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "屏幕已弹出配对请求",
            "x-en": {
              "description": "The request is on the screen"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PairStarted"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "bad_args": {
            "status": 400,
            "description": "name 要 1–32 字节、不含控制字符",
            "x-en": {
              "description": "name must be 1–32 bytes with no control characters"
            },
            "example": "browser"
          },
          "busy": {
            "status": 409,
            "description": "已有一个请求在等：等它过期（30 秒），或在设备上双击 BOOT 拒绝后再试",
            "x-en": {
              "description": "Another request is waiting: let it expire (30 s), or double-click BOOT to deny it, then retry"
            }
          }
        }
      },
      "get": {
        "tags": [
          "配对"
        ],
        "operationId": "get_v1_pair",
        "summary": "查配对结果；允许后第一次查询带密钥",
        "description": "开放。约每秒查一次。key 只给一次，之后这个 id 作废；结论出来 30 秒后、或被新请求顶掉，再查回 404",
        "x-en": {
          "summary": "Pairing result; the first query after approval includes the key",
          "description": "Open. Poll about once a second. The key is given once and the id then becomes invalid; 30 s after the outcome, or once a new request replaces it, queries return 404"
        },
        "x-only": "kernel",
        "security": [],
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "required": true,
            "description": "POST /v1/pair 回的 id",
            "x-en": {
              "description": "id returned by POST /v1/pair"
            },
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{16}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "配对结果",
            "x-en": {
              "description": "Pairing result"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PairResult"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "bad_args": {
            "status": 400,
            "description": "没带 id，或不是 16 位",
            "x-en": {
              "description": "id is missing or not 16 characters"
            }
          },
          "not_found": {
            "status": 404,
            "description": "没有这个请求：已领过密钥、被新请求顶掉，或结论出来超过 30 秒。重新 POST /v1/pair",
            "x-en": {
              "description": "No such request: the key was already taken, a new request replaced it, or the outcome is over 30 s old. POST /v1/pair again"
            }
          },
          "nvs": {
            "status": 500,
            "description": "生成密钥时存储写入失败。重试",
            "x-en": {
              "description": "Saving the new key failed. Retry"
            }
          }
        }
      }
    },
    "/v1/hid": {
      "get": {
        "tags": [
          "HID 键盘鼠标"
        ],
        "operationId": "get_v1_hid",
        "summary": "HID 状态：解锁剩余、队列、按着的键、灯（Num / Caps / Scroll）",
        "description": "随时可查，不改任何状态。等一批执行完：睡到规划结束时刻，再查 done_seq 不小于这批的 seq",
        "x-en": {
          "summary": "HID state: lease left, queue, held keys, LEDs (Num / Caps / Scroll)",
          "description": "Read-only; changes nothing. To wait for a batch, sleep until its planned end, then check that done_seq is at least the batch's seq"
        },
        "x-only": "kernel",
        "responses": {
          "200": {
            "description": "HID 状态",
            "x-en": {
              "description": "HID state"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HidState"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {}
      },
      "post": {
        "tags": [
          "HID 键盘鼠标"
        ],
        "operationId": "post_v1_hid",
        "summary": "发键盘鼠标动作（按键会打进电脑前台窗口）",
        "description": "一批动作排进队列后立即回复，不等执行完。帧与帧之间至少 8 毫秒：tap、click、media 各两帧（按下、松开），text 每个字符两帧。整批先全部校验，有一个不对就 400 bad_action、一个都不发。要先 POST /v1/hid/arm 解锁。这个写法已冻结，不再加动作：新功能只加在时间线（POST /v1/hid/timeline），主机工具用 stick.hidtl.from_actions 把动作转成时间线",
        "x-en": {
          "summary": "Send keyboard and mouse actions (keys go to the foreground window)",
          "description": "Queues a batch of actions and replies at once, without waiting for execution. Frames are at least 8 ms apart: tap, click and media take two frames each (press, release), text two per character. The whole batch is checked first; if one action is invalid the reply is 400 bad_action and nothing is sent. Arm first with POST /v1/hid/arm. This format is frozen and gets no new actions: new features go into timelines (POST /v1/hid/timeline), and host tools convert actions with stick.hidtl.from_actions"
        },
        "x-only": "kernel",
        "x-risk": "keys",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HidActionsRequest"
              },
              "examples": {
                "combo_alt_a": {
                  "summary": "组合键 Alt+A",
                  "description": "组合键是 tap 加 mods，不是 {\"key\":\"alt+a\"}",
                  "x-en": {
                    "summary": "Shortcut Alt+A",
                    "description": "A shortcut is tap plus mods, not {\"key\":\"alt+a\"}"
                  },
                  "value": {
                    "actions": [
                      {
                        "tap": "A",
                        "mods": [
                          "alt"
                        ]
                      }
                    ]
                  }
                },
                "copy_paste": {
                  "summary": "复制再粘贴",
                  "x-en": {
                    "summary": "Copy, then paste"
                  },
                  "value": {
                    "actions": [
                      {
                        "tap": "C",
                        "mods": [
                          "ctrl"
                        ]
                      },
                      {
                        "tap": "V",
                        "mods": [
                          "ctrl"
                        ]
                      }
                    ]
                  }
                },
                "type_text": {
                  "summary": "打字",
                  "description": "\\n 是回车；只收 ASCII",
                  "x-en": {
                    "summary": "Type text",
                    "description": "\\n is Enter; ASCII only"
                  },
                  "value": {
                    "actions": [
                      {
                        "text": "Hello, Keyling!\n"
                      }
                    ]
                  }
                },
                "hold_release": {
                  "summary": "按住再松开",
                  "description": "按住左 Shift，右移三次选中三个字符，再松开",
                  "x-en": {
                    "summary": "Hold and release",
                    "description": "Hold left Shift, press Right three times to select three characters, then release"
                  },
                  "value": {
                    "actions": [
                      {
                        "down": "LSHIFT"
                      },
                      {
                        "tap": "RIGHT"
                      },
                      {
                        "tap": "RIGHT"
                      },
                      {
                        "tap": "RIGHT"
                      },
                      {
                        "up": "LSHIFT"
                      }
                    ]
                  }
                },
                "release_all": {
                  "summary": "松开全部键",
                  "x-en": {
                    "summary": "Release all keys"
                  },
                  "value": {
                    "actions": [
                      {
                        "up": "all"
                      }
                    ]
                  }
                },
                "mouse_move_click": {
                  "summary": "鼠标移动加点击",
                  "description": "向右 120、向上 40，再单击左键",
                  "x-en": {
                    "summary": "Move the mouse and click",
                    "description": "Right 120, up 40, then a left click"
                  },
                  "value": {
                    "actions": [
                      {
                        "move": [
                          120,
                          -40
                        ]
                      },
                      {
                        "click": "left"
                      }
                    ]
                  }
                },
                "drag": {
                  "summary": "拖动",
                  "description": "按住左键、向右移 200 再松开",
                  "x-en": {
                    "summary": "Drag",
                    "description": "Hold the left button, move right 200, then release"
                  },
                  "value": {
                    "actions": [
                      {
                        "press": "left"
                      },
                      {
                        "move": [
                          200,
                          0
                        ]
                      },
                      {
                        "release": "left"
                      }
                    ]
                  }
                },
                "scroll": {
                  "summary": "滚轮",
                  "description": "向下滚 3 格，再向右滚 2 格",
                  "x-en": {
                    "summary": "Scroll",
                    "description": "Scroll down 3 steps, then right 2 steps"
                  },
                  "value": {
                    "actions": [
                      {
                        "wheel": -3
                      },
                      {
                        "hwheel": 2
                      }
                    ]
                  }
                },
                "media": {
                  "summary": "多媒体键",
                  "description": "音量加两下",
                  "x-en": {
                    "summary": "Media keys",
                    "description": "Volume up twice"
                  },
                  "value": {
                    "actions": [
                      {
                        "media": "volume_up"
                      },
                      {
                        "media": "volume_up"
                      }
                    ]
                  }
                },
                "pause": {
                  "summary": "停顿",
                  "description": "Win+R 打开「运行」，等 0.5 秒对话框出来，再输入 notepad 回车；tag 用于对照",
                  "x-en": {
                    "summary": "Pause",
                    "description": "Win+R opens Run, wait 0.5 s for the dialog, then type notepad and Enter; tag is for matching"
                  },
                  "value": {
                    "actions": [
                      {
                        "tap": "R",
                        "mods": [
                          "gui"
                        ]
                      },
                      {
                        "wait": 500
                      },
                      {
                        "text": "notepad\n"
                      }
                    ],
                    "tag": "open-notepad"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "已入队",
            "x-en": {
              "description": "Queued"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HidQueued"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "bad_action": {
            "status": 400,
            "description": "请求体不是 {\"actions\":[...]}、actions 为空，或某个动作写错（message 写第几个、哪里不对）。每个动作只写一种写法：组合键写 {\"tap\":\"A\",\"mods\":[\"alt\"]}，不是 {\"key\":\"alt+a\"}。整批没有入队，改好重发",
            "x-en": {
              "description": "The body is not {\"actions\":[...]}, actions is empty, or an action is wrong (message names which one and why). Each action takes exactly one form: write a shortcut as {\"tap\":\"A\",\"mods\":[\"alt\"]}, not {\"key\":\"alt+a\"}. Nothing was queued; fix it and resend"
            },
            "example": "combo_alt_a"
          },
          "bad_args": {
            "status": 400,
            "description": "带了 wait（已取消：等执行完查 GET /v1/hid 的 done_seq），或 tag 不是 1–32 个 A-Z a-z 0-9 _ . : -",
            "x-en": {
              "description": "wait was given (removed: check done_seq in GET /v1/hid to wait for completion), or tag is not 1–32 of A-Z a-z 0-9 _ . : -"
            }
          },
          "hid_locked": {
            "status": 403,
            "description": "没解锁或租约已到期：先 POST /v1/hid/arm",
            "x-en": {
              "description": "Not armed, or the lease expired: POST /v1/hid/arm first"
            }
          },
          "not_mounted": {
            "status": 503,
            "description": "电脑没枚举这个设备（没插、电脑睡眠，或 USB 模式是 serial）。插好，或 POST /v1/usb 改回 hid",
            "x-en": {
              "description": "The computer has not enumerated the device (unplugged, asleep, or USB mode is serial). Plug it in, or switch back with POST /v1/usb hid"
            }
          },
          "queue_full": {
            "status": 429,
            "description": "一次超过 512 个动作，或队列剩余放不下这批（容量 4096 项，text 按字符计）。分批发，或等 done_seq 跟上；长序列改用时间线",
            "x-en": {
              "description": "More than 512 actions at once, or the queue cannot fit the batch (4096 items, text counts per character). Send in batches or wait for done_seq to catch up; use a timeline for long sequences"
            }
          }
        }
      }
    },
    "/v1/hid/arm": {
      "post": {
        "tags": [
          "HID 键盘鼠标"
        ],
        "operationId": "post_v1_hid_arm",
        "summary": "解锁 HID 输出（租约；到期自动上锁、松开所有键），再调就是续期",
        "description": "网络来源（主机、网页、Agent）的输出要先解锁。租约 seconds 秒（1–600，省略 60）；再调就是续期，剩余时间改为新值。到期自动上锁：清掉网络来源排着的项、松开所有键，GET /v1/hid 的 stopped 记 lease。长序列由主机自己按时续期；主机崩溃或断网，最多一个租约后设备停下并松手",
        "x-en": {
          "summary": "Arm HID output (lease; disarms and releases all keys on expiry). Call again to renew",
          "description": "Output from the network source (host, web app, agent) must be armed first. The lease lasts seconds (1–600, default 60); calling again renews it and replaces the time left. On expiry the device disarms: it drops queued network-source items, releases all keys, and GET /v1/hid reports stopped.why = lease. Hosts running long sequences renew the lease themselves; if the host crashes or loses the network, the device stops and releases within one lease"
        },
        "x-only": "kernel",
        "x-risk": "keys",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HidArmRequest"
              },
              "examples": {
                "arm_60": {
                  "summary": "解锁 60 秒",
                  "x-en": {
                    "summary": "Arm for 60 s"
                  },
                  "value": {
                    "seconds": 60
                  }
                },
                "renew_300": {
                  "summary": "续期到 300 秒",
                  "description": "解锁中再调就是续期：剩余时间改为 300 秒",
                  "x-en": {
                    "summary": "Renew to 300 s",
                    "description": "Calling while armed renews: the time left becomes 300 s"
                  },
                  "value": {
                    "seconds": 300
                  }
                },
                "omit_seconds": {
                  "summary": "省略 seconds（60 秒）",
                  "x-en": {
                    "summary": "Omit seconds (60 s)"
                  },
                  "value": {}
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "已解锁",
            "x-en": {
              "description": "Armed"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HidArmReply"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "bad_seconds": {
            "status": 400,
            "description": "seconds 不是 1–600 的整数，或请求体不是 JSON 对象。改成 {\"seconds\":60}",
            "x-en": {
              "description": "seconds is not an integer in 1–600, or the body is not a JSON object. Use {\"seconds\":60}"
            },
            "example": "arm_60"
          }
        }
      }
    },
    "/v1/hid/disarm": {
      "post": {
        "tags": [
          "HID 键盘鼠标"
        ],
        "operationId": "post_v1_hid_disarm",
        "summary": "急停并上锁",
        "description": "急停：清空队列（网络与应用来源）、松开所有键与鼠标键、上锁，并暂停应用来源（人按一下 BOOT 或重启应用恢复）。stopped 记 host。立即生效（不等队列，实测约 20 毫秒）。空闲时调用是正常收尾，屏幕不弹停止面板",
        "x-en": {
          "summary": "Emergency stop and disarm",
          "description": "Emergency stop: clears the queue (network and app sources), releases all keys and mouse buttons, disarms, and pauses the app source (a press of BOOT or restarting the app resumes it). stopped.why = host. Takes effect at once without waiting for the queue (about 20 ms measured). Calling it while idle is a normal wrap-up; the screen shows no stop panel"
        },
        "x-only": "kernel",
        "responses": {
          "200": {
            "description": "已停下并上锁",
            "x-en": {
              "description": "Stopped and disarmed"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {}
      }
    },
    "/v1/hid/timeline": {
      "post": {
        "tags": [
          "HID 键盘鼠标"
        ],
        "operationId": "post_v1_hid_timeline",
        "summary": "时间线（6 字节记录，按理想时刻准时执行）",
        "description": "唯一的执行格式，新功能只加在这里。上层决定每一帧何时发、发什么，设备按理想时刻逐帧准时执行：本条在上一条的理想时刻加 dt 执行，离上一帧不少于 4 毫秒；落后理想时刻超过 20 毫秒就从当前时刻重新排，不连发补课。一批 1–4096 条，整批读进来逐条校验，全部合法才入队。按下的键要自己松开（或最后加 release_all）。签名照常，X-Stick-Sha256 是二进制体的哈希。主机：stick.hidtl.encode / from_actions，stick hid-play",
        "x-en": {
          "summary": "Timeline (6-byte records, executed at their scheduled times)",
          "description": "The only execution format; new features go here only. The upper layer decides what to send in each frame and when; the device executes frames on their scheduled times: a record runs at the previous record's scheduled time plus dt, at least 4 ms after the previous frame; when more than 20 ms behind schedule it re-schedules from now instead of bursting to catch up. A batch is 1–4096 records, read whole and checked record by record; it is queued only if all are valid. Release the keys you press (or end with release_all). Signing is as usual; X-Stick-Sha256 is the hash of the binary body. Host: stick.hidtl.encode / from_actions, stick hid-play"
        },
        "x-only": "kernel",
        "x-risk": "keys",
        "parameters": [
          {
            "name": "tag",
            "in": "query",
            "required": false,
            "description": "批次标签",
            "x-en": {
              "description": "Batch tag"
            },
            "schema": {
              "$ref": "#/components/schemas/HidTag"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/octet-stream": {
              "schema": {
                "$ref": "#/components/schemas/HidTimelineBody"
              },
              "examples": {
                "combo_alt_a": {
                  "summary": "组合键 Alt+A",
                  "description": "按下 A（修饰位 0x04 = alt），30 毫秒后松开",
                  "x-en": {
                    "summary": "Shortcut Alt+A",
                    "description": "Press A (modifier bits 0x04 = alt), release 30 ms later"
                  },
                  "value": "000001040400 1e0002040000",
                  "x-records": [
                    {
                      "dt": 0,
                      "op": "key_down",
                      "a": 4,
                      "b": 4,
                      "c": 0
                    },
                    {
                      "dt": 30,
                      "op": "key_up",
                      "a": 4,
                      "b": 0,
                      "c": 0
                    }
                  ]
                },
                "abs_click": {
                  "summary": "绝对指针移到主屏中心并单击",
                  "description": "X、Y 都是 16384（0x4000）；左键键位 1",
                  "x-en": {
                    "summary": "Click the center of the primary display",
                    "description": "X and Y are both 16384 (0x4000); left button bit 1"
                  },
                  "value": "000009004000 00000a004000 140004010000 280005010000",
                  "x-records": [
                    {
                      "dt": 0,
                      "op": "abs_x",
                      "a": 0,
                      "b": 64,
                      "c": 0
                    },
                    {
                      "dt": 0,
                      "op": "moveto",
                      "a": 0,
                      "b": 64,
                      "c": 0
                    },
                    {
                      "dt": 20,
                      "op": "btn_down",
                      "a": 1,
                      "b": 0,
                      "c": 0
                    },
                    {
                      "dt": 40,
                      "op": "btn_up",
                      "a": 1,
                      "b": 0,
                      "c": 0
                    }
                  ]
                },
                "media": {
                  "summary": "多媒体键",
                  "description": "音量加（Consumer 0xE9），30 毫秒后松开",
                  "x-en": {
                    "summary": "Media key",
                    "description": "Volume up (consumer 0xE9), released 30 ms later"
                  },
                  "value": "000008e90000 1e0008000000",
                  "x-records": [
                    {
                      "dt": 0,
                      "op": "consumer",
                      "a": 233,
                      "b": 0,
                      "c": 0
                    },
                    {
                      "dt": 30,
                      "op": "consumer",
                      "a": 0,
                      "b": 0,
                      "c": 0
                    }
                  ]
                },
                "release_all": {
                  "summary": "全部松开",
                  "description": "松开所有键、鼠标键与多媒体键（stick hid-release 发的就是这一条）",
                  "x-en": {
                    "summary": "Release everything",
                    "description": "Releases all keys, mouse buttons and media keys (what stick hid-release sends)"
                  },
                  "value": "000007000000",
                  "x-records": [
                    {
                      "dt": 0,
                      "op": "release_all",
                      "a": 0,
                      "b": 0,
                      "c": 0
                    }
                  ]
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "已入队",
            "x-en": {
              "description": "Queued"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HidQueued"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "bad_action": {
            "status": 400,
            "description": "体长不是 6 的倍数或为 0，或某条记录不合法（message 写「第 N 条记录：原因」）。整批没有入队；主机用 stick.hidtl.check 先查",
            "x-en": {
              "description": "The body length is 0 or not a multiple of 6, or a record is invalid (message gives the record number and reason). Nothing was queued; check on the host with stick.hidtl.check"
            },
            "example": "combo_alt_a"
          },
          "bad_args": {
            "status": 400,
            "description": "带了 wait（已取消：等执行完查 GET /v1/hid 的 done_seq），或 tag 不是 1–32 个 A-Z a-z 0-9 _ . : -",
            "x-en": {
              "description": "wait was given (removed: check done_seq in GET /v1/hid to wait for completion), or tag is not 1–32 of A-Z a-z 0-9 _ . : -"
            }
          },
          "too_large": {
            "status": 413,
            "description": "超过 4096 条（24576 字节）。分批发，或放到 TF 卡上用 POST /v1/hid/play_file 播",
            "x-en": {
              "description": "More than 4096 records (24576 bytes). Send in batches, or put it on the microSD card and use POST /v1/hid/play_file"
            }
          },
          "hid_locked": {
            "status": 403,
            "description": "没解锁或租约已到期：先 POST /v1/hid/arm",
            "x-en": {
              "description": "Not armed, or the lease expired: POST /v1/hid/arm first"
            }
          },
          "not_mounted": {
            "status": 503,
            "description": "电脑没枚举这个设备（没插、电脑睡眠，或 USB 模式是 serial）。插好，或 POST /v1/usb 改回 hid",
            "x-en": {
              "description": "The computer has not enumerated the device (unplugged, asleep, or USB mode is serial). Plug it in, or switch back with POST /v1/usb hid"
            }
          },
          "queue_full": {
            "status": 429,
            "description": "队列剩余放不下这批（容量 4096 项）。等 done_seq 跟上再发",
            "x-en": {
              "description": "The queue cannot fit the batch (4096 items). Wait for done_seq to catch up"
            }
          }
        }
      }
    },
    "/v1/hid/play_file": {
      "post": {
        "tags": [
          "HID 键盘鼠标"
        ],
        "operationId": "post_v1_hid_play_file",
        "summary": "从 TF 卡边读边播时间线文件",
        "description": "从 TF 卡上的时间线文件边读边播，适合大宏。文件内容同 POST /v1/hid/timeline 的体（没有文件头），1 条到 16 MB。先整文件校验（超过 1 秒先回 state=checking，再查 GET 等它变成 playing 或 stopped），再按批送进队列。要先解锁，长文件照常续租约。同一时间只播一个",
        "x-en": {
          "summary": "Stream a timeline file from the microSD card",
          "description": "Streams a timeline file from the microSD card; suited to large macros. The file holds the same records as the POST /v1/hid/timeline body (no header), from 1 record to 16 MB. The whole file is validated first (if that takes over 1 s the reply is state=checking; poll GET until playing or stopped), then fed to the queue in batches. Arm first and keep renewing the lease for long files. One file plays at a time"
        },
        "x-only": "kernel",
        "x-risk": "keys",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HidPlayFileRequest"
              },
              "examples": {
                "play": {
                  "summary": "播一个文件",
                  "x-en": {
                    "summary": "Play a file"
                  },
                  "value": {
                    "path": "/stick/macros/a.tl"
                  }
                },
                "play_tagged": {
                  "summary": "带批次标签",
                  "description": "tag 显示在监视页与 GET /v1/hid 的 batch 里",
                  "x-en": {
                    "summary": "With a batch tag",
                    "description": "tag shows on the monitor screen and in batch of GET /v1/hid"
                  },
                  "value": {
                    "path": "/stick/macros/a.tl",
                    "tag": "nightly"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "已开播或正在校验",
            "x-en": {
              "description": "Playing, or still validating"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HidPlayFileReply"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "bad_args": {
            "status": 400,
            "description": "没写 path，或 tag 不对。写成 {\"path\":\"/stick/macros/a.tl\"}",
            "x-en": {
              "description": "path is missing, or tag is invalid. Write {\"path\":\"/stick/macros/a.tl\"}"
            },
            "example": "play"
          },
          "bad_path": {
            "status": 400,
            "description": "path 不合规矩：要以 / 开头、≤ 160 字节，不含 .. // \\ : * ? \" < > | 与控制字符",
            "x-en": {
              "description": "Invalid path: it must start with /, be ≤ 160 bytes, and contain no .. // \\ : * ? \" < > | or control characters"
            },
            "example": "play"
          },
          "not_found": {
            "status": 404,
            "description": "卡上没有这个文件。先 stick sd put 放上去",
            "x-en": {
              "description": "No such file on the card. Upload it with stick sd put"
            }
          },
          "is_dir": {
            "status": 409,
            "description": "这是目录，要写文件路径",
            "x-en": {
              "description": "This is a folder; give a file path"
            }
          },
          "bad_action": {
            "status": 400,
            "description": "文件为空、长度不是 6 的倍数、超过 16 MB，或某条记录不合法（message 写原因）",
            "x-en": {
              "description": "The file is empty, not a multiple of 6 bytes, over 16 MB, or has an invalid record (message says why)"
            }
          },
          "busy": {
            "status": 409,
            "description": "正在播另一个文件。先 POST /v1/hid/play_file/stop",
            "x-en": {
              "description": "Another file is playing. POST /v1/hid/play_file/stop first"
            }
          },
          "hid_locked": {
            "status": 403,
            "description": "没解锁或租约已到期：先 POST /v1/hid/arm",
            "x-en": {
              "description": "Not armed, or the lease expired: POST /v1/hid/arm first"
            }
          },
          "not_mounted": {
            "status": 503,
            "description": "电脑没枚举这个设备（没插、电脑睡眠，或 USB 模式是 serial）。插好，或 POST /v1/usb 改回 hid",
            "x-en": {
              "description": "The computer has not enumerated the device (unplugged, asleep, or USB mode is serial). Plug it in, or switch back with POST /v1/usb hid"
            }
          },
          "no_card": {
            "status": 503,
            "description": "没插卡或卡挂不上（不是 FAT）",
            "x-en": {
              "description": "No card, or the card cannot be mounted (not FAT)"
            }
          },
          "sd_busy": {
            "status": 503,
            "description": "卡正被别的请求占着。稍后再试",
            "x-en": {
              "description": "The card is busy with another request. Try again later"
            }
          },
          "no_mem": {
            "status": 503,
            "description": "播放任务没起来（设备内存不足）。重启设备",
            "x-en": {
              "description": "The playback task did not start (out of memory). Restart the device"
            }
          }
        }
      },
      "get": {
        "tags": [
          "HID 键盘鼠标"
        ],
        "operationId": "get_v1_hid_play_file",
        "summary": "卡上时间线的播放状态",
        "description": "最近一次播放的进度与结论。播完 state 为 done；中途停下为 stopped，why 写原因",
        "x-en": {
          "summary": "Playback state of the card timeline",
          "description": "Progress and outcome of the most recent playback. state is done when finished, or stopped with why when it stopped part way"
        },
        "x-only": "kernel",
        "responses": {
          "200": {
            "description": "播放状态",
            "x-en": {
              "description": "Playback state"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HidPlayStatus"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {}
      }
    },
    "/v1/hid/play_file/stop": {
      "post": {
        "tags": [
          "HID 键盘鼠标"
        ],
        "operationId": "post_v1_hid_play_file_stop",
        "summary": "停播",
        "description": "停播：清掉还没执行的、松开全部，不上锁（租约照旧）。没在播也回成功",
        "x-en": {
          "summary": "Stop playback",
          "description": "Stops playback: drops what has not run and releases everything, without disarming (the lease continues). Succeeds even when nothing is playing"
        },
        "x-only": "kernel",
        "responses": {
          "200": {
            "description": "已停播",
            "x-en": {
              "description": "Stopped"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {}
      }
    },
    "/v1/monitor": {
      "get": {
        "tags": [
          "HID 键盘鼠标"
        ],
        "operationId": "get_v1_monitor",
        "summary": "监视页状态（屏幕右边：名字、模式、第几步、进度）",
        "description": "监视页是否在显示、右边的状态由谁设的、还剩几秒",
        "x-en": {
          "summary": "Monitor screen state (right side: name, mode, step, progress)",
          "description": "Whether the monitor screen is shown, who set the status on its right side, and how long it has left"
        },
        "x-only": "kernel",
        "responses": {
          "200": {
            "description": "监视页状态",
            "x-en": {
              "description": "Monitor screen state"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MonitorReply"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {}
      },
      "post": {
        "tags": [
          "HID 键盘鼠标"
        ],
        "operationId": "post_v1_monitor",
        "summary": "设监视页状态（整体替换）",
        "description": "设监视页右边的状态（整体替换，字段都可省）。主机设的带 ttl_s（省略 60 秒），到期自动清；与应用的 monitor.set 后设的覆盖先设的。{\"clear\":true} 清掉。只改屏幕，不发任何输入",
        "x-en": {
          "summary": "Set the monitor screen state (replaces it)",
          "description": "Sets the status on the right side of the monitor screen (replaces it; every field is optional). A host-set status carries ttl_s (default 60 s) and clears itself on expiry; between this and an app's monitor.set, the later one wins. {\"clear\":true} clears it. Only changes the screen; sends no input"
        },
        "x-only": "kernel",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MonitorSetRequest"
              },
              "examples": {
                "running": {
                  "summary": "运行中",
                  "description": "单次任务进行到第 3 步，进度 43%，120 秒后自动清掉",
                  "x-en": {
                    "summary": "Running",
                    "description": "A one-off task at step 3, 43% done, clearing itself after 120 s. Chinese values: 填单 = fill in a form, 单次 = once, 第 3 步 / 共 7 步 = step 3 of 7"
                  },
                  "value": {
                    "name": "填单",
                    "mode": "单次",
                    "source": "Agent",
                    "state": "running",
                    "line1": "第 3 步 / 共 7 步",
                    "progress": 43,
                    "ttl_s": 120
                  }
                },
                "error": {
                  "summary": "出错",
                  "description": "出错时一直显示停止面板，下面两行用 line1 / line2",
                  "x-en": {
                    "summary": "Error",
                    "description": "An error keeps the stop panel shown, with line1 / line2 below it. Chinese values: 找不到保存按钮 = Save button not found, 单击 BOOT 重试 = click BOOT to retry"
                  },
                  "value": {
                    "name": "填单",
                    "state": "error",
                    "line1": "找不到保存按钮",
                    "line2": "单击 BOOT 重试"
                  }
                },
                "clear": {
                  "summary": "清掉",
                  "x-en": {
                    "summary": "Clear"
                  },
                  "value": {
                    "clear": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "已设",
            "x-en": {
              "description": "Set"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "bad_args": {
            "status": 400,
            "description": "有不认识的字段、类型不对、超长或越界（message 写哪个）",
            "x-en": {
              "description": "Unknown field, wrong type, too long or out of range (message says which)"
            },
            "example": "running"
          },
          "bad_json": {
            "status": 400,
            "description": "请求体不是 JSON 对象",
            "x-en": {
              "description": "The body is not a JSON object"
            },
            "example": "running"
          }
        }
      }
    },
    "/v1/usb": {
      "post": {
        "tags": [
          "HID 键盘鼠标"
        ],
        "operationId": "post_v1_usb",
        "summary": "USB 模式 hid / serial，回复后重启（serial 时没有键盘鼠标）",
        "description": "USB 模式存进设备，回复后约 0.5 秒重启生效。hid（默认）：键盘、鼠标、多媒体键、绝对指针，USB 串口消失；serial：没有 HID，保留 USB 串口控制台，调试用。恢复固件总是串口",
        "x-en": {
          "summary": "USB mode hid / serial; restarts after replying (no keyboard or mouse in serial)",
          "description": "Saves the USB mode and restarts about 0.5 s after replying. hid (default): keyboard, mouse, media keys and absolute pointer, with no USB serial; serial: no HID, keeps the USB serial console for debugging. The rescue firmware always uses serial"
        },
        "x-only": "kernel",
        "x-risk": "reboot",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UsbModeRequest"
              },
              "examples": {
                "hid": {
                  "summary": "键盘鼠标",
                  "x-en": {
                    "summary": "Keyboard and mouse"
                  },
                  "value": {
                    "mode": "hid"
                  }
                },
                "serial": {
                  "summary": "USB 串口",
                  "description": "重启后没有键盘鼠标，要改回得经 Wi-Fi 再调一次",
                  "x-en": {
                    "summary": "USB serial",
                    "description": "After the restart there is no keyboard or mouse; switch back over Wi-Fi"
                  },
                  "value": {
                    "mode": "serial"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "已保存，即将重启",
            "x-en": {
              "description": "Saved; restarting"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UsbModeReply"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "bad_mode": {
            "status": 400,
            "description": "mode 只能是 hid 或 serial",
            "x-en": {
              "description": "mode must be hid or serial"
            },
            "example": "hid"
          },
          "nvs": {
            "status": 500,
            "description": "存储写入失败。重试；仍失败看 stick logs",
            "x-en": {
              "description": "Saving failed. Retry; if it persists, check stick logs"
            }
          }
        }
      }
    },
    "/v1/apps": {
      "get": {
        "tags": [
          "应用与宏"
        ],
        "operationId": "get_v1_apps",
        "summary": "应用列表、在跑的、自启动、内存",
        "description": "列出存储区 /apps 下的应用（清单坏的也列出，带 error），加上运行时状态。不改任何状态",
        "x-en": {
          "summary": "Apps, the running app, start on boot, memory",
          "description": "Lists the apps under /apps in storage (ones with a broken manifest too, with error), plus the runtime state. Changes nothing"
        },
        "x-only": "kernel",
        "responses": {
          "200": {
            "description": "应用与运行时状态",
            "x-en": {
              "description": "Apps and runtime state"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AppsList"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "no_storage": {
            "status": 503,
            "description": "存储区没挂上。看 GET /v1/logs",
            "x-en": {
              "description": "Storage is not mounted. See GET /v1/logs"
            }
          }
        }
      }
    },
    "/v1/apps/start": {
      "post": {
        "tags": [
          "应用与宏"
        ],
        "operationId": "post_v1_apps_start",
        "summary": "启动应用（宏播放器是 macro）",
        "description": "先停掉在跑的应用，再读清单、跑入口文件顶层（限 1000 毫秒），跑完才回复。顶层出错也回 HTTP 200，但 ok 为 false、error 为 app_error，应用停在 error 态。清单带 hid 权限的打开应用来源",
        "x-en": {
          "summary": "Start an app (the macro player is macro)",
          "description": "Stops the running app, reads the manifest and runs the entry file's top level (limit 1000 ms), replying when it finishes. A top-level error still returns HTTP 200, with ok false and error app_error; the app stays in the error state. A manifest with the hid permission opens the app source"
        },
        "x-only": "kernel",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AppsIdRequest"
              },
              "examples": {
                "start_clock": {
                  "summary": "启动时钟",
                  "x-en": {
                    "summary": "Start the clock"
                  },
                  "value": {
                    "id": "clock"
                  }
                },
                "start_macro": {
                  "summary": "启动宏播放器",
                  "description": "启动后单击 BOOT 运行当前宏",
                  "x-en": {
                    "summary": "Start the macro player",
                    "description": "Once started, a click of BOOT runs the current macro"
                  },
                  "value": {
                    "id": "macro"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "已启动；顶层出错时 ok 为 false",
            "x-en": {
              "description": "Started; ok is false on a top-level error"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AppsStartReply"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "no_storage": {
            "status": 503,
            "description": "存储区没挂上。看 GET /v1/logs",
            "x-en": {
              "description": "Storage is not mounted. See GET /v1/logs"
            }
          },
          "bad_json": {
            "status": 400,
            "description": "请求体不是 JSON 对象",
            "x-en": {
              "description": "The body is not a JSON object"
            }
          },
          "bad_id": {
            "status": 400,
            "description": "id 不是 1–24 个 a-z 0-9 _ -",
            "x-en": {
              "description": "id is not 1–24 of a-z 0-9 _ -"
            },
            "example": "start_clock"
          },
          "no_app": {
            "status": 404,
            "description": "存储区里没有这个应用（message 是 id）。先 stick push",
            "x-en": {
              "description": "No such app in storage (message is the id). Run stick push first"
            }
          },
          "bad_manifest": {
            "status": 400,
            "description": "manifest.json 没有、不是 JSON，或不合清单规则（docs/lua.md 第 2 节）",
            "x-en": {
              "description": "manifest.json is missing, not JSON, or breaks the manifest rules (docs/lua.md section 2)"
            }
          },
          "start_failed": {
            "status": 500,
            "description": "运行时没就绪等内部错误（message 是 ESP-IDF 错误名）",
            "x-en": {
              "description": "Internal error such as the runtime not ready (message is the ESP-IDF error name)"
            }
          }
        }
      }
    },
    "/v1/apps/stop": {
      "post": {
        "tags": [
          "应用与宏"
        ],
        "operationId": "post_v1_apps_stop",
        "summary": "停当前应用，回主页",
        "description": "停掉在跑的应用（先调 app.on_stop，限 200 毫秒），关闭应用来源，回主页。没有应用在跑也回成功。不用带请求体",
        "x-en": {
          "summary": "Stop the current app and return home",
          "description": "Stops the running app (calls app.on_stop first, limit 200 ms), closes the app source and shows the home screen. Succeeds when no app is running too. No body needed"
        },
        "x-only": "kernel",
        "responses": {
          "200": {
            "description": "已停止",
            "x-en": {
              "description": "Stopped"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "bad_json": {
            "status": 400,
            "description": "带了请求体但不是 JSON 对象。不带体即可",
            "x-en": {
              "description": "A body was sent but is not a JSON object. Send no body"
            }
          }
        }
      }
    },
    "/v1/apps/auto": {
      "post": {
        "tags": [
          "应用与宏"
        ],
        "operationId": "post_v1_apps_auto",
        "summary": "设 / 取消开机自启动（id 为 null 取消）",
        "description": "开机 3 秒后自动启动这个应用；id 为 null 取消。连续 3 次在启动后 10 秒内出错会自动取消",
        "x-en": {
          "summary": "Set or clear start on boot (id null clears)",
          "description": "Starts this app 3 s after boot; id null clears it. Cleared automatically after 3 errors in a row within 10 s of starting"
        },
        "x-only": "kernel",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AppsAutoRequest"
              },
              "examples": {
                "set_clock": {
                  "summary": "开机启动时钟",
                  "x-en": {
                    "summary": "Start the clock on boot"
                  },
                  "value": {
                    "id": "clock"
                  }
                },
                "clear": {
                  "summary": "取消自启动",
                  "x-en": {
                    "summary": "Clear start on boot"
                  },
                  "value": {
                    "id": null
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "已保存",
            "x-en": {
              "description": "Saved"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AppsAutoReply"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "no_storage": {
            "status": 503,
            "description": "存储区没挂上。看 GET /v1/logs",
            "x-en": {
              "description": "Storage is not mounted. See GET /v1/logs"
            }
          },
          "bad_json": {
            "status": 400,
            "description": "请求体不是 JSON 对象",
            "x-en": {
              "description": "The body is not a JSON object"
            }
          },
          "bad_id": {
            "status": 400,
            "description": "id 不是字符串或 null、不是 1–24 个 a-z 0-9 _ -，或以 _ 开头（临时应用不能自启动）",
            "x-en": {
              "description": "id is not a string or null, not 1–24 of a-z 0-9 _ -, or starts with _ (temporary apps cannot start on boot)"
            },
            "example": "set_clock"
          },
          "no_app": {
            "status": 404,
            "description": "存储区里没有这个应用（message 是 id）。先 stick push",
            "x-en": {
              "description": "No such app in storage (message is the id). Run stick push first"
            }
          },
          "bad_manifest": {
            "status": 400,
            "description": "manifest.json 没有、不是 JSON，或不合清单规则（docs/lua.md 第 2 节）",
            "x-en": {
              "description": "manifest.json is missing, not JSON, or breaks the manifest rules (docs/lua.md section 2)"
            }
          },
          "nvs": {
            "status": 500,
            "description": "保存到 NVS 失败。重试",
            "x-en": {
              "description": "Saving to NVS failed. Try again"
            }
          }
        }
      }
    },
    "/v1/apps/delete": {
      "post": {
        "tags": [
          "应用与宏"
        ],
        "operationId": "post_v1_apps_delete",
        "summary": "删应用目录（不删它的数据目录）",
        "description": "删掉 /apps/<id> 整个目录：在跑就先停，是自启动的就取消。数据目录 /data/<id> 不删",
        "x-en": {
          "summary": "Delete an app folder (keeps its data folder)",
          "description": "Deletes the whole /apps/<id> folder: stops the app first if it is running and clears start on boot if set. The data folder /data/<id> is kept"
        },
        "x-only": "kernel",
        "x-risk": "data",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AppsIdRequest"
              },
              "examples": {
                "delete_hello": {
                  "summary": "删除应用 hello",
                  "x-en": {
                    "summary": "Delete the app hello"
                  },
                  "value": {
                    "id": "hello"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "已删除",
            "x-en": {
              "description": "Deleted"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "no_storage": {
            "status": 503,
            "description": "存储区没挂上。看 GET /v1/logs",
            "x-en": {
              "description": "Storage is not mounted. See GET /v1/logs"
            }
          },
          "bad_json": {
            "status": 400,
            "description": "请求体不是 JSON 对象",
            "x-en": {
              "description": "The body is not a JSON object"
            }
          },
          "bad_id": {
            "status": 400,
            "description": "id 不是 1–24 个 a-z 0-9 _ -",
            "x-en": {
              "description": "id is not 1–24 of a-z 0-9 _ -"
            }
          },
          "no_app": {
            "status": 404,
            "description": "存储区里没有这个应用（message 是 id）。先 stick push",
            "x-en": {
              "description": "No such app in storage (message is the id). Run stick push first"
            }
          },
          "io_error": {
            "status": 500,
            "description": "删目录失败（存储区出错）。看 GET /v1/logs",
            "x-en": {
              "description": "Deleting the folder failed (storage error). See GET /v1/logs"
            }
          }
        }
      }
    },
    "/v1/apps/msg": {
      "post": {
        "tags": [
          "应用与宏"
        ],
        "operationId": "post_v1_apps_msg",
        "summary": "发消息给在跑的应用；宏播放器：select / run / stop / reload / plan",
        "description": "把 data 转成 Lua 值交给在跑应用的 app.on_message，排进队列就回复，不等处理完；应用的回应看 GET /v1/apps/events。宏播放器（应用 macro）认 AppsMacroCommand，命令不对时发 error 事件，接口照样回成功。error 态的应用收不到",
        "x-en": {
          "summary": "Message the running app; macro player: select / run / stop / reload / plan",
          "description": "Converts data to a Lua value for the running app's app.on_message and replies once it is queued, without waiting; read the app's response in GET /v1/apps/events. The macro player (app macro) takes AppsMacroCommand; for a bad command it emits an error event and the endpoint still succeeds. Apps in the error state receive nothing"
        },
        "x-only": "kernel",
        "x-risk": "keys",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AppsMsgRequest"
              },
              "examples": {
                "macro_select": {
                  "summary": "宏播放器：设为当前宏",
                  "description": "设备上的宏「每日签到」设为当前（在跑先停），发 selected 事件",
                  "x-en": {
                    "summary": "Macro player: set the current macro",
                    "description": "Makes the macro 每日签到 (daily check-in) on the device current (stops a running one first); emits selected"
                  },
                  "value": {
                    "data": {
                      "cmd": "select",
                      "name": "每日签到",
                      "where": "fs"
                    }
                  }
                },
                "macro_run": {
                  "summary": "宏播放器：运行当前宏",
                  "description": "会往电脑按键。已在跑时发 started 并带 already",
                  "x-en": {
                    "summary": "Macro player: run the current macro",
                    "description": "Presses keys on the computer. If already running, emits started with already"
                  },
                  "value": {
                    "data": {
                      "cmd": "run"
                    }
                  }
                },
                "macro_trial": {
                  "summary": "宏播放器：试跑",
                  "description": "按 once 跑一遍，不改当前宏；事件带 trial",
                  "x-en": {
                    "summary": "Macro player: trial run",
                    "description": "Runs it once without changing the current macro; events carry trial"
                  },
                  "value": {
                    "data": {
                      "cmd": "run",
                      "name": "每日签到"
                    }
                  }
                },
                "other_app": {
                  "summary": "发给别的应用",
                  "description": "任意 JSON，由应用的 app.on_message 解释",
                  "x-en": {
                    "summary": "Message another app",
                    "description": "Any JSON, interpreted by the app's app.on_message"
                  },
                  "value": {
                    "data": {
                      "cmd": "reset"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "已交给应用",
            "x-en": {
              "description": "Handed to the app"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "bad_json": {
            "status": 400,
            "description": "请求体不是 JSON 对象，或缺 data",
            "x-en": {
              "description": "The body is not a JSON object, or data is missing"
            }
          },
          "no_app_running": {
            "status": 409,
            "description": "没有应用在跑。先 POST /v1/apps/start（宏播放器是 macro）",
            "x-en": {
              "description": "No app is running. POST /v1/apps/start first (the macro player is macro)"
            },
            "example": "macro_run"
          },
          "msg_failed": {
            "status": 500,
            "description": "应用的消息队列满（100 毫秒内排不进去）。稍后重试",
            "x-en": {
              "description": "The app's message queue is full (not queued within 100 ms). Try again later"
            }
          }
        }
      }
    },
    "/v1/apps/events": {
      "get": {
        "tags": [
          "应用与宏"
        ],
        "operationId": "get_v1_apps_events",
        "summary": "应用发的事件（app.emit）",
        "description": "app.emit 的事件环，留最近 64 条，重启清空。增量读：since 传上次回复的 next。since 省略为 0，即从环里最早的一条起",
        "x-en": {
          "summary": "Events emitted by apps (app.emit)",
          "description": "Ring of app.emit events keeping the latest 64, cleared on reboot. To read incrementally, pass the last reply's next as since. since defaults to 0, i.e. the oldest event in the ring"
        },
        "x-only": "kernel",
        "parameters": [
          {
            "name": "since",
            "in": "query",
            "required": false,
            "description": "从这个序号起（含），取上次回复的 next；省略为 0",
            "x-en": {
              "description": "Start at this sequence number (inclusive); use the last reply's next. Defaults to 0"
            },
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          },
          {
            "name": "max",
            "in": "query",
            "required": false,
            "description": "最多几条，1–64；0 或省略为 64",
            "x-en": {
              "description": "Max events, 1–64; 0 or omitted means 64"
            },
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 64
            }
          }
        ],
        "responses": {
          "200": {
            "description": "事件",
            "x-en": {
              "description": "Events"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AppsEvents"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {}
      }
    },
    "/v1/eval": {
      "post": {
        "tags": [
          "应用与宏"
        ],
        "operationId": "post_v1_eval",
        "summary": "在应用的 Lua 状态里跑一段代码（能调 hid，小心）",
        "description": "先把 code 当表达式试（前面加 return），不行再当语句。在正在跑的应用的 Lua 状态里执行，能读写它的变量、调 hid；没有应用就用临时状态（只有 sys log json 与标准库）。出错、超时也回 HTTP 200，ok 为 false。请求体最多 64 KB",
        "x-en": {
          "summary": "Run code in the app’s Lua state (can call hid; take care)",
          "description": "Tries code as an expression first (prefixed with return), then as statements. Runs in the running app's Lua state, so it can read and change the app's variables and call hid; with no app running, in a temporary state (only sys, log, json and the standard library). Errors and timeouts still return HTTP 200 with ok false. The body is at most 64 KB"
        },
        "x-only": "kernel",
        "x-risk": "keys",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AppsEvalRequest"
              },
              "examples": {
                "heap": {
                  "summary": "看内存（表达式）",
                  "x-en": {
                    "summary": "Check memory (expression)"
                  },
                  "value": {
                    "code": "sys.heap()"
                  }
                },
                "statement": {
                  "summary": "改应用的变量（语句）",
                  "description": "没有返回值，result 为 null",
                  "x-en": {
                    "summary": "Change an app variable (statement)",
                    "description": "No return value, so result is null"
                  },
                  "value": {
                    "code": "count = 0",
                    "timeout_ms": 500
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "执行结果；出错时 ok 为 false",
            "x-en": {
              "description": "Result; ok is false on error"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AppsEvalReply"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "bad_json": {
            "status": 400,
            "description": "请求体不是 JSON 对象，或缺 code（字符串）",
            "x-en": {
              "description": "The body is not a JSON object, or code (a string) is missing"
            },
            "example": "heap"
          },
          "eval_failed": {
            "status": 500,
            "description": "Lua 运行时没就绪，或内存不足拿不到结果",
            "x-en": {
              "description": "The Lua runtime is not ready, or memory ran out before a result"
            }
          }
        }
      }
    },
    "/v1/fs/list": {
      "get": {
        "tags": [
          "存储区文件"
        ],
        "operationId": "get_v1_fs_list",
        "summary": "列存储区的目录（最多 256 项）",
        "description": "列出一层的文件与子目录，附存储区总量与已用量",
        "x-en": {
          "summary": "List a storage folder (up to 256 entries)",
          "description": "Lists the files and subfolders one level deep, with the storage total and used bytes"
        },
        "x-only": "kernel",
        "parameters": [
          {
            "name": "path",
            "in": "query",
            "required": false,
            "description": "目录，省略为根 /",
            "x-en": {
              "description": "Folder; the root / when omitted"
            },
            "schema": {
              "$ref": "#/components/schemas/FsPath"
            },
            "example": "/apps"
          }
        ],
        "responses": {
          "200": {
            "description": "目录列表",
            "x-en": {
              "description": "Folder listing"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FsList"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "bad_path": {
            "status": 400,
            "description": "path 缺了或不合规矩（见 path 的说明）",
            "x-en": {
              "description": "path is missing or invalid (see path)"
            }
          },
          "not_found": {
            "status": 404,
            "description": "没有这个目录",
            "x-en": {
              "description": "No such folder"
            }
          },
          "not_dir": {
            "status": 400,
            "description": "path 是文件。读文件用 GET /v1/fs",
            "x-en": {
              "description": "path is a file. Read files with GET /v1/fs"
            }
          },
          "no_storage": {
            "status": 503,
            "description": "存储区没挂上。重启设备；仍不行看 stick logs",
            "x-en": {
              "description": "Storage is not mounted. Restart the device; if it persists, check stick logs"
            }
          },
          "io_error": {
            "status": 500,
            "description": "读写存储区出错。重试；仍失败看 stick logs",
            "x-en": {
              "description": "Storage read/write error. Retry; if it persists, check stick logs"
            }
          }
        }
      }
    },
    "/v1/fs": {
      "get": {
        "tags": [
          "存储区文件"
        ],
        "operationId": "get_v1_fs",
        "summary": "读存储区的文件（整个文件）",
        "description": "回复是文件原样的字节。主机：stick fs get",
        "x-en": {
          "summary": "Read a storage file (whole file)",
          "description": "The reply is the file's raw bytes. Host: stick fs get"
        },
        "x-only": "kernel",
        "x-resp": "binary",
        "parameters": [
          {
            "name": "path",
            "in": "query",
            "required": true,
            "description": "文件",
            "x-en": {
              "description": "File"
            },
            "schema": {
              "$ref": "#/components/schemas/FsPath"
            },
            "example": "/apps/clock/main.lua"
          }
        ],
        "responses": {
          "200": {
            "description": "文件内容",
            "x-en": {
              "description": "File content"
            },
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "contentMediaType": "application/octet-stream"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "bad_path": {
            "status": 400,
            "description": "path 缺了或不合规矩（见 path 的说明）",
            "x-en": {
              "description": "path is missing or invalid (see path)"
            }
          },
          "not_found": {
            "status": 404,
            "description": "没有这个文件",
            "x-en": {
              "description": "No such file"
            }
          },
          "is_dir": {
            "status": 400,
            "description": "path 是目录。列目录用 GET /v1/fs/list",
            "x-en": {
              "description": "path is a folder. List it with GET /v1/fs/list"
            }
          },
          "no_storage": {
            "status": 503,
            "description": "存储区没挂上。重启设备；仍不行看 stick logs",
            "x-en": {
              "description": "Storage is not mounted. Restart the device; if it persists, check stick logs"
            }
          },
          "io_error": {
            "status": 500,
            "description": "读写存储区出错。重试；仍失败看 stick logs",
            "x-en": {
              "description": "Storage read/write error. Retry; if it persists, check stick logs"
            }
          }
        }
      },
      "put": {
        "tags": [
          "存储区文件"
        ],
        "operationId": "put_v1_fs",
        "summary": "写存储区的文件（≤ 2 MB，覆盖同名文件）",
        "description": "请求体是文件的全部内容。自动建上级目录；先写临时文件 path~ 再改名，失败不留半个文件。主机：stick fs put、stick push、stick www push",
        "x-en": {
          "summary": "Write a storage file (≤ 2 MB; replaces an existing one)",
          "description": "The body is the whole file. Parent folders are created; the device writes path~ first and then renames it, so a failure never leaves half a file. Host: stick fs put, stick push, stick www push"
        },
        "x-only": "kernel",
        "x-risk": "data",
        "parameters": [
          {
            "name": "path",
            "in": "query",
            "required": true,
            "description": "文件",
            "x-en": {
              "description": "File"
            },
            "schema": {
              "$ref": "#/components/schemas/FsPath"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "text/plain": {
              "schema": {
                "type": "string",
                "x-max-bytes": 2097152,
                "description": "文件内容：文本按 UTF-8，二进制文件（如字库）原样的字节",
                "x-en": {
                  "description": "File content: UTF-8 text, or the raw bytes of a binary file (such as a font)"
                }
              },
              "examples": {
                "app_main": {
                  "summary": "写应用的入口文件",
                  "x-en": {
                    "summary": "Write an app's entry file"
                  },
                  "x-query": {
                    "path": "/apps/clock/main.lua"
                  },
                  "value": "ui.label(ui.root(), {text = sys.date(\"%H:%M\"), font = 48, align = \"center\"})\n"
                },
                "app_manifest": {
                  "summary": "写应用清单",
                  "description": "name 是屏幕上显示的应用名",
                  "x-en": {
                    "summary": "Write an app manifest",
                    "description": "name is the app name shown on screen (时钟 = Clock)"
                  },
                  "x-query": {
                    "path": "/apps/clock/manifest.json"
                  },
                  "value": "{\"id\":\"clock\",\"name\":\"时钟\",\"version\":\"0.1.0\",\"main\":\"main.lua\"}"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "已写入",
            "x-en": {
              "description": "Written"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FsWriteReply"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "bad_path": {
            "status": 400,
            "description": "path 缺了或不合规矩（见 path 的说明），或指向目录（为 / 或以 / 结尾）",
            "x-en": {
              "description": "path is missing or invalid (see path), or names a folder (/ or ending in /)"
            }
          },
          "is_dir": {
            "status": 409,
            "description": "同名目录已存在",
            "x-en": {
              "description": "A folder with this name exists"
            }
          },
          "bad_parent": {
            "status": 409,
            "description": "上级路径上有同名文件，建不了目录",
            "x-en": {
              "description": "A file in the parent path blocks creating the folder"
            }
          },
          "too_large": {
            "status": 413,
            "description": "超过 2 MB",
            "x-en": {
              "description": "Larger than 2 MB"
            }
          },
          "no_space": {
            "status": 507,
            "description": "存储区满了。删掉不用的文件（GET /v1/fs/list 看 total、used）",
            "x-en": {
              "description": "Storage is full. Delete unused files (see total and used in GET /v1/fs/list)"
            }
          },
          "no_storage": {
            "status": 503,
            "description": "存储区没挂上。重启设备；仍不行看 stick logs",
            "x-en": {
              "description": "Storage is not mounted. Restart the device; if it persists, check stick logs"
            }
          },
          "io_error": {
            "status": 500,
            "description": "读写存储区出错。重试；仍失败看 stick logs",
            "x-en": {
              "description": "Storage read/write error. Retry; if it persists, check stick logs"
            }
          }
        }
      },
      "delete": {
        "tags": [
          "存储区文件"
        ],
        "operationId": "delete_v1_fs",
        "summary": "删存储区的文件或目录（recursive=1 连里面一起删）",
        "description": "目录要是空的，recursive=1 连里面的东西一起删。不能删根；/apps、/data、/fonts 删掉后自动重建为空目录",
        "x-en": {
          "summary": "Delete a storage file or folder (recursive=1 deletes its contents)",
          "description": "A folder must be empty unless recursive=1. The root cannot be deleted; /apps, /data and /fonts come back empty after deletion"
        },
        "x-only": "kernel",
        "x-risk": "data",
        "parameters": [
          {
            "name": "path",
            "in": "query",
            "required": true,
            "description": "文件或目录",
            "x-en": {
              "description": "File or folder"
            },
            "schema": {
              "$ref": "#/components/schemas/FsPath"
            },
            "example": "/apps/_try"
          },
          {
            "name": "recursive",
            "in": "query",
            "required": false,
            "description": "1 = 目录连里面的东西一起删",
            "x-en": {
              "description": "1 = delete a folder with everything in it"
            },
            "schema": {
              "type": "integer",
              "enum": [
                0,
                1
              ],
              "default": 0
            },
            "example": 1
          }
        ],
        "responses": {
          "200": {
            "description": "已删除",
            "x-en": {
              "description": "Deleted"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "bad_path": {
            "status": 400,
            "description": "path 缺了或不合规矩（见 path 的说明），或是根 /",
            "x-en": {
              "description": "path is missing or invalid (see path), or is the root /"
            }
          },
          "not_found": {
            "status": 404,
            "description": "没有这个文件或目录",
            "x-en": {
              "description": "No such file or folder"
            }
          },
          "not_empty": {
            "status": 409,
            "description": "目录不空：加 recursive=1",
            "x-en": {
              "description": "The folder is not empty: add recursive=1"
            }
          },
          "no_storage": {
            "status": 503,
            "description": "存储区没挂上。重启设备；仍不行看 stick logs",
            "x-en": {
              "description": "Storage is not mounted. Restart the device; if it persists, check stick logs"
            }
          },
          "io_error": {
            "status": 500,
            "description": "读写存储区出错。重试；仍失败看 stick logs",
            "x-en": {
              "description": "Storage read/write error. Retry; if it persists, check stick logs"
            }
          }
        }
      }
    },
    "/v1/sd/list": {
      "get": {
        "tags": [
          "TF 卡"
        ],
        "operationId": "get_v1_sd_list",
        "summary": "列 TF 卡上的目录（最多 256 项）",
        "description": "列出一层的文件与子目录，附卡的总量与已用量。上传中断留下的临时文件 x~ 也会列出",
        "x-en": {
          "summary": "List a folder on the microSD card (up to 256 entries)",
          "description": "Lists the files and subfolders one level deep, with the card total and used bytes. Temp files x~ left by interrupted uploads are listed too"
        },
        "x-only": "kernel",
        "parameters": [
          {
            "name": "path",
            "in": "query",
            "required": false,
            "description": "目录，省略为卡根 /",
            "x-en": {
              "description": "Folder; the card root / when omitted"
            },
            "schema": {
              "$ref": "#/components/schemas/SdPath"
            },
            "example": "/stick"
          }
        ],
        "responses": {
          "200": {
            "description": "目录列表",
            "x-en": {
              "description": "Folder listing"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FsList"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "bad_path": {
            "status": 400,
            "description": "path 缺了或不合规矩（见 path 的说明）",
            "x-en": {
              "description": "path is missing or invalid (see path)"
            }
          },
          "not_found": {
            "status": 404,
            "description": "没有这个目录",
            "x-en": {
              "description": "No such folder"
            }
          },
          "not_dir": {
            "status": 400,
            "description": "path 是文件。读文件用 GET /v1/sd",
            "x-en": {
              "description": "path is a file. Read files with GET /v1/sd"
            }
          },
          "no_card": {
            "status": 503,
            "description": "没插卡、卡不是 FAT，或刚试过挂载（2 秒后再试）；message 写原因",
            "x-en": {
              "description": "No card, the card is not FAT, or a mount was just tried (retry in 2 s); message says which"
            }
          },
          "io_error": {
            "status": 500,
            "description": "读写卡出错，设备已卸载卡，下一个请求重挂。重试",
            "x-en": {
              "description": "Card read/write error; the device unmounted the card and remounts on the next request. Retry"
            }
          }
        }
      }
    },
    "/v1/sd": {
      "get": {
        "tags": [
          "TF 卡"
        ],
        "operationId": "get_v1_sd",
        "summary": "分块读 TF 卡上的文件（每次 ≤ 1 MB）",
        "description": "回复是 [offset, offset+length) 原样的字节，头 X-Size 是文件总大小。主机每块 256 KB，读到 X-Size 为止；中断后从已有的字节数接着读（stick sd get 自动续传）。读到一半出错时设备只能断开连接，少收了就重读这一块",
        "x-en": {
          "summary": "Read a card file in chunks (≤ 1 MB per request)",
          "description": "The reply is the raw bytes of [offset, offset+length); the X-Size header is the file size. The host reads 256 KB chunks up to X-Size and resumes from the bytes it already has (stick sd get does this). If the device fails part way it can only drop the connection; re-read a short chunk"
        },
        "x-only": "kernel",
        "x-resp": "binary",
        "parameters": [
          {
            "name": "path",
            "in": "query",
            "required": true,
            "description": "文件",
            "x-en": {
              "description": "File"
            },
            "schema": {
              "$ref": "#/components/schemas/SdPath"
            },
            "example": "/stick/macros/a.tl"
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "description": "起点字节，省略为 0",
            "x-en": {
              "description": "Start byte; 0 when omitted"
            },
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 2147483647
            },
            "example": 0
          },
          {
            "name": "length",
            "in": "query",
            "required": false,
            "description": "字节数，省略或超过 1 MB 时取到 1 MB 为止（不超过文件尾）",
            "x-en": {
              "description": "Byte count; up to 1 MB when omitted or larger (never past the end of the file)"
            },
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 1048576
            },
            "example": 262144
          }
        ],
        "responses": {
          "200": {
            "description": "文件这一段的字节",
            "x-en": {
              "description": "Bytes of this part of the file"
            },
            "headers": {
              "X-Size": {
                "description": "文件总字节数",
                "x-en": {
                  "description": "File size in bytes"
                },
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "X-Offset": {
                "description": "这一段的起点（同 offset）",
                "x-en": {
                  "description": "Start of this part (same as offset)"
                },
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "contentMediaType": "application/octet-stream"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "bad_path": {
            "status": 400,
            "description": "path 缺了或不合规矩（见 path 的说明）",
            "x-en": {
              "description": "path is missing or invalid (see path)"
            }
          },
          "bad_args": {
            "status": 400,
            "description": "offset 或 length 不是非负整数",
            "x-en": {
              "description": "offset or length is not a non-negative integer"
            }
          },
          "bad_offset": {
            "status": 416,
            "description": "offset 超过文件大小（超过 2 GB 时为 400）",
            "x-en": {
              "description": "offset is past the end of the file (400 when over 2 GB)"
            }
          },
          "not_found": {
            "status": 404,
            "description": "没有这个文件",
            "x-en": {
              "description": "No such file"
            }
          },
          "is_dir": {
            "status": 400,
            "description": "path 是目录。列目录用 GET /v1/sd/list",
            "x-en": {
              "description": "path is a folder. List it with GET /v1/sd/list"
            }
          },
          "no_card": {
            "status": 503,
            "description": "没插卡、卡不是 FAT，或刚试过挂载（2 秒后再试）；message 写原因",
            "x-en": {
              "description": "No card, the card is not FAT, or a mount was just tried (retry in 2 s); message says which"
            }
          },
          "io_error": {
            "status": 500,
            "description": "读写卡出错，设备已卸载卡，下一个请求重挂。重试",
            "x-en": {
              "description": "Card read/write error; the device unmounted the card and remounts on the next request. Retry"
            }
          }
        }
      },
      "put": {
        "tags": [
          "TF 卡"
        ],
        "operationId": "put_v1_sd",
        "summary": "分块写 TF 卡上的文件（每块 ≤ 1 MB，可续传）",
        "description": "每块写进临时文件 path~ 的 offset 处：offset=0 新建，之后 offset 要等于已写的字节数；final=1 写完把 path~ 改名为 path（覆盖同名文件）。offset 与 final 都省略 = 小文件一次传完。自动建上级目录。这一块没收全或哈希不符时临时文件截回 offset，从 offset 重发即可。主机每块 256 KB（stick sd put，可传整个目录）",
        "x-en": {
          "summary": "Write a card file in chunks (≤ 1 MB each, resumable)",
          "description": "Each chunk goes into the temp file path~ at offset: offset=0 starts it, later offsets must equal the bytes written so far; final=1 then renames path~ to path (replacing an existing file). Omitting both offset and final uploads a small file in one go. Parent folders are created. If a chunk arrives incomplete or its hash mismatches, the temp file is cut back to offset; resend from offset. The host uses 256 KB chunks (stick sd put, which also uploads folders)"
        },
        "x-only": "kernel",
        "x-risk": "data",
        "parameters": [
          {
            "name": "path",
            "in": "query",
            "required": true,
            "description": "文件",
            "x-en": {
              "description": "File"
            },
            "schema": {
              "$ref": "#/components/schemas/SdPath"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "description": "这一块在文件里的起点字节",
            "x-en": {
              "description": "Start byte of this chunk in the file"
            },
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 2147483647
            }
          },
          {
            "name": "final",
            "in": "query",
            "required": false,
            "description": "1 = 最后一块，写完改名",
            "x-en": {
              "description": "1 = last chunk; rename when written"
            },
            "schema": {
              "type": "integer",
              "enum": [
                0,
                1
              ]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/octet-stream": {
              "schema": {
                "type": "string",
                "contentMediaType": "application/octet-stream",
                "x-max-bytes": 1048576,
                "description": "这一块的字节",
                "x-en": {
                  "description": "Bytes of this chunk"
                }
              },
              "examples": {
                "small_file": {
                  "summary": "小文件一次传完",
                  "description": "省略 offset 与 final；内容是 hello 加换行",
                  "x-en": {
                    "summary": "Small file in one go",
                    "description": "offset and final omitted; the content is hello and a newline"
                  },
                  "x-query": {
                    "path": "/stick/notes/hello.txt"
                  },
                  "value": "68656c6c6f0a"
                },
                "first_chunk": {
                  "summary": "大文件的第一块",
                  "description": "offset=0 新建 big.tl~；真传时每块 256 KB，这里只示意 6 字节",
                  "x-en": {
                    "summary": "First chunk of a large file",
                    "description": "offset=0 starts big.tl~; real chunks are 256 KB, 6 bytes shown here"
                  },
                  "x-query": {
                    "path": "/stick/macros/big.tl",
                    "offset": 0
                  },
                  "value": "000001040400"
                },
                "last_chunk": {
                  "summary": "续传最后一块",
                  "description": "已写 262144 字节；final=1 写完改名为 big.tl",
                  "x-en": {
                    "summary": "Resume with the last chunk",
                    "description": "262144 bytes already written; final=1 renames it to big.tl"
                  },
                  "x-query": {
                    "path": "/stick/macros/big.tl",
                    "offset": 262144,
                    "final": 1
                  },
                  "value": "1e0002040000"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "已写这一块",
            "x-en": {
              "description": "Chunk written"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SdWriteReply"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "bad_path": {
            "status": 400,
            "description": "path 缺了或不合规矩（见 path 的说明），或指向目录（为 / 或以 / 结尾）",
            "x-en": {
              "description": "path is missing or invalid (see path), or names a folder (/ or ending in /)"
            }
          },
          "bad_args": {
            "status": 400,
            "description": "offset 不是非负整数，或 final 不是 0 / 1",
            "x-en": {
              "description": "offset is not a non-negative integer, or final is not 0 / 1"
            }
          },
          "bad_offset": {
            "status": 409,
            "description": "offset 不等于临时文件现在的大小；回复另带 size（现在的大小），从那里续传。offset 超过 2 GB 时为 400",
            "x-en": {
              "description": "offset differs from the temp file's current size; the reply also carries size (the current size), resume from there. 400 when offset is over 2 GB"
            },
            "example": "last_chunk"
          },
          "too_large": {
            "status": 413,
            "description": "这一块超过 1 MB",
            "x-en": {
              "description": "The chunk is larger than 1 MB"
            }
          },
          "is_dir": {
            "status": 409,
            "description": "同名目录已存在",
            "x-en": {
              "description": "A folder with this name exists"
            }
          },
          "bad_parent": {
            "status": 409,
            "description": "上级路径上有同名文件，建不了目录",
            "x-en": {
              "description": "A file in the parent path blocks creating the folder"
            }
          },
          "no_space": {
            "status": 507,
            "description": "卡满了，临时文件已删",
            "x-en": {
              "description": "The card is full; the temp file was deleted"
            }
          },
          "no_card": {
            "status": 503,
            "description": "没插卡、卡不是 FAT，或刚试过挂载（2 秒后再试）；message 写原因",
            "x-en": {
              "description": "No card, the card is not FAT, or a mount was just tried (retry in 2 s); message says which"
            }
          },
          "io_error": {
            "status": 500,
            "description": "读写卡出错，设备已卸载卡，下一个请求重挂。重试",
            "x-en": {
              "description": "Card read/write error; the device unmounted the card and remounts on the next request. Retry"
            }
          }
        }
      },
      "delete": {
        "tags": [
          "TF 卡"
        ],
        "operationId": "delete_v1_sd",
        "summary": "删 TF 卡上的文件或目录（recursive=1 连里面一起删）",
        "description": "目录要是空的，recursive=1 连里面的东西一起删，不能删根。卡上原有的文件别删，只删自己放的（放在 /stick/ 下）",
        "x-en": {
          "summary": "Delete a card file or folder (recursive=1 deletes its contents)",
          "description": "A folder must be empty unless recursive=1; the root cannot be deleted. Leave existing files on the card alone and delete only your own (kept under /stick/)"
        },
        "x-only": "kernel",
        "x-risk": "data",
        "parameters": [
          {
            "name": "path",
            "in": "query",
            "required": true,
            "description": "文件或目录",
            "x-en": {
              "description": "File or folder"
            },
            "schema": {
              "$ref": "#/components/schemas/SdPath"
            },
            "example": "/stick/macros/old.tl"
          },
          {
            "name": "recursive",
            "in": "query",
            "required": false,
            "description": "1 = 目录连里面的东西一起删",
            "x-en": {
              "description": "1 = delete a folder with everything in it"
            },
            "schema": {
              "type": "integer",
              "enum": [
                0,
                1
              ],
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "已删除",
            "x-en": {
              "description": "Deleted"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "bad_path": {
            "status": 400,
            "description": "path 缺了或不合规矩（见 path 的说明），或是根 /",
            "x-en": {
              "description": "path is missing or invalid (see path), or is the root /"
            }
          },
          "not_found": {
            "status": 404,
            "description": "没有这个文件或目录",
            "x-en": {
              "description": "No such file or folder"
            }
          },
          "not_empty": {
            "status": 409,
            "description": "目录不空：加 recursive=1",
            "x-en": {
              "description": "The folder is not empty: add recursive=1"
            }
          },
          "no_card": {
            "status": 503,
            "description": "没插卡、卡不是 FAT，或刚试过挂载（2 秒后再试）；message 写原因",
            "x-en": {
              "description": "No card, the card is not FAT, or a mount was just tried (retry in 2 s); message says which"
            }
          },
          "io_error": {
            "status": 500,
            "description": "读写卡出错，设备已卸载卡，下一个请求重挂。重试",
            "x-en": {
              "description": "Card read/write error; the device unmounted the card and remounts on the next request. Retry"
            }
          }
        }
      }
    },
    "/v1/snap": {
      "get": {
        "tags": [
          "屏幕"
        ],
        "operationId": "get_v1_snap",
        "summary": "截屏：320×172 RGB565 原始像素",
        "description": "屏幕上实际显示的全部层（含状态栏、系统页、样张预览）。宽高看回复头，横屏是 320×172、110080 字节。恢复固件也有",
        "x-en": {
          "summary": "Screenshot: 320×172 raw RGB565 pixels",
          "description": "Everything actually on screen (all layers, including the status bar, system pages and mockup preview). Width and height are in the reply headers; landscape is 320×172, 110080 bytes. Also in the rescue firmware"
        },
        "x-resp": "rgb565",
        "responses": {
          "200": {
            "description": "原始像素",
            "x-en": {
              "description": "Raw pixels"
            },
            "headers": {
              "X-Width": {
                "description": "宽（像素）",
                "x-en": {
                  "description": "Width in pixels"
                },
                "schema": {
                  "type": "integer"
                }
              },
              "X-Height": {
                "description": "高（像素）",
                "x-en": {
                  "description": "Height in pixels"
                },
                "schema": {
                  "type": "integer"
                }
              },
              "X-Format": {
                "description": "像素格式",
                "x-en": {
                  "description": "Pixel format"
                },
                "schema": {
                  "const": "rgb565le"
                }
              }
            },
            "content": {
              "application/octet-stream": {
                "schema": {
                  "$ref": "#/components/schemas/ScreenRgb565"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "snap_failed": {
            "status": 500,
            "description": "显示没就绪、内存不足，或 2 秒内拿不到界面锁（message 是 ESP-IDF 错误名）。稍后重试",
            "x-en": {
              "description": "Display not ready, out of memory, or no UI lock within 2 s (message is the ESP-IDF error name). Try again later"
            }
          }
        }
      }
    },
    "/v1/ui": {
      "get": {
        "tags": [
          "屏幕"
        ],
        "operationId": "get_v1_ui",
        "summary": "界面对象树（坐标、文字）",
        "description": "LVGL 对象树：类型、屏幕绝对坐标与尺寸、标签文字、进度值、是否隐藏。最多 400 个节点、12 层，超了的带 children_omitted，回复带 truncated。给自动测试与 Agent 找屏幕上的东西",
        "x-en": {
          "summary": "UI object tree (coordinates, text)",
          "description": "LVGL object tree: type, absolute screen coordinates and size, label text, bar value and hidden. At most 400 nodes and 12 levels; cut subtrees carry children_omitted and the reply carries truncated. For automated tests and agents finding things on screen"
        },
        "x-only": "kernel",
        "parameters": [
          {
            "name": "layer",
            "in": "query",
            "required": false,
            "description": "app 应用区（省略时），top 状态栏与系统页，all 三层（app、top、sys）各一个根节点",
            "x-en": {
              "description": "app: the app area (default); top: the status bar and system pages; all: one root node per layer (app, top, sys)"
            },
            "schema": {
              "type": "string",
              "enum": [
                "app",
                "top",
                "all"
              ],
              "default": "app"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "对象树",
            "x-en": {
              "description": "Object tree"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScreenUiTree"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "bad_layer": {
            "status": 400,
            "description": "layer 不是 app / top / all",
            "x-en": {
              "description": "layer is not app / top / all"
            }
          },
          "busy": {
            "status": 503,
            "description": "1 秒内拿不到界面锁。重试",
            "x-en": {
              "description": "No UI lock within 1 s. Try again"
            }
          }
        }
      }
    },
    "/v1/ui/preview": {
      "get": {
        "tags": [
          "屏幕"
        ],
        "operationId": "get_v1_ui_preview",
        "summary": "整屏样张预览的状态",
        "description": "看样张预览是否在显示、还剩几秒",
        "x-en": {
          "summary": "Full-screen mockup preview state",
          "description": "Whether a mockup preview is showing and how many seconds are left"
        },
        "x-only": "kernel",
        "responses": {
          "200": {
            "description": "预览状态",
            "x-en": {
              "description": "Preview state"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScreenPreviewState"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {}
      },
      "put": {
        "tags": [
          "屏幕"
        ],
        "operationId": "put_v1_ui_preview",
        "summary": "整屏显示一张 320×172 样张（RGB565）",
        "description": "把一张 320×172 样张盖在屏幕最上层（连状态栏、HID 安全描边一起盖住），seconds 秒后自动撤掉；再推一张就换图、重新计时，期间背光常亮。体是 110080 字节，格式同 GET /v1/snap。只看样张用，不改任何设置。主机：stick preview 样张.png",
        "x-en": {
          "summary": "Show a 320×172 mockup full screen (RGB565)",
          "description": "Shows a 320×172 mockup on top of everything (status bar and HID safety outline included) and removes it after seconds; pushing another replaces it and restarts the timer; the backlight stays on meanwhile. The body is 110080 bytes in the format of GET /v1/snap. For viewing mockups only; changes no setting. Host: stick preview mockup.png"
        },
        "x-only": "kernel",
        "parameters": [
          {
            "name": "seconds",
            "in": "query",
            "required": false,
            "description": "显示几秒，1–600，省略为 30",
            "x-en": {
              "description": "Seconds to show, 1–600, default 30"
            },
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 600,
              "default": 30
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/octet-stream": {
              "schema": {
                "$ref": "#/components/schemas/ScreenRgb565"
              },
              "examples": {
                "solid_red": {
                  "summary": "整屏红色",
                  "description": "像素 0xF800（小端 00 f8）重复 55040 次（x-repeat），共 110080 字节",
                  "x-en": {
                    "summary": "Solid red",
                    "description": "Pixel 0xF800 (little-endian 00 f8) repeated 55040 times (x-repeat), 110080 bytes"
                  },
                  "value": "00f8",
                  "x-repeat": 55040
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "已显示",
            "x-en": {
              "description": "Showing"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScreenPreviewState"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "bad_args": {
            "status": 400,
            "description": "体不是 110080 字节，或 seconds 不是 1–600 的整数",
            "x-en": {
              "description": "The body is not 110080 bytes, or seconds is not an integer in 1–600"
            }
          },
          "bad_orientation": {
            "status": 409,
            "description": "屏幕不是横屏 320×172",
            "x-en": {
              "description": "The screen is not landscape 320×172"
            }
          },
          "busy": {
            "status": 503,
            "description": "拿不到界面锁。重试",
            "x-en": {
              "description": "No UI lock. Try again"
            }
          }
        }
      },
      "delete": {
        "tags": [
          "屏幕"
        ],
        "operationId": "delete_v1_ui_preview",
        "summary": "撤掉样张预览",
        "description": "立即撤掉样张预览；没在显示也回成功",
        "x-en": {
          "summary": "Remove the mockup preview",
          "description": "Removes the mockup preview at once; succeeds when none is showing"
        },
        "x-only": "kernel",
        "responses": {
          "200": {
            "description": "已撤掉",
            "x-en": {
              "description": "Removed"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScreenPreviewState"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {}
      }
    },
    "/v1/display": {
      "get": {
        "tags": [
          "屏幕"
        ],
        "operationId": "get_v1_display",
        "summary": "屏幕设置：亮度、调暗、关背光、界面风格",
        "description": "设备闲着时先调暗、再关背光（只关背光，设备照常运行）；按 BOOT、系统页与提示条出现、监视页被设置、样张预览都算有动静、会点亮。界面风格是系统界面（主页、监视页、系统页、状态栏、提示条）的样子，styles 列出可选的。存进设备，立即生效；内核与恢复固件都照它点背光，恢复固件的界面风格固定是 b，接口只在内核",
        "x-en": {
          "summary": "Screen settings: brightness, dimming, backlight off, interface style",
          "description": "When idle the device first dims, then turns the backlight off (only the backlight; the device keeps running). Pressing BOOT, a system page or toast, setting the monitor page and a preview all count as activity and light it up. The interface style is the look of the system interface (home, monitor, system pages, status bar, toasts); styles lists the choices. Saved on the device and applied at once; both kernel and rescue firmware use the backlight settings, rescue always uses style b, the endpoint is kernel only"
        },
        "responses": {
          "200": {
            "description": "屏幕设置",
            "x-en": {
              "description": "Screen settings"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeviceDisplay"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {},
        "x-only": "kernel"
      },
      "post": {
        "tags": [
          "屏幕"
        ],
        "operationId": "post_v1_display",
        "summary": "改屏幕设置或界面风格，存下并立即生效",
        "description": "只改带了的字段；回复同 GET。改完算一次有动静，屏幕马上按新亮度点亮。带 style 就换界面风格：不重启，系统界面立即按新风格重建，正在显示的系统页、提示条、监视页跟着换，应用画的界面不动",
        "x-en": {
          "summary": "Change screen settings or the interface style; saved and applied at once",
          "description": "Only the fields given change; replies like GET. Counts as activity, so the screen lights up at the new brightness right away. With style the interface style changes: no restart, the system interface is rebuilt in the new style at once (the system page, toast and monitor page on screen follow), what apps draw is left alone"
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DeviceDisplayRequest"
              },
              "examples": {
                "always_on": {
                  "summary": "常亮",
                  "x-en": {
                    "summary": "Always on"
                  },
                  "value": {
                    "dim_s": 0,
                    "off_s": 0
                  }
                },
                "saver": {
                  "summary": "省电：30 秒调暗、2 分钟关",
                  "x-en": {
                    "summary": "Power saving: dim after 30 s, off after 2 min"
                  },
                  "value": {
                    "brightness": 60,
                    "dim_s": 30,
                    "off_s": 120
                  }
                },
                "default": {
                  "summary": "出厂设置",
                  "x-en": {
                    "summary": "Factory settings"
                  },
                  "value": {
                    "brightness": 80,
                    "dim_s": 60,
                    "off_s": 300
                  }
                },
                "style": {
                  "summary": "换回默认风格（柔光）",
                  "x-en": {
                    "summary": "Back to the default style (Soft glow)"
                  },
                  "value": {
                    "style": "b"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "已保存，回当前设置",
            "x-en": {
              "description": "Saved; current settings"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeviceDisplay"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "bad_json": {
            "status": 400,
            "description": "请求体不是 JSON 对象",
            "x-en": {
              "description": "The body is not a JSON object"
            }
          },
          "bad_display": {
            "status": 400,
            "description": "取值不合规（见 message）：亮度 10–100；dim_s、off_s 为 0 或 10–86400，两个都不为 0 时 off_s 要大于 dim_s；style 不在 styles 里（message 列出可选值）。什么也没改",
            "x-en": {
              "description": "Invalid value (see message): brightness 10–100; dim_s and off_s are 0 or 10–86400, and off_s must exceed dim_s when both are set; style not in styles (message lists the choices). Nothing changed"
            }
          },
          "nvs": {
            "status": 500,
            "description": "存储写入失败：背光设置已生效、重启后回到旧设置；风格没有换。重试；仍失败看 stick logs",
            "x-en": {
              "description": "Saving failed: the backlight settings are applied but the old ones return after a restart; the style did not change. Retry; if it persists, check stick logs"
            }
          }
        },
        "x-only": "kernel"
      }
    },
    "/v1/ota": {
      "post": {
        "tags": [
          "更新与引导"
        ],
        "operationId": "post_v1_ota",
        "summary": "写签名固件镜像（stick deploy 用）",
        "description": "请求体是构建出的 .bin 原样（签名密钥签过，Content-Length 必填）。边收边写进目标分区，收完校验并验签，通过才设为下次引导。slot=kernel 写另一个内核槽，重启后新内核待确认：60 秒内 POST /v1/ota/confirm，否则回滚。slot=rescue 只在内核可用，经另一个内核槽中转，那个槽里的回退版本会被清掉。网页调不了，用 stick deploy / stick deploy rescue",
        "x-en": {
          "summary": "Write a signed firmware image (used by stick deploy)",
          "description": "The body is the built .bin as is (signed with the signing key; Content-Length required). The device writes it to the target partition as it arrives, then checks the image and its signature; only then is it set to boot. slot=kernel writes the other kernel slot, and after the restart the new kernel is pending: POST /v1/ota/confirm within 60 s or it rolls back. slot=rescue works only in the kernel and goes through the other kernel slot, wiping the fallback version there. The web app cannot call this; use stick deploy / stick deploy rescue"
        },
        "x-risk": "reboot",
        "parameters": [
          {
            "name": "slot",
            "in": "query",
            "required": false,
            "description": "kernel 内核（省略）；rescue 恢复固件",
            "x-en": {
              "description": "kernel (default) or rescue (rescue firmware)"
            },
            "schema": {
              "type": "string",
              "enum": [
                "kernel",
                "rescue"
              ],
              "default": "kernel"
            },
            "example": "kernel"
          },
          {
            "name": "reboot",
            "in": "query",
            "required": false,
            "description": "1 = 回复后重启；省略时 kernel 为 1、rescue 为 0",
            "x-en": {
              "description": "1 = restart after replying; defaults to 1 for kernel, 0 for rescue"
            },
            "schema": {
              "type": "integer",
              "enum": [
                0,
                1
              ]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/octet-stream": {
              "schema": {
                "type": "string",
                "contentMediaType": "application/octet-stream",
                "description": "签名的固件镜像，不超过目标分区",
                "x-en": {
                  "description": "Signed firmware image, no larger than the target partition"
                }
              },
              "examples": {
                "image_head": {
                  "summary": "镜像开头（示意）",
                  "description": "只有镜像头（魔数 e9）与应用描述（魔数 0xABCD5432、版本 0.1.0、project_name stick_kernel、构建号），真设备会回 bad_image；真镜像用 stick deploy 推",
                  "x-en": {
                    "summary": "Start of an image (illustration)",
                    "description": "Only the image header (magic e9) and the app description (magic 0xABCD5432, version 0.1.0, project_name stick_kernel, build ID); a real device answers bad_image. Push real images with stick deploy"
                  },
                  "value": "e907024ffc5d3740ee00000009000000 00630000000000012000143cc84b0700 3254cdab000000000000000000000000 302e312e300000000000000000000000 00000000000000000000000000000000 737469636b5f6b65726e656c00000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 1a2b3c4d5e6f7a8b0000000000000000 00000000000000000000000000000000"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "已写入",
            "x-en": {
              "description": "Written"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OtaWriteReply"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "bad_slot": {
            "status": 400,
            "description": "slot 不是 kernel / rescue，或在恢复固件里写 rescue",
            "x-en": {
              "description": "slot is not kernel / rescue, or rescue was given in the rescue firmware"
            }
          },
          "pending": {
            "status": 409,
            "description": "当前内核待确认：先 POST /v1/ota/confirm 或 /v1/ota/rollback",
            "x-en": {
              "description": "The running kernel is pending: POST /v1/ota/confirm or /v1/ota/rollback first"
            }
          },
          "busy": {
            "status": 409,
            "description": "正在写另一个镜像",
            "x-en": {
              "description": "Another image is being written"
            }
          },
          "wrong_project": {
            "status": 400,
            "description": "镜像的 project_name 不对：kernel 要 stick_kernel，rescue 要 stick_rescue",
            "x-en": {
              "description": "Wrong project_name: kernel needs stick_kernel, rescue needs stick_rescue"
            }
          },
          "bad_image": {
            "status": 400,
            "description": "不是应用镜像、不完整，或校验、验签没通过。没有写入",
            "x-en": {
              "description": "Not an app image, incomplete, or the check or signature failed. Nothing was installed"
            }
          },
          "wrong_key": {
            "status": 400,
            "description": "镜像是另一把签名密钥签的：设备只认它正在运行的固件的签名密钥（info 的 ota.sign_key）。没有写入；要换钥只能经 USB 重刷（stick usb-flash，或官网在线安装换回官方固件）",
            "x-en": {
              "description": "The image is signed with a different key: the device only accepts the signing key of the firmware it is running (ota.sign_key in info). Nothing was installed; changing keys requires reflashing over USB (stick usb-flash, or the web installer for official firmware)"
            }
          },
          "too_large": {
            "status": 413,
            "description": "比目标分区大",
            "x-en": {
              "description": "Larger than the target partition"
            }
          },
          "no_slot": {
            "status": 500,
            "description": "找不到目标分区（分区表不对）",
            "x-en": {
              "description": "Target partition not found (wrong partition table)"
            }
          },
          "ota_begin": {
            "status": 500,
            "description": "开始写分区失败。看 stick logs",
            "x-en": {
              "description": "Starting the partition write failed. Check stick logs"
            }
          },
          "set_boot": {
            "status": 500,
            "description": "设引导分区失败。看 stick logs",
            "x-en": {
              "description": "Setting the boot partition failed. Check stick logs"
            }
          }
        }
      }
    },
    "/v1/ota/confirm": {
      "post": {
        "tags": [
          "更新与引导"
        ],
        "operationId": "post_v1_ota_confirm",
        "summary": "确认待确认的内核",
        "description": "新内核开机后 60 秒内调，标记有效、不再回滚；超时或待确认期间崩溃就回滚到上一版本。stick deploy 做完健康检查自动调",
        "x-en": {
          "summary": "Confirm the pending kernel",
          "description": "Call within 60 s after a new kernel boots to mark it valid so it no longer rolls back; on timeout or a crash while pending it rolls back to the previous version. stick deploy calls it after its health check"
        },
        "responses": {
          "200": {
            "description": "已确认",
            "x-en": {
              "description": "Confirmed"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OtaConfirmReply"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "not_pending": {
            "status": 409,
            "description": "当前内核不在待确认（已确认过，或在恢复固件里）",
            "x-en": {
              "description": "The running kernel is not pending (already confirmed, or in the rescue firmware)"
            }
          },
          "confirm": {
            "status": 500,
            "description": "标记失败。看 stick logs",
            "x-en": {
              "description": "Marking failed. Check stick logs"
            }
          }
        }
      }
    },
    "/v1/ota/rollback": {
      "post": {
        "tags": [
          "更新与引导"
        ],
        "operationId": "post_v1_ota_rollback",
        "summary": "切到另一个内核槽并重启",
        "description": "引导另一个内核槽里的版本，回复后约 0.5 秒重启；新内核待确认时调就是立即放弃它。恢复固件里不能用",
        "x-en": {
          "summary": "Switch to the other kernel slot and restart",
          "description": "Boots the version in the other kernel slot, restarting about 0.5 s after replying; while a new kernel is pending this abandons it at once. Not available in the rescue firmware"
        },
        "x-risk": "reboot",
        "responses": {
          "200": {
            "description": "即将重启",
            "x-en": {
              "description": "Restarting"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OtaBootReply"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "no_fallback": {
            "status": 409,
            "description": "另一个内核槽没有可用版本，或当前在恢复固件里",
            "x-en": {
              "description": "The other kernel slot has no usable version, or this is the rescue firmware"
            }
          },
          "set_boot": {
            "status": 500,
            "description": "设引导分区失败。看 stick logs",
            "x-en": {
              "description": "Setting the boot partition failed. Check stick logs"
            }
          }
        }
      }
    },
    "/v1/boot": {
      "post": {
        "tags": [
          "更新与引导"
        ],
        "operationId": "post_v1_boot",
        "summary": "切引导分区并重启",
        "description": "设下次引导的固件，回复后约 0.5 秒重启。在恢复固件里用 kernel 回内核。主机：stick boot rescue|kernel",
        "x-en": {
          "summary": "Switch the boot partition and restart",
          "description": "Sets the firmware to boot next and restarts about 0.5 s after replying. From the rescue firmware, use kernel to go back. Host: stick boot rescue|kernel"
        },
        "x-risk": "reboot",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OtaBootRequest"
              },
              "examples": {
                "rescue": {
                  "summary": "进恢复固件",
                  "x-en": {
                    "summary": "Boot the rescue firmware"
                  },
                  "value": {
                    "target": "rescue"
                  }
                },
                "kernel": {
                  "summary": "回内核",
                  "x-en": {
                    "summary": "Back to the kernel"
                  },
                  "value": {
                    "target": "kernel"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "即将重启",
            "x-en": {
              "description": "Restarting"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OtaBootReply"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "bad_target": {
            "status": 400,
            "description": "target 只能是 rescue / kernel / kernel_a / kernel_b",
            "x-en": {
              "description": "target must be rescue / kernel / kernel_a / kernel_b"
            },
            "example": "rescue"
          },
          "no_image": {
            "status": 409,
            "description": "目标分区没有可用固件",
            "x-en": {
              "description": "The target partition has no usable firmware"
            }
          },
          "set_boot": {
            "status": 500,
            "description": "设引导分区失败。看 stick logs",
            "x-en": {
              "description": "Setting the boot partition failed. Check stick logs"
            }
          }
        }
      }
    },
    "/v1/crash": {
      "get": {
        "tags": [
          "更新与引导"
        ],
        "operationId": "get_v1_crash",
        "summary": "崩溃转储原文（stick crash --decode 解）",
        "description": "崩溃转储分区的原文（ESP-IDF raw 格式），用 stick crash --decode（按构建号找归档的 ELF）或 esp-coredump --core-format raw 解。摘要（任务、PC、回溯）在 GET /v1/info 的 crash 里",
        "x-en": {
          "summary": "Raw crash dump (decode with stick crash --decode)",
          "description": "The crash dump partition as is (ESP-IDF raw format); decode with stick crash --decode (finds the archived ELF by build ID) or esp-coredump --core-format raw. A summary (task, PC, backtrace) is in crash of GET /v1/info"
        },
        "x-resp": "binary",
        "responses": {
          "200": {
            "description": "转储原文",
            "x-en": {
              "description": "Raw dump"
            },
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "contentMediaType": "application/octet-stream"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "no_crash": {
            "status": 404,
            "description": "没有崩溃转储",
            "x-en": {
              "description": "No crash dump"
            }
          }
        }
      },
      "delete": {
        "tags": [
          "更新与引导"
        ],
        "operationId": "delete_v1_crash",
        "summary": "清除崩溃转储",
        "description": "擦掉崩溃转储分区；没有转储也回成功",
        "x-en": {
          "summary": "Clear the crash dump",
          "description": "Erases the crash dump partition; succeeds even when there is none"
        },
        "x-risk": "data",
        "responses": {
          "200": {
            "description": "已清除",
            "x-en": {
              "description": "Cleared"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "erase": {
            "status": 500,
            "description": "擦除失败。看 stick logs",
            "x-en": {
              "description": "Erasing failed. Check stick logs"
            }
          }
        }
      }
    },
    "/v1/debug/status": {
      "post": {
        "tags": [
          "调试与演练"
        ],
        "operationId": "post_v1_debug_status",
        "summary": "注入一条状态，看系统页 / 提示条 / 图标",
        "description": "界面调试：叫出状态对应的系统页、提示条或状态栏图标来看，只给界面看，不改设备实际状态。set 到时自动清掉（同一时间只留最近注入的一条）。注入 HID_* 的那几秒里单击 BOOT 会当急停",
        "x-en": {
          "summary": "Inject a status to check the system screen, banner and icons",
          "description": "UI debugging: brings up the system screen, banner or status bar icon of a status. Only the UI sees it; the device's real state does not change. set clears itself when time is up (only the latest injection is kept). While an HID_* status is injected, a click of BOOT counts as an emergency stop"
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DebugStatusRequest"
              },
              "examples": {
                "identify": {
                  "summary": "提示条：识别",
                  "x-en": {
                    "summary": "Banner: identify"
                  },
                  "value": {
                    "id": "IDENTIFY",
                    "op": "event"
                  }
                },
                "offline_icon": {
                  "summary": "状态栏显示未联网 15 秒",
                  "x-en": {
                    "summary": "Status bar shows offline for 15 s"
                  },
                  "value": {
                    "id": "WIFI_OFFLINE",
                    "op": "set",
                    "seconds": 15
                  }
                },
                "clear": {
                  "summary": "清掉",
                  "x-en": {
                    "summary": "Clear it"
                  },
                  "value": {
                    "id": "WIFI_OFFLINE",
                    "op": "clear"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "已注入",
            "x-en": {
              "description": "Injected"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "bad_args": {
            "status": 400,
            "description": "id 不是已有的状态名，op 不是 set / clear / event，或 seconds 不在 1–120",
            "x-en": {
              "description": "id is not a known status name, op is not set / clear / event, or seconds is not in 1–120"
            },
            "example": "identify"
          }
        }
      }
    },
    "/v1/debug/net_drop": {
      "post": {
        "tags": [
          "调试与演练"
        ],
        "operationId": "post_v1_debug_net_drop",
        "summary": "故障注入：断网 N 秒后自动重连（这个网页也会断）",
        "description": "演练用（stick drill wifi）：回复后约 300 毫秒断开 Wi-Fi，seconds 秒内不重连、不进配网，到时自动重连原网络。期间设备连不上",
        "x-en": {
          "summary": "Fault injection: drop the network for N s, then reconnect (this page drops too)",
          "description": "For drills (stick drill wifi): about 300 ms after replying the device disconnects Wi-Fi, neither reconnects nor enters Wi-Fi setup for seconds, then rejoins the same network. The device is unreachable meanwhile"
        },
        "x-risk": "offline",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DebugNetDropRequest"
              },
              "examples": {
                "drop_10": {
                  "summary": "断网 10 秒",
                  "x-en": {
                    "summary": "Drop for 10 s"
                  },
                  "value": {
                    "seconds": 10
                  }
                },
                "drop_60": {
                  "summary": "最长 60 秒",
                  "x-en": {
                    "summary": "Longest: 60 s"
                  },
                  "value": {
                    "seconds": 60
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "即将断网",
            "x-en": {
              "description": "Dropping"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DebugNetDropReply"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "bad_args": {
            "status": 400,
            "description": "seconds 不是 1–60 的整数，或请求体不是 JSON 对象",
            "x-en": {
              "description": "seconds is not an integer in 1–60, or the body is not a JSON object"
            },
            "example": "drop_10"
          },
          "not_connected": {
            "status": 409,
            "description": "Wi-Fi 没连上（正在连或在配网），没有可断的",
            "x-en": {
              "description": "Wi-Fi is not connected (joining or in setup); nothing to drop"
            }
          }
        }
      }
    },
    "/v1/debug/crash": {
      "post": {
        "tags": [
          "调试与演练"
        ],
        "operationId": "post_v1_debug_crash",
        "summary": "故障注入：约 0.5 秒后崩溃重启",
        "description": "演练用（stick drill crash / crash-wdt）：先打一行 E 级日志，回复后约 500 毫秒崩溃重启。照常留崩溃转储（GET /v1/crash）、计入启动保护的连续崩溃次数，黑匣子里看得到崩溃前的日志",
        "x-en": {
          "summary": "Fault injection: crash and restart after about 0.5 s",
          "description": "For drills (stick drill crash / crash-wdt): logs one E-level line, then crashes and restarts about 500 ms after replying. It leaves a crash dump as usual (GET /v1/crash), counts toward the consecutive-crash count of boot protection, and the black-box log shows the lines before it"
        },
        "x-risk": "reboot",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DebugCrashRequest"
              },
              "examples": {
                "panic": {
                  "summary": "程序崩溃",
                  "x-en": {
                    "summary": "Panic"
                  },
                  "value": {
                    "kind": "panic"
                  }
                },
                "int_wdt": {
                  "summary": "中断看门狗",
                  "x-en": {
                    "summary": "Interrupt watchdog"
                  },
                  "value": {
                    "kind": "int_wdt"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "即将崩溃",
            "x-en": {
              "description": "Crashing"
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DebugCrashReply"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "x-errors": {
          "bad_args": {
            "status": 400,
            "description": "kind 只能是 panic 或 int_wdt，或请求体不是 JSON 对象",
            "x-en": {
              "description": "kind must be panic or int_wdt, or the body is not a JSON object"
            },
            "example": "panic"
          },
          "busy": {
            "status": 409,
            "description": "已经安排了一次崩溃，正在等它发生",
            "x-en": {
              "description": "A crash is already scheduled"
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "stickHmac": {
        "type": "apiKey",
        "in": "header",
        "name": "Authorization",
        "description": "每台设备一把 32 字节密钥（配对得到：POST /v1/pair 后人单击 BOOT 允许，或 USB 串口 key 命令）。每个请求：\n1. 取 nonce：`GET /v1/nonce`（60 秒有效，用一次作废），或用上一个鉴权回复头 `X-Stick-Nonce` 附送的。\n2. 头 `X-Stick-Sha256: <请求体 SHA-256，小写十六进制>`，空体也要发。\n3. 头 `Authorization: Stick <nonce>:<mac>`，mac = 小写十六进制 HMAC-SHA256(密钥, \"stick-v1\\n\" + 方法 + \"\\n\" + URI + \"\\n\" + nonce + \"\\n\" + 体哈希)。方法大写，URI 是请求行里原样的路径加查询串。\n主机 Python 用 `stick.client.Client` 自动签名；curl 做不了。",
        "x-en": {
          "description": "Each device has one 32-byte key (obtained by pairing: POST /v1/pair and a click on BOOT to allow, or the key command over USB serial). For every request:\n1. Get a nonce: `GET /v1/nonce` (valid 60 s, single use), or take the one in the `X-Stick-Nonce` header of the previous authenticated reply.\n2. Header `X-Stick-Sha256: <SHA-256 of the body, lowercase hex>`, sent even for an empty body.\n3. Header `Authorization: Stick <nonce>:<mac>`, where mac = lowercase hex HMAC-SHA256(key, \"stick-v1\\n\" + method + \"\\n\" + URI + \"\\n\" + nonce + \"\\n\" + body hash). The method is uppercase; the URI is the path and query string exactly as in the request line.\nIn Python, `stick.client.Client` signs requests for you; curl cannot."
        }
      }
    },
    "responses": {
      "Ok": {
        "description": "成功",
        "x-en": {
          "description": "Success"
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Ok"
            }
          }
        }
      },
      "Error": {
        "description": "失败：error 是错误代码",
        "x-en": {
          "description": "Failure: error is the error code"
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "schemas": {
      "Ok": {
        "title": "成功",
        "description": "成功的回复；各接口另有字段",
        "x-en": {
          "title": "Success",
          "description": "Successful reply; endpoints add their own fields"
        },
        "type": "object",
        "required": [
          "ok"
        ],
        "properties": {
          "ok": {
            "const": true,
            "description": "总是 true",
            "x-en": {
              "description": "Always true"
            }
          }
        }
      },
      "Error": {
        "title": "失败",
        "description": "失败的回复（HTTP 状态码 4xx / 5xx）",
        "x-en": {
          "title": "Failure",
          "description": "Failure reply (HTTP status 4xx / 5xx)"
        },
        "type": "object",
        "required": [
          "ok",
          "error",
          "message"
        ],
        "properties": {
          "ok": {
            "const": false,
            "description": "总是 false",
            "x-en": {
              "description": "Always false"
            }
          },
          "error": {
            "type": "string",
            "description": "错误代码（见各接口的 x-errors 与 components.x-errors），程序以它为准",
            "x-en": {
              "description": "Error code (see x-errors of each endpoint and components.x-errors); programs go by this"
            }
          },
          "message": {
            "type": "string",
            "description": "给人看的说明（中文，不随界面语言变）",
            "x-en": {
              "description": "Human-readable detail (Chinese, independent of the UI language)"
            }
          }
        }
      },
      "HidMods": {
        "description": "修饰键，随这一键一起按下，如 [\"ctrl\",\"shift\"]",
        "x-en": {
          "description": "Modifiers pressed together with this key, e.g. [\"ctrl\",\"shift\"]"
        },
        "type": "array",
        "items": {
          "$ref": "#/components/schemas/ModName"
        }
      },
      "HidAction": {
        "title": "动作",
        "description": "一个动作是一个对象，只写下面一种写法；tap 与 down 可以另带 mods。帧与帧之间至少 8 毫秒",
        "x-en": {
          "title": "Action",
          "description": "An action is an object with exactly one of the forms below; tap and down may add mods. Frames are at least 8 ms apart"
        },
        "oneOf": [
          {
            "title": "单击键",
            "description": "按下再松开（两帧）。带 mods 时修饰键随按下一起生效：组合键写 {\"tap\":\"A\",\"mods\":[\"alt\"]}",
            "x-en": {
              "title": "Tap a key",
              "description": "Press and release (two frames). With mods, the modifiers apply to the press: write a shortcut as {\"tap\":\"A\",\"mods\":[\"alt\"]}"
            },
            "type": "object",
            "required": [
              "tap"
            ],
            "properties": {
              "tap": {
                "$ref": "#/components/schemas/KeyName",
                "description": "键名",
                "x-en": {
                  "description": "Key name"
                }
              },
              "mods": {
                "$ref": "#/components/schemas/HidMods"
              }
            },
            "additionalProperties": false
          },
          {
            "title": "按住键",
            "description": "按下不松开，之后用 up 松开。同时按住的普通键最多 6 个，超了那个忽略",
            "x-en": {
              "title": "Hold a key",
              "description": "Press without releasing; release later with up. At most 6 non-modifier keys can be held at once; extra ones are ignored"
            },
            "type": "object",
            "required": [
              "down"
            ],
            "properties": {
              "down": {
                "$ref": "#/components/schemas/KeyName",
                "description": "键名",
                "x-en": {
                  "description": "Key name"
                }
              },
              "mods": {
                "$ref": "#/components/schemas/HidMods"
              }
            },
            "additionalProperties": false
          },
          {
            "title": "松开键",
            "description": "松开一个键；\"all\" 松开全部键",
            "x-en": {
              "title": "Release a key",
              "description": "Release one key; \"all\" releases every key"
            },
            "type": "object",
            "required": [
              "up"
            ],
            "properties": {
              "up": {
                "anyOf": [
                  {
                    "$ref": "#/components/schemas/KeyName"
                  },
                  {
                    "const": "all",
                    "x-case-insensitive": true,
                    "description": "全部松开",
                    "x-en": {
                      "description": "Release all keys"
                    }
                  }
                ],
                "description": "键名，或 all",
                "x-en": {
                  "description": "Key name, or all"
                }
              }
            },
            "additionalProperties": false
          },
          {
            "title": "打字",
            "description": "按美式布局逐字打出：每个字符按下、松开各一帧，要 Shift 的自动带上。占队列的项数按字符计",
            "x-en": {
              "title": "Type text",
              "description": "Types character by character with the US layout: one press frame and one release frame per character, adding Shift where needed. Counts one queue item per character"
            },
            "type": "object",
            "required": [
              "text"
            ],
            "properties": {
              "text": {
                "$ref": "#/components/schemas/HidText"
              }
            },
            "additionalProperties": false
          },
          {
            "title": "移动鼠标",
            "description": "相对移动 [dx, dy]，向右、向下为正",
            "x-en": {
              "title": "Move the mouse",
              "description": "Relative move [dx, dy]; right and down are positive"
            },
            "type": "object",
            "required": [
              "move"
            ],
            "properties": {
              "move": {
                "type": "array",
                "minItems": 2,
                "maxItems": 2,
                "items": {
                  "$ref": "#/components/schemas/HidMoveDelta"
                },
                "description": "[dx, dy]",
                "x-en": {
                  "description": "[dx, dy]"
                }
              }
            },
            "additionalProperties": false
          },
          {
            "title": "单击鼠标键",
            "description": "按下再松开",
            "x-en": {
              "title": "Click a mouse button",
              "description": "Press and release"
            },
            "type": "object",
            "required": [
              "click"
            ],
            "properties": {
              "click": {
                "$ref": "#/components/schemas/MouseButton",
                "description": "鼠标键",
                "x-en": {
                  "description": "Mouse button"
                }
              }
            },
            "additionalProperties": false
          },
          {
            "title": "按住鼠标键",
            "description": "按下不松开（拖动用），之后用 release 松开",
            "x-en": {
              "title": "Press a mouse button",
              "description": "Press without releasing (for dragging); release later with release"
            },
            "type": "object",
            "required": [
              "press"
            ],
            "properties": {
              "press": {
                "$ref": "#/components/schemas/MouseButton",
                "description": "鼠标键",
                "x-en": {
                  "description": "Mouse button"
                }
              }
            },
            "additionalProperties": false
          },
          {
            "title": "松开鼠标键",
            "description": "松开按住的鼠标键",
            "x-en": {
              "title": "Release a mouse button",
              "description": "Release a held mouse button"
            },
            "type": "object",
            "required": [
              "release"
            ],
            "properties": {
              "release": {
                "$ref": "#/components/schemas/MouseButton",
                "description": "鼠标键",
                "x-en": {
                  "description": "Mouse button"
                }
              }
            },
            "additionalProperties": false
          },
          {
            "title": "竖向滚轮",
            "description": "正数向上滚，负数向下滚",
            "x-en": {
              "title": "Vertical wheel",
              "description": "Positive scrolls up, negative scrolls down"
            },
            "type": "object",
            "required": [
              "wheel"
            ],
            "properties": {
              "wheel": {
                "$ref": "#/components/schemas/HidWheelSteps"
              }
            },
            "additionalProperties": false
          },
          {
            "title": "横向滚轮",
            "description": "正数向右滚，负数向左滚",
            "x-en": {
              "title": "Horizontal wheel",
              "description": "Positive scrolls right, negative scrolls left"
            },
            "type": "object",
            "required": [
              "hwheel"
            ],
            "properties": {
              "hwheel": {
                "$ref": "#/components/schemas/HidWheelSteps"
              }
            },
            "additionalProperties": false
          },
          {
            "title": "多媒体键",
            "description": "单击一次多媒体键（按下再松开）",
            "x-en": {
              "title": "Media key",
              "description": "Click a media key once (press and release)"
            },
            "type": "object",
            "required": [
              "media"
            ],
            "properties": {
              "media": {
                "$ref": "#/components/schemas/MediaName",
                "description": "多媒体键名",
                "x-en": {
                  "description": "Media key name"
                }
              }
            },
            "additionalProperties": false
          },
          {
            "title": "停顿",
            "description": "停顿若干毫秒再执行下一个动作（不发帧）",
            "x-en": {
              "title": "Pause",
              "description": "Wait some milliseconds before the next action (sends nothing)"
            },
            "type": "object",
            "required": [
              "wait"
            ],
            "properties": {
              "wait": {
                "$ref": "#/components/schemas/HidWaitMs"
              }
            },
            "additionalProperties": false
          }
        ]
      },
      "HidActionsRequest": {
        "title": "动作批次",
        "description": "一批动作。顶层只认 actions 与 tag；以前的 wait 已取消（带了回 400 bad_args），等执行完查 GET /v1/hid 的 done_seq",
        "x-en": {
          "title": "Action batch",
          "description": "A batch of actions. Only actions and tag are accepted at the top level; the former wait was removed (sending it returns 400 bad_args). To wait for completion, check done_seq in GET /v1/hid"
        },
        "type": "object",
        "required": [
          "actions"
        ],
        "properties": {
          "actions": {
            "$ref": "#/components/schemas/HidActionList"
          },
          "tag": {
            "$ref": "#/components/schemas/HidTag"
          }
        },
        "additionalProperties": false
      },
      "HidQueued": {
        "title": "已入队",
        "description": "整批已入队（还没执行完）",
        "x-en": {
          "title": "Queued",
          "description": "The whole batch is queued (not yet executed)"
        },
        "type": "object",
        "required": [
          "ok",
          "seq",
          "queued"
        ],
        "properties": {
          "ok": {
            "const": true,
            "description": "总是 true",
            "x-en": {
              "description": "Always true"
            }
          },
          "seq": {
            "type": "integer",
            "minimum": 0,
            "description": "这一批的序号；GET /v1/hid 的 done_seq 不小于它就是执行完（或已丢弃）",
            "x-en": {
              "description": "Batch sequence number; the batch is finished (or dropped) once done_seq in GET /v1/hid is at least this"
            }
          },
          "queued": {
            "type": "integer",
            "minimum": 0,
            "description": "占队列的项数（text 按字符计，时间线按记录计）",
            "x-en": {
              "description": "Queue items taken (text counts per character, timelines per record)"
            }
          }
        }
      },
      "HidArmRequest": {
        "title": "解锁",
        "description": "请求体可省（省略按 60 秒）",
        "x-en": {
          "title": "Arm",
          "description": "The body is optional (defaults to 60 s)"
        },
        "type": "object",
        "properties": {
          "seconds": {
            "type": "integer",
            "minimum": 1,
            "maximum": 600,
            "default": 60,
            "description": "租约秒数，1–600",
            "x-en": {
              "description": "Lease in seconds, 1–600"
            }
          }
        },
        "additionalProperties": false
      },
      "HidArmReply": {
        "title": "已解锁",
        "description": "租约已开始或续期",
        "x-en": {
          "title": "Armed",
          "description": "The lease started or was renewed"
        },
        "type": "object",
        "required": [
          "ok",
          "armed_left_s"
        ],
        "properties": {
          "ok": {
            "const": true,
            "description": "总是 true",
            "x-en": {
              "description": "Always true"
            }
          },
          "armed_left_s": {
            "type": "integer",
            "minimum": 1,
            "maximum": 600,
            "description": "租约剩余秒数",
            "x-en": {
              "description": "Seconds left on the lease"
            }
          }
        }
      },
      "HidState": {
        "title": "HID 状态",
        "description": "HID 输出的整体状态",
        "x-en": {
          "title": "HID state",
          "description": "Overall state of HID output"
        },
        "type": "object",
        "required": [
          "ok",
          "usb",
          "mounted",
          "armed",
          "armed_left_s",
          "app_allowed",
          "app_paused",
          "active",
          "queue",
          "queue_max",
          "sent",
          "last_seq",
          "done_seq",
          "leds",
          "held",
          "batch",
          "stopped"
        ],
        "properties": {
          "ok": {
            "const": true,
            "description": "总是 true",
            "x-en": {
              "description": "Always true"
            }
          },
          "usb": {
            "type": "string",
            "enum": [
              "hid",
              "serial"
            ],
            "description": "USB 模式（POST /v1/usb）",
            "x-en": {
              "description": "USB mode (POST /v1/usb)"
            }
          },
          "mounted": {
            "type": "boolean",
            "description": "电脑已枚举这个设备（插着、没睡眠；serial 模式恒为 false）",
            "x-en": {
              "description": "The computer has enumerated the device (plugged in, awake; always false in serial mode)"
            }
          },
          "armed": {
            "type": "boolean",
            "description": "网络来源已解锁",
            "x-en": {
              "description": "The network source is armed"
            }
          },
          "armed_left_s": {
            "type": "integer",
            "minimum": 0,
            "description": "租约剩余秒数，没解锁为 0",
            "x-en": {
              "description": "Seconds left on the lease; 0 when disarmed"
            }
          },
          "app_allowed": {
            "type": "boolean",
            "description": "应用来源开着（在跑的应用有 hid 权限）",
            "x-en": {
              "description": "The app source is open (the running app has the hid permission)"
            }
          },
          "app_paused": {
            "type": "boolean",
            "description": "急停暂停了应用来源，等人按一下 BOOT 恢复",
            "x-en": {
              "description": "An emergency stop paused the app source; a press of BOOT resumes it"
            }
          },
          "active": {
            "type": "boolean",
            "description": "正在输出（队列空 300 毫秒后变回 false）",
            "x-en": {
              "description": "Output in progress (turns false 300 ms after the queue empties)"
            }
          },
          "queue": {
            "type": "integer",
            "minimum": 0,
            "description": "队列里待执行的项数",
            "x-en": {
              "description": "Items waiting in the queue"
            }
          },
          "queue_max": {
            "type": "integer",
            "minimum": 0,
            "description": "队列容量",
            "x-en": {
              "description": "Queue capacity"
            }
          },
          "sent": {
            "type": "integer",
            "minimum": 0,
            "description": "开机以来执行完的项数（text 按字符计）",
            "x-en": {
              "description": "Items executed since boot (text counts per character)"
            }
          },
          "last_seq": {
            "type": "integer",
            "minimum": 0,
            "description": "最近入队那一批的序号",
            "x-en": {
              "description": "Sequence number of the most recently queued batch"
            }
          },
          "done_seq": {
            "type": "integer",
            "minimum": 0,
            "description": "seq 不大于它的批次都已执行完或已丢弃",
            "x-en": {
              "description": "Every batch with seq up to this is finished or dropped"
            }
          },
          "leds": {
            "type": "object",
            "description": "电脑设的键盘灯",
            "x-en": {
              "description": "Keyboard LEDs set by the computer"
            },
            "required": [
              "num",
              "caps",
              "scroll"
            ],
            "properties": {
              "num": {
                "type": "boolean",
                "description": "Num Lock",
                "x-en": {
                  "description": "Num Lock"
                }
              },
              "caps": {
                "type": "boolean",
                "description": "Caps Lock",
                "x-en": {
                  "description": "Caps Lock"
                }
              },
              "scroll": {
                "type": "boolean",
                "description": "Scroll Lock",
                "x-en": {
                  "description": "Scroll Lock"
                }
              }
            }
          },
          "held": {
            "type": "object",
            "description": "电脑端当前按着的",
            "x-en": {
              "description": "What the computer currently sees held"
            },
            "required": [
              "keys",
              "buttons",
              "consumer"
            ],
            "properties": {
              "keys": {
                "type": "array",
                "items": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 255
                },
                "description": "按着的键（用途码，含修饰键 0xE0–0xE7；见 KeyName 的 x-codes）",
                "x-en": {
                  "description": "Held keys (usage codes, modifiers 0xE0–0xE7 included; see x-codes of KeyName)"
                }
              },
              "buttons": {
                "type": "integer",
                "minimum": 0,
                "maximum": 31,
                "description": "按着的鼠标键位（见 MouseButton 的 x-bits）",
                "x-en": {
                  "description": "Held mouse button bits (see x-bits of MouseButton)"
                }
              },
              "consumer": {
                "type": "integer",
                "minimum": 0,
                "maximum": 1023,
                "description": "按着的多媒体用途码，0 = 没有",
                "x-en": {
                  "description": "Held consumer usage code, 0 = none"
                }
              }
            }
          },
          "batch": {
            "type": [
              "object",
              "null"
            ],
            "description": "正在执行的批次，空闲为 null",
            "x-en": {
              "description": "Batch being executed; null when idle"
            },
            "required": [
              "seq",
              "tag",
              "started_ms",
              "done",
              "count"
            ],
            "properties": {
              "seq": {
                "type": "integer",
                "minimum": 0,
                "description": "批次序号",
                "x-en": {
                  "description": "Batch sequence number"
                }
              },
              "tag": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "批次标签，没带为 null",
                "x-en": {
                  "description": "Batch tag; null if none"
                }
              },
              "started_ms": {
                "type": "integer",
                "minimum": 0,
                "description": "开始执行时的设备开机毫秒",
                "x-en": {
                  "description": "Device uptime in ms when it started"
                }
              },
              "done": {
                "type": "integer",
                "minimum": 0,
                "description": "已执行的项数",
                "x-en": {
                  "description": "Items executed"
                }
              },
              "count": {
                "type": "integer",
                "minimum": 0,
                "description": "这一批的项数",
                "x-en": {
                  "description": "Items in the batch"
                }
              }
            }
          },
          "stopped": {
            "type": [
              "object",
              "null"
            ],
            "description": "最近一次停下，没停过为 null",
            "x-en": {
              "description": "The most recent stop; null if none"
            },
            "required": [
              "why",
              "ms"
            ],
            "properties": {
              "why": {
                "type": "string",
                "enum": [
                  "boot",
                  "host",
                  "lease",
                  "usb"
                ],
                "description": "boot 按 BOOT 急停，host 主机 disarm，lease 租约到期，usb USB 断开",
                "x-en": {
                  "description": "boot = BOOT emergency stop, host = host disarm, lease = lease expired, usb = USB disconnected"
                }
              },
              "ms": {
                "type": "integer",
                "minimum": 0,
                "description": "停下时的设备开机毫秒",
                "x-en": {
                  "description": "Device uptime in ms when it stopped"
                }
              }
            }
          }
        }
      },
      "HidPlayFileRequest": {
        "title": "播卡上的时间线",
        "description": "卡上时间线文件的路径与批次标签",
        "x-en": {
          "title": "Play a card timeline",
          "description": "Path of the timeline file on the card and the batch tag"
        },
        "type": "object",
        "required": [
          "path"
        ],
        "additionalProperties": false,
        "properties": {
          "path": {
            "type": "string",
            "minLength": 2,
            "maxLength": 160,
            "pattern": "^/",
            "x-max-bytes": 160,
            "description": "卡上的文件路径，以 / 开头、相对卡根，≤ 160 字节，规则同 /v1/sd，如 /stick/macros/a.tl",
            "x-en": {
              "description": "File path on the card, starting with / from the card root, ≤ 160 bytes, same rules as /v1/sd, e.g. /stick/macros/a.tl"
            }
          },
          "tag": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/HidTag"
              },
              {
                "type": "null"
              }
            ],
            "description": "批次标签，省略或 null 为 sdplay",
            "x-en": {
              "description": "Batch tag; sdplay when omitted or null"
            }
          }
        }
      },
      "HidPlayFileReply": {
        "title": "开播",
        "description": "校验完开始送料，或大文件还在校验",
        "x-en": {
          "title": "Playback started",
          "description": "Validated and feeding, or a large file is still being checked"
        },
        "oneOf": [
          {
            "title": "开始播放",
            "description": "整文件校验通过，已开始送进队列",
            "x-en": {
              "title": "Playing",
              "description": "The whole file passed validation and is being fed to the queue"
            },
            "type": "object",
            "required": [
              "ok",
              "records",
              "duration_ms"
            ],
            "properties": {
              "ok": {
                "const": true,
                "description": "总是 true",
                "x-en": {
                  "description": "Always true"
                }
              },
              "records": {
                "type": "integer",
                "minimum": 0,
                "description": "记录条数",
                "x-en": {
                  "description": "Number of records"
                }
              },
              "duration_ms": {
                "type": "integer",
                "minimum": 0,
                "description": "预计时长（毫秒）",
                "x-en": {
                  "description": "Estimated duration in ms"
                }
              }
            }
          },
          {
            "title": "还在校验",
            "description": "校验超过 1 秒先回；再查 GET /v1/hid/play_file 等它变成 playing 或 stopped",
            "x-en": {
              "title": "Checking",
              "description": "Returned when validation takes over 1 s; poll GET /v1/hid/play_file until it becomes playing or stopped"
            },
            "type": "object",
            "required": [
              "ok",
              "state",
              "records"
            ],
            "properties": {
              "ok": {
                "const": true,
                "description": "总是 true",
                "x-en": {
                  "description": "Always true"
                }
              },
              "state": {
                "const": "checking",
                "description": "正在整文件校验",
                "x-en": {
                  "description": "Validating the whole file"
                }
              },
              "records": {
                "type": "integer",
                "minimum": 0,
                "description": "记录条数",
                "x-en": {
                  "description": "Number of records"
                }
              }
            }
          }
        ]
      },
      "HidPlayStatus": {
        "title": "卡上时间线的播放状态",
        "description": "最近一次播放的状态",
        "x-en": {
          "title": "Card timeline playback state",
          "description": "State of the most recent playback"
        },
        "type": "object",
        "required": [
          "ok",
          "state",
          "path",
          "src",
          "tag",
          "records",
          "sent",
          "done",
          "duration_ms",
          "elapsed_ms",
          "why",
          "message"
        ],
        "properties": {
          "ok": {
            "const": true,
            "description": "总是 true",
            "x-en": {
              "description": "Always true"
            }
          },
          "state": {
            "type": "string",
            "enum": [
              "idle",
              "checking",
              "playing",
              "done",
              "stopped"
            ],
            "description": "idle 开机后还没播过，checking 整文件校验中，playing 播放中，done 播完，stopped 中途停下",
            "x-en": {
              "description": "idle = nothing played since boot, checking = validating the file, playing, done = finished, stopped = stopped part way"
            }
          },
          "path": {
            "type": [
              "string",
              "null"
            ],
            "description": "卡上的路径",
            "x-en": {
              "description": "Path on the card"
            }
          },
          "src": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "net",
              "app",
              null
            ],
            "description": "谁开播的：net 主机，app 应用",
            "x-en": {
              "description": "Who started it: net = host, app = an app"
            }
          },
          "tag": {
            "type": [
              "string",
              "null"
            ],
            "description": "批次标签",
            "x-en": {
              "description": "Batch tag"
            }
          },
          "records": {
            "type": "integer",
            "minimum": 0,
            "description": "记录条数",
            "x-en": {
              "description": "Number of records"
            }
          },
          "sent": {
            "type": "integer",
            "minimum": 0,
            "description": "已交给 HID 队列的条数",
            "x-en": {
              "description": "Records handed to the HID queue"
            }
          },
          "done": {
            "type": "integer",
            "minimum": 0,
            "description": "已执行完的条数（按批次算，最多落后一批）",
            "x-en": {
              "description": "Records executed (counted per batch, at most one batch behind)"
            }
          },
          "duration_ms": {
            "type": "integer",
            "minimum": 0,
            "description": "预计时长（毫秒）",
            "x-en": {
              "description": "Estimated duration in ms"
            }
          },
          "elapsed_ms": {
            "type": "integer",
            "minimum": 0,
            "description": "开始送料以来的毫秒",
            "x-en": {
              "description": "Milliseconds since feeding started"
            }
          },
          "why": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "stop",
              "flushed",
              "locked",
              "not_mounted",
              "sd_read",
              "file_changed",
              "bad_action",
              null
            ],
            "description": "停下的原因：stop 主机停播，flushed 急停或租约到期清了队列，locked 闸门关了，not_mounted 电脑断开，sd_read 读卡出错，file_changed 文件被改，bad_action 某条记录不合法",
            "x-en": {
              "description": "Why it stopped: stop = host stop, flushed = queue cleared by an emergency stop or lease expiry, locked = output gate closed, not_mounted = computer disconnected, sd_read = card read error, file_changed = file modified, bad_action = invalid record"
            }
          },
          "message": {
            "type": [
              "string",
              "null"
            ],
            "description": "细节，bad_action 时是「第 N 条记录：原因」",
            "x-en": {
              "description": "Detail; for bad_action, the record number and reason"
            }
          }
        }
      },
      "MonitorStatus": {
        "title": "监视页状态",
        "description": "监视页右边显示的内容",
        "x-en": {
          "title": "Monitor screen status",
          "description": "What the right side of the monitor screen shows"
        },
        "type": "object",
        "required": [
          "name",
          "mode",
          "source",
          "title",
          "line1",
          "line2",
          "state",
          "progress"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "状态栏左边的名字，空则显示设备编号",
            "x-en": {
              "description": "Name on the left of the status bar; device ID when empty"
            }
          },
          "mode": {
            "type": "string",
            "description": "胶囊里的模式，如 单次、LOOP",
            "x-en": {
              "description": "Mode in the pill, e.g. once or LOOP"
            }
          },
          "source": {
            "type": "string",
            "description": "胶囊右边的来源",
            "x-en": {
              "description": "Source to the right of the pill"
            }
          },
          "title": {
            "type": "string",
            "description": "大字标题，空则按 state 显示",
            "x-en": {
              "description": "Large title; follows state when empty"
            }
          },
          "line1": {
            "type": "string",
            "description": "第一行说明",
            "x-en": {
              "description": "First line"
            }
          },
          "line2": {
            "type": "string",
            "description": "第二行说明（进度管下方）",
            "x-en": {
              "description": "Second line (below the progress bar)"
            }
          },
          "state": {
            "type": "string",
            "enum": [
              "ready",
              "running",
              "stopped",
              "error"
            ],
            "description": "状态：就绪、运行中、已停止、出错",
            "x-en": {
              "description": "State: ready, running, stopped, error"
            }
          },
          "progress": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "maximum": 100,
            "description": "进度 0–100，null 不画进度管",
            "x-en": {
              "description": "Progress 0–100; null hides the bar"
            }
          }
        }
      },
      "MonitorSetRequest": {
        "title": "设监视页",
        "description": "整体替换，字段都可省；{\"clear\":true} 清掉。字段长度按 UTF-8 字节算",
        "x-en": {
          "title": "Set the monitor screen",
          "description": "Replaces the whole status; every field is optional. {\"clear\":true} clears it. Lengths are UTF-8 bytes"
        },
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 48,
            "x-max-bytes": 48,
            "description": "状态栏左边的名字，≤ 48 字节",
            "x-en": {
              "description": "Status bar name, ≤ 48 bytes"
            }
          },
          "mode": {
            "type": "string",
            "maxLength": 12,
            "x-max-bytes": 12,
            "description": "胶囊里的模式，≤ 12 字节",
            "x-en": {
              "description": "Mode in the pill, ≤ 12 bytes"
            }
          },
          "source": {
            "type": "string",
            "maxLength": 24,
            "x-max-bytes": 24,
            "description": "来源，≤ 24 字节",
            "x-en": {
              "description": "Source, ≤ 24 bytes"
            }
          },
          "title": {
            "type": "string",
            "maxLength": 48,
            "x-max-bytes": 48,
            "description": "大字标题，≤ 48 字节；省略按 state 显示",
            "x-en": {
              "description": "Large title, ≤ 48 bytes; follows state when omitted"
            }
          },
          "line1": {
            "type": "string",
            "maxLength": 48,
            "x-max-bytes": 48,
            "description": "第一行，≤ 48 字节",
            "x-en": {
              "description": "First line, ≤ 48 bytes"
            }
          },
          "line2": {
            "type": "string",
            "maxLength": 48,
            "x-max-bytes": 48,
            "description": "第二行，≤ 48 字节",
            "x-en": {
              "description": "Second line, ≤ 48 bytes"
            }
          },
          "state": {
            "type": "string",
            "enum": [
              "ready",
              "running",
              "stopped",
              "error"
            ],
            "default": "running",
            "description": "状态，省略 running；stopped / error 时一直显示停止面板",
            "x-en": {
              "description": "State, running when omitted; stopped / error keep the stop panel shown"
            }
          },
          "progress": {
            "type": [
              "number",
              "null"
            ],
            "minimum": 0,
            "maximum": 100,
            "description": "进度 0–100（四舍五入），null 或省略不画进度管",
            "x-en": {
              "description": "Progress 0–100 (rounded); null or omitted hides the bar"
            }
          },
          "ttl_s": {
            "type": "integer",
            "minimum": 1,
            "maximum": 3600,
            "default": 60,
            "description": "几秒后自动清掉，1–3600",
            "x-en": {
              "description": "Seconds until it clears itself, 1–3600"
            }
          },
          "clear": {
            "type": "boolean",
            "description": "true = 清掉（不论谁设的），其它字段不看",
            "x-en": {
              "description": "true clears it (whoever set it); other fields are ignored"
            }
          }
        }
      },
      "MonitorReply": {
        "title": "监视页",
        "description": "监视页是否显示与右边的状态",
        "x-en": {
          "title": "Monitor screen",
          "description": "Whether the monitor screen is shown and its status"
        },
        "type": "object",
        "required": [
          "ok",
          "visible",
          "owner",
          "ttl_s",
          "status"
        ],
        "properties": {
          "ok": {
            "const": true,
            "description": "总是 true",
            "x-en": {
              "description": "Always true"
            }
          },
          "visible": {
            "type": "boolean",
            "description": "监视页正在显示",
            "x-en": {
              "description": "The monitor screen is shown"
            }
          },
          "owner": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "app",
              "host",
              null
            ],
            "description": "谁设的状态：app 应用（monitor.set），host 主机；没设为 null",
            "x-en": {
              "description": "Who set the status: app (monitor.set) or host; null when unset"
            }
          },
          "ttl_s": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "description": "主机设的状态还剩几秒，应用设的或没设为 null",
            "x-en": {
              "description": "Seconds left on a host-set status; null for app-set or unset"
            }
          },
          "status": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/MonitorStatus"
              },
              {
                "type": "null"
              }
            ],
            "description": "当前状态，没设为 null",
            "x-en": {
              "description": "Current status; null when unset"
            }
          }
        }
      },
      "UsbModeRequest": {
        "title": "USB 模式",
        "description": "要切换到的 USB 模式",
        "x-en": {
          "title": "USB mode",
          "description": "USB mode to switch to"
        },
        "type": "object",
        "required": [
          "mode"
        ],
        "additionalProperties": false,
        "properties": {
          "mode": {
            "type": "string",
            "enum": [
              "hid",
              "serial"
            ],
            "description": "hid 键盘鼠标（默认），serial USB 串口控制台（没有 HID）",
            "x-en": {
              "description": "hid = keyboard and mouse (default), serial = USB serial console (no HID)"
            }
          }
        }
      },
      "UsbModeReply": {
        "title": "已保存",
        "description": "已存下，回复后约 0.5 秒重启",
        "x-en": {
          "title": "Saved",
          "description": "Saved; restarts about 0.5 s after replying"
        },
        "type": "object",
        "required": [
          "ok",
          "usb"
        ],
        "properties": {
          "ok": {
            "const": true,
            "description": "总是 true",
            "x-en": {
              "description": "Always true"
            }
          },
          "usb": {
            "type": "string",
            "enum": [
              "hid",
              "serial"
            ],
            "description": "重启后的 USB 模式",
            "x-en": {
              "description": "USB mode after the restart"
            }
          }
        }
      },
      "KeyName87": {
        "description": "标准 87 键（无小键盘键盘：主键区、F1–F12、PrtSc / ScrLk / Pause、编辑区 6 键、方向键、8 个修饰键与菜单键）。主机工具与 SDK 默认只认这些。不分大小写，这里列规范写法；x-codes 是 USB 键盘用途码（时间线 key_down / key_up 的 a）",
        "x-en": {
          "description": "Standard 87-key set (TKL: main block, F1–F12, PrtSc / ScrLk / Pause, 6 editing keys, arrows, 8 modifiers and Menu). Host tools and the SDK accept only these by default. Case-insensitive; the canonical spelling is listed. x-codes are USB keyboard usage codes (field a of timeline key_down / key_up)"
        },
        "type": "string",
        "enum": [
          "A",
          "B",
          "C",
          "D",
          "E",
          "F",
          "G",
          "H",
          "I",
          "J",
          "K",
          "L",
          "M",
          "N",
          "O",
          "P",
          "Q",
          "R",
          "S",
          "T",
          "U",
          "V",
          "W",
          "X",
          "Y",
          "Z",
          "1",
          "2",
          "3",
          "4",
          "5",
          "6",
          "7",
          "8",
          "9",
          "0",
          "ENTER",
          "ESC",
          "BACKSPACE",
          "TAB",
          "SPACE",
          "MINUS",
          "EQUAL",
          "LBRACKET",
          "RBRACKET",
          "BACKSLASH",
          "SEMICOLON",
          "QUOTE",
          "GRAVE",
          "COMMA",
          "PERIOD",
          "SLASH",
          "CAPSLOCK",
          "F1",
          "F2",
          "F3",
          "F4",
          "F5",
          "F6",
          "F7",
          "F8",
          "F9",
          "F10",
          "F11",
          "F12",
          "PRINTSCREEN",
          "SCROLLLOCK",
          "PAUSE",
          "INSERT",
          "HOME",
          "PGUP",
          "DELETE",
          "END",
          "PGDN",
          "RIGHT",
          "LEFT",
          "DOWN",
          "UP",
          "MENU",
          "LCTRL",
          "LSHIFT",
          "LALT",
          "LGUI",
          "RCTRL",
          "RSHIFT",
          "RALT",
          "RGUI"
        ],
        "x-case-insensitive": true,
        "x-codes": {
          "A": 4,
          "B": 5,
          "C": 6,
          "D": 7,
          "E": 8,
          "F": 9,
          "G": 10,
          "H": 11,
          "I": 12,
          "J": 13,
          "K": 14,
          "L": 15,
          "M": 16,
          "N": 17,
          "O": 18,
          "P": 19,
          "Q": 20,
          "R": 21,
          "S": 22,
          "T": 23,
          "U": 24,
          "V": 25,
          "W": 26,
          "X": 27,
          "Y": 28,
          "Z": 29,
          "1": 30,
          "2": 31,
          "3": 32,
          "4": 33,
          "5": 34,
          "6": 35,
          "7": 36,
          "8": 37,
          "9": 38,
          "0": 39,
          "ENTER": 40,
          "ESC": 41,
          "BACKSPACE": 42,
          "TAB": 43,
          "SPACE": 44,
          "MINUS": 45,
          "EQUAL": 46,
          "LBRACKET": 47,
          "RBRACKET": 48,
          "BACKSLASH": 49,
          "SEMICOLON": 51,
          "QUOTE": 52,
          "GRAVE": 53,
          "COMMA": 54,
          "PERIOD": 55,
          "SLASH": 56,
          "CAPSLOCK": 57,
          "F1": 58,
          "F2": 59,
          "F3": 60,
          "F4": 61,
          "F5": 62,
          "F6": 63,
          "F7": 64,
          "F8": 65,
          "F9": 66,
          "F10": 67,
          "F11": 68,
          "F12": 69,
          "PRINTSCREEN": 70,
          "SCROLLLOCK": 71,
          "PAUSE": 72,
          "INSERT": 73,
          "HOME": 74,
          "PGUP": 75,
          "DELETE": 76,
          "END": 77,
          "PGDN": 78,
          "RIGHT": 79,
          "LEFT": 80,
          "DOWN": 81,
          "UP": 82,
          "MENU": 101,
          "LCTRL": 224,
          "LSHIFT": 225,
          "LALT": 226,
          "LGUI": 227,
          "RCTRL": 228,
          "RSHIFT": 229,
          "RALT": 230,
          "RGUI": 231
        },
        "x-generated": "stick.apispec"
      },
      "KeyNameExtended": {
        "description": "扩展键：设备认，但前台程序一般不响应，只给自检与演练用。主机工具要加 --extended / extended=True，SDK 计划要写 \"keyset\": \"full\"；设备与时间线不区分",
        "x-en": {
          "description": "Extended keys: the device accepts them, but foreground programs usually ignore them; for self-tests and drills only. Host tools need --extended / extended=True and SDK plans need \"keyset\": \"full\"; the device and timelines make no distinction"
        },
        "type": "string",
        "enum": [
          "NUMLOCK",
          "F13",
          "F14",
          "F15",
          "F16",
          "F17",
          "F18",
          "F19",
          "F20",
          "F21",
          "F22",
          "F23",
          "F24"
        ],
        "x-case-insensitive": true,
        "x-codes": {
          "NUMLOCK": 83,
          "F13": 104,
          "F14": 105,
          "F15": 106,
          "F16": 107,
          "F17": 108,
          "F18": 109,
          "F19": 110,
          "F20": 111,
          "F21": 112,
          "F22": 113,
          "F23": 114,
          "F24": 115
        },
        "x-generated": "stick.apispec"
      },
      "KeyName": {
        "description": "键名。设备认全表：标准 87 键（KeyName87）加扩展键（KeyNameExtended）。不分大小写",
        "x-en": {
          "description": "Key name. The device accepts the full table: the standard 87-key set (KeyName87) plus extended keys (KeyNameExtended). Case-insensitive"
        },
        "anyOf": [
          {
            "$ref": "#/components/schemas/KeyName87"
          },
          {
            "$ref": "#/components/schemas/KeyNameExtended"
          }
        ],
        "x-keysets": {
          "87": "KeyName87",
          "full": "KeyName"
        },
        "x-generated": "stick.apispec"
      },
      "ModName": {
        "description": "修饰名：ctrl shift alt gui 是左边的（gui = Windows 键 / Command），r 开头是右边的。不分大小写；x-bits 是修饰位（时间线 key_down 的 b）",
        "x-en": {
          "description": "Modifier name: ctrl shift alt gui are the left ones (gui = Windows / Command key), the r-prefixed ones are on the right. Case-insensitive; x-bits are modifier bits (field b of timeline key_down)"
        },
        "type": "string",
        "enum": [
          "ctrl",
          "shift",
          "alt",
          "gui",
          "rctrl",
          "rshift",
          "ralt",
          "rgui"
        ],
        "x-case-insensitive": true,
        "x-bits": {
          "ctrl": 1,
          "shift": 2,
          "alt": 4,
          "gui": 8,
          "rctrl": 16,
          "rshift": 32,
          "ralt": 64,
          "rgui": 128
        },
        "x-generated": "stick.apispec"
      },
      "MouseButton": {
        "description": "鼠标键。不分大小写；x-bits 是键位（时间线 btn_down / btn_up 的 a）",
        "x-en": {
          "description": "Mouse button. Case-insensitive; x-bits are button bits (field a of timeline btn_down / btn_up)"
        },
        "type": "string",
        "enum": [
          "left",
          "right",
          "middle",
          "back",
          "forward"
        ],
        "x-case-insensitive": true,
        "x-bits": {
          "left": 1,
          "right": 2,
          "middle": 4,
          "back": 8,
          "forward": 16
        },
        "x-generated": "stick.apispec"
      },
      "MediaName": {
        "description": "多媒体键（Consumer 页）。不分大小写；x-codes 是 Consumer 用途码（时间线 consumer 的 a | b << 8）",
        "x-en": {
          "description": "Media key (consumer page). Case-insensitive; x-codes are consumer usage codes (a | b << 8 of timeline consumer)"
        },
        "type": "string",
        "enum": [
          "volume_up",
          "volume_down",
          "mute",
          "play_pause",
          "next",
          "prev",
          "stop",
          "brightness_up",
          "brightness_down"
        ],
        "x-case-insensitive": true,
        "x-codes": {
          "volume_up": 233,
          "volume_down": 234,
          "mute": 226,
          "play_pause": 205,
          "next": 181,
          "prev": 182,
          "stop": 183,
          "brightness_up": 111,
          "brightness_down": 112
        },
        "x-generated": "stick.apispec"
      },
      "HidTag": {
        "description": "批次标签：1–32 个 A-Z a-z 0-9 _ . : -。只用于对照（GET /v1/hid 的 batch、监视页的来源），不参与执行",
        "x-en": {
          "description": "Batch tag: 1–32 of A-Z a-z 0-9 _ . : -. For matching only (batch in GET /v1/hid, the source on the monitor screen); does not affect execution"
        },
        "type": "string",
        "minLength": 1,
        "maxLength": 32,
        "pattern": "^[A-Za-z0-9_.:-]{1,32}$",
        "x-generated": "stick.apispec"
      },
      "HidText": {
        "description": "要打的字：ASCII 可打印字符与 \\n \\t，按美式布局，1–256 个。中文等非 ASCII 打不出",
        "x-en": {
          "description": "Text to type: printable ASCII plus \\n and \\t, US layout, 1–256 characters. Non-ASCII text (such as Chinese) cannot be typed"
        },
        "type": "string",
        "minLength": 1,
        "maxLength": 256,
        "pattern": "^[ -~\\t\\n]+$",
        "x-generated": "stick.apispec"
      },
      "HidMoveDelta": {
        "description": "相对位移（鼠标计数，受系统鼠标加速影响），±2000 以内；超过 ±127 的设备自动拆成多帧",
        "x-en": {
          "description": "Relative movement (mouse counts, subject to pointer acceleration), within ±2000; the device splits values beyond ±127 into several frames"
        },
        "type": "integer",
        "minimum": -2000,
        "maximum": 2000,
        "x-generated": "stick.apispec"
      },
      "HidWheelSteps": {
        "description": "滚轮格数，±127",
        "x-en": {
          "description": "Wheel steps, ±127"
        },
        "type": "integer",
        "minimum": -127,
        "maximum": 127,
        "x-generated": "stick.apispec"
      },
      "HidWaitMs": {
        "description": "停顿毫秒数，0–5000",
        "x-en": {
          "description": "Pause in milliseconds, 0–5000"
        },
        "type": "integer",
        "minimum": 0,
        "maximum": 5000,
        "x-generated": "stick.apispec"
      },
      "HidActionList": {
        "description": "动作列表，按顺序执行，1–512 个。整批先全部校验：有一个不对就一个都不入队",
        "x-en": {
          "description": "Actions, executed in order, 1–512. The whole batch is checked first: if one is invalid, none is queued"
        },
        "type": "array",
        "minItems": 1,
        "maxItems": 512,
        "items": {
          "$ref": "#/components/schemas/HidAction"
        },
        "x-generated": "stick.apispec"
      },
      "HidTimelineBody": {
        "description": "时间线：6 字节记录首尾相接，没有文件头，1–4096 条。每条小端 u16 dt、u8 op、u8 a、i8 b、i8 c：dt 是距上一条的毫秒数（0–5000），op 见 x-ops，没用到的字段必须为 0。帧间隔不小于 4 毫秒（不足的设备顺延）",
        "x-en": {
          "description": "Timeline: 6-byte records back to back, no header, 1–4096 records. Each is little-endian u16 dt, u8 op, u8 a, i8 b, i8 c: dt is milliseconds after the previous record (0–5000), op is listed in x-ops, and unused fields must be 0. Frames are at least 4 ms apart (the device delays shorter gaps)"
        },
        "type": "string",
        "contentMediaType": "application/octet-stream",
        "x-record-size": 6,
        "x-records-max": 4096,
        "x-dt-max": 5000,
        "x-frame-min-ms": 4,
        "x-abs-max": 32767,
        "x-consumer-max": 1023,
        "x-ops": {
          "nop": {
            "code": 0,
            "description": "不发帧，只占时间（dt）。a b c 为 0",
            "x-en": {
              "description": "Sends nothing; only takes time (dt). a b c are 0"
            }
          },
          "key_down": {
            "code": 1,
            "description": "按下：a 键盘用途码（见 KeyName 的 x-codes，含修饰键 0xE0–0xE7），b 修饰位（按 u8 读，见 ModName 的 x-bits）",
            "x-en": {
              "description": "Key down: a = keyboard usage code (x-codes of KeyName, modifiers 0xE0–0xE7 included), b = modifier bits (read as u8, x-bits of ModName)"
            }
          },
          "key_up": {
            "code": 2,
            "description": "松开：a 用途码，0 = 全部松开",
            "x-en": {
              "description": "Key up: a = usage code, 0 releases all keys"
            }
          },
          "move": {
            "code": 3,
            "description": "鼠标相对移动：b dx、c dy（±127）",
            "x-en": {
              "description": "Relative mouse move: b = dx, c = dy (±127)"
            }
          },
          "btn_down": {
            "code": 4,
            "description": "鼠标键按下：a 键位（1–0x1F，见 MouseButton 的 x-bits）",
            "x-en": {
              "description": "Mouse button down: a = button bits (1–0x1F, x-bits of MouseButton)"
            }
          },
          "btn_up": {
            "code": 5,
            "description": "鼠标键松开：a 键位",
            "x-en": {
              "description": "Mouse button up: a = button bits"
            }
          },
          "wheel": {
            "code": 6,
            "description": "滚轮：b 竖向（正 = 向上）、c 横向（正 = 向右），±127",
            "x-en": {
              "description": "Wheel: b = vertical (positive scrolls up), c = horizontal (positive scrolls right), ±127"
            }
          },
          "release_all": {
            "code": 7,
            "description": "松开所有键、鼠标键与多媒体键（键盘、鼠标、Consumer 各 1 帧，占 8 毫秒）",
            "x-en": {
              "description": "Release all keys, mouse buttons and media keys (one keyboard, mouse and consumer frame each; takes 8 ms)"
            }
          },
          "consumer": {
            "code": 8,
            "description": "多媒体键：a 低 8 位、b（按 u8 读）高 8 位，Consumer 用途码 0–0x3FF（见 MediaName 的 x-codes）；0 = 松开。按住直到下一条 consumer",
            "x-en": {
              "description": "Media key: a = low 8 bits, b (read as u8) = high 8 bits of the consumer usage code 0–0x3FF (x-codes of MediaName); 0 releases. Held until the next consumer record"
            }
          },
          "abs_x": {
            "code": 9,
            "description": "绝对指针 X：a 低 8 位、b（按 u8 读）高 8 位，0–32767；不发帧，等下一条 moveto",
            "x-en": {
              "description": "Absolute pointer X: a = low 8 bits, b (read as u8) = high 8 bits, 0–32767; sends nothing until the next moveto"
            }
          },
          "moveto": {
            "code": 10,
            "description": "绝对指针 Y（编码同 abs_x），发一帧移到 (X, Y)；0–32767 铺满主显示器",
            "x-en": {
              "description": "Absolute pointer Y (encoded like abs_x); sends one frame moving to (X, Y). 0–32767 spans the primary display"
            }
          }
        },
        "x-generated": "stick.apispec"
      },
      "WifiForgetRequest": {
        "title": "忘记网络",
        "description": "请求体可省：带 ssid 只忘记这一个；省略（空体或 {}）全部清掉并进配网",
        "x-en": {
          "title": "Forget network",
          "description": "The body is optional: with ssid, forget that one; without (empty body or {}), clear all and enter Wi-Fi setup"
        },
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "ssid": {
            "$ref": "#/components/schemas/WifiSsid"
          }
        }
      },
      "WifiList": {
        "title": "记住的网络",
        "description": "记住的网络与正连着的",
        "x-en": {
          "title": "Saved networks",
          "description": "Saved networks and the current one"
        },
        "type": "object",
        "required": [
          "ok",
          "current",
          "max",
          "networks"
        ],
        "properties": {
          "ok": {
            "description": "总是 true",
            "x-en": {
              "description": "Always true"
            },
            "const": true
          },
          "current": {
            "description": "正连着的网络；没联网为 null",
            "x-en": {
              "description": "Network in use; null when offline"
            },
            "type": [
              "string",
              "null"
            ]
          },
          "max": {
            "description": "最多记住几个",
            "x-en": {
              "description": "Maximum number of saved networks"
            },
            "type": "integer",
            "minimum": 1
          },
          "networks": {
            "description": "记住的网络，最近连上的在前",
            "x-en": {
              "description": "Saved networks, most recent first"
            },
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WifiNetwork"
            }
          }
        }
      },
      "WifiNetwork": {
        "title": "记住的网络",
        "description": "记住的一个网络（不含密码）",
        "x-en": {
          "title": "Saved network",
          "description": "One saved network (no password)"
        },
        "type": "object",
        "required": [
          "ssid",
          "last_ok",
          "channel"
        ],
        "properties": {
          "ssid": {
            "$ref": "#/components/schemas/WifiSsid"
          },
          "last_ok": {
            "description": "上次连上的 Unix 时间（秒）；当时没校时为 null",
            "x-en": {
              "description": "Unix time (s) it last connected; null if the clock was not set then"
            },
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "channel": {
            "description": "上次连上的信道；不知道为 null",
            "x-en": {
              "description": "Channel it last connected on; null if unknown"
            },
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "maximum": 14
          }
        }
      },
      "WifiPass": {
        "description": "密码：开放网络留空或省略，否则 8–64 字节",
        "x-en": {
          "description": "Password: empty or omitted for open networks, otherwise 8–64 bytes"
        },
        "type": "string",
        "maxLength": 64,
        "x-max-bytes": 64,
        "pattern": "^(.{8,})?$"
      },
      "WifiProvForgetForm": {
        "title": "忘记网络",
        "description": "要忘记的网络",
        "x-en": {
          "title": "Forget network",
          "description": "Network to forget"
        },
        "type": "object",
        "required": [
          "ssid"
        ],
        "additionalProperties": false,
        "properties": {
          "ssid": {
            "$ref": "#/components/schemas/WifiSsid"
          }
        }
      },
      "WifiProvLangForm": {
        "title": "屏幕语言",
        "description": "要设的屏幕语言",
        "x-en": {
          "title": "Screen language",
          "description": "Screen language to set"
        },
        "type": "object",
        "required": [
          "lang"
        ],
        "additionalProperties": false,
        "properties": {
          "lang": {
            "description": "zh 中文，en 英文",
            "x-en": {
              "description": "zh = Chinese, en = English"
            },
            "type": "string",
            "enum": [
              "zh",
              "en"
            ]
          }
        }
      },
      "WifiProvStatus": {
        "title": "配网进度",
        "description": "候选这次的结果优先；没有候选时连着就是 up",
        "x-en": {
          "title": "Setup progress",
          "description": "The candidate's result comes first; without a candidate, state is up when connected"
        },
        "type": "object",
        "required": [
          "ok",
          "id",
          "state",
          "ssid",
          "reason",
          "known",
          "max"
        ],
        "properties": {
          "ok": {
            "description": "总是 true",
            "x-en": {
              "description": "Always true"
            },
            "const": true
          },
          "id": {
            "description": "设备编号，也是热点名称",
            "x-en": {
              "description": "Device ID, also the hotspot name"
            },
            "type": "string",
            "pattern": "^stick-[0-9a-f]{6}$"
          },
          "state": {
            "description": "idle 没在连，connecting 正在连，got_ap 已连上路由器、等 IP，up 已联网，failed 候选没连上（看 reason）",
            "x-en": {
              "description": "idle = not connecting, connecting, got_ap = joined the router and waiting for an IP, up = online, failed = the candidate did not connect (see reason)"
            },
            "type": "string",
            "enum": [
              "idle",
              "connecting",
              "got_ap",
              "up",
              "failed"
            ]
          },
          "ssid": {
            "description": "正在连或连着的网络；没有为 null",
            "x-en": {
              "description": "Network being joined or in use; null if none"
            },
            "type": [
              "string",
              "null"
            ]
          },
          "reason": {
            "description": "failed 的原因：auth 密码不对（候选随即丢掉），not_found 找不到，timeout 超时，no_ip 拿不到 IP；其它状态为 null",
            "x-en": {
              "description": "Why it failed: auth = wrong password (the candidate is dropped), not_found = network not found, timeout, no_ip = got no IP address; null in other states"
            },
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "auth",
              "not_found",
              "timeout",
              "no_ip",
              null
            ]
          },
          "ip": {
            "description": "设备在这个网络上的地址，只在 up 时有",
            "x-en": {
              "description": "Device address on that network; only when up"
            },
            "type": "string",
            "format": "ipv4"
          },
          "rssi": {
            "description": "信号强度（dBm），只在 up 时有",
            "x-en": {
              "description": "Signal strength (dBm); only when up"
            },
            "type": "integer",
            "maximum": 0
          },
          "known": {
            "description": "记住的网络，最近连上的在前",
            "x-en": {
              "description": "Saved networks, most recent first"
            },
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WifiNetwork"
            }
          },
          "max": {
            "description": "最多记住几个",
            "x-en": {
              "description": "Maximum number of saved networks"
            },
            "type": "integer",
            "minimum": 1
          },
          "lang": {
            "description": "设备屏幕语言",
            "x-en": {
              "description": "Screen language of the device"
            },
            "type": "string",
            "enum": [
              "zh",
              "en"
            ]
          },
          "lang_chosen": {
            "description": "有人选过语言；没选过时配网页按手机语言设一次",
            "x-en": {
              "description": "Someone has chosen a language; if not, the setup page sets one from the phone's language"
            },
            "type": "boolean"
          }
        }
      },
      "WifiSaveRequest": {
        "title": "网络",
        "description": "要连的网络",
        "x-en": {
          "title": "Network",
          "description": "Network to join"
        },
        "type": "object",
        "required": [
          "ssid"
        ],
        "additionalProperties": false,
        "properties": {
          "ssid": {
            "$ref": "#/components/schemas/WifiSsid"
          },
          "pass": {
            "$ref": "#/components/schemas/WifiPass"
          }
        }
      },
      "WifiScanReply": {
        "title": "附近网络",
        "description": "信号强的在前；同名只列一次，不含隐藏网络，最多 20 个",
        "x-en": {
          "title": "Nearby networks",
          "description": "Strongest first; each name listed once, hidden networks excluded, at most 20"
        },
        "type": "object",
        "required": [
          "ok",
          "networks"
        ],
        "properties": {
          "ok": {
            "description": "总是 true",
            "x-en": {
              "description": "Always true"
            },
            "const": true
          },
          "networks": {
            "description": "附近网络",
            "x-en": {
              "description": "Nearby networks"
            },
            "type": "array",
            "maxItems": 20,
            "items": {
              "type": "object",
              "required": [
                "ssid",
                "rssi",
                "secure"
              ],
              "properties": {
                "ssid": {
                  "$ref": "#/components/schemas/WifiSsid"
                },
                "rssi": {
                  "description": "信号强度（dBm）",
                  "x-en": {
                    "description": "Signal strength (dBm)"
                  },
                  "type": "integer",
                  "maximum": 0
                },
                "secure": {
                  "description": "要密码",
                  "x-en": {
                    "description": "Needs a password"
                  },
                  "type": "boolean"
                }
              }
            }
          }
        }
      },
      "WifiSsid": {
        "description": "网络名称（SSID），1–32 字节，区分大小写",
        "x-en": {
          "description": "Network name (SSID), 1–32 bytes, case-sensitive"
        },
        "type": "string",
        "minLength": 1,
        "maxLength": 32,
        "x-max-bytes": 32
      },
      "DebugCrashReply": {
        "title": "即将崩溃",
        "description": "回复后约 500 毫秒崩溃重启",
        "x-en": {
          "title": "Crashing",
          "description": "Crashes and restarts about 500 ms after replying"
        },
        "type": "object",
        "required": [
          "ok",
          "kind"
        ],
        "properties": {
          "ok": {
            "description": "总是 true",
            "x-en": {
              "description": "Always true"
            },
            "const": true
          },
          "kind": {
            "description": "崩溃方式",
            "x-en": {
              "description": "How it crashes"
            },
            "type": "string",
            "enum": [
              "panic",
              "int_wdt"
            ]
          }
        }
      },
      "DebugCrashRequest": {
        "title": "崩溃",
        "description": "请求体可省（省略按 panic）",
        "x-en": {
          "title": "Crash",
          "description": "The body is optional (defaults to panic)"
        },
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "kind": {
            "description": "panic 程序崩溃（abort）；int_wdt 关掉本核中断空转，让中断看门狗触发",
            "x-en": {
              "description": "panic = abort(); int_wdt = spin with interrupts off on this core so the interrupt watchdog fires"
            },
            "type": "string",
            "enum": [
              "panic",
              "int_wdt"
            ],
            "default": "panic"
          }
        }
      },
      "DebugNetDropReply": {
        "title": "即将断网",
        "description": "回复后约 300 毫秒断开",
        "x-en": {
          "title": "Dropping",
          "description": "Disconnects about 300 ms after replying"
        },
        "type": "object",
        "required": [
          "ok",
          "seconds"
        ],
        "properties": {
          "ok": {
            "description": "总是 true",
            "x-en": {
              "description": "Always true"
            },
            "const": true
          },
          "seconds": {
            "description": "断网秒数",
            "x-en": {
              "description": "Seconds offline"
            },
            "type": "integer",
            "minimum": 1,
            "maximum": 60
          }
        }
      },
      "DebugNetDropRequest": {
        "title": "断网",
        "description": "请求体可省（省略按 20 秒）",
        "x-en": {
          "title": "Network drop",
          "description": "The body is optional (defaults to 20 s)"
        },
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "seconds": {
            "description": "断网秒数，1–60",
            "x-en": {
              "description": "Seconds offline, 1–60"
            },
            "type": "integer",
            "minimum": 1,
            "maximum": 60,
            "default": 20
          }
        }
      },
      "DebugStatusRequest": {
        "title": "注入状态",
        "description": "要注入的状态",
        "x-en": {
          "title": "Status injection",
          "description": "Status to inject"
        },
        "type": "object",
        "required": [
          "id"
        ],
        "additionalProperties": false,
        "properties": {
          "id": {
            "description": "状态名（status_map.def，如 PROVISIONING、IDENTIFY、WIFI_OFFLINE）；GET /v1/status 里的 id 同名",
            "x-en": {
              "description": "Status name (status_map.def, such as PROVISIONING, IDENTIFY, WIFI_OFFLINE); same as id in GET /v1/status"
            },
            "type": "string",
            "pattern": "^[A-Z][A-Z0-9_]*$"
          },
          "op": {
            "description": "set 设上、到时自动清掉，clear 清掉，event 发一次性事件",
            "x-en": {
              "description": "set = show it and clear it when time is up, clear = clear it, event = send a one-off event"
            },
            "type": "string",
            "enum": [
              "set",
              "clear",
              "event"
            ],
            "default": "set"
          },
          "value": {
            "description": "状态的数值，含义随状态",
            "x-en": {
              "description": "Status value; meaning depends on the status"
            },
            "type": "integer",
            "default": -1
          },
          "detail": {
            "description": "附带文字，超过 63 字节截断",
            "x-en": {
              "description": "Detail text; truncated beyond 63 bytes"
            },
            "type": "string"
          },
          "seconds": {
            "description": "set 的持续秒数，1–120",
            "x-en": {
              "description": "How long set lasts, in seconds, 1–120"
            },
            "type": "integer",
            "minimum": 1,
            "maximum": 120,
            "default": 10
          }
        }
      },
      "DeviceButton": {
        "title": "BOOT 键",
        "description": "BOOT 键事件",
        "x-en": {
          "title": "BOOT button",
          "description": "BOOT button events"
        },
        "type": "object",
        "required": [
          "ok",
          "next",
          "down",
          "press_stop",
          "events"
        ],
        "properties": {
          "ok": {
            "const": true,
            "description": "总是 true",
            "x-en": {
              "description": "Always true"
            }
          },
          "next": {
            "type": "integer",
            "minimum": 0,
            "description": "最新事件的序号，下次请求的 since",
            "x-en": {
              "description": "Sequence number of the latest event; since for the next request"
            }
          },
          "down": {
            "type": "boolean",
            "description": "BOOT 现在按着",
            "x-en": {
              "description": "BOOT is held now"
            }
          },
          "press_stop": {
            "type": "boolean",
            "description": "最近一按是急停",
            "x-en": {
              "description": "The latest press was an emergency stop"
            }
          },
          "events": {
            "type": "array",
            "items": {
              "description": "一个事件",
              "x-en": {
                "description": "One event"
              },
              "type": "object",
              "required": [
                "seq",
                "ms",
                "ev",
                "stop"
              ],
              "properties": {
                "seq": {
                  "type": "integer",
                  "minimum": 0,
                  "description": "序号",
                  "x-en": {
                    "description": "Sequence number"
                  }
                },
                "ms": {
                  "type": "integer",
                  "minimum": 0,
                  "description": "开机毫秒",
                  "x-en": {
                    "description": "Uptime in ms"
                  }
                },
                "ev": {
                  "type": "string",
                  "enum": [
                    "down",
                    "up",
                    "click",
                    "double",
                    "long",
                    "hold"
                  ],
                  "description": "down 按下，up 松开，click 单击，double 双击，long 长按 0.8 秒，hold 按住 5 秒",
                  "x-en": {
                    "description": "down, up, click, double = double-click, long = long press (0.8 s), hold = held 5 s"
                  }
                },
                "stop": {
                  "type": "boolean",
                  "description": "这一按是急停",
                  "x-en": {
                    "description": "This press was an emergency stop"
                  }
                }
              }
            },
            "description": "事件，旧的在前（环里留最近 32 条）",
            "x-en": {
              "description": "Events, oldest first (the ring keeps the latest 32)"
            }
          }
        }
      },
      "DeviceInfo": {
        "title": "设备信息",
        "description": "各段由各组件填；hid、apps、sd、blackbox、www 只在内核有",
        "x-en": {
          "title": "Device info",
          "description": "Sections are filled in by components; hid, apps, sd, blackbox and www exist only in the kernel"
        },
        "type": "object",
        "required": [
          "ok",
          "api",
          "id",
          "mode",
          "lang",
          "fw",
          "uptime_ms",
          "reset_reason",
          "heap",
          "wifi",
          "paired",
          "ota",
          "crash"
        ],
        "properties": {
          "ok": {
            "const": true,
            "description": "总是 true",
            "x-en": {
              "description": "Always true"
            }
          },
          "api": {
            "type": "integer",
            "minimum": 1,
            "description": "接口版本，现为 1",
            "x-en": {
              "description": "API version, currently 1"
            }
          },
          "id": {
            "type": "string",
            "description": "设备编号：stick- 加 Wi-Fi MAC 后 6 位十六进制",
            "x-en": {
              "description": "Device ID: stick- plus the last 6 hex digits of the Wi-Fi MAC"
            }
          },
          "mode": {
            "type": "string",
            "enum": [
              "kernel",
              "rescue"
            ],
            "description": "在跑的固件：kernel 内核，rescue 恢复固件",
            "x-en": {
              "description": "Running firmware: kernel, or rescue (rescue firmware)"
            }
          },
          "lang": {
            "type": "string",
            "enum": [
              "zh",
              "en"
            ],
            "description": "屏幕语言（GET /v1/lang）",
            "x-en": {
              "description": "Screen language (GET /v1/lang)"
            }
          },
          "fw": {
            "description": "在跑的固件",
            "x-en": {
              "description": "Running firmware"
            },
            "type": "object",
            "required": [
              "project",
              "version",
              "build",
              "idf",
              "date"
            ],
            "properties": {
              "project": {
                "type": "string",
                "description": "项目名：stick_kernel / stick_rescue",
                "x-en": {
                  "description": "Project name: stick_kernel / stick_rescue"
                }
              },
              "version": {
                "type": "string",
                "description": "版本号",
                "x-en": {
                  "description": "Version"
                }
              },
              "build": {
                "type": "string",
                "pattern": "^[0-9a-f]{16}$",
                "description": "构建号：ELF 的 SHA-256 前 16 位",
                "x-en": {
                  "description": "Build ID: first 16 hex digits of the ELF SHA-256"
                }
              },
              "idf": {
                "type": "string",
                "description": "ESP-IDF 版本",
                "x-en": {
                  "description": "ESP-IDF version"
                }
              },
              "date": {
                "type": "string",
                "description": "编译时间",
                "x-en": {
                  "description": "Build time"
                }
              }
            }
          },
          "uptime_ms": {
            "type": "integer",
            "minimum": 0,
            "description": "开机以来的毫秒数",
            "x-en": {
              "description": "Milliseconds since boot"
            }
          },
          "reset_reason": {
            "type": "string",
            "enum": [
              "poweron",
              "sw",
              "panic",
              "int_wdt",
              "task_wdt",
              "wdt",
              "brownout",
              "deepsleep",
              "other"
            ],
            "description": "这次开机的原因：poweron 上电，sw 软件重启，panic 崩溃，int_wdt / task_wdt / wdt 看门狗，brownout 欠压",
            "x-en": {
              "description": "Reset reason of this boot: poweron, sw = software restart, panic = crash, int_wdt / task_wdt / wdt = watchdog, brownout = low voltage"
            }
          },
          "heap": {
            "description": "内存（字节）",
            "x-en": {
              "description": "Memory (bytes)"
            },
            "type": "object",
            "required": [
              "internal_free",
              "internal_min",
              "psram_free"
            ],
            "properties": {
              "internal_free": {
                "type": "integer",
                "minimum": 0,
                "description": "内部内存剩余",
                "x-en": {
                  "description": "Free internal memory"
                }
              },
              "internal_min": {
                "type": "integer",
                "minimum": 0,
                "description": "开机以来内部内存剩余的最低值",
                "x-en": {
                  "description": "Lowest free internal memory since boot"
                }
              },
              "psram_free": {
                "type": "integer",
                "minimum": 0,
                "description": "PSRAM 剩余",
                "x-en": {
                  "description": "Free PSRAM"
                }
              }
            }
          },
          "wifi": {
            "description": "Wi-Fi",
            "x-en": {
              "description": "Wi-Fi"
            },
            "type": "object",
            "required": [
              "ssid",
              "rssi",
              "ip",
              "provisioning",
              "known"
            ],
            "properties": {
              "ssid": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "当前（或正在连）的网络，没有为 null",
                "x-en": {
                  "description": "Current (or connecting) network; null if none"
                }
              },
              "rssi": {
                "type": [
                  "integer",
                  "null"
                ],
                "description": "信号强度（dBm），没连上为 null",
                "x-en": {
                  "description": "Signal strength (dBm); null when not connected"
                }
              },
              "ip": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "IP 地址，没连上为 null",
                "x-en": {
                  "description": "IP address; null when not connected"
                }
              },
              "provisioning": {
                "type": "boolean",
                "description": "正在配网（开着配网热点）",
                "x-en": {
                  "description": "Wi-Fi setup is on (setup hotspot open)"
                }
              },
              "known": {
                "type": "integer",
                "minimum": 0,
                "maximum": 3,
                "description": "记住的网络数（最多 3 个）",
                "x-en": {
                  "description": "Number of remembered networks (up to 3)"
                }
              }
            }
          },
          "paired": {
            "type": "boolean",
            "description": "已配对（设备有配对密钥）",
            "x-en": {
              "description": "Paired (the device has a pairing key)"
            }
          },
          "ota": {
            "description": "分区与最近一次更新",
            "x-en": {
              "description": "Partitions and the latest update"
            },
            "type": "object",
            "required": [
              "running",
              "boot",
              "state",
              "confirm_left_s",
              "slots",
              "last"
            ],
            "properties": {
              "running": {
                "type": "string",
                "description": "在跑的分区：rescue / kernel_a / kernel_b",
                "x-en": {
                  "description": "Running partition: rescue / kernel_a / kernel_b"
                }
              },
              "boot": {
                "type": "string",
                "description": "下次开机的分区",
                "x-en": {
                  "description": "Partition for the next boot"
                }
              },
              "state": {
                "$ref": "#/components/schemas/DeviceSlotState"
              },
              "confirm_left_s": {
                "type": [
                  "integer",
                  "null"
                ],
                "description": "待确认时离自动回滚的秒数，否则 null",
                "x-en": {
                  "description": "Seconds until automatic rollback while awaiting confirmation; otherwise null"
                }
              },
              "sign_key": {
                "type": "string",
                "description": "经 Wi-Fi 更新时认的签名公钥摘要（运行中固件签名块里公钥的 SHA-256，64 位十六进制；读不出为空串）。2026-12-02 起的固件才有",
                "x-en": {
                  "description": "Digest of the signing public key accepted for Wi-Fi updates (SHA-256 of the public key in the running firmware's signature block, 64 hex digits; empty if unreadable). Firmware from 2026-12-02 on"
                }
              },
              "slots": {
                "type": "array",
                "items": {
                  "description": "一个分区；有镜像才带 project、version、build",
                  "x-en": {
                    "description": "One partition; project, version and build only when it holds an image"
                  },
                  "type": "object",
                  "required": [
                    "label",
                    "state"
                  ],
                  "properties": {
                    "label": {
                      "type": "string",
                      "enum": [
                        "rescue",
                        "kernel_a",
                        "kernel_b"
                      ],
                      "description": "分区名",
                      "x-en": {
                        "description": "Partition name"
                      }
                    },
                    "project": {
                      "type": "string",
                      "description": "项目名",
                      "x-en": {
                        "description": "Project name"
                      }
                    },
                    "version": {
                      "type": "string",
                      "description": "版本号",
                      "x-en": {
                        "description": "Version"
                      }
                    },
                    "build": {
                      "type": "string",
                      "pattern": "^[0-9a-f]{16}$",
                      "description": "构建号",
                      "x-en": {
                        "description": "Build ID"
                      }
                    },
                    "state": {
                      "$ref": "#/components/schemas/DeviceSlotState"
                    }
                  }
                },
                "description": "rescue、kernel_a、kernel_b 三个分区",
                "x-en": {
                  "description": "The rescue, kernel_a and kernel_b partitions"
                }
              },
              "last": {
                "description": "最近一次更新的结果",
                "x-en": {
                  "description": "Result of the latest update"
                },
                "type": "object",
                "required": [
                  "result",
                  "build",
                  "detail"
                ],
                "properties": {
                  "result": {
                    "type": "string",
                    "enum": [
                      "none",
                      "written",
                      "confirmed",
                      "rolled_back"
                    ],
                    "description": "none 没有记录，written 已写入，confirmed 已确认，rolled_back 已回滚",
                    "x-en": {
                      "description": "none = no record, written, confirmed, rolled_back"
                    }
                  },
                  "build": {
                    "type": "string",
                    "description": "相关的构建号，没有为空串",
                    "x-en": {
                      "description": "Build ID involved; empty if none"
                    }
                  },
                  "detail": {
                    "type": "string",
                    "description": "附注：写入的分区、确认方式或回滚原因",
                    "x-en": {
                      "description": "Note: partition written, how it was confirmed, or why it rolled back"
                    }
                  }
                }
              }
            }
          },
          "crash": {
            "description": "崩溃转储（GET /v1/crash 取原文）；没有时只有 present",
            "x-en": {
              "description": "Crash dump (fetch it with GET /v1/crash); without one, only the present field"
            },
            "type": "object",
            "required": [
              "present"
            ],
            "properties": {
              "present": {
                "type": "boolean",
                "description": "有崩溃转储",
                "x-en": {
                  "description": "A crash dump exists"
                }
              },
              "size": {
                "type": "integer",
                "minimum": 0,
                "description": "转储字节数",
                "x-en": {
                  "description": "Dump size in bytes"
                }
              },
              "task": {
                "type": "string",
                "description": "崩溃的任务",
                "x-en": {
                  "description": "Task that crashed"
                }
              },
              "pc": {
                "type": "string",
                "description": "崩溃地址",
                "x-en": {
                  "description": "Crash address"
                }
              },
              "backtrace": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "回溯地址，最多 16 个",
                "x-en": {
                  "description": "Backtrace addresses, up to 16"
                }
              },
              "backtrace_corrupted": {
                "type": "boolean",
                "description": "回溯不完整",
                "x-en": {
                  "description": "The backtrace is corrupted"
                }
              },
              "build": {
                "type": "string",
                "description": "转储所属的构建号（stick crash --decode 按它找 ELF）",
                "x-en": {
                  "description": "Build ID of the dump (stick crash --decode finds the ELF by it)"
                }
              }
            }
          },
          "hid": {
            "description": "HID 概况（详见 GET /v1/hid）",
            "x-en": {
              "description": "HID summary (details in GET /v1/hid)"
            },
            "type": "object",
            "required": [
              "usb",
              "mounted",
              "armed",
              "play"
            ],
            "properties": {
              "usb": {
                "type": "string",
                "enum": [
                  "hid",
                  "serial"
                ],
                "description": "USB 模式",
                "x-en": {
                  "description": "USB mode"
                }
              },
              "mounted": {
                "type": "boolean",
                "description": "电脑已枚举这个设备",
                "x-en": {
                  "description": "The computer has enumerated the device"
                }
              },
              "armed": {
                "type": "boolean",
                "description": "网络来源已解锁",
                "x-en": {
                  "description": "The network source is armed"
                }
              },
              "play": {
                "description": "TF 卡时间线播放（详见 GET /v1/hid/play_file）",
                "x-en": {
                  "description": "microSD card timeline playback (details in GET /v1/hid/play_file)"
                },
                "type": "object",
                "required": [
                  "state",
                  "path",
                  "done",
                  "records"
                ],
                "properties": {
                  "state": {
                    "type": "string",
                    "enum": [
                      "idle",
                      "checking",
                      "playing",
                      "done",
                      "stopped"
                    ],
                    "description": "播放状态",
                    "x-en": {
                      "description": "Playback state"
                    }
                  },
                  "path": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "卡上的路径，没播过为 null",
                    "x-en": {
                      "description": "Path on the card; null if nothing played"
                    }
                  },
                  "done": {
                    "type": "integer",
                    "minimum": 0,
                    "description": "已执行完的条数",
                    "x-en": {
                      "description": "Records executed"
                    }
                  },
                  "records": {
                    "type": "integer",
                    "minimum": 0,
                    "description": "记录条数",
                    "x-en": {
                      "description": "Number of records"
                    }
                  }
                }
              }
            }
          },
          "apps": {
            "description": "应用",
            "x-en": {
              "description": "Apps"
            },
            "type": "object",
            "required": [
              "running",
              "state",
              "auto",
              "fs_used",
              "fs_total",
              "fonts",
              "time_synced"
            ],
            "properties": {
              "running": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "在跑的应用编号，没有为 null",
                "x-en": {
                  "description": "ID of the running app; null if none"
                }
              },
              "state": {
                "type": "string",
                "enum": [
                  "stopped",
                  "running",
                  "error"
                ],
                "description": "应用状态",
                "x-en": {
                  "description": "App state"
                }
              },
              "auto": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "开机自动启动的应用，没有为 null",
                "x-en": {
                  "description": "App that starts on boot; null if none"
                }
              },
              "fs_used": {
                "type": "integer",
                "minimum": 0,
                "description": "存储区已用字节",
                "x-en": {
                  "description": "Storage bytes used"
                }
              },
              "fs_total": {
                "type": "integer",
                "minimum": 0,
                "description": "存储区总字节",
                "x-en": {
                  "description": "Storage bytes in total"
                }
              },
              "fonts": {
                "type": "array",
                "items": {
                  "type": "integer",
                  "enum": [
                    20,
                    24,
                    32,
                    48
                  ]
                },
                "description": "已挂上完整字库的字号",
                "x-en": {
                  "description": "Font sizes with the full font loaded"
                }
              },
              "time_synced": {
                "type": "boolean",
                "description": "已校时",
                "x-en": {
                  "description": "Time is synced"
                }
              }
            }
          },
          "sd": {
            "description": "TF 卡；没挂上只有 present 与 reason",
            "x-en": {
              "description": "microSD card; only the present and reason fields when not mounted"
            },
            "type": "object",
            "required": [
              "present"
            ],
            "properties": {
              "present": {
                "type": "boolean",
                "description": "卡已挂上",
                "x-en": {
                  "description": "The card is mounted"
                }
              },
              "card": {
                "type": "string",
                "description": "卡名（CID）",
                "x-en": {
                  "description": "Card name (CID)"
                }
              },
              "kind": {
                "type": "string",
                "enum": [
                  "SDSC",
                  "SDHC/SDXC",
                  "MMC",
                  "SDIO"
                ],
                "description": "卡类型",
                "x-en": {
                  "description": "Card type"
                }
              },
              "bus_khz": {
                "type": "integer",
                "minimum": 0,
                "description": "总线频率（kHz）",
                "x-en": {
                  "description": "Bus clock (kHz)"
                }
              },
              "total": {
                "type": "integer",
                "minimum": 0,
                "description": "FAT 总字节",
                "x-en": {
                  "description": "FAT size in bytes"
                }
              },
              "used": {
                "type": "integer",
                "minimum": 0,
                "description": "FAT 已用字节",
                "x-en": {
                  "description": "FAT bytes used"
                }
              },
              "reason": {
                "type": "string",
                "enum": [
                  "no_card",
                  "not_fat",
                  "io_error"
                ],
                "description": "没挂上的原因：no_card 没卡，not_fat 不是 FAT，io_error 读写出错",
                "x-en": {
                  "description": "Why it is not mounted: no_card, not_fat = not FAT formatted, io_error = read/write error"
                }
              }
            }
          },
          "blackbox": {
            "description": "黑匣子日志（写在 TF 卡上）",
            "x-en": {
              "description": "Black-box log (written to the microSD card)"
            },
            "type": "object",
            "required": [
              "state",
              "file",
              "bytes",
              "lost"
            ],
            "properties": {
              "state": {
                "type": "string",
                "enum": [
                  "waiting",
                  "writing",
                  "full",
                  "error"
                ],
                "description": "waiting 等卡，writing 在写，full 到 16 MB 停写，error 出错",
                "x-en": {
                  "description": "waiting = waiting for a card, writing, full = stopped at 16 MB, error"
                }
              },
              "file": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "卡上的日志文件，没有为 null",
                "x-en": {
                  "description": "Log file on the card; null if none"
                }
              },
              "bytes": {
                "type": "integer",
                "minimum": 0,
                "description": "已写字节",
                "x-en": {
                  "description": "Bytes written"
                }
              },
              "lost": {
                "type": "integer",
                "minimum": 0,
                "description": "本次开机丢掉的行数",
                "x-en": {
                  "description": "Lines lost since boot"
                }
              }
            }
          },
          "www": {
            "description": "设备网页，没装为 null",
            "x-en": {
              "description": "Device web app; null if not installed"
            },
            "type": [
              "object",
              "null"
            ],
            "required": [
              "version",
              "api"
            ],
            "properties": {
              "version": {
                "type": "string",
                "description": "网页版本",
                "x-en": {
                  "description": "Web app version"
                }
              },
              "api": {
                "type": "integer",
                "description": "网页要求的接口版本",
                "x-en": {
                  "description": "API version the web app needs"
                }
              }
            }
          }
        }
      },
      "DeviceLang": {
        "title": "屏幕语言",
        "description": "屏幕语言",
        "x-en": {
          "title": "Screen language",
          "description": "Screen language"
        },
        "type": "object",
        "required": [
          "ok",
          "lang",
          "chosen",
          "langs"
        ],
        "properties": {
          "ok": {
            "const": true,
            "description": "总是 true",
            "x-en": {
              "description": "Always true"
            }
          },
          "lang": {
            "type": "string",
            "enum": [
              "zh",
              "en"
            ],
            "description": "当前语言：zh 中文，en 英文",
            "x-en": {
              "description": "Current language: zh = Chinese, en = English"
            }
          },
          "chosen": {
            "type": "boolean",
            "description": "有人选过；没选过按中文",
            "x-en": {
              "description": "Someone has chosen it; Chinese until then"
            }
          },
          "langs": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "zh",
                "en"
              ]
            },
            "description": "可选的语言",
            "x-en": {
              "description": "Available languages"
            }
          }
        }
      },
      "DeviceLangRequest": {
        "title": "设屏幕语言",
        "description": "要换成的屏幕语言",
        "x-en": {
          "title": "Set screen language",
          "description": "Screen language to switch to"
        },
        "type": "object",
        "required": [
          "lang"
        ],
        "properties": {
          "lang": {
            "type": "string",
            "enum": [
              "zh",
              "en"
            ],
            "description": "zh 中文，en 英文",
            "x-en": {
              "description": "zh = Chinese, en = English"
            }
          }
        },
        "additionalProperties": false
      },
      "DeviceLogs": {
        "title": "日志",
        "description": "日志环里的一段",
        "x-en": {
          "title": "Logs",
          "description": "A slice of the log ring"
        },
        "type": "object",
        "required": [
          "ok",
          "boot",
          "next",
          "dropped",
          "lines"
        ],
        "properties": {
          "ok": {
            "const": true,
            "description": "总是 true",
            "x-en": {
              "description": "Always true"
            }
          },
          "boot": {
            "type": "string",
            "pattern": "^[0-9a-f]{8}$",
            "description": "开机标识：每次开机随机，变了说明重启过",
            "x-en": {
              "description": "Boot ID: random per boot; a change means the device restarted"
            }
          },
          "next": {
            "type": "integer",
            "minimum": 0,
            "description": "下次请求的 since",
            "x-en": {
              "description": "since for the next request"
            }
          },
          "dropped": {
            "type": "integer",
            "minimum": 0,
            "description": "since 之后已被覆盖、取不到的行数",
            "x-en": {
              "description": "Lines after since that were overwritten and are lost"
            }
          },
          "lines": {
            "type": "array",
            "items": {
              "description": "一行",
              "x-en": {
                "description": "One line"
              },
              "type": "object",
              "required": [
                "seq",
                "ms",
                "text"
              ],
              "properties": {
                "seq": {
                  "type": "integer",
                  "minimum": 0,
                  "description": "序号",
                  "x-en": {
                    "description": "Sequence number"
                  }
                },
                "ms": {
                  "type": "integer",
                  "minimum": 0,
                  "description": "开机毫秒",
                  "x-en": {
                    "description": "Uptime in ms"
                  }
                },
                "text": {
                  "type": "string",
                  "x-max-bytes": 240,
                  "description": "内容，不带换行与颜色码；超长截断并加「…」",
                  "x-en": {
                    "description": "Text without newline or color codes; long lines are cut and end with …"
                  }
                }
              }
            },
            "description": "日志行，旧的在前",
            "x-en": {
              "description": "Log lines, oldest first"
            }
          }
        }
      },
      "DeviceNonce": {
        "title": "nonce",
        "description": "签名用的一次性 nonce",
        "x-en": {
          "title": "Nonce",
          "description": "One-time nonce for signing"
        },
        "type": "object",
        "required": [
          "ok",
          "nonce",
          "ttl_s"
        ],
        "properties": {
          "ok": {
            "const": true,
            "description": "总是 true",
            "x-en": {
              "description": "Always true"
            }
          },
          "nonce": {
            "type": "string",
            "pattern": "^[0-9a-f]{32}$",
            "description": "32 位十六进制，用一次作废",
            "x-en": {
              "description": "32 hex digits; single use"
            }
          },
          "ttl_s": {
            "type": "integer",
            "minimum": 1,
            "description": "有效秒数",
            "x-en": {
              "description": "Seconds it stays valid"
            }
          }
        }
      },
      "DeviceSlotState": {
        "type": "string",
        "enum": [
          "valid",
          "pending",
          "new",
          "invalid",
          "aborted",
          "undefined",
          "empty"
        ],
        "description": "分区状态：valid 有效，pending 待确认，new 刚写入、还没启动过，invalid / aborted 已作废，undefined 不明，empty 空",
        "x-en": {
          "description": "Partition state: valid, pending = awaiting confirmation, new = written but not booted yet, invalid / aborted = discarded, undefined = unknown, empty"
        }
      },
      "DeviceStatus": {
        "title": "状态",
        "description": "状态总线快照",
        "x-en": {
          "title": "Status",
          "description": "Status bus snapshot"
        },
        "type": "object",
        "required": [
          "ok",
          "active",
          "recent"
        ],
        "properties": {
          "ok": {
            "const": true,
            "description": "总是 true",
            "x-en": {
              "description": "Always true"
            }
          },
          "active": {
            "type": "array",
            "items": {
              "description": "一个状态",
              "x-en": {
                "description": "One state"
              },
              "type": "object",
              "required": [
                "id",
                "value",
                "detail",
                "since_ms"
              ],
              "properties": {
                "id": {
                  "type": "string",
                  "description": "状态名（status_map.def，如 OTA_PENDING）",
                  "x-en": {
                    "description": "Status name (status_map.def, e.g. OTA_PENDING)"
                  }
                },
                "value": {
                  "type": "integer",
                  "description": "数值，-1 = 没有",
                  "x-en": {
                    "description": "Value; -1 = none"
                  }
                },
                "detail": {
                  "type": "string",
                  "x-max-bytes": 63,
                  "description": "附注，可为空串",
                  "x-en": {
                    "description": "Detail; may be empty"
                  }
                },
                "since_ms": {
                  "type": "integer",
                  "minimum": 0,
                  "description": "开始时的开机毫秒",
                  "x-en": {
                    "description": "Uptime in ms when it began"
                  }
                }
              }
            },
            "description": "当前开着的状态",
            "x-en": {
              "description": "States currently on"
            }
          },
          "recent": {
            "type": "array",
            "items": {
              "description": "一条事件",
              "x-en": {
                "description": "One event"
              },
              "type": "object",
              "required": [
                "id",
                "value",
                "detail",
                "t_ms"
              ],
              "properties": {
                "id": {
                  "type": "string",
                  "description": "状态名（status_map.def，如 OTA_PENDING）",
                  "x-en": {
                    "description": "Status name (status_map.def, e.g. OTA_PENDING)"
                  }
                },
                "value": {
                  "type": "integer",
                  "description": "数值，-1 = 没有",
                  "x-en": {
                    "description": "Value; -1 = none"
                  }
                },
                "detail": {
                  "type": "string",
                  "x-max-bytes": 63,
                  "description": "附注，可为空串",
                  "x-en": {
                    "description": "Detail; may be empty"
                  }
                },
                "t_ms": {
                  "type": "integer",
                  "minimum": 0,
                  "description": "发生时的开机毫秒",
                  "x-en": {
                    "description": "Uptime in ms when it happened"
                  }
                }
              }
            },
            "description": "最近 16 条事件，旧的在前",
            "x-en": {
              "description": "The latest 16 events, oldest first"
            }
          }
        }
      },
      "DeviceTime": {
        "title": "时间",
        "description": "时间与时区",
        "x-en": {
          "title": "Time",
          "description": "Time and time zone"
        },
        "type": "object",
        "required": [
          "ok",
          "synced",
          "epoch",
          "local",
          "tz",
          "zone"
        ],
        "properties": {
          "ok": {
            "const": true,
            "description": "总是 true",
            "x-en": {
              "description": "Always true"
            }
          },
          "synced": {
            "type": "boolean",
            "description": "已校时（SNTP）",
            "x-en": {
              "description": "Time is synced (SNTP)"
            }
          },
          "epoch": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Unix 秒，没校时为 null",
            "x-en": {
              "description": "Unix seconds; null until synced"
            }
          },
          "local": {
            "type": [
              "string",
              "null"
            ],
            "description": "本地时间 YYYY-MM-DD HH:MM:SS，没校时为 null",
            "x-en": {
              "description": "Local time YYYY-MM-DD HH:MM:SS; null until synced"
            }
          },
          "tz": {
            "type": "string",
            "description": "POSIX TZ 串（没设过为 CST-8）",
            "x-en": {
              "description": "POSIX TZ string (CST-8 until set)"
            }
          },
          "zone": {
            "type": "string",
            "description": "IANA 时区名，可为空串",
            "x-en": {
              "description": "IANA time zone name; may be empty"
            }
          }
        }
      },
      "DeviceTimeRequest": {
        "title": "设时区",
        "description": "要设的时区",
        "x-en": {
          "title": "Set time zone",
          "description": "Time zone to set"
        },
        "type": "object",
        "required": [
          "tz"
        ],
        "properties": {
          "tz": {
            "type": "string",
            "minLength": 1,
            "maxLength": 63,
            "pattern": "^[A-Za-z0-9<>+,.:/-]+$",
            "description": "POSIX TZ 串，1–63 字节，只许字母数字与 <>+-,.:/",
            "x-en": {
              "description": "POSIX TZ string, 1–63 bytes of letters, digits and <>+-,.:/"
            }
          },
          "zone": {
            "type": "string",
            "maxLength": 63,
            "pattern": "^[!-~]*$",
            "description": "IANA 时区名，只做显示；可省（存空串），≤ 63 字节可打印 ASCII、不含空格",
            "x-en": {
              "description": "IANA time zone name, for display only; optional (stored empty), ≤ 63 bytes of printable ASCII without spaces"
            }
          }
        },
        "additionalProperties": false
      },
      "PairRequest": {
        "title": "申请配对",
        "description": "配对申请",
        "x-en": {
          "title": "Request pairing",
          "description": "Pairing request"
        },
        "type": "object",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 32,
            "pattern": "^[^\\u0000-\\u001f\\u007f]+$",
            "x-max-bytes": 32,
            "description": "请求方名字，显示在设备屏幕上；1–32 字节、不含控制字符",
            "x-en": {
              "description": "Requester name shown on the device screen; 1–32 bytes, no control characters"
            }
          }
        },
        "additionalProperties": false
      },
      "PairResult": {
        "title": "配对结果",
        "description": "配对结果",
        "x-en": {
          "title": "Pairing result",
          "description": "Pairing result"
        },
        "type": "object",
        "required": [
          "ok",
          "state"
        ],
        "properties": {
          "ok": {
            "const": true,
            "description": "总是 true",
            "x-en": {
              "description": "Always true"
            }
          },
          "state": {
            "type": "string",
            "enum": [
              "waiting",
              "approved",
              "denied",
              "expired"
            ],
            "description": "waiting 等人按键，approved 已允许，denied 已拒绝，expired 过期",
            "x-en": {
              "description": "waiting = waiting for a press, approved, denied, expired"
            }
          },
          "left_s": {
            "type": "integer",
            "minimum": 0,
            "description": "waiting 时还剩几秒",
            "x-en": {
              "description": "Seconds left while waiting"
            }
          },
          "key": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$",
            "description": "配对密钥（64 位十六进制），只在 approved 时、且只给这一次",
            "x-en": {
              "description": "Pairing key (64 hex digits), only when approved and only this once"
            }
          }
        }
      },
      "PairStarted": {
        "title": "配对请求",
        "description": "已在设备屏幕上弹出配对请求",
        "x-en": {
          "title": "Pairing request",
          "description": "The pairing request is shown on the device screen"
        },
        "type": "object",
        "required": [
          "ok",
          "id",
          "code",
          "expires_s"
        ],
        "properties": {
          "ok": {
            "const": true,
            "description": "总是 true",
            "x-en": {
              "description": "Always true"
            }
          },
          "id": {
            "type": "string",
            "pattern": "^[0-9a-f]{16}$",
            "description": "请求编号，查结果用",
            "x-en": {
              "description": "Request ID for checking the result"
            }
          },
          "code": {
            "type": "string",
            "pattern": "^[0-9]{4}$",
            "description": "屏幕上显示的 4 位数字，供人核对",
            "x-en": {
              "description": "4-digit code shown on the screen for the person to compare"
            }
          },
          "expires_s": {
            "type": "integer",
            "minimum": 1,
            "description": "多少秒内要按 BOOT",
            "x-en": {
              "description": "Seconds left to press BOOT"
            }
          }
        }
      },
      "AppsAutoReply": {
        "title": "自启动",
        "description": "已保存的自启动设置",
        "x-en": {
          "title": "Start on boot",
          "description": "Saved start-on-boot setting"
        },
        "type": "object",
        "required": [
          "ok",
          "auto"
        ],
        "properties": {
          "ok": {
            "description": "总是 true",
            "x-en": {
              "description": "Always true"
            },
            "const": true
          },
          "auto": {
            "description": "现在开机自启动的应用；null 为没有",
            "x-en": {
              "description": "App now started on boot; null if none"
            },
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "AppsAutoRequest": {
        "title": "自启动",
        "description": "设或取消开机自启动",
        "x-en": {
          "title": "Start on boot",
          "description": "Sets or clears start on boot"
        },
        "type": "object",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "description": "开机自启动的应用编号，不能以 _ 开头；null 取消",
            "x-en": {
              "description": "App ID to start on boot, not starting with _; null clears"
            },
            "type": [
              "string",
              "null"
            ],
            "pattern": "^[a-z0-9-][a-z0-9_-]{0,23}$"
          }
        },
        "additionalProperties": false
      },
      "AppsEvalReply": {
        "title": "执行结果",
        "description": "ok 为 false 是执行出错（仍是 HTTP 200）",
        "x-en": {
          "title": "Run result",
          "description": "ok false means the code failed (still HTTP 200)"
        },
        "type": "object",
        "required": [
          "ok",
          "prints"
        ],
        "properties": {
          "ok": {
            "description": "是否执行成功",
            "x-en": {
              "description": "Whether the code ran"
            },
            "type": "boolean"
          },
          "result": {
            "description": "返回值转成的 JSON（成功时有）：多个返回值成数组，没有为 null；函数等转成描述字符串",
            "x-en": {
              "description": "Return value as JSON (on success): several values become an array, none is null; functions and the like become description strings"
            }
          },
          "error": {
            "description": "失败原因：lua_error 语法或运行出错，timeout 超时，no_mem 内存不够",
            "x-en": {
              "description": "Failure: lua_error = syntax or runtime error, timeout, no_mem = out of memory"
            },
            "type": "string",
            "enum": [
              "lua_error",
              "timeout",
              "no_mem"
            ]
          },
          "message": {
            "description": "错误原文（失败时有）",
            "x-en": {
              "description": "Error text (on failure)"
            },
            "type": "string"
          },
          "prints": {
            "description": "执行期间 print 与 log.* 的输出，最多 64 条",
            "x-en": {
              "description": "Output of print and log.* during the run, up to 64 lines"
            },
            "type": "array",
            "maxItems": 64,
            "items": {
              "type": "string"
            }
          }
        }
      },
      "AppsEvalRequest": {
        "title": "执行代码",
        "description": "一段 Lua 代码",
        "x-en": {
          "title": "Run code",
          "description": "A piece of Lua code"
        },
        "type": "object",
        "required": [
          "code"
        ],
        "properties": {
          "code": {
            "description": "Lua 代码",
            "x-en": {
              "description": "Lua code"
            },
            "type": "string"
          },
          "timeout_ms": {
            "description": "限时毫秒数，0 或省略为 2000，最多 10000",
            "x-en": {
              "description": "Time limit in ms; 0 or omitted means 2000, at most 10000"
            },
            "type": "integer",
            "minimum": 0,
            "maximum": 10000,
            "default": 2000
          }
        },
        "additionalProperties": false
      },
      "AppsEvent": {
        "title": "事件",
        "description": "一条 app.emit",
        "x-en": {
          "title": "Event",
          "description": "One app.emit"
        },
        "type": "object",
        "required": [
          "seq",
          "ms",
          "app",
          "data"
        ],
        "properties": {
          "seq": {
            "description": "序号，从 0 递增，重启归零",
            "x-en": {
              "description": "Sequence number from 0, reset on reboot"
            },
            "type": "integer",
            "minimum": 0
          },
          "ms": {
            "description": "发出时的开机毫秒数",
            "x-en": {
              "description": "Uptime in ms when emitted"
            },
            "type": "integer",
            "minimum": 0
          },
          "app": {
            "description": "发事件的应用编号",
            "x-en": {
              "description": "ID of the emitting app"
            },
            "type": "string"
          },
          "data": {
            "description": "app.emit 的值（任意 JSON，≤ 4096 字节）。宏播放器的事件用 ev 区分（docs/web.md 第 7 节）",
            "x-en": {
              "description": "Value given to app.emit (any JSON, ≤ 4096 bytes). Macro player events are told apart by ev (docs/web.md section 7)"
            }
          }
        }
      },
      "AppsEvents": {
        "title": "应用事件",
        "description": "app.emit 的事件",
        "x-en": {
          "title": "App events",
          "description": "Events from app.emit"
        },
        "type": "object",
        "required": [
          "ok",
          "next",
          "events"
        ],
        "properties": {
          "ok": {
            "description": "总是 true",
            "x-en": {
              "description": "Always true"
            },
            "const": true
          },
          "next": {
            "description": "下次的 since",
            "x-en": {
              "description": "since for the next call"
            },
            "type": "integer",
            "minimum": 0
          },
          "events": {
            "description": "按序号从小到大",
            "x-en": {
              "description": "In sequence order"
            },
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AppsEvent"
            }
          }
        }
      },
      "AppsId": {
        "description": "应用编号：1–24 个 a-z 0-9 _ -，即 /apps 下的目录名。_ 开头留给主机临时应用（如 _try）",
        "x-en": {
          "description": "App ID: 1–24 of a-z 0-9 _ -, the folder name under /apps. IDs starting with _ are for temporary host apps (such as _try)"
        },
        "type": "string",
        "pattern": "^[a-z0-9_-]{1,24}$"
      },
      "AppsIdRequest": {
        "title": "应用",
        "description": "指定一个应用",
        "x-en": {
          "title": "App",
          "description": "Names one app"
        },
        "type": "object",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/AppsId"
          }
        },
        "additionalProperties": false
      },
      "AppsInfo": {
        "title": "应用",
        "description": "/apps 下的一个应用；清单坏的只有 id、error、auto、size",
        "x-en": {
          "title": "App",
          "description": "An app under /apps; one with a broken manifest has only id, error, auto and size"
        },
        "type": "object",
        "required": [
          "id",
          "auto",
          "size"
        ],
        "properties": {
          "id": {
            "description": "应用编号（目录名）",
            "x-en": {
              "description": "App ID (folder name)"
            },
            "type": "string"
          },
          "name": {
            "description": "名字（清单的 name，省略时同 id）",
            "x-en": {
              "description": "Name (manifest name; defaults to the id)"
            },
            "type": "string",
            "maxLength": 64,
            "x-max-bytes": 64
          },
          "version": {
            "description": "版本（清单的 version，可为空串）",
            "x-en": {
              "description": "Version (manifest version; may be empty)"
            },
            "type": "string",
            "maxLength": 32,
            "x-max-bytes": 32
          },
          "perms": {
            "description": "权限：目前只有 hid（经应用来源按键）",
            "x-en": {
              "description": "Permissions: only hid so far (keys through the app source)"
            },
            "type": "array",
            "items": {
              "enum": [
                "hid"
              ]
            }
          },
          "auto": {
            "description": "是开机自启动的应用",
            "x-en": {
              "description": "Starts on boot"
            },
            "type": "boolean"
          },
          "size": {
            "description": "目录里文件的总字节数",
            "x-en": {
              "description": "Total bytes of the folder's files"
            },
            "type": "integer",
            "minimum": 0
          },
          "error": {
            "description": "清单坏了：没有、不是 JSON 或不合规则",
            "x-en": {
              "description": "Broken manifest: missing, not JSON or breaking the rules"
            },
            "const": "bad_manifest"
          }
        }
      },
      "AppsList": {
        "title": "应用列表",
        "description": "应用与运行时状态",
        "x-en": {
          "title": "App list",
          "description": "Apps and runtime state"
        },
        "type": "object",
        "required": [
          "ok",
          "apps",
          "running",
          "state",
          "error",
          "mem",
          "mem_max",
          "started_ms",
          "auto"
        ],
        "properties": {
          "ok": {
            "description": "总是 true",
            "x-en": {
              "description": "Always true"
            },
            "const": true
          },
          "apps": {
            "description": "存储区里的应用",
            "x-en": {
              "description": "Apps in storage"
            },
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AppsInfo"
            }
          },
          "running": {
            "description": "在跑的应用编号（error 态也算）；没有为 null",
            "x-en": {
              "description": "ID of the running app (also in the error state); null if none"
            },
            "type": [
              "string",
              "null"
            ]
          },
          "state": {
            "description": "stopped 没在跑，running 在跑，error 出错停住（定时器全停、界面保留）",
            "x-en": {
              "description": "stopped: none running; running; error: halted on an error (timers stopped, UI kept)"
            },
            "type": "string",
            "enum": [
              "stopped",
              "running",
              "error"
            ]
          },
          "error": {
            "description": "最近一次出错的原文（Lua 错误与位置）；没有为 null",
            "x-en": {
              "description": "Text of the latest error (Lua error and location); null if none"
            },
            "type": [
              "string",
              "null"
            ]
          },
          "mem": {
            "description": "应用已用的 Lua 内存（字节）",
            "x-en": {
              "description": "Lua memory used by the app (bytes)"
            },
            "type": "integer",
            "minimum": 0
          },
          "mem_max": {
            "description": "每个应用的 Lua 内存上限（字节）",
            "x-en": {
              "description": "Lua memory limit per app (bytes)"
            },
            "type": "integer"
          },
          "started_ms": {
            "description": "应用启动时的开机毫秒数；没在跑为 0",
            "x-en": {
              "description": "Uptime in ms when the app started; 0 if none running"
            },
            "type": "integer",
            "minimum": 0
          },
          "auto": {
            "description": "开机自启动的应用；没有为 null",
            "x-en": {
              "description": "App started on boot; null if none"
            },
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "AppsMacroCommand": {
        "title": "宏播放器命令",
        "description": "宏播放器（应用 macro）的 data。结果看 GET /v1/apps/events 的 selected、started、stopped、plan、error 等事件（docs/web.md 第 7 节）；宏文件格式见 web/spec/macro.schema.json",
        "x-en": {
          "title": "Macro player command",
          "description": "data for the macro player (app macro). Results arrive as selected, started, stopped, plan, error and other events in GET /v1/apps/events (docs/web.md section 7); the macro file format is web/spec/macro.schema.json"
        },
        "type": "object",
        "required": [
          "cmd"
        ],
        "properties": {
          "cmd": {
            "description": "select 设为当前宏（在跑先停，要带 name）；run 跑当前宏，带 name 是试跑那个宏（跑一遍、不改当前宏）；stop 停止并复位；reload 重新读当前宏（改了文件之后）；plan 演练：载入、检查，再用假的 hid 走前几步，回 plan 事件（步数、估计用时、每步会调的 hid.*），不发 HID、不改当前宏、不停在跑的",
            "x-en": {
              "description": "select: set the current macro (stops a running one; needs name); run: run the current macro, or with name a trial run of that macro (once, current macro unchanged); stop: stop and reset; reload: re-read the current macro (after the file changed); plan: dry run — load and check, then walk the first steps with a fake hid and emit a plan event (step counts, estimated time, the hid.* calls each step would make); sends no HID, keeps the current macro and anything running"
            },
            "type": "string",
            "enum": [
              "select",
              "run",
              "stop",
              "reload",
              "plan"
            ]
          },
          "doc": {
            "description": "只给 plan：直接给宏内容（宏对象或它的 JSON 字符串），代替 name / where 读文件",
            "x-en": {
              "description": "plan only: the macro itself (a macro object or its JSON string) instead of reading a file by name / where"
            },
            "type": [
              "object",
              "string"
            ]
          },
          "trace": {
            "description": "只给 plan：走前几步并逐步列出",
            "x-en": {
              "description": "plan only: how many steps to walk and list"
            },
            "type": "integer",
            "minimum": 0,
            "maximum": 200,
            "default": 20
          },
          "json": {
            "description": "只给 plan：事件里带回规范化后的宏 JSON（事件超过 4 KB 时先去掉）",
            "x-en": {
              "description": "plan only: include the normalized macro JSON in the event (dropped first when the event would exceed 4 KB)"
            },
            "type": "boolean",
            "default": false
          },
          "name": {
            "description": "宏名，即文件名去掉 .json",
            "x-en": {
              "description": "Macro name: the file name without .json"
            },
            "type": [
              "string",
              "null"
            ],
            "minLength": 1,
            "maxLength": 48,
            "x-max-bytes": 48
          },
          "where": {
            "description": "宏在哪：fs 设备存储区 /data/macro/（省略时），sd TF 卡 /stick/data/macro/",
            "x-en": {
              "description": "Where the macro is: fs = device storage /data/macro/ (default), sd = microSD card /stick/data/macro/"
            },
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "fs",
              "sd",
              null
            ]
          }
        },
        "additionalProperties": false
      },
      "AppsMsgRequest": {
        "title": "消息",
        "description": "发给在跑应用的消息",
        "x-en": {
          "title": "Message",
          "description": "Message for the running app"
        },
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "description": "交给 app.on_message 的值。宏播放器认 AppsMacroCommand",
            "x-en": {
              "description": "Value for app.on_message. The macro player takes AppsMacroCommand"
            },
            "anyOf": [
              {
                "$ref": "#/components/schemas/AppsMacroCommand"
              },
              {
                "description": "别的应用：任意 JSON",
                "x-en": {
                  "description": "Other apps: any JSON"
                }
              }
            ]
          }
        },
        "additionalProperties": false
      },
      "AppsStartReply": {
        "title": "启动结果",
        "description": "ok 为 false 是顶层出错（HTTP 200），应用停在 error 态",
        "x-en": {
          "title": "Start result",
          "description": "ok false means a top-level error (HTTP 200); the app stays in the error state"
        },
        "type": "object",
        "required": [
          "ok"
        ],
        "properties": {
          "ok": {
            "description": "是否启动成功",
            "x-en": {
              "description": "Whether the app started"
            },
            "type": "boolean"
          },
          "running": {
            "description": "启动的应用编号（成功时有）",
            "x-en": {
              "description": "ID of the started app (on success)"
            },
            "type": "string"
          },
          "error": {
            "description": "顶层出错（失败时有）",
            "x-en": {
              "description": "Top-level error (on failure)"
            },
            "const": "app_error"
          },
          "message": {
            "description": "Lua 错误原文（失败时有）",
            "x-en": {
              "description": "Lua error text (on failure)"
            },
            "type": "string"
          }
        }
      },
      "ScreenPreviewState": {
        "title": "预览状态",
        "description": "整屏样张预览的状态",
        "x-en": {
          "title": "Preview state",
          "description": "State of the full-screen mockup preview"
        },
        "type": "object",
        "required": [
          "ok",
          "active",
          "left_s"
        ],
        "properties": {
          "ok": {
            "description": "总是 true",
            "x-en": {
              "description": "Always true"
            },
            "const": true
          },
          "active": {
            "description": "在显示",
            "x-en": {
              "description": "Showing"
            },
            "type": "boolean"
          },
          "left_s": {
            "description": "还剩几秒；不在显示为 0",
            "x-en": {
              "description": "Seconds left; 0 when not showing"
            },
            "type": "integer",
            "minimum": 0,
            "maximum": 600
          }
        }
      },
      "ScreenRgb565": {
        "description": "RGB565 小端原始像素，按行排列，每像素 2 字节（红 0xF800 是 00 f8）",
        "x-en": {
          "description": "Raw little-endian RGB565 pixels, row by row, 2 bytes each (red 0xF800 is 00 f8)"
        },
        "type": "string",
        "contentMediaType": "application/octet-stream"
      },
      "ScreenUiNode": {
        "title": "界面对象",
        "description": "一个 LVGL 对象",
        "x-en": {
          "title": "UI object",
          "description": "One LVGL object"
        },
        "type": "object",
        "required": [
          "type",
          "x",
          "y",
          "w",
          "h",
          "hidden"
        ],
        "properties": {
          "type": {
            "description": "LVGL 类名去掉 lv_，如 obj label bar arc image button",
            "x-en": {
              "description": "LVGL class name without lv_, such as obj label bar arc image button"
            },
            "type": "string"
          },
          "x": {
            "description": "左上角的屏幕 X 坐标",
            "x-en": {
              "description": "Screen X of the top-left corner"
            },
            "type": "integer"
          },
          "y": {
            "description": "左上角的屏幕 Y 坐标",
            "x-en": {
              "description": "Screen Y of the top-left corner"
            },
            "type": "integer"
          },
          "w": {
            "description": "宽",
            "x-en": {
              "description": "Width"
            },
            "type": "integer"
          },
          "h": {
            "description": "高",
            "x-en": {
              "description": "Height"
            },
            "type": "integer"
          },
          "text": {
            "description": "标签文字（label 才有），最多 200 字节",
            "x-en": {
              "description": "Label text (labels only), up to 200 bytes"
            },
            "type": "string",
            "x-max-bytes": 200
          },
          "text_truncated": {
            "description": "文字被截断",
            "x-en": {
              "description": "The text was cut"
            },
            "const": true
          },
          "value": {
            "description": "值（bar、slider、arc 才有）",
            "x-en": {
              "description": "Value (bar, slider and arc only)"
            },
            "type": "integer"
          },
          "hidden": {
            "description": "隐藏",
            "x-en": {
              "description": "Hidden"
            },
            "type": "boolean"
          },
          "children": {
            "description": "子对象；没有时不带",
            "x-en": {
              "description": "Child objects; absent if none"
            },
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ScreenUiNode"
            }
          },
          "children_omitted": {
            "description": "没展开的子对象数",
            "x-en": {
              "description": "Child objects left out"
            },
            "type": "integer",
            "minimum": 1
          },
          "layer": {
            "description": "所在层（layer=all 的根节点才有）",
            "x-en": {
              "description": "Layer (root nodes of layer=all only)"
            },
            "type": "string",
            "enum": [
              "app",
              "top",
              "sys"
            ]
          }
        }
      },
      "ScreenUiTree": {
        "title": "对象树",
        "description": "界面的 LVGL 对象树",
        "x-en": {
          "title": "Object tree",
          "description": "LVGL object tree of the UI"
        },
        "type": "object",
        "required": [
          "ok",
          "tree",
          "nodes"
        ],
        "properties": {
          "ok": {
            "description": "总是 true",
            "x-en": {
              "description": "Always true"
            },
            "const": true
          },
          "tree": {
            "description": "顶层节点",
            "x-en": {
              "description": "Top-level nodes"
            },
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ScreenUiNode"
            }
          },
          "nodes": {
            "description": "节点数（最多 400）",
            "x-en": {
              "description": "Node count (at most 400)"
            },
            "type": "integer",
            "minimum": 0,
            "maximum": 400
          },
          "truncated": {
            "description": "有节点没展开（超过 400 个或 12 层）；没有时不带",
            "x-en": {
              "description": "Some nodes were left out (over 400 or 12 levels); absent otherwise"
            },
            "const": true
          }
        }
      },
      "FsEntry": {
        "title": "目录项",
        "description": "目录里的一项",
        "x-en": {
          "title": "Entry",
          "description": "One item in a folder"
        },
        "type": "object",
        "required": [
          "name",
          "dir"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "名字（不带路径）",
            "x-en": {
              "description": "Name (without the path)"
            }
          },
          "dir": {
            "type": "boolean",
            "description": "是不是目录",
            "x-en": {
              "description": "Whether it is a folder"
            }
          },
          "size": {
            "type": "integer",
            "minimum": 0,
            "description": "文件字节数；目录没有这一项",
            "x-en": {
              "description": "File size in bytes; absent for folders"
            }
          }
        }
      },
      "FsList": {
        "title": "目录列表",
        "description": "存储区与 TF 卡的目录列表（同一格式）",
        "x-en": {
          "title": "Folder listing",
          "description": "Folder listing for storage and the microSD card (same format)"
        },
        "type": "object",
        "required": [
          "ok",
          "path",
          "entries",
          "total",
          "used"
        ],
        "properties": {
          "ok": {
            "const": true,
            "description": "总是 true",
            "x-en": {
              "description": "Always true"
            }
          },
          "path": {
            "type": "string",
            "description": "列的目录",
            "x-en": {
              "description": "The folder listed"
            }
          },
          "entries": {
            "type": "array",
            "maxItems": 256,
            "items": {
              "$ref": "#/components/schemas/FsEntry"
            },
            "description": "目录项，最多 256 个，顺序不定",
            "x-en": {
              "description": "Entries, up to 256, in no particular order"
            }
          },
          "truncated": {
            "type": "boolean",
            "description": "超过 256 项时为 true（只给了前 256 项）",
            "x-en": {
              "description": "true when there are more than 256 entries (only 256 returned)"
            }
          },
          "total": {
            "type": "integer",
            "minimum": 0,
            "description": "存储区或卡的总字节数",
            "x-en": {
              "description": "Total bytes of the storage or card"
            }
          },
          "used": {
            "type": "integer",
            "minimum": 0,
            "description": "已用字节数",
            "x-en": {
              "description": "Used bytes"
            }
          }
        }
      },
      "FsPath": {
        "description": "相对存储区根，以 / 开头，≤ 96 字节，不含 ..、//、反斜杠与控制字符",
        "x-en": {
          "description": "Relative to the storage root, starting with /, ≤ 96 bytes, without .., //, backslashes or control characters"
        },
        "type": "string",
        "minLength": 1,
        "maxLength": 96,
        "pattern": "^/",
        "x-max-bytes": 96
      },
      "FsWriteReply": {
        "title": "已写入",
        "description": "文件已写好",
        "x-en": {
          "title": "Written",
          "description": "The file is written"
        },
        "type": "object",
        "required": [
          "ok",
          "path",
          "size"
        ],
        "properties": {
          "ok": {
            "const": true,
            "description": "总是 true",
            "x-en": {
              "description": "Always true"
            }
          },
          "path": {
            "type": "string",
            "description": "写的文件",
            "x-en": {
              "description": "The file written"
            }
          },
          "size": {
            "type": "integer",
            "minimum": 0,
            "description": "文件字节数",
            "x-en": {
              "description": "File size in bytes"
            }
          }
        }
      },
      "SdPath": {
        "description": "相对卡根，以 / 开头，≤ 160 字节，不含 ..、//、控制字符与 \\ : * ? \" < > |",
        "x-en": {
          "description": "Relative to the card root, starting with /, ≤ 160 bytes, without .., //, control characters or \\ : * ? \" < > |"
        },
        "type": "string",
        "minLength": 1,
        "maxLength": 160,
        "pattern": "^/",
        "x-max-bytes": 160
      },
      "SdWriteReply": {
        "title": "已写这一块",
        "description": "这一块已写进临时文件；done 时已改名成正式文件",
        "x-en": {
          "title": "Chunk written",
          "description": "The chunk is in the temp file; when done, it was renamed to the final file"
        },
        "type": "object",
        "required": [
          "ok",
          "path",
          "size",
          "done"
        ],
        "properties": {
          "ok": {
            "const": true,
            "description": "总是 true",
            "x-en": {
              "description": "Always true"
            }
          },
          "path": {
            "type": "string",
            "description": "文件（不带 ~）",
            "x-en": {
              "description": "The file (without ~)"
            }
          },
          "size": {
            "type": "integer",
            "minimum": 0,
            "description": "已写的总字节数，下一块的 offset",
            "x-en": {
              "description": "Total bytes written so far; the offset of the next chunk"
            }
          },
          "done": {
            "type": "boolean",
            "description": "true = 已改名为 path，传完了；false = 还在临时文件 path~ 里",
            "x-en": {
              "description": "true = renamed to path, upload complete; false = still in the temp file path~"
            }
          }
        }
      },
      "OtaBootReply": {
        "title": "即将重启",
        "description": "引导分区已设好，回复后约 0.5 秒重启",
        "x-en": {
          "title": "Restarting",
          "description": "The boot partition is set; restarts about 0.5 s after replying"
        },
        "type": "object",
        "required": [
          "ok",
          "target"
        ],
        "properties": {
          "ok": {
            "const": true,
            "description": "总是 true",
            "x-en": {
              "description": "Always true"
            }
          },
          "target": {
            "type": "string",
            "enum": [
              "rescue",
              "kernel_a",
              "kernel_b"
            ],
            "description": "重启后进的分区",
            "x-en": {
              "description": "Partition booted after the restart"
            }
          }
        }
      },
      "OtaBootRequest": {
        "title": "切引导分区",
        "description": "要引导的固件",
        "x-en": {
          "title": "Switch boot partition",
          "description": "Firmware to boot"
        },
        "type": "object",
        "required": [
          "target"
        ],
        "additionalProperties": false,
        "properties": {
          "target": {
            "type": "string",
            "enum": [
              "rescue",
              "kernel",
              "kernel_a",
              "kernel_b"
            ],
            "description": "rescue 恢复固件；kernel 上次确认过的内核槽（没有就取有效的那个）；kernel_a / kernel_b 指定槽",
            "x-en": {
              "description": "rescue = rescue firmware; kernel = the last confirmed kernel slot (else whichever is valid); kernel_a / kernel_b = that slot"
            }
          }
        }
      },
      "OtaConfirmReply": {
        "title": "已确认",
        "description": "运行中的内核已标记有效",
        "x-en": {
          "title": "Confirmed",
          "description": "The running kernel is marked valid"
        },
        "type": "object",
        "required": [
          "ok",
          "build"
        ],
        "properties": {
          "ok": {
            "const": true,
            "description": "总是 true",
            "x-en": {
              "description": "Always true"
            }
          },
          "build": {
            "type": "string",
            "pattern": "^[0-9a-f]{16}$",
            "description": "构建号：ELF 的 SHA-256 前 16 位十六进制",
            "x-en": {
              "description": "Build ID: first 16 hex digits of the ELF's SHA-256"
            }
          }
        }
      },
      "OtaWriteReply": {
        "title": "已写入",
        "description": "镜像已写入并验签通过",
        "x-en": {
          "title": "Written",
          "description": "The image is written and its signature verified"
        },
        "type": "object",
        "required": [
          "ok",
          "slot",
          "version",
          "build",
          "reboot"
        ],
        "properties": {
          "ok": {
            "const": true,
            "description": "总是 true",
            "x-en": {
              "description": "Always true"
            }
          },
          "slot": {
            "type": "string",
            "enum": [
              "kernel_a",
              "kernel_b",
              "rescue"
            ],
            "description": "写进的分区",
            "x-en": {
              "description": "Partition written"
            }
          },
          "version": {
            "type": "string",
            "description": "镜像的版本号",
            "x-en": {
              "description": "Version of the image"
            }
          },
          "build": {
            "type": "string",
            "pattern": "^[0-9a-f]{16}$",
            "description": "构建号：ELF 的 SHA-256 前 16 位十六进制",
            "x-en": {
              "description": "Build ID: first 16 hex digits of the ELF's SHA-256"
            }
          },
          "reboot": {
            "type": "boolean",
            "description": "true = 回复后约 0.5 秒重启进新镜像",
            "x-en": {
              "description": "true = restarts into the new image about 0.5 s after replying"
            }
          }
        }
      },
      "DeviceDisplay": {
        "title": "屏幕设置",
        "description": "屏幕设置：亮度、调暗、关背光、界面风格",
        "x-en": {
          "title": "Screen settings",
          "description": "Screen settings: brightness, dimming, backlight off, interface style"
        },
        "type": "object",
        "required": [
          "ok",
          "brightness",
          "dim_s",
          "off_s",
          "dim_pct",
          "style",
          "styles"
        ],
        "properties": {
          "ok": {
            "const": true,
            "description": "总是 true",
            "x-en": {
              "description": "Always true"
            }
          },
          "brightness": {
            "type": "integer",
            "minimum": 10,
            "maximum": 100,
            "description": "常亮亮度（%），出厂 80",
            "x-en": {
              "description": "Brightness while active (%), default 80"
            }
          },
          "dim_s": {
            "type": "integer",
            "minimum": 0,
            "maximum": 86400,
            "description": "空闲多少秒调暗；0 = 不调暗；否则 10–86400，出厂 60",
            "x-en": {
              "description": "Seconds idle before dimming; 0 = never; otherwise 10–86400, default 60"
            }
          },
          "off_s": {
            "type": "integer",
            "minimum": 0,
            "maximum": 86400,
            "description": "空闲多少秒关背光；0 = 不关（常亮）；否则 10–86400 且大于 dim_s，出厂 300",
            "x-en": {
              "description": "Seconds idle before the backlight turns off; 0 = never (always on); otherwise 10–86400 and greater than dim_s, default 300"
            }
          },
          "dim_pct": {
            "type": "integer",
            "description": "调暗时的亮度（%），固定 20；常亮亮度更低时取常亮亮度",
            "x-en": {
              "description": "Brightness when dimmed (%), fixed at 20; the active brightness if that is lower"
            }
          },
          "style": {
            "type": "string",
            "description": "当前界面风格（styles 里的 id），出厂 b（柔光）",
            "x-en": {
              "description": "Current interface style (an id from styles), default b (Soft glow)"
            }
          },
          "styles": {
            "type": "array",
            "description": "可选的界面风格，按登记顺序，默认的在最前",
            "x-en": {
              "description": "Available interface styles in registration order, the default first"
            },
            "items": {
              "type": "object",
              "description": "一种界面风格",
              "x-en": {
                "description": "One interface style"
              },
              "required": [
                "id",
                "name",
                "name_en"
              ],
              "properties": {
                "id": {
                  "type": "string",
                  "description": "风格的 id（小写 ASCII），POST 的 style 用它",
                  "x-en": {
                    "description": "Style id (lowercase ASCII), used as style in POST"
                  }
                },
                "name": {
                  "type": "string",
                  "description": "中文名，如「柔光」",
                  "x-en": {
                    "description": "Chinese name, e.g. 柔光"
                  }
                },
                "name_en": {
                  "type": "string",
                  "description": "英文名，如 Soft glow",
                  "x-en": {
                    "description": "English name, e.g. Soft glow"
                  }
                }
              }
            }
          }
        }
      },
      "DeviceDisplayRequest": {
        "title": "改屏幕设置",
        "description": "只改带了的字段，其余保持",
        "x-en": {
          "title": "Change screen settings",
          "description": "Only the fields given are changed; the rest stay"
        },
        "type": "object",
        "properties": {
          "brightness": {
            "type": "integer",
            "minimum": 10,
            "maximum": 100,
            "description": "常亮亮度（%），出厂 80",
            "x-en": {
              "description": "Brightness while active (%), default 80"
            }
          },
          "dim_s": {
            "type": "integer",
            "minimum": 0,
            "maximum": 86400,
            "description": "空闲多少秒调暗；0 = 不调暗；否则 10–86400，出厂 60",
            "x-en": {
              "description": "Seconds idle before dimming; 0 = never; otherwise 10–86400, default 60"
            }
          },
          "off_s": {
            "type": "integer",
            "minimum": 0,
            "maximum": 86400,
            "description": "空闲多少秒关背光；0 = 不关（常亮）；否则 10–86400 且大于 dim_s，出厂 300",
            "x-en": {
              "description": "Seconds idle before the backlight turns off; 0 = never (always on); otherwise 10–86400 and greater than dim_s, default 300"
            }
          },
          "style": {
            "type": "string",
            "description": "换界面风格：styles 里的 id 之一。存进设备，立即按新风格重建系统界面（不重启，应用画的界面不动）",
            "x-en": {
              "description": "Switch the interface style: one of the ids in styles. Saved on the device; the system interface is rebuilt in the new style at once (no restart; what apps draw is left alone)"
            }
          }
        },
        "additionalProperties": false
      }
    },
    "x-errors": {
      "auth_required": {
        "status": 401,
        "description": "没带 Authorization 或 X-Stick-Sha256，或格式不对。照 stickHmac 的规则签名",
        "x-en": {
          "description": "Authorization or X-Stick-Sha256 is missing or malformed. Sign as described in stickHmac"
        }
      },
      "bad_nonce": {
        "status": 401,
        "description": "nonce 无效、已用过或过期（60 秒）。用这个回复头里的 X-Stick-Nonce 立即重发",
        "x-en": {
          "description": "The nonce is invalid, used or expired (60 s). Resend at once with the X-Stick-Nonce of this reply"
        }
      },
      "bad_mac": {
        "status": 401,
        "description": "签名不符：密钥不对，或签名用的方法、URI（含查询串）、体哈希与实际请求不一致",
        "x-en": {
          "description": "Signature mismatch: wrong key, or the signed method, URI (with query string) or body hash differs from the actual request"
        }
      },
      "unpaired": {
        "status": 403,
        "description": "设备还没配对、没有密钥：先 POST /v1/pair，或用 USB 串口的 key 命令",
        "x-en": {
          "description": "The device is not paired and has no key: POST /v1/pair first, or use the key command over USB serial"
        }
      },
      "body_mismatch": {
        "status": 400,
        "description": "请求体的 SHA-256 与 X-Stick-Sha256 不符：体在签名后被改过，或哈希算错",
        "x-en": {
          "description": "The body's SHA-256 does not match X-Stick-Sha256: the body changed after signing, or the hash is wrong"
        }
      },
      "bad_body": {
        "status": 400,
        "description": "请求体没收完整（连接中断或 Content-Length 不对）。重发",
        "x-en": {
          "description": "The body arrived incomplete (connection dropped or wrong Content-Length). Resend"
        }
      },
      "too_large": {
        "status": 413,
        "description": "请求体超过这个接口的上限",
        "x-en": {
          "description": "The body exceeds this endpoint's limit"
        }
      },
      "not_found": {
        "status": 404,
        "description": "路径不存在（message 是路径）；只在内核的接口在恢复固件里也回这个",
        "x-en": {
          "description": "No such path (message is the path); kernel-only endpoints return this in the rescue firmware"
        }
      },
      "no_memory": {
        "status": 500,
        "description": "设备内存不足。稍后重试",
        "x-en": {
          "description": "The device is out of memory. Try again later"
        }
      }
    }
  }
}
