Skip to content

fix: safely launch Windows SSH executors - #4664

Merged
7Sageer merged 3 commits into
MoonshotAI:release/2026-11-04from
7Sageer:fix-remote-windows
Nov 4, 2026
Merged

7Sageer merged 3 commits into
MoonshotAI:release/2026-11-04from
7Sageer:fix-remote-windows

Conversation

@7Sageer

@7Sageer 7Sageer commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Requirement or Bug

Windows SSH 用户使用默认安装位置或带空格的 Windows 绝对路径时,执行器需要通过适合目标系统的命令启动。当前发布基线已经包含 #4610 的 Windows 环境、路径桥接和 ripgrep 支持;本 PR 补齐 SSH 启动路径,并守住会话创建前的信任检查时序。

Bug Reproduction Steps

  1. 在 Windows 目标安装 Windows 版 Kimi Code CLI 和 Git for Windows,将执行器放在账户主目录下的 .kimi-code/bin/kimi.exe。
  2. 配置 type = "ssh"、host = "windows-dev"、defaultCwd = 'C:\work\project',不设置 remoteBin;或将 remoteBin 设为带空格的 Windows 绝对路径。
  3. 从 TUI 或 SDK 连接该环境。旧启动命令使用 POSIX 的 $HOME 和引号,无法由 cmd / Windows PowerShell 直接执行。

Root Cause

SSH 会把远端命令交给目标账户的默认 Shell,客户端不能在握手前假定它支持 POSIX 语法。把 POSIX 和 PowerShell 执行器串成条件命令,还会把执行器自身的非零退出误当成平台探测失败,并让路径经过外层 Shell 的展开。

修复将平台探测与执行器启动分开。探测只运行固定命令,执行器只启动一次,退出码直接向上传递。会话信任检查继续使用基线的纯路径规范化,不提前建立 SSH 连接。

Code Changes

SSH 连接
  裸 remoteBin 名称 → 直接启动,保持现有行为
  路径或默认 remoteBin
    固定 uname 探测 → POSIX / MSYS
    必要时固定 PowerShell 探测 → Windows
    确认平台后只启动一次 executor
      POSIX → 保留原有路径引用和 ~ 展开
      Windows → 编码 PowerShell 脚本、字面量路径、传递退出码

探测与执行阶段复用 SSH 主机校验、认证参数和 askpass。每次探测与握手各有 10 秒上限,探测输出也有大小上限;认证失败或超时立即终止。Windows 脚本使用 -EncodedCommand,外层命令没有 && / ||,适用于 Windows PowerShell 5.1。

先看 remote/client/launchers.ts 的命令构造,再看 remote/client/remoteSession.ts 的探测与资源释放。其余改动是回归测试和双语说明。Windows 路径桥接、进程生命周期、握手能力和 ripgrep 安装沿用发布基线。

Behavior Changes and Affected Users

行为 之前 之后 受影响人群 退路
Windows SSH 默认执行器路径 必须配置目标 PATH 中的裸名称 默认从目标账户的 ~/.kimi-code/bin/kimi.exe 启动,支持绝对路径和空格 TUI、SDK、server 的 Windows SSH 环境用户 仍可配置 remoteBin = "kimi" 或 "kimi.exe"
使用路径的 SSH 连接 直接发送执行器命令 先运行固定探测,再启动一次执行器;增加一至两次短 SSH 连接 Linux、macOS、Windows 上使用默认路径或路径形式 remoteBin 的用户 裸名称保持直接启动;限制远端命令的 SSH 配置可使用该方式
SSH 探测失败 没有独立探测阶段 认证失败、超时或无法识别目标时明确报错,不尝试运行执行器 密码认证用户、不可达主机、缺少探测命令或限制 SSH 命令的目标 认证流程不变;裸名称可绕过平台探测
POSIX 路径引用、裸名称、Docker 与自定义 command 现有引用和参数传递 保留原行为;路径中的命令替换字符按字面量处理 现有远程环境用户 无需迁移
信任检查、Windows 工具路径与 ripgrep 发布基线已提供无连接的路径规范化、远端路径桥接和 rg.exe 安装 保留这些实现并增加信任检查及 Windows 缓存缺失回归验证 密码认证 TUI 用户、Windows 文件和搜索工具用户 /c/... 可用;/tmp、/usr 等无法确认映射的 MSYS 路径继续明确拒绝

