Skip to content

fix(plugins): confirm stopping Windows CU processes before install - #4670

Merged
liruifengv merged 3 commits into
release/2026-11-04from
codex/win-cu-install-confirm
Nov 4, 2026
Merged

liruifengv merged 3 commits into
release/2026-11-04from
codex/win-cu-install-confirm

Conversation

@liruifengv

@liruifengv liruifengv commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Requirement or Bug

Windows 用户安装或更新 Computer Use 插件时,旧的后台进程可能仍占用插件目录,安装立即失败。该进程可以独立于客户端存活,因此重启客户端不一定能恢复。

本次为 TUI 和客户端安装接口增加明确的确认流程:告知会中断正在进行的电脑操作,用户同意后结束相关进程并继续安装。无关联 issue。

Bug Reproduction Steps

  1. 在 Windows 启动 Computer Use 后台进程,使其工作目录位于受管理的插件目录。
  2. 从 /plugins 或 desktop/web 插件设置中安装或更新 Windows Computer Use。
  3. 原安装器替换目录时收到 EBUSY,提示重启客户端;旧后台进程仍可能存活并继续占用目录。

Root Cause

Windows 不允许重命名被进程作为工作目录使用的目录。安装器在替换插件目录前未处理运行中的 Computer Use 进程,而本进程的 MCP 连接也可能重新启动插件进程。

本次在安装前解除已识别进程造成的占用,并在替换期间暂停该插件的 MCP 连接。其他应用造成的占用仍按安装错误报告,不再误称一定由当前客户端占用。

Code Changes

安装接口继续接受无请求体的 POST,并将省略的选项归一为空对象。进程枚举独立选择可用的 PowerShell,只有运行时需要安装时才检查完整安装器命令。

把“需要结束进程”作为安装状态返回,只有确认后的重试带 stopRunningProcesses: true。TUI、SDK、klient、REST 和 WebSocket 使用同一契约。

flowchart TD
    UI[TUI 或 desktop/web] --> START[请求安装]
    START --> CHECK{Windows CU 进程运行中}
    CHECK -- 是且未授权 --> ASK[返回 confirmationRequired]
    ASK --> CONFIRM[界面二次确认]
    CONFIRM -- 取消 --> END[结束本次安装]
    CONFIRM -- 同意 --> RETRY[携带 stopRunningProcesses 重试]
    RETRY --> SUSPEND[暂停目标插件 MCP 并等待断开]
    CHECK -- 否 --> SUSPEND
    SUSPEND --> STOP[再次检测并按授权结束匹配进程]
    STOP --> INSTALL[执行原插件和运行时安装]
    INSTALL --> RESTORE[成功或失败均恢复 MCP]
Loading

暂停和恢复属于插件服务的临时状态,不修改用户的启用配置。安装期间的 reload 也保留暂停状态,避免替换文件时重新拉起 MCP。

进程筛选限定在当前登录会话、已知安装路径或配置路径,以及 agent / agent-background / mcp 模式。结束进程前再次核对可执行文件和创建时间,并等待退出。没有按进程名批量终止。

运行时安装器保留原有启动后台进程的行为;只更新插件时恢复 MCP,由后续使用按需启动。

阅读顺序:windowsCuProcesses.ts 查看识别及结束范围,kimiCu.ts 查看安装顺序,pluginService.ts 查看临时暂停及恢复,tui/commands/plugins.ts 查看确认与重试。其余协议、SDK 和测试文件是透传与覆盖。

Screenshots / Recordings

以下为本分支确认组件经虚拟终端渲染的原始文本快照,默认选中 Cancel;确认选项必须显式选择后按 Enter。

────────────────────────────────────────────────────────────────────────────────────────────────────
 Stop running processes for Kimi Computer Use?
 ↑↓ navigate · Enter select · Esc cancel

 Continuing will stop the running plugin processes and interrupt any computer operations in
 progress.

  ❯ Cancel
    Leave running processes untouched.
    Stop processes and continue

────────────────────────────────────────────────────────────────────────────────────────────────────

Behavior Changes and Affected Users

