Repository navigation
Pass through the voice pack list and packages for the app's Language page - #261
Open
virtitnerd wants to merge 1 commit into
Open
virtitnerd wants to merge 1 commit into
virtitnerd wants to merge 1 commit into
Conversation
…page GET /voice-pkg/info?model=<model> (and the plugin's own /app/<bucket>/voice-pkg/info path) fetches the official plugin's voice pack info file from the region's cosHost, falling back to its FDS host, and serves the last good copy when both fail. Each voice_pkg_url is rewritten to /voice-pkg/files/<host>/<path>.pkg on this server, which downloads the pack once, caches it, and serves it to the robot, so the robot never needs to reach the cloud host itself. Model to bucket follows the plugin's device configs. Upstream requests carry X-RR-Voice-Proxy so a DNS loop back to this server answers 508 instead of recursing. Only allowlisted Roborock and Xiaomi FDS hosts are fetched. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why The official app's voice Language page lists the robot's voice packs and installs one by sending the robot a package URL. With the robot on the local server, the app's list request and the robot's download both go to cloud hosts that the local setup either answers with nothing or does not resolve, so the page is empty and no pack can be installed. This PR lets the server fetch the list from Roborock, point every package URL at itself, and serve the packages to the robot. ### How it works -
GET /voice-pkg/info?model=<model>maps the model to the plugin's product bucket (for exampleroborock.vacuum.a245toberyllite) and builds the same info path the official plugin uses (/app/<bucket>/voice-pkg/info, the older/<bucket>/app/voice-pkg/infolayout for four buckets, anddebug/forv2tov5models). The model to bucket table comes from the plugin's device configs. An unknown model gets a 404. - The plugin's own path (/app/<bucket>/voice-pkg/info, with or withoutdebug/) is answered the same way, so a request that reaches the server under the cloud path also works. - The list is fetched from the region's app host first (us-app.roborock.com,eu-app.roborock.com,cn-app.roborock.com), then the region's FDS host, in the order of the plugin'sareaServerMap. For the a245 the list is only on the app host; the FDS host does not have it. - Eachvoice_pkg_urlinvoice_list,special_voice_listandfactory_test_listis rewritten to<api_url>/voice-pkg/files/<host>/<path>.pkg, using the host the list came from (the plugin rehosts the package path the same way). The original is kept invoice_pkg_source_url, andvoice_pkg_md5is left as is. -GET /voice-pkg/files/<host>/<path>.pkgdownloads the package from that host once, stores it under<runtime_dir>/voice_pkg_cache/, and serves it to the robot from there afterwards. - This hooks intodispatch_plugin_zip_request: a path that is not a plugin zip is offered to the voice handler. Upstream failures become the existing 502 response with routevoice_pkg_proxy. ### Safety - Allowed hosts only. The list is fetched only from the fixed per-region hosts above. Packages are fetched only from the three Roborock app hosts or*.fds.api.xiaomi.com/*.fds.api.mi-img.com, and the path must contain/voice-pkg/, end in.pkgand not contain... Anything else gets a 403 without a request upstream. Redirects are not followed, so an allowed host cannot send the server somewhere else. - Size cap. Lists over 2 MB and packages over 64 MB are refused and not cached. A declaredContent-Lengthover the cap is refused before reading, and the body is read in chunks that stop at the cap. - Loop guard. Upstream requests carryX-RR-Voice-Proxy: 1. If DNS sends the cloud host back to this server, the request with that header gets a 508 instead of being fetched again. - Cache. Packages are cached by source URL and written through a temp file, so a failed download leaves nothing behind. The last good list is kept per path and served (headerX-RR-Voice-Cache: stale) when every upstream host fails. Responses carryX-RR-Voice-Cache: hit,missorstale. - A failure answers 502 withvoice_pkg_proxy_failed(the plugin proxy keepsplugin_proxy_failed). - Like the existing plugin zip proxy, the routes are unauthenticated, and the upstream requests send no account data (no token, no cookies, only a generic User-Agent). ### Testing - Newtests/test_voice_pkg_routes.py: model to path mapping (including theppscouple,rubysc1andrubysespecial cases and an unknown model), list fetched from the region host with URLs rewritten to this server, fallback to the FDS host and then to the cached copy, 502 with no upstream, 404 for an unknown model, a package proxied once and then served from the cache, a package from an unknown host refused, the loop guard, a redirect not followed, and the size cap enforced while streaming and fromContent-Length. Full suite on this branch: 468 passed. - Live on 2026-11-14 with a Qrevo Curv 2 Flow (roborock.vacuum.a245): - The official app readshttps://us-app.roborock.com/app/beryllite/voice-pkg/info. Through this route the server returned more than 20 packs with the URLs rewritten to<api_url>/voice-pkg/files/.... - The German pack (5.7 MB) downloaded through the server, and its md5 matched the list. - The robot accepteddnld_install_soundwith the server URL, reported progress 100, state 3 andsid_in_use103 within about 4 seconds, and then switched back to English (sid 3) the same way. ### Related LocalRock PR: DonSidro/LocalRock#119 (the app side of the Language page).