覆盖了执行器非零退出、含引号和命令替换字符的完整路径执行、Windows 编码命令、探测超时和失败、真实 askpass 密码重试、信任检查不发起连接,以及 Windows x64/arm64 ripgrep 下载选择。没有修改配置字段、会话存储格式或外部 API 契约。

验证范围与结果
  • 远程环境及关联路径、会话、ripgrep 测试:15 个文件、277 个用例通过。
  • @moonshot-ai/agent-core-v2 typecheck 通过。
  • 本次修改文件的 type-aware lint 通过;comment-free 检查通过。
  • 真实 Windows x64 ripgrep 包下载通过 SHA-256 校验和 ZIP 解包,模拟远端文件系统收到 rg.exe,未调用 chmod。
  • lint:imports 有一条基线已有失败:human/agent/origin.ts 导入 agent/prompt/promptMetadataText。该文件和检查脚本均与发布基线一致。
  • 本轮没有重跑原生 Windows / PowerShell 5.1 主机验收或全量测试;SSH 控制流程通过替身 transport 验证,完整 POSIX 命令通过真实 Shell 执行验证。

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: issue must have a maintainer's /approve).
  • I have added tests that prove my feature works.
  • The behavior-change table above is complete, and every removed behavior or flipped default is named in the changeset and either has an escape hatch or was explicitly approved by a maintainer in this PR.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 21f68c0

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

@7Hanrui

7Hanrui commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

@codex review

@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-04T05:53:07.643429Z 21f68c0 Draft marked ready
ℹ️ 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: b178304d98