行为 修改前 修改后 受影响人群 退出方式
Windows CU 安装/更新遇到运行中进程 直接替换目录,可能报占用错误 先返回待确认状态,同意后结束匹配进程并继续 Windows TUI、desktop/web 用户 取消或 Esc,保留运行中的进程
安装期间目标插件的 MCP 连接 可能继续占用或重新拉起进程 临时暂停,成功或失败均恢复;不改变启用配置 Windows CU 用户及同一进程的活动会话 取消安装;已确认时进行中的电脑操作会被中断
能力安装协议 无进程终止选项/待确认状态 新增可选请求字段和状态字段,省略请求体仍可调用,省略授权不结束进程 SDK 调用方、REST/WS 客户端 处理确认状态,或由用户手动退出进程后重试
TUI 安装结果 未处理待确认状态 确认后仅重试一次,取消退出,失败不报成功 /plugins 用户 默认取消,Esc 取消
剩余目录占用报错 指向当前客户端并要求重启 提示关闭其他占用应用后重试 Windows CU 用户 关闭占用应用后重试

仅 Windows CU 安装入口启用进程控制。其他平台、其他插件沿用原安装入口。desktop/web 的二次确认在 kimi-code-app #1144,app submodule 由维护者另行处理。

已验证未确认时不结束进程、确认重试、结束失败后的恢复、MCP 暂停期间 reload、协议字段透传、TUI 默认取消/Esc/重试失败,以及真实 Windows 临时进程占用目录释放。真实进程测试同时验证不同路径的同名进程和 doctor 模式不被终止。未对用户实际安装的 CU 进程执行终止测试。

验证详情
  • 核心能力与插件服务:86 passed、1 skipped。
  • server 路由和事件:73 passed、1 skipped。
  • TUI 命令与确认组件:84 passed。
  • SDK 授权透传:1 passed;klient facade:33 passed。
  • 评审修复回归:Windows CU 安装、真实进程控制、server 能力路由共 49 passed、2 skipped;覆盖无请求体、仅插件修复不依赖安装器命令、PowerShell 7 回退和进程检查失败。
  • agent-core-v2、kap-server、klient、SDK、CLI 类型检查通过。
  • 改动文件 lint 无错误,存在未修改代码的既有告警;git diff --check 通过。

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue — 无关联 issue,按维护者要求修复。
  • I have added tests that prove my feature works.
  • The behavior-change table above is complete.
  • Ran gen-changesets skill — 按维护者明确要求,本 PR 不添加 changeset。
  • This PR needs no doc update — 未新增命令或配置,交互提示包含操作影响。

@changeset-bot

changeset-bot Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 002cc0e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@002cc0e
npx https://pkg.pr.new/@moonshot-ai/kimi-code@002cc0e

