Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ Double-click `ModAVD.exe` in the package root: it starts a local server that lis
- It does only the step you explicitly ask for; it never goes online automatically and never downloads in the background:
- `modavd update` (`status`) looks at local state only; `check` looks up the latest version;
- `prepare` downloads, unpacks, verifies file by file against the `modavd-manifest.json` in the package, and stages the result; instances can be running;
- `install` runs `prepare` first if needed, then swaps in `sdk\emulator` and the other files in the package. All instances, the manager (including one left in the tray) and MCP clients must be closed first; if any program is using the files, it changes nothing (exit code 5), and the staged new version is kept so the next run can swap it in directly;
- `install` runs `prepare` first if needed, then swaps in `sdk\emulator` and the other files in the package. All instances and the manager (including one left in the tray) must be closed first; the MCP servers (`modavd mcp`) this root has running are stopped by `install` itself, and the AI assistant's next call starts the new version. If any other program is using the files, it changes nothing (exit code 5), and the staged new version is kept so the next run can swap it in directly;
- `recover` finishes or rolls back a swap that was left unfinished last time (it also runs first at the start of every step).
- The update source is chosen in the manager's "Settings": GitHub (the latest Release of `ModAVD/ModAVD`; only the changed files are fetched with HTTP Range requests and the rest is copied from the root, falling back to the full package, with the reason in `notices`, when the server does not serve ranges, more than 40% of the package or 3000 files changed, or the fetched data or the assembled result fails its checks) or MirrorChyan (downloads need a CDK, and it can provide delta packages; on errors it downloads from GitHub instead and says so in the result's `notices`). The optional GitHub token is used for GitHub version checks and downloads in the manager and CLI. The CDK and token are encrypted with Windows DPAPI and stored in `%LOCALAPPDATA%\ModAVD\update-settings.json`; only this Windows user can decrypt it, and the values stay out of logs, command-line arguments and API responses.
- Settings the caller passes for one run (`status`, `check`, `prepare` and `install` accept them, `recover` does not; they only override "Settings", are never saved, and `source` / `cdk_set` in the result report what was in effect):
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ Apple Silicon macOS 可运行 `ModAVD` 管理器;`ModAVD.app` 放在包根目
- 只做明确要求的那一步,不自动联网、不在后台下载:
- `modavd update`(`status`)只看本地;`check` 查最新版本;
- `prepare` 下载、解包、按包里的 `modavd-manifest.json` 逐文件核对、暂存好,实例开着也行;
- `install` 需要时先 `prepare`,再换上 `sdk\emulator` 和包里的其他文件。要先关掉所有实例、管理器(包括托盘里的)和 MCP 客户端,有程序在用就什么都不动(退出码 5),暂存的新版留着,下次直接换;
- `install` 需要时先 `prepare`,再换上 `sdk\emulator` 和包里的其他文件。要先关掉所有实例和管理器(包括托盘里的);这个根目录开着的 MCP 服务(`modavd mcp`)由它自己关掉,AI 助手下次调用时用的就是新版。别的程序在用就什么都不动(退出码 5),暂存的新版留着,下次直接换;
- `recover` 补完或退回上次没做完的换上(每一步开始前也会先做)。
- 更新源在管理器的「设置」里选:GitHub(`ModAVD/ModAVD` 的最新 Release;先按区间只下变了的文件、没变的从本地复制,服务器不认 Range、变了的超过整包 40% 或 3000 个文件、取回的数据或拼好后的清单核对不过时改下整包,原因写进 `notices`)或 Mirror 酱(填了 CDK 才能下载,能拿到增量包;出错时改从 GitHub 下,并在结果的 `notices` 里写明)。GitHub token 可留空,填好后用于管理器和命令行的 GitHub 版本查询及下载。CDK 和 token 用 Windows DPAPI 加密存在 `%LOCALAPPDATA%\ModAVD\update-settings.json`,只有这个 Windows 用户能解开,不写日志、不出现在命令行和接口返回里。
- 调用方传这一次的设置(`status`、`check`、`prepare`、`install` 都可以带,`recover` 不带;只盖过「设置」里的,不保存,`status` 等结果里的 `source`、`cdk_set` 是这次生效的):
Expand Down
2 changes: 2 additions & 0 deletions changelog.d/461-mcp-stop-on-update.change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
更新时自动关掉 AI 助手开着的 modavd mcp,不用再手动关 (ModAVD/ModAVD#461)
Updating now stops the modavd mcp servers an AI assistant left running; no need to close them first
5 changes: 4 additions & 1 deletion internal/cli/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ func init() {
"--cdk-dpapi 是用 Windows DPAPI 加密好的 CDK 的 base64,解不开或格式不对是 invalid_argument,CDK 不进日志和输出。" +
"不自动联网,只做给出的那一步:" +
"status(默认)只看本地;check 查最新版本;prepare 下载、按清单核对、暂存好,实例开着也行;" +
"install 需要时先 prepare,再换上 sdk\\emulator 和包里的其他文件,要先关掉所有实例、管理器(包括托盘里的)和 MCP 客户端;" +
"install 需要时先 prepare,再换上 sdk\\emulator 和包里的其他文件,要先关掉所有实例和管理器(包括托盘里的),这个根目录开着的 MCP 服务由它自己关掉;" +
"recover 补完或退回上次没做完的换上。和 AUTO-MAS 用同一个 .update 目录,能接着对方没做完的做。" +
"--automas-version 是调用方 AUTO-MAS 的版本,新版要求更高的 AUTO-MAS 时不装。" +
"--after-pid、--reopen、--reopen-arg、--handoff-id 是管理器「设置」里点「更新」时用的:管理器下载核对好、关掉实例后启动这条命令并退出," +
Expand Down Expand Up @@ -2074,9 +2074,12 @@ func runMCP(c *cmdCtx) (any, error) {
c.log.Infof("MCP 服务已就绪,根目录 %s", r.Dir)
}
var mu sync.Mutex
// An update of the root this program belongs to asks the server to exit (ModAVD/ModAVD#461).
exe, _ := os.Executable()
opt := mcp.Options{
Version: buildinfo.Version,
Log: c.log,
Exit: update.WatchMCPExit(c.ctx, exe),
NewManager: func(log *logx.Logger) (*emu.Manager, error) {
mu.Lock()
defer mu.Unlock()
Expand Down
2 changes: 1 addition & 1 deletion internal/i18n/locales/en/cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@
"挂不上:%v": "Could not attach: %v",
"按应用走代理": "Per-app proxy",
"按应用走代理:名单里的应用走代理,其余直连": "Per-app proxy: apps in the list go through the proxy, the rest connect directly",
"按管理器「设置」里选的更新源(GitHub 或 Mirror 酱,Mirror 酱下载要填 CDK);调用方有自己的设置时用 --source 和 --cdk-dpapi 传这一次的,只盖过「设置」、不保存,status 里的 source、cdk_set 是这次生效的。--cdk-dpapi 是用 Windows DPAPI 加密好的 CDK 的 base64,解不开或格式不对是 invalid_argument,CDK 不进日志和输出。不自动联网,只做给出的那一步:status(默认)只看本地;check 查最新版本;prepare 下载、按清单核对、暂存好,实例开着也行;install 需要时先 prepare,再换上 sdk\\emulator 和包里的其他文件,要先关掉所有实例、管理器(包括托盘里的)和 MCP 客户端;recover 补完或退回上次没做完的换上。和 AUTO-MAS 用同一个 .update 目录,能接着对方没做完的做。--automas-version 是调用方 AUTO-MAS 的版本,新版要求更高的 AUTO-MAS 时不装。--after-pid、--reopen、--reopen-arg、--handoff-id 是管理器「设置」里点「更新」时用的:管理器下载核对好、关掉实例后启动这条命令并退出,命令等它退出再换上新版,然后重新打开管理器。macOS 可用 --package ZIP --sha256 HEX 准备或安装本地完整签名包;摘要需从可信来源独立取得。--json 时每个进度在 stderr 的日志行里多一个 progress 对象(checking、extracting、verifying、installing 开始时各一行,percent 为 -1;downloading 第一行就带真实进度,之后约 2 秒一行,下完那行一定有):{\"stage\":\"checking|downloading|extracting|verifying|installing\",\"percent\":-1 或 0–100,\"done_bytes\":N,\"total_bytes\":N}。查不了是退出码 9(update_unavailable),下载没通过核对也是 9(update_rejected),有程序在用是 5。": "Uses the update source chosen in the manager's \"Settings\" (GitHub or MirrorChyan; downloading from MirrorChyan needs a CDK); a caller with its own settings passes this run's with --source and --cdk-dpapi, which only override \"Settings\" and are not saved; source and cdk_set in status are the ones in effect for this run. --cdk-dpapi is the base64 of the CDK encrypted with Windows DPAPI; if it cannot be decrypted or the format is wrong it is invalid_argument, and the CDK never goes into logs or output. It does not go online by itself and only does the step you give: status (default) only looks locally; check looks up the latest version; prepare downloads, verifies against the manifest and stages, even while instances are running; install runs prepare first if needed, then puts in sdk\\emulator and the other files of the package, and requires all instances, the manager (including in the tray) and MCP clients to be closed first; recover finishes or rolls back an install that was not completed. It uses the same .update folder as AUTO-MAS and can continue what the other side did not finish. --automas-version is the caller's AUTO-MAS version; if the new version needs a newer AUTO-MAS, it is not installed. --after-pid, --reopen, --reopen-arg and --handoff-id are used when \"Update\" is clicked in the manager's \"Settings\": the manager downloads and verifies, closes the instances, starts this command and exits; the command waits for it to exit, puts the new version in place, and then reopens the manager. On macOS, --package ZIP --sha256 HEX prepares or installs a local full signed package; the digest must be obtained independently from a trusted source. With --json, each progress step adds a progress object to the log line on stderr (one line each when checking, extracting, verifying and installing start, with percent -1; downloading carries real progress from its first line, then about one line every 2 seconds, and always one when the download finishes): {\"stage\":\"checking|downloading|extracting|verifying|installing\",\"percent\":-1 or 0-100,\"done_bytes\":N,\"total_bytes\":N}. Being unable to check is exit code 9 (update_unavailable), a download that fails verification is also 9 (update_rejected), and a program in use is 5.",
"按管理器「设置」里选的更新源(GitHub 或 Mirror 酱,Mirror 酱下载要填 CDK);调用方有自己的设置时用 --source 和 --cdk-dpapi 传这一次的,只盖过「设置」、不保存,status 里的 source、cdk_set 是这次生效的。--cdk-dpapi 是用 Windows DPAPI 加密好的 CDK 的 base64,解不开或格式不对是 invalid_argument,CDK 不进日志和输出。不自动联网,只做给出的那一步:status(默认)只看本地;check 查最新版本;prepare 下载、按清单核对、暂存好,实例开着也行;install 需要时先 prepare,再换上 sdk\\emulator 和包里的其他文件,要先关掉所有实例和管理器(包括托盘里的),这个根目录开着的 MCP 服务由它自己关掉;recover 补完或退回上次没做完的换上。和 AUTO-MAS 用同一个 .update 目录,能接着对方没做完的做。--automas-version 是调用方 AUTO-MAS 的版本,新版要求更高的 AUTO-MAS 时不装。--after-pid、--reopen、--reopen-arg、--handoff-id 是管理器「设置」里点「更新」时用的:管理器下载核对好、关掉实例后启动这条命令并退出,命令等它退出再换上新版,然后重新打开管理器。macOS 可用 --package ZIP --sha256 HEX 准备或安装本地完整签名包;摘要需从可信来源独立取得。--json 时每个进度在 stderr 的日志行里多一个 progress 对象(checking、extracting、verifying、installing 开始时各一行,percent 为 -1;downloading 第一行就带真实进度,之后约 2 秒一行,下完那行一定有):{\"stage\":\"checking|downloading|extracting|verifying|installing\",\"percent\":-1 或 0–100,\"done_bytes\":N,\"total_bytes\":N}。查不了是退出码 9(update_unavailable),下载没通过核对也是 9(update_rejected),有程序在用是 5。": "Uses the update source chosen in the manager's \"Settings\" (GitHub or MirrorChyan; downloading from MirrorChyan needs a CDK); a caller with its own settings passes this run's with --source and --cdk-dpapi, which only override \"Settings\" and are not saved; source and cdk_set in status are the ones in effect for this run. --cdk-dpapi is the base64 of the CDK encrypted with Windows DPAPI; if it cannot be decrypted or the format is wrong it is invalid_argument, and the CDK never goes into logs or output. It does not go online by itself and only does the step you give: status (default) only looks locally; check looks up the latest version; prepare downloads, verifies against the manifest and stages, even while instances are running; install runs prepare first if needed, then puts in sdk\\emulator and the other files of the package, and requires all instances and the manager (including in the tray) to be closed first; it stops the MCP servers this root folder has running itself; recover finishes or rolls back an install that was not completed. It uses the same .update folder as AUTO-MAS and can continue what the other side did not finish. --automas-version is the caller's AUTO-MAS version; if the new version needs a newer AUTO-MAS, it is not installed. --after-pid, --reopen, --reopen-arg and --handoff-id are used when \"Update\" is clicked in the manager's \"Settings\": the manager downloads and verifies, closes the instances, starts this command and exits; the command waits for it to exit, puts the new version in place, and then reopens the manager. On macOS, --package ZIP --sha256 HEX prepares or installs a local full signed package; the digest must be obtained independently from a trusted source. With --json, each progress step adds a progress object to the log line on stderr (one line each when checking, extracting, verifying and installing start, with percent -1; downloading carries real progress from its first line, then about one line every 2 seconds, and always one when the download finishes): {\"stage\":\"checking|downloading|extracting|verifying|installing\",\"percent\":-1 or 0-100,\"done_bytes\":N,\"total_bytes\":N}. Being unable to check is exit code 9 (update_unavailable), a download that fails verification is also 9 (update_rejected), and a program in use is 5.",
"控制台 %d,adb %d,gRPC %d": "Console %d, adb %d, gRPC %d",
"提示:%v": "Note: %v",
"收集完成。": "Collection finished.",
Expand Down
1 change: 1 addition & 0 deletions internal/i18n/locales/en/mcp.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"MCP 服务没有设置实例管理器(NewManager)": "The MCP server has no instance manager set (NewManager)",
"MCP 服务被中止": "MCP server was aborted",
"MCP 消息编码失败: %v": "Failed to encode MCP message: %v",
"ModAVD 正在更新,MCP 服务退出;客户端重新连接后用的就是新版": "ModAVD is updating, MCP server exiting; the client gets the new version when it reconnects",
"apk_path 不能为空": "apk_path cannot be empty",
"apk_path 必须是宿主机上的绝对路径: %s": "apk_path must be an absolute path on the host: %s",
"command 不能为空": "command cannot be empty",
Expand Down
2 changes: 1 addition & 1 deletion internal/i18n/locales/en/ui.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"保存主题设置失败: %v": "Cannot save the theme setting: %v",
"保存语言设置失败: %v": "Cannot save the language setting: %v",
"修改设置": "changing settings",
"先关掉它们(比如用 modavd mcp 的 AI 助手、别的命令行窗口);%v": "Close them first (for example an AI assistant that uses modavd mcp, or other command-line windows); %v",
"先关掉它们(比如别的命令行窗口);%v": "Close them first (for example other command-line windows); %v",
"先用 GET /api/components/license 取许可协议(和这次一样的下载源),把它的 license_sha256 原样带上": "First get the license agreement with GET /api/components/license (same download source as this request), and send its license_sha256 back unchanged",
"先阅读许可协议,再发送 accept_license: true": "Read the license agreement first, then send accept_license: true",
"关掉管理器后运行 tools\\modavd.exe update install": "Close the manager and run tools\\modavd.exe update install",
Expand Down
6 changes: 5 additions & 1 deletion internal/i18n/locales/en/update.json
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,11 @@
"读不到": "unreadable",
"读到了没取回的位置": "Read a position that was not fetched",
"载荷版本清单与更新版本不一致": "The payload version manifest does not match the update version",
"还有程序在用模拟器或管理器的文件:%s。什么都没动,请先关掉所有实例、管理器(包括托盘里的,在托盘图标的菜单里退出)和 MCP 客户端再%s": "Programs are still using emulator or manager files: %s. Nothing was changed. Close all instances, managers (including the one in the tray: exit it from the tray icon menu), and MCP clients first, then %s",
"还有程序在用模拟器或管理器的文件:%s。什么都没动,请先关掉所有实例和管理器(包括托盘里的,在托盘图标的菜单里退出)再%s": "Programs are still using emulator or manager files: %s. Nothing was changed. Close all instances and managers (including the one in the tray: exit it from the tray icon menu) first, then %s",
"关掉这个根目录开着的 MCP 服务(%s),AI 助手下次调用时会用上新版": "Stopping the MCP servers of this root folder (%s); the AI assistant's next call uses the new version",
"MCP 服务(pid %d)%.0f 秒内没有退出,强制结束它": "The MCP server (pid %d) did not exit within %.0f s; force-stopping it",
"结束 MCP 服务(pid %d)失败(%v),什么都没动": "Could not end the MCP server (pid %d) (%v). Nothing was changed",
"通知 MCP 服务退出失败,什么都没动: %v": "Could not ask the MCP servers to exit. Nothing was changed: %v",
"还没有准备好的新版,请先下载": "No prepared new version yet; download it first",
"这个根目录在 mas-avd.json 里设了 sdkRoot(开发用的本地 SDK),不更新": "This root folder sets sdkRoot in mas-avd.json (a local SDK for development); not updating",
"这个根目录正在更新": "This root folder is being updated",
Expand Down
Loading
Loading