mirror of
https://github.com/MoonshotAI/kimi-code.git
synced 2026-12-04 04:46:03 +00:00
1721 commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
68a2838941
|
fix(agent-core-v2): keep the prompt cache through auto compaction (#4456)
* fix(agent-core-v2): only pre-shrink compaction history when the request overflows the window The pre-shrink budget (~0.74 of the window) sat below the auto-compaction trigger (min(0.85W, W-50k)), so every auto compaction on windows above ~195k dropped the oldest messages and broke the prompt-cache prefix. Gate pre-shrinking on the real input limit (window minus output reserve) and keep the safety budget as the shrink target. * fix(agent-core-v2): pin degraded media to the count captured at the 413 Media degradation recomputed 'keep the 2 most recent' on every request, so each new image after a 413 replaced an older kept image and broke the prompt-cache prefix. Record how many leading media were degraded when the provider rejected the request, re-capture only when an inherited degraded request is rejected again with more than 2 visible media, and drop the prompt-cache guard's tolerance for rolling degradation. * feat(agent-core-v2): probe compaction prompt cache prefixes * chore: drop duplicate degraded media changeset * fix(agent-core-v2): report prefix loss after compaction shrinks history * fix(agent-core-v2): clamp compaction completion budget to the remaining window Sending the full history leaves less room than the configured output cap, so pass the estimated request size as usedContextTokens and let the provider clamp max_tokens to the window that is actually left. * Delete .changeset/fix-compaction-pre-shrink-cache.md Signed-off-by: 7Sageer <sag77r@hotmail.com> --------- Signed-off-by: 7Sageer <sag77r@hotmail.com> |
||
|
|
e2ad1dcf21
|
feat: support symlinked directories in file tree (#4457)
Some checks failed
CI / test (5) (push) Has been cancelled
CI / test-pi-tui (push) Has been cancelled
CI / test-vscode-legacy (push) Has been cancelled
CI / test-windows (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / test (3) (push) Has been cancelled
CI / test (4) (push) Has been cancelled
CI / release-workflow-tests (push) Has been cancelled
CI / build (push) Has been cancelled
CI / test (1) (push) Has been cancelled
CI / test (2) (push) Has been cancelled
CI / typecheck (push) Has been cancelled
Nix Build / Check flake.nix workspace sync (push) Has been cancelled
Nix Build / nix build .#kimi-code (push) Has been cancelled
* feat: support symlinked directories in file tree * docs: document symlinked directory support * fix: address symlink file tree review feedback * fix: address remaining symlink file tree review feedback * fix: limit symlink expansion without capping ordinary listings * fix: scope symlink budget and workspace list contract * fix: provide default git status for workspace listing * fix: isolate symlink budget from ordinary traversal * fix: detect symlinks across root path prefixes * fix: detect symlinked workspace root prefixes |
||
|
|
78b72fe456
|
fix(kap-server): apply swarm mode from prompt submissions (#4460)
Co-authored-by: kimi-agent-bot <kimi-agent-bot@users.noreply.github.com> |
||
|
|
39d149eb64
|
fix(agent-core-v2): answer questions without edits and clean up test leftovers (#4450)
* fix(agent-core-v2): answer questions without edits and clean up test leftovers Let the request type decide the deliverable in Delivering work: change requests (including "can you add..." questions) get the change, while questions, explanations, and discussions get an answer that leaves the project untouched. Diagnosis requests find the cause before naming it, separate confirmed facts from hypotheses, and apply a fix only when asked. Before replying after running tests or builds, check for new files and delete the logs and test output those commands created when the task does not need them, without touching files the agent did not create. * chore: drop changesets for the delivery prompt change * fix(agent-core-v2): scope delivery rules by request type and keep files of unclear origin |
||
|
|
3154ec41f0
|
fix(agent-core-v2): scope verification to the change and stop repeating passed checks (#4451)
* fix(agent-core-v2): scope verification to the change and stop repeating passed checks The delivery verification rule in the default system prompt applied to every turn, required the project's standard build and test commands regardless of what changed, and had no point at which checking stops. After compaction, the summary prefix also told the agent to re-verify everything the summary reported as done or passed, contradicting the system prompt's instruction not to redo work the summary reports as done. - Apply the build-and-test requirement to changes, and only to the standard build and test commands that cover the change; keep verifying the deliverable itself with real calls. - Once those checks pass, repeat or broaden them only for a new change, a failure, or an unresolved concern. - After compaction, rely on what the summary reports as done or passed and re-check only what it marks as unverified. - Have the compaction summary mark a passed check as unverified when the code it covers changed afterwards. * fix(agent-core-v2): report unrelated failures instead of fixing them The red-tests rule in the delivery paragraph applied to any failing test, and nothing said what to do with bugs or broken tests the change did not cause. Read literally, a pre-existing failure left the agent two options: fix code outside the task or never call the work complete. - Only tests that cover the change keep the work from being marked complete. - Do not attempt to fix unrelated bugs or broken tests; mention them in the final message instead. - Drop the changeset; this PR ships without one. |
||
|
|
979304401c
|
feat: add independent dev release channel (#4425) | ||
|
|
461c6e92d5
|
feat(kap-server): push approvals and questions as interaction frames (#4428)
* feat(kap-server): push approvals and questions as interaction events
Replace event.approval.* / event.question.* with a single volatile
interaction event carrying the draft Interaction shape. Every subscriber
of a session receives it, including interactions raised by sub-agents
whose transcripts are subscribed. After each subscribe ack the server
sends the session's pending interactions to that connection, so clients
rebuild their list on (re)subscribe instead of relying on journal replay.
Map engine-cancelled questions to cancelled instead of answered.
* docs: describe the interaction event in the server API reference
* chore: add changeset for the interaction event
* feat(kap-server): flatten interaction frames and unify the response route
Send `interaction` as a flat, unsequenced frame `{ type, session_id, agent_id,
event_created_at, interaction_id, kind, status, ... }` outside the event
envelope, add approval `expires_at`, and register the frame in the WS schema
and AsyncAPI document.
Replace `POST /sessions/{sid}/approvals/{id}`, `POST /sessions/{sid}/questions/{id}`
and `:dismiss` with `POST /sessions/{sid}/interactions/{id}`, whose body is
discriminated by `kind` and whose result is `{ outcome, ended_at }`; dismissing a
question now succeeds with code 0. Error codes become 40404 (interaction not
found), 40902 (interaction ended) and 40001 (kind mismatch).
* chore: update the interaction changeset for the unified response route
* feat(kap-server): remove the pending approval and question list routes
Pending interactions now reach clients only through the interaction frames
sent after each subscribe ack, so drop GET /sessions/{sid}/approvals and
GET /sessions/{sid}/questions with their schemas, docs and harness helpers.
The wire helpers still used by the WS broadcaster and the snapshot route move
to protocol/interaction-wire.ts.
* chore: note the removed list routes in the interaction changeset
* fix(transcript): require the engine cancellation shape for cancelled interactions
* refactor(kap-server): derive interaction outcomes in one place
|
||
|
|
d18a7bcd31
|
chore: sync release/2026-10-26 (2.3.3) back to main (#4453)
* feat(agent-core-v2): add cross-process session occupancy lock (#4246) * feat(agent-core-v2): add cross-process session occupancy lock Multiple clients (TUI / kap-server / VS Code / ACP) running core in separate processes could open the same session and corrupt each other's wire.jsonl and metadata. Each session now holds a cross-process occupancy lock ({homeDir}/locks/sessions/{id}.lock) taken only while writing: runs acquire it on submit / compact / undo / cron / delete / fork / cold-archive, the append log holds it before flushing, and a stale check compares the main agent wire's on-disk length with the length this process knows. Collisions surface as session.occupied (holder in details); writes by another client detected after acquire surface as session.stale and the caller reloads before continuing. kap-server maps them to SESSION_OCCUPIED (40903) / SESSION_STALE (40930), reloads the session on stale, and re-attaches WS subscriptions; the TUI shows an occupancy dialog (retry/cancel) or reloads and replays history keeping the input; print exits with code 4 on occupied and reloads automatically on stale; VS Code / ACP get minimal occupancy notices. Locks are released a few seconds after the session goes idle, on close, and on process exit; locking I/O failures degrade to unlocked operation with a warning. * docs: document session occupancy error codes and lock directory * fix: address codex review on session occupancy lock - metadata: re-read state.json on the first write of each lock-hold epoch (holdToken), so pure-metadata changes made by another client (title, archive) are not clobbered by turn-end lastPrompt writes - lifecycle: hold an explicit lease across live archive(), matching delete(), so the idle release timer cannot drop the lock mid-teardown - tui: route the occupied dialog's Cancel selection through the same cleanup as Esc (restore input, release recalled media) - acp: tell stale-session users to close and reopen the session - append-log: warn when retirement drops records kept in memory because the session lock was unavailable * fix: always run the staleness check in beginSessionRun The prompt channels (AgentPromptChannel.submit/submitSteer, kap /prompts, promptWithSkills) write prompt metadata before calling loop.submit, and the metadata write acquires the session lock first. beginSessionRun then short-circuited on 'already held' and skipped the wire-length staleness check, so the main prompt path never detected updates written by another client. Drop the already-held shortcut: the check is a single stat and always passes while the lock is continuously held, so every acquisition path now runs it regardless of order. * fix(print): preserve occupied handling on the stale retry If another client acquires the session between the reload and the retry, the retried turn now goes through the same conflict handler: session.occupied reports to stderr / stream-json and exits with code 4 instead of bubbling out as exit code 1. * fix: do not mistake own in-flight writes for external modification storage.append grows the file (writeFile) before fsync/close complete, and knownLength only catches up afterwards; a beginSessionRun landing in that window (steer, queued prompts, cron fires during a turn) was misjudged as session.stale and deleted the lock file mid-turn. Track in-flight bytes per log and compare disk against known + in-flight. Cover the analogous rewrite window (post-rename syncDir) with an expected-final-length marker. * fix: bound the staleness comparison and check once per lock hold The equality check disk !== known + inFlight moved the false-positive window to before the append lands (mkdir/open) and into chunked writes, so beginSessionRun during a turn (steer, cron, queued prompts) could misjudge, delete the lock file mid-turn, and later append behind another client. Compare known <= disk <= known + inFlight instead, and evaluate the check only on a fresh hold (holdToken epoch): re-entrant runs pass through without a stat, matching the RFC's 'already held passes through' while every acquisition path still triggers the check exactly once per hold. Also unify the occupancy prompt copy across clients: the engine error message is now the single user-facing text ('该会话正在被其他 Kimi Code 进程使用;请停止其他进程中的会话或退出该进程后重试'), and the TUI dialog, /compact /undo errors, print output, and the VS Code fallback all display it instead of maintaining their own wordings. * fix: address third-round codex review - metadata: hold an explicit lease across each state.json write so the idle release timer cannot unlink the lock mid-write - print: preflight the session lock before goal creation; make goal creation idempotent and emit the goal summary only for attempts that did not fail with session.stale, so a stale reload + retry neither duplicates the goal nor the summary - tui: route every prompt-launch path (plain, goal steer, plugin command, inline skill, batch steer) through one conflict handler with the occupied dialog and stale reload + input restore - tui: snapshot and restore the attachment store across stale reloads so pasted media placeholders still resolve after history replay * fix: move session occupancy to a fresh error code, use English copy, release locks on exit SESSION_OCCUPIED reused 40903, which belonged to PROMPT_ALREADY_COMPLETED until #3747 retired it, and web clients still allowlist 40903 for that old meaning; reusing it conflated the two semantics. Move session occupancy to the never-used 40931 and update the server API reference in both locales. The occupied error message was hardcoded in Chinese while every other engine error is English, so the TUI, print mode, VS Code, and ACP clients all rendered mixed-language output; replace it with an English equivalent. The lock release hook ran on 'beforeExit', which never fires when the process leaves through process.exit (SIGHUP in the TUI goes through emergencyTerminalExit), leaving stale lock files that could keep a session looking occupied forever after a hostname change or pid reuse. releaseAll is fully synchronous, so hook 'exit' instead. * fix(agent-core-v2): decide prompt-derived titles after re-reading session metadata applyPromptMetadataUpdate decided whether to derive a title from the prompt from the in-memory metadata cache, which is only refreshed when the session lock is re-acquired. If another client named the session in the meantime, the stale cache still looked untitled, so the next prompt from this client overwrote the other client's title — both on the stale path, where the prompt is rejected afterwards, and on the fresh path, where the other client only changed the title on disk. Move the untitled check into SessionMetadata.applyPromptMetadata, which runs after ensureWriteOwnership() has re-read state.json, so the decision is based on the latest persisted metadata. The published SessionMetaUpdated event now carries the derived title only when it was actually written. * fix: address fourth-round codex review - vscode: classify session.occupied and session.stale as preflight errors so the webview toasts them instead of silently swallowing the send, and give session.occupied the same English copy the engine emits (the toast text comes from getUserMessage in the extension host). - engine: beginSessionRun now takes the session context and agent lifecycle service, and on the first check of each lock hold it runs externallyModified over every loaded agent's wire (scope agents/<agentId>, key wire.jsonl) instead of only the main agent's, so a fork that only touched a subagent journal is detected as stale. All four call sites (loop submit, manual compaction begin, undo, print preflight) pass the extra dependency. - tui: keep the request in flight across a stale reload instead of dropping to idle, so input submitted during the reload queues rather than racing the closing session; park the queue around switchToSession (resetSessionRuntime would clear it) and drain it into the reloaded session afterwards; when restoring the rejected text, prepend it before content the user typed during the reload instead of overwriting it. - kap-server: clear the in-flight turn tracker and subagent roster in detachSession so a reattached session no longer reports stale in-flight turns or running subagents in REST snapshots and WS resyncs. * fix: harden session conflict recovery Detect external appends that race journal reads so a later run cannot miss session.stale. Keep deferred wire migrations pending and finish them before appending, while rejecting the append if migration still cannot complete. Restore the complete plugin command after an occupied cancellation, including commands without arguments. * fix: scope session staleness cache to session context Replace the process-global session-id map with a WeakMap keyed by ISessionContext so closed and reloaded sessions do not retain cache entries for the lifetime of the process. * fix: document session conflicts for metadata routes Declare SESSION_OCCUPIED and SESSION_STALE in the response schemas for profile updates, title generation, and child creation. Cover the OpenAPI declarations and the existing HTTP 200 conflict envelopes with regression tests. * refactor: centralize session conflict handling Move session error mapping and stale reloads into one shared route helper, reuse shared conflict response declarations, and cover skill activation conflicts. Remove the duplicate prompt, session, and skill error mappers while preserving their existing envelopes. * fix(sdk): restate session conflict errors * fix(tui): keep the reloaded session open and resend after a stale conflict * fix(agent-core-v2): lazily rebuild registered agents after a session reload * refactor: simplify session conflict handling * refactor: hygiene fixes from session-lock review - kap-server: move SESSION_STALE to 40932 (collided with DEFAULT_WORKSPACE_UNAVAILABLE at 40930) and pin ErrorCode value uniqueness with a test - node-sdk: fold six catch-and-restate copies into a restate() helper - acp-server: sync mapPromptLaunchError docstring with the occupied/stale branches - replace hardcoded session.stale/session.occupied literals with ErrorCodes constants - inline the single-use sessionStaleError - restore the strict timer-leak assertion with a warmup baseline instead of a blanket +1 allowance - narrow SessionState.detached to ?: true * refactor: introduce session-level run gate - replace the beginSessionRun free function with ISessionRunGate, a Session-scoped service; loop/compaction/undo now inject one dependency instead of four, and sessionLock.ts no longer imports session-layer modules - tryHold() absorbs the duplicated try/catch hold copies in wireService and sessionMetadataService - resolve IAgentLifecycleService lazily inside the gate to avoid a construction-time cycle with agentLifecycleService * refactor: tighten session lock and conflict recovery structure - Narrow ISessionLockService to hold/tryHold/release/lease/held and share the hold bookkeeping between the memory and node-fs backends; drop holdToken and the module-level exit hook state. - Session metadata refreshes on a new hold via onDidHold and skips agent registration through tryHold instead of catching session.occupied. - AppendLogStore reads sizes through IFileSystemStorageService.sizeSync and exposes a generic write guard instead of a session-lock binding. - kap: reload stale sessions only at the call sites that can raise session.stale and log reload failures; error mapping stays side-effect free. - TUI: recover from a stale conflict through the in-place session reload with history replay, removing the same-session switch special case, the media store snapshot, and the queue parking. - print: bound stale reloads with a simple retry loop. * refactor(agent-core-v2): merge session lock release into run gate * test(agent-core-v2): reuse append log fixtures * refactor(agent-core-v2): break run gate and agent lifecycle dependency cycle * refactor: reload stale sessions in core instead of each host Stale detection already lived in core, but every host re-implemented the recovery: TUI, print, and kap each closed and resumed the session, and TUI and web resent the rejected input themselves. Core now exposes reloadOnStale: on session.stale it closes and resumes the session, lets the caller refresh, then retries the call once (undo reloads and still rejects, since its count depends on what the user saw). - kap: prompt submit, skill activation, and compact retry in place instead of returning 40932; undo still returns 40932 after reloading - print: retries through reloadOnStale on the same session id and keeps the original permission mode to restore - SDK: run-starting calls reload and retry internally; Session gains setStaleReloadHandler so hosts refresh before the retry - TUI: drops its own reload/resend/queue-merge path; the stale handler replays history and keeps in-flight messages * docs(server-api): note that only undo returns 40932 after a stale reload * refactor(agent-core-v2): ask each agent's wire whether it was modified externally * refactor(agent-core-v2): clarify agent restoration helper name * Delete .changeset/ensure-agent-lazy-rebuild.md Signed-off-by: 7Sageer <sag77r@hotmail.com> * fix(tui): wrap session occupied notice --------- Signed-off-by: 7Sageer <sag77r@hotmail.com> * revert: remove default workspace session creation (#4295) * chore: merge release/2026-10-20 into release/2026-10-21 (#4294) * feat(kap-server): add remote control device deletion (#4192) (#4195) * feat(kap-server): add remote control device deletion * fix(kap-server): coordinate with the local tunnel before deleting this machine's device Co-authored-by: liruifengv <liruifeng1024@gmail.com> * ci: enable recoverable publishing for the October release (#4218) * ci: publish core releases from isolated release branches * ci: simplify release recovery to the CLI package * ci: publish VS Code from approved release commits * test: await release test registration for type-aware lint * test: avoid assuming order of independent tower events * ci: limit release migration to existing publishing flow * chore: sync web dist from code-app (#4221) * chore: sync web dist from code-app code-app: f828bac439ab5b9266ff8387c2afb96ecfcb59ae * ci: retrigger (flaky rpc-events teardown ENOTEMPTY) --------- Co-authored-by: kimi-agent-bot <kimi-agent-bot@users.noreply.github.com> * ci: release packages (#4220) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * feat(tui): queue /compact behind the running turn (#4276) * feat(tui): queue /compact behind the running turn * docs: note /compact queueing while the agent is busy * fix(tui): harden queued /compact edge cases - keep /compact blocked while a compaction holds the turn (busy reason normalized to compacting) - treat the first queued /compact as a FIFO barrier for Ctrl-S manual steer - gate the failed-fire retry timer on the session actually going idle * fix(tui): cover remaining /compact queue review edges - advertise Ctrl-S in the queue pane only for items ahead of the compact barrier - queue /compact when the awaited lazy session creation lands on a running turn - document the auto-compaction skip for queued /compact in docs and the changeset * fix(tui): guard queued /compact against concurrent compactions - requeue without firing when another compaction already started (the SDK's begin() swallows this as a silent no-op; declared residual window needs the contract to expose the result) - restore the input when a duplicate /compact is refused after lazy session creation * fix(tui): render requeued /compact and mark it always available in docs - request a render after restoring a compact item to the queue so it does not appear vanished during backoff - the reference table's availability column now matches the queueing behavior (/compact is accepted during streaming and runs in order) * fix(tui): steer messages ahead of a queued /compact automatically The automatic (tower/WaitFor) steer batch now slices at the first queued /compact just like the manual path, so pre-barrier prompts still end a WaitFor promptly instead of being blocked by an unrelated compact item. Batches containing bash or skill items ahead of the barrier keep their existing all-or-nothing semantics. * test(tui): drive the tower steer barrier case through the WaitFor event path * chore: downgrade the /compact queue changeset to patch (#4279) * feat: add cloud-gated model switch confirmation (#4286) * feat(cli): add cloud-gated model switch confirmation dialog * feat(server): expose named client_configs endpoint for cloud-controlled clients * fix(server): keep broadcasting compaction events to transcript subscribers * Revert "fix(server): keep broadcasting compaction events to transcript subscribers" This reverts commit e489915bd8bf753033f982ce1b0845cea64c0784. * fix(cli): address review findings on the model switch confirmation * test(cli): fix the auth-flow gate test typing * fix: close the login-path holes in the model switch gate - install the refreshed model catalog before matching the cloud rule, so an alias introduced by /login no longer bypasses the confirmation - return 'gated' from refreshConfigAfterLogin and forward the picked effort to the dialog; setDefaultModel skips its follow-up activation while the gate owns the switch - ignore Escape once a dialog action was chosen so the input lock survives the new-session creation * fix: keep displaced panels alive when the new-session switch settles The async finalizer of a settled dialog action now only restores the editor while the model-switch dialog still owns the editor replacement, so an approval or question panel mounted over it is never wiped out with its reverse-RPC request still pending. * feat: support id lists and always-fresh model switch confirmation configs (#4292) * feat: accept id lists in model switch confirmation rules * feat: fetch client configs fresh on every request The /client_configs endpoint now proxies the cloud per request instead of serving a copy cached at server startup, so config changes take effect without a server restart. The startup warm-up and the in-memory store are removed; region is resolved per request. --------- Co-authored-by: qer <wbxl2000@outlook.com> Co-authored-by: Kimi Agent <zhangkaiyi@moonshot.ai> Co-authored-by: kimi-agent-bot <kimi-agent-bot@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * chore: sync web dist from code-app (#4304) code-app: 913137036c35c608f3a487eb2c7b4a8815b53b95 Co-authored-by: kimi-agent-bot <kimi-agent-bot@users.noreply.github.com> * ci: release packages (#4288) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix: decouple workspace trust from runtime initialization (#4348) * fix(kap-server): decouple workspace trust from runtime initialization * fix: preserve workspace trust errors * fix: emit workspace trust recovery changes * fix: complete workspace trust recovery * fix(agent-core-v2): reclaim session locks from zombie processes (#4320) (cherry picked from commit |
||
|
|
4be3f0b741
|
fix(agent-core-v2): reconnect MCP servers automatically after transient failures (#4283)
- serialize per-server connection, probe, close, and OAuth transitions - retry transient startup and session failures with live backoff settings - persist failure episodes and expose retry timing across client contracts |
||
|
|
8dabf4a10e
|
fix(agent-core-v2): keep media recovery across turns and compaction (#4413)
Some checks are pending
CI / test-vscode-legacy (push) Waiting to run
CI / test-windows (push) Waiting to run
CI / lint (push) Waiting to run
CI / typecheck (push) Waiting to run
CI / release-workflow-tests (push) Waiting to run
CI / build (push) Waiting to run
CI / test (1) (push) Waiting to run
CI / test (2) (push) Waiting to run
CI / test (3) (push) Waiting to run
CI / test (4) (push) Waiting to run
CI / test (5) (push) Waiting to run
CI / test-pi-tui (push) Waiting to run
Nix Build / Check flake.nix workspace sync (push) Waiting to run
Nix Build / nix build .#kimi-code (push) Blocked by required conditions
* test(agent-core-v2): pin prompt-cache prefix parity across media recovery Add failing tests showing that requests after a media-degraded or media-stripped recovery do not extend the previous request's prefix: the next turn and compaction requests resend full media first, and a compaction request re-captures the strip snapshot, hiding media that the loop request still showed. * fix(agent-core-v2): keep media recovery across turns and compaction Media recovery after a provider rejection was keyed by turn id and only honored for turn requests, so the next turn and compaction requests resent full media, got rejected again, and re-captured the strip snapshot. Keep a single agent-level recovery keyed by model alias and context prefix revision, applied to every later request until the model changes or the history is rewritten. * fix(agent-core-v2): keep media recovery across turns and compaction * fix(agent-core-v2): recover new media and invalidate recovery on undo Keep the per-request strip retry budget separate from the inherited media snapshot so newly added media can recover from 413 and image-format rejections. Stop recapturing once this request has stripped its media or an inherited snapshot leaves no visible media. Advance the context prefix revision when context state is restored so undo invalidates media recovery without adding service dependencies. Cover later turns, automatic and manual compaction, bounded retries, and real prompt-to-undo flows for both degraded and stripped media. * test(agent-core-v2): guard prompt-cache prefix parity in the test harness Every harness agent now checks that the first attempt of each turn request (a new turn or a later step) and of each full compaction request extends the last successful turn request: same model profile fields (cache key, thinking, extra params, response format, tool message conversion), same system prompt, same tools unless the tool-name set changed, and a history prefix. Requests after a model switch or a context prefix rewrite are skipped, and media turned into the degraded placeholder at the same position is allowed while the request runs under media-degraded recovery. Violations fail the running test. Add an end-to-end case that runs a turn after media recovery so the next-turn check sees both degraded and stripped projections. * test(agent-core-v2): check stable prefix fields on every generate attempt Recovery retries were recorded as the next baseline without being compared. Compare profile fields, system prompt, and tools on every attempt, and only treat a same-position media replacement as a prefix when it is the degraded placeholder or a single media path tag. Count real comparisons so an unwired guard fails the media-recovery test. |
||
|
|
93137cad20
|
fix(agent-core-v2): return a stopped subagent's partial output to the parent agent (#4430)
A subagent run only wrote to its task output when it completed. When it was stopped (TaskStop, a user interrupt, or a cancelled parent turn), timed out, or failed, the parent agent saw a bare status and lost whatever the subagent had already written. runAgentTurn now collects the run's public assistant text from the child's AssistantDelta, TurnStepStarted and TurnStepRetrying events: current turn only, the text of retried step attempts dropped, kept to the most recent 32K characters on code point boundaries, and released once the run settles. The run handle exposes it through partialOutput(). SubagentTask writes that text to the task output, marked as incomplete, before settling a killed or failed task, and flushes it in forceStop when cancellation outlives the grace period. The output is written at most once, so a completion that arrives after a forced settle cannot append to it. TaskStop on an agent task now shows that output together with the agent_id, output_path and a resume hint, and still suppresses the terminal notification. A failed or cancelled foreground Agent call inlines the same block. When the subagent wrote nothing, both say so explicitly. No extra model request is made, and completion and cancellation semantics are unchanged. |
||
|
|
4ba6593202
|
docs(changelog): sync 2.3.3 from apps/kimi-code/CHANGELOG.md (#4445)
Co-authored-by: kimi-agent-bot <kimi-agent-bot@users.noreply.github.com> |
||
|
|
b3c6e0a75a
|
feat(tui): support OSC 7501 program status (#4347) | ||
|
|
2e539f2f68
|
fix(workspace): reclaim instances when last owner releases (#4422)
* fix(workspace): reclaim instances when last owner releases - hold reference-counted leases across sessions and temporary callers - await MCP and stdio process cleanup before rebuilding instances - restore persisted directories and clear ephemeral directories on reclamation * fix(workspace): bound MCP stdio termination - escalate stdio shutdown to SIGKILL after a bounded SIGTERM grace - cover workspace reacquisition while an uncooperative MCP is closing * fix(workspace): retain workspaces during MCP probes - hold the containing workspace lease until stdio probe shutdown completes - cover lease ordering across connection and shutdown |
||
|
|
70a661c873
|
fix(server): allow Shiki WASM in CSP (#4435)
Co-authored-by: kimi-agent-bot <kimi-agent-bot@users.noreply.github.com> Co-authored-by: qer <wbxl2000@outlook.com> |
||
|
|
f47400a418
|
fix(server): allow data and blob media fetches in CSP (#4434)
Co-authored-by: kimi-agent-bot <kimi-agent-bot@users.noreply.github.com> |
||
|
|
98c1cfbfbd
|
fix(agent-core-v2): close idle MCP OAuth callback connections (#4431) | ||
|
|
f7d28cd268
|
fix(agent-core-v2): drop empty OpenAI tool declaration messages (#4421) | ||
|
|
f70c365294
|
fix(tui): show compacting activity with working tips (#4346)
Some checks are pending
CI / release-workflow-tests (push) Waiting to run
CI / build (push) Waiting to run
CI / test (1) (push) Waiting to run
CI / test (2) (push) Waiting to run
CI / test (3) (push) Waiting to run
CI / test (4) (push) Waiting to run
CI / test (5) (push) Waiting to run
CI / test-pi-tui (push) Waiting to run
CI / test-vscode-legacy (push) Waiting to run
CI / test-windows (push) Waiting to run
CI / lint (push) Waiting to run
CI / typecheck (push) Waiting to run
Nix Build / Check flake.nix workspace sync (push) Waiting to run
Nix Build / nix build .#kimi-code (push) Blocked by required conditions
|
||
|
|
8df234a618
|
feat(tui): refine fullscreen docks and transcript cards (#4310) | ||
|
|
a9dc3a9af4
|
fix(agent-core-v2): stop stripping dynamic tool context from compaction requests (#4410)
The compaction request ran stripDynamicToolContext() before handing the history to the LLM requester, while loop requests only go through toolSelect.shapeHistory(). With tool select enabled and any deferred tool configured, this removed the loadable-tools announcement (and the tools field of loaded schema messages), so the compaction request diverged from the previous loop request early in the history and lost almost all prompt cache reuse. Drop the extra strip so both requests share the single shaping point in the LLM requester. Add a harness helper that reports the first prefix break between two provider-visible requests, and a compaction test matrix (tool select off / announced / schema loaded x manual / auto) asserting the compaction request extends the last loop request. Resolve #4389 |
||
|
|
eb1205c402
|
fix(agent-core-v2): truncate tool results on code point boundaries (#4365)
* fix(agent-core-v2): truncate tool results on code point boundaries Co-authored-by: ahyangyi <ahyangyi@gmail.com> * fix(agent-core-v2): cap accumulated tool output on a code point boundary Co-authored-by: ahyangyi <ahyangyi@gmail.com> * fix(agent-core-v2): saturate tool output accumulator after a retention cut Co-authored-by: ahyangyi <ahyangyi@gmail.com> * fix(agent-core-v2): apply code point boundaries to remaining tool-result truncation paths Review follow-ups: a) agentTool: truncateReason now slices the model-visible sub-agent stop reason via sliceOnCodePointBoundary so it cannot split a surrogate pair. No dedicated agentTool test home exists; the helper stays covered by the code-points tests only. b) taskService: readOutput clamps the tail length first and then moves the slice start to a code point boundary, so a tail window cannot begin with a lone low surrogate. Covered by a focused output-access test. c) toolResultTruncation test: verified the 1_983-'a' padding makes the 2000-14=1986 per-line cut land mid-pair — the case fails on the pre-fix service and passes on the fixed one, so no test change was needed (and this package forbids comments). d) code-points: suppress unicorn/prefer-code-point on the intentional charCodeAt calls. The helpers only avoid creating new mid-pair cuts and deliberately do not clean pre-existing lone surrogates in the input — the request-side sanitizer handles those. Co-authored-by: ahyangyi <ahyangyi@gmail.com> * fix(agent-core-v2): preserve full output for nonpositive task-output tails The code point boundary rewrite of readOutput changed the established tail=0 behavior: slice(-0) starts at zero and returned the entire output, while clamping the tail window to zero returned ''. Return the output unchanged when the requested tail truncates to zero (zero and negative tails alike), and pin the contract with a focused test. Co-authored-by: ahyangyi <ahyangyi@gmail.com> --------- Co-authored-by: kimi-agent-bot <kimi-agent-bot@users.noreply.github.com> Co-authored-by: ahyangyi <ahyangyi@gmail.com> Co-authored-by: kimi-agent-bot <317908118+kimi-agent-bot@users.noreply.github.com> |
||
|
|
4a24ae1238
|
feat: import Claude Code and Codex sessions (#4342)
* feat: add standalone session import conversion package * fix(session-import): address rollout and image review findings - Extend a rollback cutoff only over records that share a defined turn id. - Keep tool-call arguments verbatim instead of rewriting image-shaped values. - Keep media from an assistant projection that its matching response lacks. - Count unknown event and projection kinds as unrecognized source content. * feat(session-import): render imported history as visible messages Follow the Codex /import format: each source turn becomes an ordinary user message and one assistant message, tool calls and results become tagged text notes clipped to 2,000 and 4,000 characters, and thinking, source events and injected context stay only in the full history attachment. A final user notice records the source session, included turns, attachment paths and known limitations. Prefer a user-set title over later generated ones and fall back to the first prompt line, treat agent-name rows as metadata, stop reporting missing reasoning text, return EMPTY_SOURCE_HISTORY for sources without a prompt, and explain why forked or restarted Codex sessions are rejected. * feat: import Claude Code and Codex sessions Add /import-sessions and `kimi import-sessions`, which open the same page: scan recent Claude Code and Codex sessions, choose the last 15 days (the default) or 30 days, import the newest 100 with progress, and summarize what was imported and skipped. Reruns skip sessions imported before. Imported sessions are written into the workspace of their original folder with their title, last activity time, and synthesized turn records, using the migration-legacy session writer, and show a [Claude Code] or [Codex] badge in /sessions. Discovery lives in session-import and leaves out subagent, non-interactive, and prompt-less sessions. Sessions still being written are reported as in use, and fallback titles skip lines without letters or digits. * fix: list imported sessions in /sessions right away /import-sessions writes sessions straight to disk, which the running session index only noticed on its next periodic reconcile, so /sessions missed them until a restart or up to a minute later. Look each imported session up by id after the run so the index records it immediately. * fix(session-import): store each source record once in the full history Records without text of their own, such as titles, mode changes, and request dumps, were kept three times in the full history attachment: in a header list, as the step text, and again in the step's source metadata. Keep them only as the step text with the source line in the metadata, and do the same for unknown content blocks and unknown Codex response items. On local sessions the attachments shrink from 346 MB to 141 MB for 240 MB of source files. * feat(session-import): import the conversation as one framed user message Render the imported history as a single user message: a system note before and after it, session info, attachment locations, known limitations, and the included turns. Every tool call keeps the first 2,000 characters of its recorded input instead of three picked fields. The session list shows the last real prompt from the source. * fix(session-import): skip the Claude Code API request log Claude Code 2.1.300 and later write API request records into the session file. Their message copies were read as conversation records, which duplicated tool calls and results and wrote the request log into the full history attachment. * fix: fit session imports to the model and skip missing folders up front Size the imported message from the default model's input limit and keep it below the automatic compaction threshold, so continuing an imported session does not start with a compaction or an over-limit request. Sessions whose project folder no longer exists are left out when scanning, so they no longer take the newest-100 slots of every run. * fix(session-import): keep late-written parents and clean up titles Link a Claude Code record to its parent even when the parent was written after it, placing the parent first, instead of cutting the history there. Titles and last prompts skip IDE context ahead of the request and image reference lines. Codex tool search results and three recent Claude Code metadata records are no longer reported as unrecognized content. * fix(session-import): find the chain end and publish without hard links Take the last record that no other record names as its parent as the end of a Claude Code conversation, so a parent written after its child at the end of the file no longer hides the final prompt. On filesystems without hard links, publish attachments with an exclusive copy instead of failing the import. * fix: apply model overrides before sizing session imports Resolve the default model through its overrides, as the engine does, before taking its input limit, so an override that lowers the context size also lowers the import budget. * feat(session-import): keep a copy of the source session with each import Save the source session file in the import's attachments, minus Claude Code's API request log, together with its Claude Code folder of subagent transcripts and saved tool output, so history from before compaction and abandoned branches outlive the source files. The imported message says what the full history and the copy each hold, and clipped tool notes point to the full history. * feat(session-import): keep more of the source session in imports - Copy the rollouts of the subagent threads a Codex session spawned under source/subagents/. - Show what the user did during a turn (interruptions, slash commands, messages sent while the agent worked, Codex shell commands) as [user_event] notes. - Show the work recorded after a source compaction with its summary instead of dropping it. - Title Codex sessions with the thread name from Codex's state database. - Point omitted media and injected source context to the attachments that keep them. * fix(session-import): show what came before a prompt at the start of its turn - Show work and commands recorded before a turn's prompt at the start of that turn, including Codex work before the first prompt, instead of dropping them without a summary. - Wait up to 3 seconds for a Codex state database lock before falling back to the first prompt as the title. * fix(session-import): stop a Codex turn start from claiming earlier turns - When a turn starts, claim only the records written before it that can open a turn (user input and context), so a rollback no longer drops the previous turn's answer and tool work in sessions that mix records with and without turn ids. |
||
|
|
1011d8b63f
|
chore: sync release/2026-10-25 (2.3.2) back to main (#4387)
* fix(agent-core-v2): leave swarm mode to the user (#4384) * fix(agent-core-v2): leave swarm mode to the user AgentSwarm now runs only while swarm mode is on, and only the user can turn swarm mode on, so the model can no longer start a swarm by itself. - Reject AgentSwarm at resolve time while swarm mode is off and check again right before it runs; no subagents start and swarm mode stays off. - Stop AgentSwarm from entering swarm mode, reject the tool trigger, and ignore tool-triggered entries that older versions recorded on replay. - Skip the one-AgentSwarm-per-response veto while swarm mode is off so the other tools in that response still run. - Say in the AgentSwarm description and the swarm exit reminder that only the user can turn swarm mode on. - Update the tools and slash-command reference docs. * fix(transcript): ignore model-started swarm entries when folding history Swarm mode entries with the tool trigger come only from older versions, where the model started a swarm by itself. The engine already ignores them on replay, so a session that stopped mid-swarm resumes with swarm mode off. Folding history still marked swarm mode on from that entry, and no later status update turned it off, so the web UI kept showing swarm mode as on. Keep the swarm.enter marker in history, but leave meta.modes untouched for tool-triggered entries. # Conflicts: # packages/agent-core-v2/test/agent/fullCompaction/fullCompaction.test.ts # packages/agent-core-v2/test/agent/loop/loop.test.ts # packages/agent-core-v2/test/tool/tool.test.ts * fix(agent-core-v2): launch subagents only on explicit request (#4386) The main agent launched subagents on its own: the explore type told it to delegate any exploration needing more than three searches and to run several explore agents at once, the Agent description sold delegation, and the EnterPlanMode description sent plan mode to an explore subagent first. - Agent description: launch a subagent only when the user asks for one, or AGENTS.md, a skill, or a multi-agent mode the user turned on calls for it; agent type descriptions only pick a type once launching is authorized. - System prompt: state the same rule for Agent. - Drop the delegation nudges from the Agent and explore descriptions and from the EnterPlanMode description. - Swarm exit reminder: once swarm mode ends, handle the next request without subagents unless it asks for them. * ci: release packages (#4385) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * test(agent-core-v2): update snapshots and token expectations for merged prompt changes --------- Co-authored-by: kimi-agent-bot <kimi-agent-bot@users.noreply.github.com> Co-authored-by: Kai <me@kaiyi.cool> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> |
||
|
|
743f140978
|
docs(changelog): sync 2.3.2 from apps/kimi-code/CHANGELOG.md (#4388)
Some checks are pending
CI / test (1) (push) Waiting to run
CI / test (2) (push) Waiting to run
CI / test (3) (push) Waiting to run
CI / test (4) (push) Waiting to run
CI / test (5) (push) Waiting to run
CI / test-pi-tui (push) Waiting to run
CI / test-vscode-legacy (push) Waiting to run
CI / test-windows (push) Waiting to run
CI / lint (push) Waiting to run
CI / build (push) Waiting to run
CI / release-workflow-tests (push) Waiting to run
CI / typecheck (push) Waiting to run
Nix Build / Check flake.nix workspace sync (push) Waiting to run
Nix Build / nix build .#kimi-code (push) Blocked by required conditions
Co-authored-by: kimi-agent-bot <kimi-agent-bot@users.noreply.github.com> |
||
|
|
7ccac2b45b
|
fix(agent-core-v2): wait for MCP discovery before tool announcements (#4364)
Some checks failed
CI / release-workflow-tests (push) Has been cancelled
CI / build (push) Has been cancelled
CI / test (1) (push) Has been cancelled
CI / test (2) (push) Has been cancelled
CI / test (3) (push) Has been cancelled
CI / test (4) (push) Has been cancelled
CI / test (5) (push) Has been cancelled
CI / test-pi-tui (push) Has been cancelled
CI / test-vscode-legacy (push) Has been cancelled
CI / test-windows (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / typecheck (push) Has been cancelled
Nix Build / Check flake.nix workspace sync (push) Has been cancelled
Nix Build / nix build .#kimi-code (push) Has been cancelled
* fix(agent-core-v2): wait for MCP discovery before tool announcements * test(agent-core-v2): register MCP dependency in tool-select harness |
||
|
|
087db850e0
|
test: isolate cloud config in message flow tests (#4363) | ||
|
|
273ddb077a
|
feat(oauth): infer region for logged-out installs (#4311) | ||
|
|
f8925ab95e
|
chore: sync release/2026-10-23 (2.3.1) back to main (#4361)
* fix: decouple workspace trust from runtime initialization (#4348) * fix(kap-server): decouple workspace trust from runtime initialization * fix: preserve workspace trust errors * fix: emit workspace trust recovery changes * fix: complete workspace trust recovery * fix(agent-core-v2): reclaim session locks from zombie processes (#4320) (cherry picked from commit |
||
|
|
fc31d047cb
|
docs(changelog): sync 2.3.1 from apps/kimi-code/CHANGELOG.md (#4360)
Co-authored-by: kimi-agent-bot <kimi-agent-bot@users.noreply.github.com> |
||
|
|
0325b755db
|
feat(agent-core-v2): leave Plan mode to the user and review every plan (#4247)
Some checks are pending
CI / release-workflow-tests (push) Waiting to run
CI / build (push) Waiting to run
CI / test (1) (push) Waiting to run
CI / test (2) (push) Waiting to run
CI / test (3) (push) Waiting to run
CI / test (4) (push) Waiting to run
CI / test (5) (push) Waiting to run
CI / test-pi-tui (push) Waiting to run
CI / test-vscode-legacy (push) Waiting to run
CI / test-windows (push) Waiting to run
CI / lint (push) Waiting to run
CI / typecheck (push) Waiting to run
Nix Build / Check flake.nix workspace sync (push) Waiting to run
Nix Build / nix build .#kimi-code (push) Blocked by required conditions
* feat(agent-core-v2): leave Plan mode to the user and review every plan Plan mode becomes a user-controlled mode: the model no longer has a tool to enter it, and every plan waits for the user's review before plan mode ends, including in Never Ask mode. - Remove the EnterPlanMode tool, its default approval and its telemetry event, and drop both plan tools from the coder and Tower worker profiles. - Review ExitPlanMode in every permission mode, and keep plan mode active when the plan could not be shown for review. - Tell the main agent that only the user can turn plan mode on, and to answer plan-first or approach questions with a recommendation before changing code. - Rework the plan-mode reminders and the ExitPlanMode description: plans lead with context and list verification steps and assumptions; questions are limited to what the code cannot answer; in auto mode open decisions are recorded as assumptions. - Stop the exit reminder from implying that a plan was approved after the user turns plan mode off. - Make kimi -p skip default_plan_mode and refuse to resume a session that is still in plan mode. - Update the Never Ask copy, the goal and swarm start dialogs, and the docs. * chore: merge the plan mode changesets into one * fix(agent-core-v2): never wait for a person in non-interactive runs kimi -p declares the host non-interactive, but approvals and questions still queued for a person with no timeout. Print mode only avoided this because auto mode never asked. Plan reviews now ask in auto mode too, so a subagent left in Plan mode by an older version made kimi -p wait for a review nobody could give. Approvals now resolve at once in non-interactive hosts and are never treated as approved: a plain approval denies the call, the plan review keeps Plan mode on and tells the agent not to retry, and AskUserQuestion returns that nobody can answer. * fix: say that plans still wait for review in Never Ask copy and docs The goal and swarm start dialogs, the /auto tip, the VS Code Auto mode copy and the reference docs still promised that Never Ask never interrupts. Plans in Plan mode now wait for review in every permission mode, so these surfaces name that exception. The agents page also no longer says that coder subagents can enter Plan mode. * test(agent-core-v2): pin how bindings recorded with EnterPlanMode resume Sessions created before EnterPlanMode was removed keep their recorded system prompt and tool list. Resuming one keeps that prompt, keeps ExitPlanMode usable for user-started Plan mode, and answers an EnterPlanMode call with a not-found error. * fix(agent-core-v2): keep Plan mode on the main agent only Only the user can turn Plan mode on, and every user-side switch targets the main agent. Subagents in sessions from older versions could still be restored in Plan mode, because they used to enter it themselves through EnterPlanMode. In the TUI their plan review popped up while the main agent was not in Plan mode, and a subagent whose tool list lacked ExitPlanMode could not leave Plan mode at all. The plan state now ignores plan mode entries from any agent but the main one, live and on replay, and entering Plan mode for a subagent fails. Restored subagents simply continue their work. * fix: let kimi -p run sessions that are still in Plan mode kimi -p refused to resume a session that was in Plan mode, so a session that any older version could run in print mode now failed with exit 1. Nobody can review a plan in print mode, but the run does not need to stop: the plan review already returns at once in non-interactive runs. A resumed session in Plan mode now runs as usual and stays in Plan mode. The run can only update the plan, which waits for review the next time the session is opened interactively, and stderr says so up front. * chore: rewrite the plan mode changeset * fix: stop promising that Plan-mode print runs are read-only The note for a resumed Plan-mode session said the run could only update the plan, but Plan mode blocks only Write and Edit outside the plan file. Bash and delegated work follow the permission mode, as they do in interactive Never Ask. The note, the docs and the changeset now state what is guaranteed: the plan cannot be approved in print mode and waits for review. * fix(agent-core-v2): let the agent answer in text while Plan mode is on Every Plan-mode reminder told the agent to end each turn with AskUserQuestion or ExitPlanMode, and in auto permission mode only with ExitPlanMode, so even a plain question in Plan mode was supposed to end in a question or a plan review. A planning turn still ends with one of the two, but a message that calls for an answer rather than a plan, such as a question about the code, now gets a text answer, and Plan mode stays on until the user approves a plan or turns it off. The Plan-mode note in the system prompt now keeps only the facts and the user's intent: only the user can turn Plan mode on, and when they ask to plan first, the agent waits for their go-ahead before changing code. It no longer treats every question about how to approach a task as a reason to stop, and no longer prescribes the shape of the reply. In non-interactive runs, the plan review and AskUserQuestion results now only state that nobody can review or answer, and that Plan mode stays on for the rest of the run, instead of telling the agent what to do next. * test: pin that every plan waits for review across modes and hosts Plan reviews now run in every permission mode, so pin the cases where a regression would most likely slip through: - yolo mode, allow rules for ExitPlanMode, and an earlier approval for the whole session do not skip the review of the next plan; - in Never Ask, kap-server surfaces the review as a pending plan_review approval over REST and in the transcript, and approving, revising and dismissing it leave Plan mode in the expected state; - kimi -p keeps stream-json stdout parseable when the resumed session is still in Plan mode; - the reminder sent after leaving Plan mode only carries out a plan the user approved. |
||
|
|
01ef64ea92
|
feat(tower): improve concurrency, locking, and per-spawn model selection (#4312)
* fix(tower): remove fixed agent concurrency cap * perf(tower): parallelize mission status processing * fix(tower): shrink state lock critical sections * fix(tower): preserve lock exclusion and completion idempotency * fix(tower): serialize stale lock reclamation * fix(tower): canonicalize reaper lock identity * fix(tower): clarify dependency merge ordering * feat(tower): allow per-spawn model selection * fix(tower): simplify lock configuration and dependency prompts * fix(tower): cap default agent concurrency at 256 * fix(tower): fall back when hard links are unavailable * fix(tower): use bounded backoff for prepared commits * fix(tower): serialize inbox publication with completion --------- Co-authored-by: konghuanjun <konghuanjun@moonshot.ai> |
||
|
|
759958afdf
|
fix(agent-core-v2): update import-from-cc-codex for current Claude Code and Codex layouts (#4331)
Some checks are pending
CI / release-workflow-tests (push) Waiting to run
CI / build (push) Waiting to run
CI / test (1) (push) Waiting to run
CI / test (2) (push) Waiting to run
CI / test (3) (push) Waiting to run
CI / test (4) (push) Waiting to run
CI / test (5) (push) Waiting to run
CI / test-pi-tui (push) Waiting to run
CI / test-vscode-legacy (push) Waiting to run
CI / test-windows (push) Waiting to run
CI / lint (push) Waiting to run
CI / typecheck (push) Waiting to run
Nix Build / Check flake.nix workspace sync (push) Waiting to run
Nix Build / nix build .#kimi-code (push) Blocked by required conditions
* fix(agent-core-v2): update import-from-cc-codex for current Claude Code and Codex layouts Honor CLAUDE_CONFIG_DIR and CODEX_HOME, import project CLAUDE.md, CLAUDE.local.md, Claude rules, Codex AGENTS.override.md, and Claude project-local MCP servers, and map the current Claude Code and Codex MCP fields. Stop scanning .claude/AGENTS.md, .codex/AGENTS.md, and .codex/skills, which neither tool reads. * fix: preserve imported instructions and server settings * fix(agent-core-v2): keep placeholder examples literal in import-from-cc-codex The skill renderer substitutes argument and KIMI placeholders anywhere in a skill body, so the migration guidance reached the model with the session ID and a builtin path in place of the Kimi placeholder names, and invocation arguments were spliced into the prose. Name the placeholders without their literal forms and pin the rendered body in a test. --------- Co-authored-by: qer <wbxl2000@outlook.com> |
||
|
|
79a76ea2da
|
refactor: remove unused session terminal service (#4333)
* refactor: remove unused session terminal service The terminal_* WebSocket controls lost their dispatch when the v1 connection was rewritten, so terminals could be created over REST but never attached, written to, or resized. No client uses them: the web UI has no terminal and the desktop app runs its own native PTY. Remove the REST routes, WebSocket schemas, meta capability, error code, session terminal service, host PTY backend, runtime terminal capability, and the node-pty dependency. * chore: update nix pnpmDeps hash after node-pty removal |
||
|
|
44cdf8f403
|
feat(tui): allow expanding streaming thinking (#4322) | ||
|
|
4c5d7d5e27
|
chore: upgrade to TypeScript 7 (native compiler) (#4329)
* chore: upgrade to TypeScript 7 (native compiler) - typescript 6.0.2 -> 7.0.2, tsdown 0.22.0 -> 0.23.1 (peer range now allows typescript ^7) - CI typecheck uses the workspace tsc (native) instead of the frozen @typescript/native-preview beta snapshot - product entry-points test spawns the tsc binary; the JS compiler API no longer ships with typescript - check-no-comments.mjs pins typescript-legacy (TS6) for AST access Co-authored-by: chengluyu <2239547+chengluyu@users.noreply.github.com> * chore: align remaining typescript pins and refresh the nix pnpmDeps hash - apps/kimi-inspect and apps/vis/web pin their own typescript; bump to 7.0.2 (sherif multiple-dependency-versions) - flake.nix fetchPnpmDeps hash tracked the old lockfile; recompute for the new one (fixes nix build) Co-authored-by: chengluyu <2239547+chengluyu@users.noreply.github.com> * test(product): fail loudly when the tsc subprocess cannot run runTsc only scanned output text; a missing native binary, a timeout, or a spawn failure would yield empty diagnostics and the boundary checks would pass vacuously. Assert the spawn error and exit status first. Co-authored-by: chengluyu <2239547+chengluyu@users.noreply.github.com> --------- Co-authored-by: kimi-agent-bot <kimi-agent-bot@users.noreply.github.com> Co-authored-by: chengluyu <2239547+chengluyu@users.noreply.github.com> |
||
|
|
e7f1a99fc5
|
feat: let users take over a session lock left by an exited process (#4328)
* feat: let users take over a session lock left by an exited process
Session locks judged alive by mistake (a different hostname, pid reuse, or a failed process-state probe) blocked the session with no way out. Add a takeover path: the lock service evicts another process's lock, the SDK exposes Session.takeOverLock(), kap-server adds POST /api/v1/sessions/{id}:takeover, and the TUI offers Take over once a retry is still occupied. KIMI_CODE_SESSION_LOCK=0 turns the lock off for a process.
* fix(agent-core-v2): evict the lock directly on takeover
Takeover went through the reclaim marker, so a stale marker left by a crashed reclaimer on another host made takeover a silent no-op while the API reported success. Unlink the lock file directly instead.
* fix(agent-core-v2): surface takeover failures when the lock cannot be removed
Takeover swallowed unlink errors, so a lock file another user owns in a shared sticky directory was reported as taken over while the next retry stayed occupied. Ignore only ENOENT and let other errors reach the caller. Also fix the run gate test bootstrap stub typing.
* fix(tui): simplify the session takeover copy
* fix(tui): tie the takeover warning to the takeover action
* fix(tui): drop the holder line from the takeover dialog
* refactor(tui): move the session occupancy dialogs into a controller
|
||
|
|
874d9abb32
|
feat: add /provider refresh subcommand (#4316)
Some checks are pending
CI / test-vscode-legacy (push) Waiting to run
CI / test-windows (push) Waiting to run
CI / lint (push) Waiting to run
CI / typecheck (push) Waiting to run
CI / release-workflow-tests (push) Waiting to run
CI / build (push) Waiting to run
CI / test (1) (push) Waiting to run
CI / test (2) (push) Waiting to run
CI / test (3) (push) Waiting to run
CI / test (4) (push) Waiting to run
CI / test (5) (push) Waiting to run
CI / test-pi-tui (push) Waiting to run
Nix Build / Check flake.nix workspace sync (push) Waiting to run
Nix Build / nix build .#kimi-code (push) Blocked by required conditions
|
||
|
|
0a90e2e8a2
|
fix(agent-core-v2): reclaim session locks from zombie processes (#4320) | ||
|
|
366fafbf92
|
feat(kap-server): reclaim idle sessions (#4284)
* feat(kap-server): reclaim idle sessions * test: trim idle session reclaim test duplication * test: fix idle reaper fake typing * fix(kap-server): preserve session state during idle reclaim * fix(kap-server): resume cold sessions for tool routes * fix(kap-server): report failed WS session resumes * refactor(agent-core-v2): let features declare session idle retention Move the cron, goal, and lifecycle-hook reclaim guards out of SessionManager into a SessionRetentionContribution collection that each feature contributes, check retention once under the session lease, and drop the dead optional task-service branches in the tasks route. * refactor(agent-core-v2): measure session idle from the activity view * refactor(agent-core-v2): reclaim idle sessions silently instead of retaining hooked sessions * fix(kap-server): only resume explicitly requested sessions in tool routes * refactor(agent-core-v2): inline the cron idle-reclaim guard and stop retaining active goals * fix(kap-server): reject invalid idle reclaim timeouts * fix(kap-server): preserve rating evaluation across idle reclaim * test(kap-server): trim idle reclaim tests * fix(kap-server): validate idle reclaim config early * refactor(agent-core-v2): rename the reclaim resume source and derive lifecycle literal unions * refactor(agent-core-v2): keep the reclaim lifecycle tags off the public lifecycle interface * fix(agent-core-v2): drop the reclaim marker once a session is archived * Implement session unload after 30 minutes of idle time Updated session management to unload sessions after 30 minutes of inactivity for both web and desktop applications. Signed-off-by: 7Sageer <sag77r@hotmail.com> * fix(agent-core-v2): reclaim sessions with exited terminals --------- Signed-off-by: 7Sageer <sag77r@hotmail.com> |
||
|
|
256ce61f0c
|
perf(agent-core-v2): speed up large session resume (#4313) | ||
|
|
4bad441fef
|
chore: sync release/2026-10-21 (2.3.0) back to main (#4306)
* ci: release packages (#4288) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * revert: remove default workspace session creation (#4295) (cherry picked from commit |
||
|
|
95eeeecf9b
|
docs(changelog): sync 2.3.0 from apps/kimi-code/CHANGELOG.md (#4305)
* docs(changelog): sync 2.3.0 from apps/kimi-code/CHANGELOG.md * docs(changelog): drop VS Code 0.8.3 entry from 2.3.0 CLI changelog --------- Co-authored-by: kimi-agent-bot <kimi-agent-bot@users.noreply.github.com> |
||
|
|
67325c1b25
|
fix(transcript): realign rebuilt turn ordinals to wire ids and mark wedged turns (#4280)
Some checks are pending
CI / release-workflow-tests (push) Waiting to run
CI / build (push) Waiting to run
CI / test (1) (push) Waiting to run
CI / test (2) (push) Waiting to run
CI / test (3) (push) Waiting to run
CI / test (4) (push) Waiting to run
CI / test (5) (push) Waiting to run
CI / test-pi-tui (push) Waiting to run
CI / test-vscode-legacy (push) Waiting to run
CI / test-windows (push) Waiting to run
CI / lint (push) Waiting to run
CI / typecheck (push) Waiting to run
Nix Build / Check flake.nix workspace sync (push) Waiting to run
Nix Build / nix build .#kimi-code (push) Blocked by required conditions
* fix(transcript): realign rebuilt turn ordinals to wire ids and mark wedged turns Cold transcript rebuilds numbered materialized turns 0..N while the live projector assigns ordinal=wireId, so a session rebuilt after a restart got a shifted axis that no longer aligned with what clients had cached live, and a turn whose loop died before writing a terminal event was rebuilt as a fake completed turn with no timestamps. foldWireRecordFacts now reassigns every matched rebuilt turn to its wire turn id (leaving holes for folded turns), restores startedAt from the agent.turn.started / turn.prompt records, and marks a turn with no terminal event as wedged (state failed + wedged flag) once a later turn prompt exists in the wire; the tail turn is only wedged when it is not the live active one. The live projector closes the previous running turn as wedged when a new turn starts. The wedged marker is an additive optional field so released clients keep parsing transcripts and render the turn as failed. * feat(agent-core-v2): surface silent notification-delivery and persistence failures The wedged-turn incident showed a main agent loop can stall for hours with zero diagnostics: task notifications pooled in memory, a latched or hung wire flush swallowed every subsequent record, and the running turn produced no watchdog output. - AppendLogStore warns once when an append is accepted while a storage failure is latched, and warns when a flush stays pending past 30s (repeating every 10min) with scope/key/pending counts. - WireService routes append failures to ILogService in addition to onUnexpectedError so they land in the daemon log. - AgentLoopService arms a per-turn watchdog that warns after 10min without observable progress (steps, streaming partials, machine phase), including pending notification/pause/queue state; loop.notify and nudge consumption log buffered/drained counts at debug level. - AgentTaskService warns when lifecycle guards silently drop task notifications or terminal events, and debug-logs in-process redelivery suppression. - EventDispatcherService warns once per episode when dispatch is stuck for over 30s and events keep queueing behind it. * test(agent-core-v2): quiesce the spawned notification turn before counting leaked timers With the loop turn watchdog armed, a notification-driven turn that happens to be running at the assertion holds a legitimate interval, making the global timer count scheduling-dependent. Cancel any spawned turn and pump the clock until the loop is idle before counting. * chore: add changeset for the wedged-turn transcript fix |
||
|
|
3079e9515f
|
feat(agent-core-v2): add cross-process session occupancy lock (#4246)
* feat(agent-core-v2): add cross-process session occupancy lock
Multiple clients (TUI / kap-server / VS Code / ACP) running core in
separate processes could open the same session and corrupt each
other's wire.jsonl and metadata. Each session now holds a cross-process
occupancy lock ({homeDir}/locks/sessions/{id}.lock) taken only while
writing: runs acquire it on submit / compact / undo / cron / delete /
fork / cold-archive, the append log holds it before flushing, and a
stale check compares the main agent wire's on-disk length with the
length this process knows.
Collisions surface as session.occupied (holder in details); writes by
another client detected after acquire surface as session.stale and the
caller reloads before continuing. kap-server maps them to
SESSION_OCCUPIED (40903) / SESSION_STALE (40930), reloads the session
on stale, and re-attaches WS subscriptions; the TUI shows an occupancy
dialog (retry/cancel) or reloads and replays history keeping the input;
print exits with code 4 on occupied and reloads automatically on stale;
VS Code / ACP get minimal occupancy notices. Locks are released a few
seconds after the session goes idle, on close, and on process exit;
locking I/O failures degrade to unlocked operation with a warning.
* docs: document session occupancy error codes and lock directory
* fix: address codex review on session occupancy lock
- metadata: re-read state.json on the first write of each lock-hold
epoch (holdToken), so pure-metadata changes made by another client
(title, archive) are not clobbered by turn-end lastPrompt writes
- lifecycle: hold an explicit lease across live archive(), matching
delete(), so the idle release timer cannot drop the lock mid-teardown
- tui: route the occupied dialog's Cancel selection through the same
cleanup as Esc (restore input, release recalled media)
- acp: tell stale-session users to close and reopen the session
- append-log: warn when retirement drops records kept in memory because
the session lock was unavailable
* fix: always run the staleness check in beginSessionRun
The prompt channels (AgentPromptChannel.submit/submitSteer, kap
/prompts, promptWithSkills) write prompt metadata before calling
loop.submit, and the metadata write acquires the session lock first.
beginSessionRun then short-circuited on 'already held' and skipped the
wire-length staleness check, so the main prompt path never detected
updates written by another client. Drop the already-held shortcut: the
check is a single stat and always passes while the lock is continuously
held, so every acquisition path now runs it regardless of order.
* fix(print): preserve occupied handling on the stale retry
If another client acquires the session between the reload and the
retry, the retried turn now goes through the same conflict handler:
session.occupied reports to stderr / stream-json and exits with code 4
instead of bubbling out as exit code 1.
* fix: do not mistake own in-flight writes for external modification
storage.append grows the file (writeFile) before fsync/close complete,
and knownLength only catches up afterwards; a beginSessionRun landing
in that window (steer, queued prompts, cron fires during a turn) was
misjudged as session.stale and deleted the lock file mid-turn. Track
in-flight bytes per log and compare disk against known + in-flight.
Cover the analogous rewrite window (post-rename syncDir) with an
expected-final-length marker.
* fix: bound the staleness comparison and check once per lock hold
The equality check disk !== known + inFlight moved the false-positive
window to before the append lands (mkdir/open) and into chunked
writes, so beginSessionRun during a turn (steer, cron, queued prompts)
could misjudge, delete the lock file mid-turn, and later append behind
another client. Compare known <= disk <= known + inFlight instead, and
evaluate the check only on a fresh hold (holdToken epoch): re-entrant
runs pass through without a stat, matching the RFC's 'already held
passes through' while every acquisition path still triggers the check
exactly once per hold.
Also unify the occupancy prompt copy across clients: the engine error
message is now the single user-facing text ('该会话正在被其他 Kimi
Code 进程使用;请停止其他进程中的会话或退出该进程后重试'), and the
TUI dialog, /compact /undo errors, print output, and the VS Code
fallback all display it instead of maintaining their own wordings.
* fix: address third-round codex review
- metadata: hold an explicit lease across each state.json write so the
idle release timer cannot unlink the lock mid-write
- print: preflight the session lock before goal creation; make goal
creation idempotent and emit the goal summary only for attempts that
did not fail with session.stale, so a stale reload + retry neither
duplicates the goal nor the summary
- tui: route every prompt-launch path (plain, goal steer, plugin
command, inline skill, batch steer) through one conflict handler
with the occupied dialog and stale reload + input restore
- tui: snapshot and restore the attachment store across stale reloads
so pasted media placeholders still resolve after history replay
* fix: move session occupancy to a fresh error code, use English copy, release locks on exit
SESSION_OCCUPIED reused 40903, which belonged to PROMPT_ALREADY_COMPLETED until #3747 retired it, and web clients still allowlist 40903 for that old meaning; reusing it conflated the two semantics. Move session occupancy to the never-used 40931 and update the server API reference in both locales.
The occupied error message was hardcoded in Chinese while every other engine error is English, so the TUI, print mode, VS Code, and ACP clients all rendered mixed-language output; replace it with an English equivalent.
The lock release hook ran on 'beforeExit', which never fires when the process leaves through process.exit (SIGHUP in the TUI goes through emergencyTerminalExit), leaving stale lock files that could keep a session looking occupied forever after a hostname change or pid reuse. releaseAll is fully synchronous, so hook 'exit' instead.
* fix(agent-core-v2): decide prompt-derived titles after re-reading session metadata
applyPromptMetadataUpdate decided whether to derive a title from the
prompt from the in-memory metadata cache, which is only refreshed when
the session lock is re-acquired. If another client named the session in
the meantime, the stale cache still looked untitled, so the next prompt
from this client overwrote the other client's title — both on the stale
path, where the prompt is rejected afterwards, and on the fresh path,
where the other client only changed the title on disk.
Move the untitled check into SessionMetadata.applyPromptMetadata, which
runs after ensureWriteOwnership() has re-read state.json, so the
decision is based on the latest persisted metadata. The published
SessionMetaUpdated event now carries the derived title only when it was
actually written.
* fix: address fourth-round codex review
- vscode: classify session.occupied and session.stale as preflight errors so the webview toasts them instead of silently swallowing the send, and give session.occupied the same English copy the engine emits (the toast text comes from getUserMessage in the extension host).
- engine: beginSessionRun now takes the session context and agent lifecycle service, and on the first check of each lock hold it runs externallyModified over every loaded agent's wire (scope agents/<agentId>, key wire.jsonl) instead of only the main agent's, so a fork that only touched a subagent journal is detected as stale. All four call sites (loop submit, manual compaction begin, undo, print preflight) pass the extra dependency.
- tui: keep the request in flight across a stale reload instead of dropping to idle, so input submitted during the reload queues rather than racing the closing session; park the queue around switchToSession (resetSessionRuntime would clear it) and drain it into the reloaded session afterwards; when restoring the rejected text, prepend it before content the user typed during the reload instead of overwriting it.
- kap-server: clear the in-flight turn tracker and subagent roster in detachSession so a reattached session no longer reports stale in-flight turns or running subagents in REST snapshots and WS resyncs.
* fix: harden session conflict recovery
Detect external appends that race journal reads so a later run cannot miss session.stale. Keep deferred wire migrations pending and finish them before appending, while rejecting the append if migration still cannot complete. Restore the complete plugin command after an occupied cancellation, including commands without arguments.
* fix: scope session staleness cache to session context
Replace the process-global session-id map with a WeakMap keyed by ISessionContext so closed and reloaded sessions do not retain cache entries for the lifetime of the process.
* fix: document session conflicts for metadata routes
Declare SESSION_OCCUPIED and SESSION_STALE in the response schemas for profile updates, title generation, and child creation. Cover the OpenAPI declarations and the existing HTTP 200 conflict envelopes with regression tests.
* refactor: centralize session conflict handling
Move session error mapping and stale reloads into one shared route helper, reuse shared conflict response declarations, and cover skill activation conflicts. Remove the duplicate prompt, session, and skill error mappers while preserving their existing envelopes.
* fix(sdk): restate session conflict errors
* fix(tui): keep the reloaded session open and resend after a stale conflict
* fix(agent-core-v2): lazily rebuild registered agents after a session reload
* refactor: simplify session conflict handling
* refactor: hygiene fixes from session-lock review
- kap-server: move SESSION_STALE to 40932 (collided with
DEFAULT_WORKSPACE_UNAVAILABLE at 40930) and pin ErrorCode value
uniqueness with a test
- node-sdk: fold six catch-and-restate copies into a restate() helper
- acp-server: sync mapPromptLaunchError docstring with the
occupied/stale branches
- replace hardcoded session.stale/session.occupied literals with
ErrorCodes constants
- inline the single-use sessionStaleError
- restore the strict timer-leak assertion with a warmup baseline
instead of a blanket +1 allowance
- narrow SessionState.detached to ?: true
* refactor: introduce session-level run gate
- replace the beginSessionRun free function with ISessionRunGate, a
Session-scoped service; loop/compaction/undo now inject one
dependency instead of four, and sessionLock.ts no longer imports
session-layer modules
- tryHold() absorbs the duplicated try/catch hold copies in
wireService and sessionMetadataService
- resolve IAgentLifecycleService lazily inside the gate to avoid a
construction-time cycle with agentLifecycleService
* refactor: tighten session lock and conflict recovery structure
- Narrow ISessionLockService to hold/tryHold/release/lease/held and share
the hold bookkeeping between the memory and node-fs backends; drop
holdToken and the module-level exit hook state.
- Session metadata refreshes on a new hold via onDidHold and skips agent
registration through tryHold instead of catching session.occupied.
- AppendLogStore reads sizes through IFileSystemStorageService.sizeSync and
exposes a generic write guard instead of a session-lock binding.
- kap: reload stale sessions only at the call sites that can raise
session.stale and log reload failures; error mapping stays side-effect free.
- TUI: recover from a stale conflict through the in-place session reload with
history replay, removing the same-session switch special case, the media
store snapshot, and the queue parking.
- print: bound stale reloads with a simple retry loop.
* refactor(agent-core-v2): merge session lock release into run gate
* test(agent-core-v2): reuse append log fixtures
* refactor(agent-core-v2): break run gate and agent lifecycle dependency cycle
* refactor: reload stale sessions in core instead of each host
Stale detection already lived in core, but every host re-implemented the
recovery: TUI, print, and kap each closed and resumed the session, and TUI
and web resent the rejected input themselves.
Core now exposes reloadOnStale: on session.stale it closes and resumes the
session, lets the caller refresh, then retries the call once (undo reloads
and still rejects, since its count depends on what the user saw).
- kap: prompt submit, skill activation, and compact retry in place instead
of returning 40932; undo still returns 40932 after reloading
- print: retries through reloadOnStale on the same session id and keeps the
original permission mode to restore
- SDK: run-starting calls reload and retry internally; Session gains
setStaleReloadHandler so hosts refresh before the retry
- TUI: drops its own reload/resend/queue-merge path; the stale handler
replays history and keeps in-flight messages
* docs(server-api): note that only undo returns 40932 after a stale reload
* refactor(agent-core-v2): ask each agent's wire whether it was modified externally
* refactor(agent-core-v2): clarify agent restoration helper name
* Delete .changeset/ensure-agent-lazy-rebuild.md
Signed-off-by: 7Sageer <sag77r@hotmail.com>
* fix(tui): wrap session occupied notice
---------
Signed-off-by: 7Sageer <sag77r@hotmail.com>
|
||
|
|
5fec8d19a5
|
test(remote-control): split the tunnel end-to-end case and make transfer limits injectable (#4290)
Co-authored-by: kimi-agent-bot <317908118+kimi-agent-bot@users.noreply.github.com> |
||
|
|
ce0834a8f3
|
feat: share session rating rules across CLI and server (#4272) | ||
|
|
5710c5496a
|
fix(kap-server): evict session event state on session close and archive (#4281)
Some checks are pending
CI / release-workflow-tests (push) Waiting to run
CI / build (push) Waiting to run
CI / test (1) (push) Waiting to run
CI / test (2) (push) Waiting to run
CI / test (3) (push) Waiting to run
CI / test (4) (push) Waiting to run
CI / test (5) (push) Waiting to run
CI / test-pi-tui (push) Waiting to run
CI / test-vscode-legacy (push) Waiting to run
CI / test-windows (push) Waiting to run
CI / lint (push) Waiting to run
CI / typecheck (push) Waiting to run
Nix Build / Check flake.nix workspace sync (push) Waiting to run
Nix Build / nix build .#kimi-code (push) Blocked by required conditions
|
||
|
|
e5e56bc5fe
|
feat(server): place the default workspace under the home folder (#4277)
Some checks are pending
CI / release-workflow-tests (push) Waiting to run
CI / build (push) Waiting to run
CI / test (1) (push) Waiting to run
CI / test (2) (push) Waiting to run
CI / test (3) (push) Waiting to run
CI / test (4) (push) Waiting to run
CI / test (5) (push) Waiting to run
CI / test-pi-tui (push) Waiting to run
CI / test-vscode-legacy (push) Waiting to run
CI / test-windows (push) Waiting to run
CI / lint (push) Waiting to run
CI / typecheck (push) Waiting to run
Nix Build / Check flake.nix workspace sync (push) Waiting to run
Nix Build / nix build .#kimi-code (push) Blocked by required conditions
The default workspace lived in <Documents>/KimiCode/Default. On macOS the first chat there triggered a Documents privacy prompt, and a denial blocked every later chat until the user found the setting. Documents is also synced by iCloud and OneDrive, and covered by Windows Controlled Folder Access. Use ~/KimiCode/Default on every platform instead. This drops the Windows PowerShell lookup, the XDG user-dirs parsing, and the documents_unavailable reason; the error path is now always present. |
||
|
|
47002256a0
|
feat: add a default workspace for chats without a project (#4224)
* feat(server): create sessions in a default workspace when none is chosen
POST /api/v1/sessions accepts default_workspace: true, exclusive with
workspace_id and metadata.cwd. The server resolves <Documents>/KimiCode/Default
on every request, creates it on first use, and reuses it afterwards. A path
blocked by a file fails with 40409 and a permission error with 40411; the
server never relocates silently.
Workspace payloads on REST and WebSocket events carry is_default.
* fix(server): fail instead of relocating when Windows Documents cannot be resolved
A failed registry lookup used to fall back to %USERPROFILE%\Documents, which
could silently create a second default workspace when Documents is redirected
(for example by OneDrive). The lookup now fails with 40409, the failure is not
cached so the next request retries, and is_default reports false meanwhile.
* fix(server): resolve Windows Documents through the shell folder API
Reading User Shell Folders with reg.exe misses the default when the value is
absent, cannot expand every variable, and is blocked where registry tools are
disabled by policy. Ask Windows for the Documents folder through PowerShell
instead, forcing UTF-8 output so non-ASCII paths survive. A reported folder
that does not exist is treated as unresolved, so garbled output can never
create a workspace in the wrong place.
* test(server): assert the existing error code for a missing Windows Documents folder
* fix(server): start Windows PowerShell by absolute path
The Documents lookup spawned the bare name powershell.exe, so Windows
resolved it through the current directory and PATH. In an untrusted
checkout that lets a repository-provided powershell.exe run before the
trust gate. Resolve it under SystemRoot (falling back to windir and
then C:\Windows) instead.
* feat(server): report an unusable default workspace with its path and reason
Creating a session in the default workspace used to surface folder problems
as generic codes: 40409 when a file blocked the path or the Windows
Documents folder could not be located, 40411 on permission errors, and a
plain internal error for anything else. Clients could not tell the default
workspace apart from an ordinary missing directory, nor explain what to fix.
DefaultWorkspaceService now throws DefaultWorkspaceUnavailableError
(default_workspace.unavailable) carrying the folder path and one of
blocked_by_file, permission_denied, missing_parent, no_space, read_only,
invalid_path, documents_unavailable or unknown. ensure() also verifies that
a file can be created and removed in the folder, so a read-only folder is
reported before a session is placed there. The server maps the error to
40930 with { path, reason } in data.
* feat(server): make the default workspace location configurable
The default workspace was fixed at <Documents>/KimiCode/Default. Users who
keep chats on another disk, or whose Documents folder is synced, had no way
to move it.
Add a default_workspace.path setting in config.toml. It accepts an absolute
path or ~/..., and on Windows only a drive path or a full UNC share; the
value is checked for writability before it is saved and is never moved
silently. An invalid value in the file is reported as invalid_path instead
of falling back to the system location.
The server exposes GET and PATCH /api/v1/default-workspace with the
effective path, the saved custom path, the system path and the folder's
health. The section is kept out of GET /api/v1/config and rejected by
POST /api/v1/config so it has a single writer. Whenever the location
changes, through PATCH or an edit to config.toml, every registered
workspace broadcasts event.workspace.updated with its current is_default.
* feat(cli): add --default-workspace and expose the default workspace in the SDK
Add kimi --default-workspace to work in the shared default workspace instead
of the current directory. Both the interactive shell and print mode resolve
the folder through the engine before the session starts and change into it,
keeping PWD in sync; when the folder cannot be used, startup fails with its
path and reason. Resume hints become kimi --default-workspace -r <id> for
such sessions.
The session picker labels sessions in the default workspace as "Default
workspace" and copies a resume command without a cd for them. kimi doctor
reports the location and whether it can be used. The stty lookup excludes
both the launch directory and the new working directory, so a binary
planted in either is never executed.
The SDK gains KimiHarness.ensureDefaultWorkspace(), getDefaultWorkspacePath()
and getDefaultWorkspaceStatus(), maps default_workspace.unavailable to a
KimiError, and exports workspaceRootKey and DEFAULT_WORKSPACE_PROBLEM_MESSAGES.
* fix(server): never remove a write probe the check did not create
createExclusive resolves to false when the probe name already exists. The
write check ignored that result and went on to remove the path, which is a
recursive delete of an entry it did not create. Report the folder as
unknown instead and leave the entry alone.
* fix(server): declare 40001 on PATCH /default-workspace and log failed broadcasts
The PATCH route returns 40001 when the body fails validation, but its
OpenAPI response union only listed success and 40930, so generated clients
could not model it.
When the default workspace location changed but the workspace catalog
could not be read, the publisher dropped the broadcast without a trace.
Log a warning so the missing event.workspace.updated can be diagnosed.
* fix(cli): point the resume hint at the session folder after the default moves
A session started with --default-workspace printed
kimi --default-workspace -r <id> on exit even if default_workspace.path
changed while it was open. Following that hint moved into the new default
folder and refused the session, which still lives in the old one.
Repeat the flag only while the session folder is still the default
workspace; otherwise print cd <folder> && kimi -r <id>.
* refactor: trim the default workspace to what clients use
Keep session creation in the default workspace, the configurable
location, the 40930 error with its reason, and `kimi --default-workspace`.
Remove what no client needs:
- write probes, ancestor walks, and dangling-link checks; saving a
location now creates the folder, and use-time errors come from mkdir
- `system_path` and `problem` in the status response
- the workspace-update publisher; clients refetch workspaces after PATCH
- special handling of `default_workspace` in GET/POST /config
- the stray FS_PERMISSION_DENIED mapping on session routes
- the session picker label, the doctor check, the extra stty exclusion,
the moved-default resume hint, and the SDK path/status methods
Fix three gaps found along the way:
- clearing the location left `path` in config.toml, so it came back on
reload; drop the section instead
- treat an empty or relative XDG_CONFIG_HOME as unset
- honor HostProcessOptions.timeout so a stalled PowerShell lookup ends
* refactor: drop the --default-workspace CLI flag
No CLI user needs it yet. Desktop and web reach the default workspace
through the server, so the flag, its resume hint, and the SDK's
ensureDefaultWorkspace() go away along with their changesets.
* refactor: drop the default workspace settings endpoint
The location is now changed only by editing default_workspace.path in
config.toml, which the config watcher picks up without a restart. Remove
GET/PATCH /api/v1/default-workspace and the engine's status() and
setCustomPath(). Session creation keeps mapping the unavailable error to
40930 with { path, reason }, and the reason list moves to the
POST /sessions docs.
* fix: require a drive or UNC share for a Windows default workspace path
Rooted paths such as \Chats resolve against the server's current drive,
so the same setting could point at different folders. Treat them as
invalid_path instead.
|