commit: 002cc0e

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a6a60fa5b7

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-04T10:49:19.453993Z 002cc0e New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 002cc0ed68

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@liruifengv
liruifengv merged commit 5e85af3 into release/2026-11-04 Nov 4, 2026
15 checks passed
@liruifengv
liruifengv deleted the codex/win-cu-install-confirm branch November 4, 2026 10:49
Grapedge pushed a commit that referenced this pull request Nov 4, 2026
* fix(tui): read welcome cwd and footer git status from the session environment (#4649)

* fix(tui): show remote cwd in welcome panel

* fix(tui): read footer git status through the session environment

The footer ran git and gh on the local machine, so a remote-bound session
hid the git badge. Read branch, working-tree, and pull request state through
the SDK instead: a live session's own environment, or the local work dir
before the lazy session exists. The local HEAD poll stays as a refresh
trigger only.

Core git commands now time out after 30s, and the pull request cache is
keyed by branch so a branch switch no longer serves the previous branch's
pull request.

* fix(agent-core-v2): resolve local git and gh outside the working directory

GitService spawned bare git and gh with the workspace as cwd. On Windows a
bare name is looked up in the cwd before PATH, so a binary planted in the
workspace could run, and the TUI footer now reads git status at startup,
before the workspace trust gate. Resolve both through PATH for the local
environment and refuse any match inside the working directory.

* chore: merge changesets for remote cwd and git status

* fix(tui): drop the startup Ready. row once startup succeeds

The startup progress row turned into a permanent "Ready." line under the
welcome panel. Remove it on success; a failed startup still leaves the
"Startup failed." row.

* fix(agent-core-v2): compare workspace containment case-insensitively on Windows

resolveProgramPath compared the PATH candidate against the working directory
case-sensitively, so on Windows a PATH entry spelled with different casing
(c:\repo\bin vs C:\Repo) let a workspace-local executable through.

* fix(tui): keep the footer git badge through a remote disconnect

The git cache key included the environment status, so a remote dropping to
connecting or disconnected rebuilt the cache and lost the last badge. Key
the cache by session and work dir only, and refresh it when the environment
turns ready again.

* feat: isolate plugin availability by client (#4653)

* fix: preserve marketplace descriptions

* fix: preserve localized plugin display names

* feat: isolate plugin availability by client

* fix: preserve cli marketplace loading

* fix: harden plugin availability reconciliation

* fix: hash plugin marketplace provenance

* fix: complete plugin availability reconciliation

* fix(transcript): keep realigned turn ids unique when folding cold facts (#4658)

* fix(transcript): keep realigned turn ids unique when folding cold facts

Realigning base turns to their wire ids only skipped ordinals held by
turns without a wire id. When an inherited turn held a forked turn's
wire id, that turn kept its base ordinal, and the next turn's wire id
could land on the same ordinal, so two turns shared a turn id and the
later one replaced the earlier in clients. Claim ordinals in order:
turns without a wire id or already at their wire id first, then each
realigned turn takes its wire id when free, else keeps its ordinal or
moves to the next free one.

* chore: add changeset for side chat turn order fix

* fix(kap-server): wait for an agent's history before accepting its prompt (#4659)

* fix(kap-server): backfill a side chat fork before replying to :btw

A fork's inherited history folds into a cold turn at t0, while the live
transcript only records it as markers. When the fork's first prompt
started before anything read the fork transcript, its live turn took t0;
the history backfill then merged the inherited main turn into it by turn
id, so the first side chat turn carried the main answer and the real
answer landed in a duplicate turn. Finish the fork's history backfill
before :btw replies, so the inherited turn holds t0 before the first
prompt can start.

* fix(kap-server): wait for an agent's history before accepting its prompt

Delaying the :btw reply did not order the fork's first prompt after its
history backfill: other clients learn the fork from the agent roster as
soon as it is created, and checking for a live transcript with
forSessionLive created one, so every :btw also waited for the whole main
history. Move the wait to prompt submission: a prompt for a non-main
agent awaits that agent's history backfill before it is enqueued, which
covers every client and leaves :btw unchanged. The backfill is cached
per agent, so later prompts do not wait again.

* fix: safely launch Windows SSH executors (#4664)

* feat: support Windows SSH remote environments

* Delete .changeset/windows-remote-environments.md

Signed-off-by: 7Sageer <[email protected]>

---------

Signed-off-by: 7Sageer <[email protected]>

* fix(agent-core-v2): match regional plugin locales (#4666)

* fix(plugins): confirm stopping Windows CU processes before install (#4670)

* fix(plugins): confirm stopping Windows CU processes before install

* test(plugins): cover capability install confirmation contract

* fix(plugins): preserve bodyless installs and plugin-only repairs

* chore: sync web dist from code-app (#4667)

* chore: sync web dist from code-app

code-app: 63661fc449e2ec0ce024bc08fe87f2c757d483e8

* chore: sync web dist from code-app

code-app: d0e913a6c9607be778c62f0c74ee7310bfb8862a

* chore: sync web dist from code-app

code-app: b306f4a2f9be8944e5a8064ecb076e3137c968f1

---------

Co-authored-by: kimi-agent-bot <[email protected]>

* ci: release packages (#4672)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

---------

Signed-off-by: 7Sageer <[email protected]>
Co-authored-by: 7Sageer <[email protected]>
Co-authored-by: liruifengv <[email protected]>
Co-authored-by: qer <[email protected]>
Co-authored-by: kimi-agent-bot <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 4, 2026
Fifteen rows enter the ledger: the six commits that landed on
upstream/main after the last refresh, and the nine commits that reach
main only through the release/2026-11-04 sync (MoonshotAI#4674), which is where
the 2.5.0 changelog entries come from.

Each 2.5.0 row records what it needs from this tree, so the next batch
starts from the blocker instead of rediscovering it:

- MoonshotAI#4658 and MoonshotAI#4659 are ported (79a4199, 7a531f5) with tests that
  fail on the pre-change tree.
- MoonshotAI#4649 is in_progress: its agent-core-v2 half landed in 2fa7b6b,
  while the footer and welcome half needs the pull-request API of MoonshotAI#4527
  and the session workdir of MoonshotAI#4062.
- MoonshotAI#4653, MoonshotAI#4666 and MoonshotAI#4670 build on the MoonshotAI#4525 plugin marketplace, absent
  here; MoonshotAI#4670 additionally needs isError2.
- MoonshotAI#4664 needs the MoonshotAI#4062 remote environments.
- MoonshotAI#4667 and MoonshotAI#4672 are generated-bundle and release commits; settling
  them as not-applicable needs a signature.

Rows were appended by a one-off writer because --refresh fetches and
that fetch does not complete on this network; the file still parses
under the tool's own column contract, and --verify --batch B5 passes
both new probes.
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 5, 2026
… resolve seam

The row looked like a 34-file mechanical port, but its installer call goes
through `installResolvedMarketplacePlugin(plugins, input, resolved, requiredSkill)`,
which needs `marketplace.resolveInstall` and the `MarketplacePluginInstall` type
from upstream's `app/plugin/marketplaceService.ts`. That file has no counterpart
here: the marketplace port (MoonshotAI#4525, equivalent) carried the entry model and parser
only, and this tree installs through `manager.install` plus
`availability.matchByArtifact`, so there is nothing for the capability entry to
hand over.

A trial apply was written and then fully reverted (11 conflicted files, and the
new pluginService/kimiCu imports resolve against symbols this tree does not
export), and the engine typecheck is clean again. The row now names the
prerequisite: port the resolveInstall seam and the type, and the row turns back
into a mechanical port.
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 5, 2026
…tall

Port of upstream MoonshotAI/kimi-code 5e85af3 (MoonshotAI#4670).

Installing or updating the Windows Kimi Computer Use plugin while its
processes are running fails on a locked directory, and the old failure
surfaced only after the installer had already started. The capability now
asks first: `install` reports `confirmationRequired: 'stop-processes'`
instead of throwing, the caller re-invokes it with
`stopRunningProcesses: true`, and only then are the matching processes
stopped and the install retried.

Process discovery is scoped precisely: only `kimi-cu.exe` images whose
executable sits at one of the known install paths, in the current session,
and whose command line starts with an `agent` / `agent-background` / `mcp`
mode. Anything else with that name is left alone, and the stop path
re-verifies each process's image path and start time before killing it, so
a recycled pid cannot take out an unrelated process.

`IPluginService.withMcpServersSuspended(id, task)` holds a plugin's MCP
servers out of the projection for the duration of a task and restores them
afterwards — the running MCP child process would otherwise keep the plugin
directory busy. The confirmation reaches the surfaces: the TUI mounts a
stop-processes dialog and cancels cleanly on Escape, kap-server accepts an
optional install body, and klient / node-sdk forward it.

Local-form notes:
- `kimiCu.ts` installs through `installPluginLayer(ctx, windowsPlugin())`
  here; upstream routes it through
  `installResolvedMarketplacePlugin` from the marketplace service this fork
  does not have (MoonshotAI#4525's seam). The wrapper sits around the existing call,
  so the suspension and the consent check apply identically.
- The dialog copy and the "still running" notice go through `t()` with
  en/zh keys, and the two new error codes get `errorCodes.*` entries, since
  both gates are enforced here.
- `capabilityInstallOptionsSchema` is `.strict()`, which
  `check:strict-request-bodies` requires at this boundary.
- Two test-only fixes for this host rather than for the product: the
  integration case compares the executable through `[IO.Path]::GetFullPath`
  on both sides and accepts either form in the command line, because a
  short-path `%TEMP%` (`ADMINI~1`) otherwise never matches; and its temp
  directory is removed with retries, since Windows releases the image
  handle just after `exit`. Both reproduce on the unmodified upstream test.

Verified: agent-core-v2 typecheck clean; kimiCu 43 pass, windowsCuProcesses
1 pass (twice in a row), capabilityService 13, pluginService 33,
pluginCommand 2, skillCatalog 24, agentProfileLoader 24; kap-server
capabilities + sessionEventBroadcaster + sessions 176; klient 32; node-sdk
sdk-rpc-client-v2 86; apps/kimi-code plugins-capability 15 and
plugins-selector 50; oxlint --type-aware 0 errors; check:no-comments,
check:no-hardcoded-prose, check:locale-keys, check:locale-placeholders,
check:t-coverage, check:strict-request-bodies and
check:status-surface-i18n green.
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant