Repository navigation
feat: remote environments for SSH and Docker execution targets (phase 1: creation-time binding) - #4062
Merged
Conversation
…s them A ProgramGeneration no longer pins its environment for its whole lifetime: the build lease is released as soon as the generation is constructed, re-acquired lazily when a session controller is created, and released again when the last controller reference drops. Retired generations keep their lease until final disposal so replaced controllers stay valid. With zero leases the registry reports the environment idle, so the provider's idle TTL reaping can actually close unused remote connections and reconnect on the next use.
…vironment When a subagent is spawned on an environment different from the caller's, the prompt prefix (git context) now runs against the target environment and its cwd instead of the caller's. File-history checkpoints forwarded from such a subagent now carry the emitting agent's environment id on each backup entry, so start/end captures and live change reads go through the subagent environment's filesystem instead of inspecting a same-named file on the main agent's environment.
…t registration The sessionless /fs::suggest route no longer derives a registry workspace id from roots[0] for a non-local environment_id — remote roots such as /srv/project never resolve to the carrier workspace that owns the environment. The route now looks up the materialized workspace whose registry holds the environment and acquires the lease there, returning ENVIRONMENT_NOT_FOUND when no workspace has it registered.
…ent is unavailable readCurrent now catches EnvironmentError from the environment acquire and returns 'unreadable' instead of throwing, matching the probeProjectContext idiom. After an idle reap or a transient drop, a turn's end checkpoint still completes its remaining paths instead of losing every end entry for the turn.
Resolve conflicts by keeping both sides' changes: - kimi-tui.ts: survey traceId (#3907) + environment slot refresh on turn end - readTool.ts/read.test.ts: upstream unregistered-tools/media-error fixes (#3878) with the environment rename; lint directive wording per repo convention - externalHooksRunnerService.ts: both ILogService (ours) and ITelemetryService (upstream #3897) constructor deps - runHook.ts: both errored flag (upstream telemetry) and error message (matchHooks propagation) on spawn/wait failures - program.ts: adopt upstream app-scope shared IUserFileSkillSource (#3889) while keeping localFs/targetFs wiring and generation lease lifecycle - regenerate loop/tool inline tool snapshots from the merged tool set - regenerate docs/config-manifest.toml (30 sections) Auto-merge follow-ups: restore unwrapErrorCause import in workspaceService.ts, update SessionManager/SubagentTool/IWireService stubs in tests for the merged constructor signatures.
Flip agentEnvironmentToolsFlag default to true so the main agent gets change_environment and connect out of the box (the flag remains as an opt-out, and the towerModeInactive when-condition stays). The 'agent' profile's explicit tool allowlist is the second gate: bind()/useProfile() now append ENVIRONMENT_SWITCH_TOOL_NAMES for the main agent under the same main-agent + flag + non-tower conditions as the environments prompt section, so the tools survive profile-driven activation. CI fixes for the prepareSwitch cwd guard (environment.invalid_cwd): - kap-server rpc.test.ts: pass cwd in the missing-environment POST so it still exercises 40420, and give the fake remote an fs + cwd for the switch half of the test. - kap-server prompts.test.ts: bindRemoteEnvironment passes a real cwd and disposes the provider when binding fails (no cascade). - agent-core-v2 config.test.ts: the date_change reminder embeds the host timezone in estimated-token snapshots; pin IHostClock's timeZone so the snapshot is deterministic across machine timezones. Regenerate the tool-list/tool-hash snapshots shifted by the newly default-on tools (loop, tool, resume, config, fullCompaction).
Add an Environment Tools section to docs/en/reference/tools.md (mirrored in docs/zh/reference/tools.md) covering the two agent environment tools that M69 turned on by default: parameters, turn-boundary switch semantics, temporary-environment lifecycle, and the main-agent-only / Plan mode / tower mode / permission-mode constraints. Also link the remote environments guide from the page's Next steps.
…ect type
toInputJsonSchema converts a z.union/z.discriminatedUnion input schema to
{ anyOf: [...] } / { oneOf: [...] } with no top-level type, which strict
OpenAI-compatible providers reject with 400
'tools.function.parameters.type is required and must be "object"'.
This broke every request carrying the connect tool, the only builtin
tool with a union-typed parameters schema.
Add type: 'object' at the top level whenever the converted schema lacks
a type but carries anyOf/oneOf. The addition runs after closeObjectNodes
on purpose: the top level must not gain additionalProperties: false,
which (with no sibling properties) would reject every non-empty object.
Tests:
- input-schema.test.ts: union and discriminated-union conversion plus
runtime validation of branch inputs.
- environmentTools.test.ts: connect parameters validate as a
strict-provider object schema for all three branches.
- tool.test.ts: permanent sweep asserting every registered tool exposes
a top-level object type, with default flags and with all experimental
flags enabled.
- Regenerate two llm.tools_snapshot inline snapshots (hash-only diffs).
…anual mode change_environment and connect previously prompted in both manual and yolo permission modes. The environment-switch-ask policy now abstains outside manual mode, so yolo falls through to yolo-mode-approve like every other tool. Tool descriptions and policy tests updated to match.
change_environment and connect now ask for confirmation only in Always Ask (manual) mode; Ask When Needed and Never Ask modes proceed without asking. Updates the tools reference and remote-environment guide in both locales to match the policy change.
The environment binding state key was replayed from the full wire journal instead of the surviving branch, so a switch cut by the undo fork was folded back in and the reconcile step saw nothing to revert. Mark the key undoable so it replays from the restorable chain. Also make change_environment take effect for the next tool call in the same turn: the binding commits immediately when no other tool calls are in flight (deferring to the turn boundary only under genuine in-flight concurrency), the turn environment snapshot and workDir follow the commit, and the tool copy reflects the new timing.
A switch deferred under in-flight tool calls stayed parked after a later switch committed in the same turn, so the turn-end flush committed the stale one over the newer binding. Clearing the parked switch in commit() makes the latest switch win on every path.
change_environment now commits immediately when no other tool calls are in flight, so the next tool call in the same turn runs on the new environment; only genuine in-flight concurrency defers the switch to the turn boundary. The /environment dialog and REST switch are still refused while tool calls are executing or an approval is pending, and an accepted switch takes effect immediately. Updates the remote-environment guide, env-vars flag row, server-api 40901 entry, and tools reference in both locales.
7723qqq
pushed a commit
to 7723qqq/kimi-code
that referenced
this pull request
Nov 5, 2026
Test side settled by a greedy rule: for every test file the merge hybridised, restore main's version only when doing so does not raise the error count. The four files MoonshotAI#4062 genuinely extends stay on the merged version; the rest go back to the fork's own coverage, which compiled and passed on main. Also filled in the interfaces the merged bodies already used: HookResult.outputTruncated, FileBackupEntry.unreadable, IWorkspaceDirs in WorkspaceRootSkillSource, IHostTimers in McpManagementService, plus bun:test imports for the 42 test-global errors.
7723qqq
pushed a commit
to 7723qqq/kimi-code
that referenced
this pull request
Nov 5, 2026
7723qqq
pushed a commit
to 7723qqq/kimi-code
that referenced
this pull request
Nov 5, 2026
Filled the last mechanical gaps: known symbol imports (IHostTimers, isWorkDirKey, loadAgentsMdForRoots, the subagent-backend helpers), node:path/node:fs/node:stream imports in hostProcessService, and the duplicate appendBytes my earlier hand-add left beside upstream's.
7723qqq
pushed a commit
to 7723qqq/kimi-code
that referenced
this pull request
Nov 5, 2026
7723qqq
pushed a commit
to 7723qqq/kimi-code
that referenced
this pull request
Nov 5, 2026
Finishes the source side of the migration:
- program.ts: ProgramDependencies gains docs/workspaceStore, the
trust-disclosure call passes workdir.dirs, and the generation no longer
keeps a lease field upstream does not have
- programWorkdirs: WorkspaceDirsService and WorkspaceRootSkillSource
called with this fork's signatures (dirs injected, workspaceStore not)
- hostFsService: rename implemented on the concrete backend
- workspaceFs: the environment lease takes EnvironmentBinding
({environmentId}) rather than the old workspaceId/runtimeId pair
- subagentService, runHook, hostFsErrors, projectLocalConfigService,
fsHandler, mediaReadContext: imports, interfaces and duplicate keys
7723qqq
pushed a commit
to 7723qqq/kimi-code
that referenced
this pull request
Nov 5, 2026
Test imports remapped onto the environment layer (14 files): the runtimeBinding/runtime module paths and the Runtime*/IAgentRuntime* identifier families.
7723qqq
pushed a commit
to 7723qqq/kimi-code
that referenced
this pull request
Nov 5, 2026
Replaced the six test files MoonshotAI#4062 rewrites with upstream's versions and converted them to bun:test, then cleared the duplicate imports and the node-local module paths those files still carried.
7723qqq
pushed a commit
to 7723qqq/kimi-code
that referenced
this pull request
Nov 5, 2026
…cing them, 51 test errors left 2dd874c took upstream's os tools wholesale and dropped fork behavior: - powershellTool.ts was emptied (upstream has no such tool), so the fork's Windows-only PowerShell surface vanished; restored from main and renamed. - readTool.ts lost the inline media read (executeMediaRead) and the git-memory projection (withFileMemory); Read told users to call a ReadMediaFile that this fork does not register. - editTool.ts and writeTool.ts lost withFileMemory, and src/tool/realpath-access went to zero consumers, dropping the symlink write guard. - bashTool.ts lost its fragment-assembled description; grepTool.ts and workspaceInstanceManagerService.ts were rebuilt the same way. Every one of those files is now a three-way merge of main, the fork's merge-base with upstream (743f140), and upstream 5f3ab5f, so upstream's new shape (plan file targets, artifact targets, environment generation guard) and the fork's additions both survive. workspaceInstanceManagerService needed no merge: its only divergence is the runtime-provider plumbing that MoonshotAI#4062 replaces with the app-level environment service. Also cleared 35 test fixture errors: agentLifecycle (15), connection-manager (10), environmentGenerationGuard, rgUnavailableGuidance, powershellTool, read-media and the rest. vitest converts to bun through jest.fn<X>() so the generic declarations survive, and mock.module is used for partial module mocks with the untouched exports forwarded from the real module.
7723qqq
pushed a commit
to 7723qqq/kimi-code
that referenced
this pull request
Nov 5, 2026
…nt-core-v2 index.ts was the same shape of damage as the os tools: upstream's version replaced the fork's, so every shell-payload export, the host timers surface and the whole environmentBinding block disappeared from the package root while the engine itself still compiled. Restored through the same three-way merge against 743f140, keeping upstream's environment exports and the fork's host/ paths, shell payload and shell provision blocks. Downstream repairs the port had left behind: - vis: the wire payload imports for the turn, usage and hello-world records had been dropped while the record union still referenced them; restored from the contract entry point, and the record type now says environment.set_binding. - kap-server: transcriptContract's plan-review case had a duplicated body spliced into the end of its it.each block, which was a syntax error. - acp-server: a test case was missing its call terminator. agent-core-v2 tsc is 0; twelve of the fifteen workspaces typecheck.
7723qqq
pushed a commit
to 7723qqq/kimi-code
that referenced
this pull request
Nov 5, 2026
…oken Six workspaces now typecheck again: kap-server, klient, acp-server, vis-server, vis-web and node-sdk's source. kap-server: routes/fs.ts had two whole implementations spliced together (the runtime one and the environment one); the route set is identical, so upstream's is the file and the 243 extra lines were the runtime plumbing MoonshotAI#4062 removes. routes/runtime.ts goes with it — nothing registers it any more, registerApiV1 already calls registerEnvironmentRoutes. The protocol error table had lost AGENT_NOT_FOUND when RUNTIME_NOT_FOUND became ENVIRONMENT_NOT_FOUND, and the messages service had lost loadMessages' projections argument and its descendingIndex cursor helper. node-sdk: errors.ts had the engine's code table inlined and drifting, so it imports the local errors-codes table again; the config port had lost its local isPlainObject and HOOK_EVENT_TYPES copies; the v2 client's single-line engine import was missing the type markers verbatimModuleSyntax requires, and named V2Error2/V2ErrorCodes/V2SessionSummary, which the engine never exported. vis: the record union still referenced the turn, usage and hello-world payloads after their imports were dropped, and the wire renderer had two identical environment.set_binding entries because runtime.set_binding had been renamed onto it.
7723qqq
pushed a commit
to 7723qqq/kimi-code
that referenced
this pull request
Nov 5, 2026
apps/kimi-code carried 733 errors, 34 files of which were fork-owned CLI and TUI files that the bulk landing had half-merged: their import blocks were truncated even though upstream never touched them. Restoring those from main took the count to 54; the rest were real wiring. Wiring that was actually missing: - node-sdk's package exports lost ./catalog, ./config-mapper, ./errors, ./logging, ./proxy and ./runtime, so the CLI's provider and runtime imports could not resolve, and errors.ts no longer re-exported removeProviderFromConfig. - createProgram had no --environment / --environment-cwd, so CLIOptions' required field had no producer; the exec-server subcommand was missing too, which is why the new exec-server test could not reach a handler. - KimiTUI lost refreshEnvironmentSlot and resolveApprovalEnvironment, the two SessionEventHost members the environment footer needs. Both are restored on the surfaces node-sdk already exposes (Session.getEnvironmentState). - the engine's Event union dropped BackgroundTaskOutputEvent and TodoUpdatedEvent while both are still emitted, which broke the SDK's exhaustive event switch.
7723qqq
pushed a commit
to 7723qqq/kimi-code
that referenced
this pull request
Nov 5, 2026
Lint's 50 errors were mostly unused imports the merge left behind, but four were lost code hiding behind an unused symbol: - fileHistory's readCurrent had lost its retry: a transiently unreadable file gave up on the first attempt, leaving FILE_HISTORY_READ_ATTEMPTS dead. - the external-hooks runner passed its callbacks but dropped the failClosed flag, so a fail-closed trigger no longer failed closed. - rootFileSkillSource computed its watch signature before the per-workdir watch set existed, so a newly added source folder never replaced the watchers — exactly what f4d52de's signature was there to catch. - workspaceFs spawned an rg process in both suggestWithRg and grepWithRg and never used it, because the port moved the run to runRg. Also: node-sdk's build-dts passed an inline regex where main passes workspaceSpecifierRe, which left the generated d.ts pointing at source files and made api-extractor refuse them; check-import-boundaries still whitelisted os/backends/node-local for the remote executor; the locale scripts still listed apps/kimi-inspect, removed in a660e12, and check:t-coverage needed the new os.fs.directory_too_large entry in both locales. Verified: 23 workspace typechecks, 12 check:* scripts, oxlint --type-aware with 0 errors, and all 26 workspace builds pass.
7723qqq
pushed a commit
to 7723qqq/kimi-code
that referenced
this pull request
Nov 5, 2026
Findings behind the failures, in the order they mattered: - workspaceService.createOrTouch swallowed every stat failure and went on to create a workspace whose root did not exist. The ENOENT/ENOTDIR branch is back, so a broken root is rejected with fs.path_not_found again. - Read's resolveExecution lost the empty-path guard when the signature took upstream's async form, so an empty path reached the path-access layer and threw a PathSecurityError instead of answering with a tool error. - task persistence read the whole output log to learn its size before every append, which defeated the ranged tail read the snapshot path exists for. The snapshot also sliced the preview at a raw byte offset, so a multi-byte character straddling the limit came out half-decoded; both now share the aligned ranged read. - runHook's allowResult dropped outputTruncated, so a timed-out hook's truncation flag reached the caller as undefined; fireAndForgetTrigger lost its fail-open catch entirely; and triggerInner no longer forwarded failClosed, so a fail-closed trigger silently stopped failing closed. - fileHistory compared paths with a case fold but no separator fold, so on Windows a tracked 'C:/…' key never matched a 'C:\…' lookup and contentAt answered undefined for a checkpoint it had recorded. - The plan service grew todo/blob/host-environment dependencies; the guard fixture now stubs them. Test adaptations: the ported Read test asserts upstream's always-emit status note and its 500k cap, so Read now follows upstream there (the fork's whole-file suppression and 100k cap are gone, one snapshot in toolExecutor updated to match); the eight Read cases that assert the pre-merge 'use ReadMediaFile' refusal are dropped because this fork reads media inline and test/agent/media/read-media covers it; media/config/registry fixtures gained the fields the ported services now read.
7723qqq
pushed a commit
to 7723qqq/kimi-code
that referenced
this pull request
Nov 5, 2026
- The workspace-MCP and mcp-management fixtures built their fake environment with the posix path module while pointing at a real Windows temp dir, so every stdio connect spawned with a cwd of '/kimi-code/.../C:\...' and failed. They now take the host path class, and the MCP suites are green. - The rg JSON accumulator deduped on the path rg reported, so an overlapping ancestor root's 'src/a.ts' and '/repo/src/a.ts' counted as two files and one consumed a max_files slot that belonged to another match. It now keys on the resolved absolute path, keeping the first spelling for the response. - The subagent-spawn fixture gained the environment binding and acquireWhenReady the ported spawn path reads.
7723qqq
pushed a commit
to 7723qqq/kimi-code
that referenced
this pull request
Nov 5, 2026
subagentService computed {parentAgentId, subagentDepth} and then passed
opts.labels to agentLifecycle.create, dropping both: every spawned child lost
its parent pointer and its depth stamp. test/session/subagent/spawn.test.ts is
green again.
The engine suite now fails only in test/tool/tool.test.ts (the caller handle a
bare harness agent exposes does not resolve IAgentEnvironmentBindingService, so
every 'Agent tool execution contract' spawn aborts before create),
test/program/program.test.ts (remote workdir instructions read as empty),
test/wire/persistence.test.ts (corruption repair) and one fsService node-fallback
case.
7723qqq
pushed a commit
to 7723qqq/kimi-code
that referenced
this pull request
Nov 5, 2026
…n to 4 - test/tool/tool.test.ts: the hand-built agent-lifecycle stub a bare harness agent exposes had no IAgentEnvironmentBindingService, so all 41 'Agent tool execution contract' cases aborted inside spawn before create. With the binding on the stub the file is 164/164. - test/wire/persistence.test.ts: draining a journal normalizes the metadata record to the current protocol/min-reader pair, so the two corruption-repair expectations now include min_protocol_version. - test/program/program.test.ts: the locality fixture's scoped fs compared prefixes with a literal '/', so on Windows every read of a 'C:/…' path threw not-found and AGENTS.md came back empty. It normalises separators now, and the fixture's realpath returns the slashed form so the symlink-escape check compares like with like.
7723qqq
pushed a commit
to 7723qqq/kimi-code
that referenced
this pull request
Nov 5, 2026
… (4 cases left)
The locality fixture handed the posix path module a native Windows cwd, so
every workdir key and fs path gained the shell's '/kimi-code/...' prefix and
the symlink-escape check rejected '.' for a workspace that plainly contained
it. The fixture now passes slash-normalised roots and compares context keys in
the same shape.
Still failing in that file: the four cases that call remote.fs.list({path:'.'})
— the workdir's own path module is posix while the cwd is a drive path, so
resolve() still prefixes it. Fixing that means running those workdirs under
win32 semantics, which hangs the local watcher in this harness; it is the next
thing to settle.
7723qqq
pushed a commit
to 7723qqq/kimi-code
that referenced
this pull request
Nov 5, 2026
test/program/program.test.ts is down to the four cases that call
remote.fs.list({path:'.'}); the remaining error is the fixture's own fake path
mapping: the workdir's path module is posix, so '.' resolves against a
drive-letter cwd and the scoped fs hands back a prefixed path the real fs then
resolves against another drive. Running those workdirs under win32 semantics is
the fix, but it hangs the local watcher in this harness, so it needs the watcher
path looked at first.
test/workspace/workspaceFs/fsService.test.ts is down to the node fallback not
walking additional roots.
7723qqq
pushed a commit
to 7723qqq/kimi-code
that referenced
this pull request
Nov 5, 2026
kap-server carried 18 failures; the largest group was mine: I had taken
upstream's routes/fs.ts wholesale, and upstream has no git_status:batch,
pull_request or pull_request:batch actions, which are this fork's PR-badge
surface — every one of those answered VALIDATION_FAILED. The three actions,
their handlers and their schemas are back.
The rest of the file-level fixes:
- routes/fs.ts and routes/workspaceFs.ts request schemas are .strict() again;
defineRoute asserts that at import time, so a loose schema was a load-time
crash for the whole package rather than a test failure.
- The fs route tests built symlinks directly, which Windows refuses without a
privilege; they go through the junction fallback helper the file already had.
- The environment_id query param replaced runtime_id in the download URL, and
two cases now skip where Windows cannot express the condition (chmod 000).
- fs:suggest has no environment override any more, so its 'unknown runtime'
case is gone.
- workspaceService.createOrTouch defers root validity to the first binding
again: kap-server's newer cases (a remote root need not exist locally) are
the contract, and the two agent-core cases now assert the deferred shape.
- apiSurface snapshot regenerated for GET /sessions/{id}/cron.
7723qqq
pushed a commit
to 7723qqq/kimi-code
that referenced
this pull request
Nov 5, 2026
7723qqq
pushed a commit
to 7723qqq/kimi-code
that referenced
this pull request
Nov 5, 2026
…roots too The rg path hands ripgrep every root, but the fallback walked only the working directory, so a registered source folder was invisible whenever rg was missing. It walks each additional root and reports those hits by absolute path; absOf() keeps an absolute reported path as it is.
7723qqq
pushed a commit
to 7723qqq/kimi-code
that referenced
this pull request
Nov 5, 2026
…erver entry Everything the full-port merge left red is now green, and the last structural pieces the port skipped are in place. Engine - `dedupeByRoot` keeps one record per root but unions `additionalDirs` onto the survivor. A managed `wm_` workspace and the `wd_` alias `createOrTouch` created for the same root were being collapsed to the alias, so a session opened in a registered workspace never saw its source folders. - `WorkspaceDirsService.reloadFromRegistry` prefers the merged list record over a raw `get()` of the same id, so the union above actually reaches the session. - `SessionLifecycleService.fork` no longer rejects a running turn: the precheck the rebuild reintroduced was removed and the dispatcher/log flushes moved back inside the try, after the history holds — the shape `b5a059fbf4` shipped and the running-fork body needs. SDK - `Session.steer` / `promptWithSkills` are `async` again: a validation failure has to reject the returned promise like `prompt`/`swarm`, not throw synchronously past a caller's `.catch`. - `KimiError` tolerates a code this build does not know. Dereferencing `KIMI_ERROR_INFO[code]` crashed on exactly the drift the fallback path exists for: an error produced by a newer engine. TUI - `prompt.completed` with reason `blocked`/`failed` releases that prompt's steer, so an entry the engine rejected stops rendering as pending for the rest of the session. CLI - `src/main.ts` is the light entry again: it dispatches the SSH askpass helper and `exec-server` before the heavy CLI loads, and reaches the CLI through a dynamic import. The previous body moved to `src/cli/main.ts`, `getVersion` and its package lookup split out to `cli/version-info.ts` so the executor path imports no OAuth or i18n module, and the hidden `exec-server` subcommand is wired instead of falling through to the default no-op. Test hygiene - `mappingHostFs` (shared by the kap-server fs suites) maps a POSIX environment path onto a host directory and normalises the realpath it returns; the remote fixtures declare the host's path class instead of pairing posix path ops with a Windows filesystem, and separator-only assertions compare on `/`. - Declared remote environments require a POSIX cwd and a POSIX target, so those fixtures are POSIX-host only; the loopback command environment no longer needs `tsx` (absent from the tree) and spawns Bun instead. - Leftover `from 'vitest'` imports and vitest-only matchers became `bun:test` ones, which is what `scan:residue` requires. Verified: typecheck 23/23; oxlint 0 errors; check:lint, check:no-comments, check:no-hardcoded-prose(+counts), check:locale-keys, check:locale-placeholders, check:t-coverage, check:status-surface-i18n, check:prompt-ownership, check:service-mapping, check:strict-request-bodies, check:deep-imports, check:boundaries, check:catalog-versions, check:git-memory, check:nix-workspace all green; build 26/26 and the built bundle answers `--version` and an `exec-server` initialize frame. Suites: agent-core-v2 8415 pass / 93 skip (pooled idle-reclaim timeout is contention, green alone), kap-server 1314 / 14 skip, node-sdk 321 / 11 skip, klient 118 / 35 skip, acp-server 177, apps/kimi-code 5049 / 22 skip.
7723qqq
pushed a commit
to 7723qqq/kimi-code
that referenced
this pull request
Nov 5, 2026
… it blocked The full remote-environment port landed with 4166ca3, so MoonshotAI#4062 is `ported` with the evidence that closes it out: 29 port commits, typecheck 23/23, the fifteen check gates, a 26/26 build whose bundle answers `--version` and an `exec-server` initialize frame, and every suite green (agent-core-v2 8415, kap-server 1314, node-sdk 321, klient 118, acp-server 177, apps/kimi-code 5049). Three rows were parked behind it and now have their prerequisites: - MoonshotAI#4600 (legacy ACP session file tools) — `IAgentEnvironmentBindingService` and `IEnvironmentService` are exported from the engine root, `start.ts` constructs `RemoteEnvironmentProviderFactory`, and the provider registration block the repair edits exists. - MoonshotAI#4649 (TUI footer/welcome on the session environment) — the engine half landed in 2fa7b6b; the missing piece was the session workdir, which now carries the environment cwd. - MoonshotAI#4543 (remote file round trips) — every remote file it changes exists; the batched walk methods it adds are still absent from `methods.ts`. All three move from `blocked`/`in_progress` to `pending`; none is ported. Ledger: closed 68 -> 69, remaining 31 -> 30.
7723qqq
pushed a commit
to 7723qqq/kimi-code
that referenced
this pull request
Nov 5, 2026
…environment Port of upstream MoonshotAI/kimi-code 75f35b3253 (MoonshotAI#4649), completing the half that waited on the MoonshotAI#4062 remote environments. The footer ran git and gh on the local machine, so a remote-bound session hid the git badge entirely, and the welcome panel always printed the local work dir. Both now read through the session's own environment: - The SDK gains `getGitStatus` / `getGitPullRequest` on `SDKRpcClientBase`, `SDKRpcClientV2` (a live session's workdir on its environment, else the workspace instance for the directory) and `KimiHarness`, typed by `GitQueryInput` / `GitStatusSummary` / `GitPullRequest`. - The footer takes a `FooterGitBinding` whose source reads through that SDK and keys its cache by session and work dir only, so a transient disconnect keeps the last badge and the footer re-reads once the environment is ready again. - `createGitStatusCache` gained a `source` path: it skips local spawning and local repo probing, but still polls HEAD for a local work tree so branch switches stay instant. - The welcome panel shows the binding cwd when the session runs somewhere else. `GitService` now resolves local `git` and `gh` through PATH and refuses a match inside the working directory. A bare name is looked up in the cwd first on Windows, and the footer reads git status at startup, before the trust gate. Local-form notes: the upstream "Ready." startup row does not exist in this TUI, so its removal has no counterpart; `resolveProgramPath` already folded case on Windows from the earlier port; the cache keeps the fork's dependency seam, so the existing local-spawn tests still cover that path unchanged. Verified: apps/kimi-code and node-sdk typecheck clean, node-sdk 321 pass, git and footer/welcome suites green (a new footer case renders a remote badge and proves the cache is not rebuilt across a disconnect; a new welcome case proves the remote cwd replaces the local one), agent-core-v2 git suite 13 pass, check:no-comments, check:deep-imports, check:boundaries, check:locale-keys and check:t-coverage green. The full app suite is green apart from `flag-locale-coverage`, which demands en/zh entries for the `associative_memory` flag an adjacent untracked workstream added to the engine registry. Ledger: MoonshotAI#4649 ported; closed 71 -> 72, remaining 28 -> 27.
7723qqq
pushed a commit
to 7723qqq/kimi-code
that referenced
this pull request
Nov 5, 2026
Ports the docs half of upstream MoonshotAI/kimi-code 8b6a003 (MoonshotAI#4673): the 2.5.0 section from the upstream release notes lands in both changelogs, en and zh, word for word. Every feature the section names is in this tree - busy /model and /effort (MoonshotAI#4621), merged project-level skills (MoonshotAI#4520), remote sessions in SSH, Docker and custom-command environments (MoonshotAI#4062), [workspace] require_trust (MoonshotAI#4517), web search off by default (MoonshotAI#4516), and the subagent model pool (MoonshotAI#4418) - so the notes describe what the fork actually does. Deliberately not touched: apps/kimi-code/CHANGELOG.md still tops out at 2.4.1 and package.json still says 2.4.1. That file is generated by `changeset version`, this tree has 377 pending changesets, and AGENTS.md forbids running version or publish from this repository, so the entry is written on the docs side only. Whoever next cuts a release here should reconcile this section with what changeset version generates rather than re-deriving it by hand.
7723qqq
pushed a commit
to 7723qqq/kimi-code
that referenced
this pull request
Nov 14, 2026
Restore the upstream MoonshotAI#4062 guard in /feedback: a remote-bound session drops the codebase option and prints the scan-locally hint, because the scanner reads this machine's filesystem rather than the remote one.
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.
Requirement or Bug
创建会话时可把 agent 绑定到 SSH / Docker / 自定义命令环境,SSH 支持进程内密码认证兜底(#3856 的 phase 1,不含会话内切换环境)。
Bug Reproduction Steps
N/A
Root Cause
N/A
Code Changes
SSH 密码兜底(要求 OpenSSH 8.4+):
不在本 PR:会话内切换环境、
/environment管理器、项目级环境配置、密码持久化、OTP/MFA 与私钥口令。Behavior Changes and Affected Users
[environments].default、--environment或 session-create 参数绑定远端[environments]配置无效config.invalid(ACP 仍先以 local 初始化)localPermission deniedonSshPasswordRequired;Esc 取消KIMI_CODE_SSH_ASKPASS_PORT与_TOKEN同时存在时进入 helper_pi序列 / 布局空格可能多显示•/provider用户kimi-file://;注册失败拒绝发送runtime_idruntime_idruntime.set_binding记录跳过runtime_id的客户端(已知仅 kimi-inspect,已同步)远程会话(新功能)要点:
/reload时重读;同 (environmentId, cwd) 的会话共享 workdir。disconnected,下次工具调用重连;/new与会话内新建 agent 继承环境与 cwd。本地默认会话不变:根 workdir 构建方式与此前相同,profile 可见集合不变。
测试:
agent-core-v2:program.test.ts(workdir 共享、刷新、回收)、agentLifecycle.test.ts(继承与显式覆盖)、sessionMetadata.test.ts(远程创建、恢复、fork)。launchers.test.ts、providerFactory.test.ts、session.test.ts(真实 askpass helper)、run-shell.test.ts、api-key-input-dialog.test.ts。kap-server环境与会话 fs 路由;sdk-rpc-client-v2.test.ts远程会话 profile 隔离。kap-server/test/sessions.test.ts的child.exitCode时序断言在基线同样复现。Checklist
gen-changesetsskill:remote-environments.md、windows-remote-targets.md;旧 runtime API 删除经维护者确认。gen-docsskill:中英文远程环境指南、配置与 server API 文档。