ℹ️ 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".

);
}
if (this.environmentValue.pathClass !== 'posix') {
if (this.environmentValue.pathClass !== 'posix' && this.environmentValue.pathClass !== 'win32') {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Provision ripgrep for newly accepted Windows targets

For a Windows target that does not already have rg on PATH (for example a bare executor plus Git Bash), this newly accepted handshake reaches ensureRgPath; however detectRemoteTarget in src/os/backends/node-local/tools/rgLocator.ts explicitly returns undefined for Windows and shareBinRgPath still names rg rather than rg.exe. Both Glob and Grep therefore return “Unsupported platform/arch” instead of provisioning their fallback, so enable the existing Windows archive/install path before admitting this environment.

AGENTS.md reference: AGENTS.md:L128-L128

Useful? React with 👍 / 👎.

get path(): Environment['path'] {
return this.session === undefined ? undefined : POSIX_ENVIRONMENT_PATH;
if (this.session === undefined) return undefined;
return this.session.host.pathClass === 'win32' ? WIN32_ENVIRONMENT_PATH : POSIX_ENVIRONMENT_PATH;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Resolve Git Bash mount paths on the remote host

When a non-Windows Kimi host drives this Windows environment and remote Git Bash emits a non-drive mount path such as /tmp/out from mktemp, EnvironmentWorkspaceView and path-access call getShellPathBridge with the remote host metadata, but that bridge locates and runs cygpath.exe using the client process's local existsSync/execFileSync. It therefore leaves /tmp/out unresolved and the new win32 path implementation sends \tmp\out (effectively C:\tmp\out) instead of Git Bash's actual mount, so Read/Edit can fail or target the wrong file; the provider needs a bridge backed by the remote FS/process or server-side conversion.

AGENTS.md reference: AGENTS.md:L128-L128

Useful? React with 👍 / 👎.


private scheduleGroupReap(processId: string, group: ExitedProcessGroup): void {
if (process.platform === 'win32') {
this.exitedGroups.delete(processId);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Retain exited Windows process trees until cleanup

When a Windows remote process leader exits after daemonizing a child with redirected stdio (for example a Git Bash command ending in &), maybeClose reaches this branch and immediately deletes the only processId ownership record. A later RemoteProcess.kill('SIGTERM') is silently accepted as an unknown pre-start termination and terminateAll() cannot invoke taskkill, leaving the child running after the session or SSH connection closes; retain Windows tree ownership, for example with a Job Object, rather than discarding it here.

AGENTS.md reference: AGENTS.md:L128-L128

Useful? React with 👍 / 👎.

function sshRemoteCommand(remoteBin: string): string {
const posix = shQuote(execServerShellCommand(remoteBin));
const windows = `"${execServerPowerShellCommand(remoteBin)}"`;
return `sh -c exit && sh -c ${posix} || powershell -NoLogo -NoProfile -NonInteractive -Command ${windows}`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Avoid POSIX chaining under a PowerShell default shell

When Windows OpenSSH is configured to use built-in Windows PowerShell 5.1 as its DefaultShell, sshd asks that shell to parse this entire remote command before the nested powershell invocation can run. Microsoft's pipeline-chain documentation says && and || are available beginning in PowerShell 7, so 5.1 rejects the line and every connection fails before starting the executor; dispatch with syntax valid for the configured remote shell instead of assuming cmd/POSIX parsing.

Useful? React with 👍 / 👎.

}

function windowsExecutorPath(remoteBin: string): string {
const path = remoteBin === DEFAULT_REMOTE_BIN ? '~/.kimi-code/bin/kimi.exe' : remoteBin;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Report the Windows executor path in upgrade guidance

When a Windows executor completes the handshake but is below the minimum version, connectWithGuidance obtains the path from launcherRemoteBin() and tells the user to replace ~/.kimi-code/bin/kimi. This line silently changes the executable actually launched to ~/.kimi-code/bin/kimi.exe, so following the upgrade guidance leaves the old .exe in place and reconnecting repeats the same incompatibility; carry the effective Windows path (or both platform paths) into the guidance.

AGENTS.md reference: AGENTS.md:L128-L128

Useful? React with 👍 / 👎.

function sshRemoteCommand(remoteBin: string): string {
const posix = shQuote(execServerShellCommand(remoteBin));
const windows = `"${execServerPowerShellCommand(remoteBin)}"`;
return `sh -c exit && sh -c ${posix} || powershell -NoLogo -NoProfile -NonInteractive -Command ${windows}`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve install guidance for PowerShell command misses

When the Windows executor is not installed yet, the nested PowerShell command-not-found leaves $? false and the documented string -Command exit contract returns code 1. classifyHandshakeFailure recognizes only executor exits 126/127 as missing, so the normal first Windows connection is rethrown without the promised install instructions; make the PowerShell branch return a recognized missing-executable status or classify this failure explicitly.

AGENTS.md reference: AGENTS.md:L128-L128

Useful? React with 👍 / 👎.

@7Sageer 7Sageer changed the title feat: support Windows SSH remote environments fix: safely launch Windows SSH executors Nov 4, 2026
@7Hanrui

7Hanrui commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

@codex review

@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: 21f68c0a73

ℹ️ 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".

Comment on lines +169 to +170
throw new HandshakeError(`Could not detect the SSH target platform: ${result.stderr.trim() || result.stdout.trim() || `probe exited with code ${result.code}`}`, {
kind: 'executor-exit', exitCode: result.code,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid labeling platform-probe failures as a missing executor

When a path-based SSH target cannot run the probes—for example, both uname and powershell are blocked or missing—this assigns the final probe's 126/127 status to an executor-exit; classifyHandshakeFailure consequently takes its missing-executor branch and connectWithGuidance tells the user to reinstall Kimi even though the executor was never started. The timeout branch at line 148 similarly reuses the handshake timeout kind and receives install guidance, so preserve a probe-specific failure class (or skip executor guidance) instead.

AGENTS.md reference: AGENTS.md:L112-L112

Useful? React with 👍 / 👎.

@7Sageer
7Sageer marked this pull request as ready for review November 4, 2026 05:47
@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@21f68c0
npx https://pkg.pr.new/@moonshot-ai/kimi-code@21f68c0

commit: 21f68c0

@7Sageer
7Sageer merged commit 212127a into MoonshotAI:release/2026-11-04 Nov 4, 2026
27 of 28 checks passed

@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: 21f68c0a73

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

};
const remoteBin = spec.remoteBin ?? DEFAULT_REMOTE_BIN;
return resolveSshCommand(spec.host,
sshPlatform === 'windows' && !isBareRemoteBin(remoteBin)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Add a changeset for the Windows SSH launch fix

This new Windows path-based launch branch changes behavior visible to CLI users, but the commit adds no .changeset entry, so the fix is omitted from the user-facing changelog; add a @moonshot-ai/kimi-code patch changeset.

AGENTS.md reference: AGENTS.md:L89-L90

Useful? React with 👍 / 👎.

function execServerPowerShellCommand(remoteBin: string): string {
const path = remoteBin === DEFAULT_REMOTE_BIN ? '~/.kimi-code/bin/kimi.exe' : remoteBin;
const literal = (value: string) => `'${value.replaceAll("'", "''")}'`;
const executable = /^~[\\/]/.test(path)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve named-user tilde paths in Windows SSH

When a Windows SSH target uses Git Bash and remoteBin is a named-home path such as ~alice/bin/kimi.exe, this predicate falls through to a literal PowerShell path because it only recognizes ~/ or ~\; the previous execServerShellCommand path let Bash expand ~alice, so the executor now fails to launch. Preserve named-user expansion in this branch.

AGENTS.md reference: AGENTS.md:L112-L112

Useful? React with 👍 / 👎.

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
Port of upstream MoonshotAI/kimi-code 212127a (MoonshotAI#4664).

An SSH target running Windows could only be reached with a bare `remoteBin`
name: the launcher always built a POSIX shell command, so a path such as
`~/.kimi-code/bin/kimi.exe` was handed to cmd or PowerShell as broken syntax.

- `launchers.ts` gains `isBareRemoteBin`, `powerShellCommand` (one
  `-EncodedCommand` carrying the base64 of the UTF-16LE script),
  `execServerPowerShellCommand` (`$env:USERPROFILE` for `~/` paths,
  single-quote doubling for literals, `exit $LASTEXITCODE`), and
  `resolveSshCommand`; `resolveLauncher` takes an `sshPlatform` and switches
  only when the `remoteBin` is a path, so a bare name keeps today's command.
- A bare `remoteBin` is no longer quoted on the shell path either.
- `RemoteSession.connect` probes the target before launching: `uname -s`, and
  `windows` when it reports MINGW/MSYS/CYGWIN; otherwise a PowerShell probe
  that prints `KIMI_WINDOWS`. Exit 255 becomes an `authentication` or
  `executor-exit` HandshakeError and a killed probe a `timeout`, so a wrong
  password or a missing shell fails with the same shape as the executor
  handshake.

Coverage gap, recorded rather than hidden: the upstream session-level
detection cases are POSIX-only (a fake `ssh` on `PATH`) and are not ported, so
the probe branch is pinned only through the launcher command shape; this fork's
remote suite is POSIX-gated the same way.

Verified: agent-core-v2 typecheck clean, remote suite 54 pass / 49 skip with
three new launcher cases (the encoded Windows script for the default path, a
`~/` path and a path with quotes/metacharacters, plus the bare-name and posix
counterparts), sessionManager 31 pass, node-local tools 348 pass;
check:no-comments, check:deep-imports and check:boundaries green. Docs updated
in both locales: `remoteBin` now documents the Windows default and the probe.

Ledger: MoonshotAI#4664 ported; closed 72 -> 73, remaining 27 -> 26.
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.

2 participants