* feat(kap-server): support server-local path attachments
Web and desktop clients can now attach files, images, and videos to a
prompt by server-local absolute path instead of uploading a copy. The
daemon validates the path (absolute, realpath-resolved, non-sensitive,
local runtime only) and references the original file in place, so the
agent reads the original path; the upload flow is unchanged.
Submitted file attachments are also recorded on the prompt origin and
projected as typed transcript attachments, so web clients render
attachment chips for plain files without parsing the model-facing
notice text.
* fix(kap-server): forward file attachment metadata from skill activations
* Delete .changeset/web-attach-by-path.md
Signed-off-by: 7Sageer <sag77r@hotmail.com>
---------
Signed-off-by: 7Sageer <sag77r@hotmail.com>
* chore: sync web dist from code-app
code-app: 758f4587d10e28de8ac04678df8e379ca0f10387
* chore: consolidate web dist changesets by theme
* chore: trim web dist changesets to headline items
* chore: drop web prefix from fix-known-issues changeset
* chore: drop web-mobile-interaction changeset as duplicative of existing mobile entries
* fix(auth): keep OAuth login alive when its own provisioning writes the provider
* fix(auth): settle the OAuth flow as authenticated before provisioning
* fix(auth): publish the login as authenticated only after provisioning completes
* fix(mcp): forward structuredContent only as fallback when content has no usable text
Servers that follow the MCP spec's backwards-compatibility SHOULD return
the same JSON both as a TextContent block and as structuredContent.
Forwarding both to the model sent the same data twice. structuredContent
now rides the mcp-structured-result block only when the content blocks
carry no usable text; _meta still always passes through.
* test(mcp): verify structured-content fallback over a real stdio MCP server
Round-trip four server result shapes (dual-emit, structuredContent-only,
prose+structured, vendor _meta) through StdioMcpClient and the output
pipeline, so the fallback behaviour is checked against real protocol
bytes instead of hand-built result objects.
* fix(mcp): dedupe structuredContent only against its verbatim serialization
The earlier has-usable-text gate also suppressed the structured payload
when content was a lossy human summary — the primary case from #2554
(list_projects returning 'N item(s)' while the items live in
structuredContent). Skip the structured block only when a content text
block parses to the same JSON value (semantic compare, key order and
formatting insensitive); summaries and structured-only results still
pass through.
* fix(mcp): forward structuredContent only when content does not already cover it
Replace the verbatim-serialization comparison with a size heuristic:
well-behaved servers render the same data into content (the spec's
dual-emit, or a faithful human reorganisation), and either way the text
measures at roughly the same size as the payload, so forwarding it would
double the information. Append the structured payload only when content
carries no usable text, or when the payload is more than twice the text
size — the signature of a lossy summary. Verified against a live video-
editor MCP whose tools all measure a json/text ratio of 1.2-1.9.
* fix(mcp): send content or structuredContent to the model, never both
Final policy: content and structuredContent are alternatives. content
wins whenever it carries anything usable (a media block or non-whitespace
text); structuredContent fills in only for an empty content array. There
is no reliable signal that the structured payload is richer than what the
server already rendered into content, so no size or structure heuristic
is attempted. _meta still always passes through.
* refactor(mcp): rename the structured-extras wrapper to mcp-result-extras
The block carries structuredContent and/or _meta; the old
mcp-structured-result name was inaccurate whenever it is a pure _meta
carrier.
* ci: retrigger after flaky mcpCore client-stdio close-buffering test
* ci: retrigger after flaky minidb concurrent writer/reader test
* fix(secondary-model): stop rewriting the section when providers refresh or are removed
Provider refresh, provider deletion/rename, catalog/registry import,
OAuth logout, and SDK removeProvider used to cascade into the user's
[secondary_model] block: pool entries were silently pruned, and the
whole section was deleted when its effective default dangled. The
cascade ran from a cache-refresh path (including an unattended 6h
scheduler), so upstream model-list changes could irreversibly destroy
hand-written configuration without any notice.
Config is user intent; the catalog is an availability snapshot. Stop
rewriting the section on every provider/models writer. An entry whose
model no longer resolves fails pool validation on the next session
create with a message naming the offending alias, which is the same
fail-fast contract hand-written typos already had.
* chore(sdk): add changeset for the removed secondary-model cascade export
* Delete .changeset/sdk-remove-secondary-model-cascade.md
Signed-off-by: 7Sageer <sag77r@hotmail.com>
* Delete .changeset/secondary-model-no-silent-rewrite.md
Signed-off-by: 7Sageer <sag77r@hotmail.com>
---------
Signed-off-by: 7Sageer <sag77r@hotmail.com>
* feat(kap-server): add task detach action to move foreground tasks to background
* test(kimi-code-sdk): normalize v2-only parentToolCallId in task parity projections
* fix(agent-core-v2): distinguish user-initiated detach in tool result text
* feat(agent-core-v2): mention user-initiated backgrounding in the bash tool description
* feat(agent-core-v2): use a client-agnostic background-task panel hint in the bash tool description
* ci: retrigger checks
* feat(agent-core-v2): client-agnostic human_shell_hint and a detached_by_user marker in tool results
* fix(protocol,docs): declare parent_tool_call_id in the shared task schema and document the detach action
* style: remove added comments
Concurrent openSession/attachResumedSession calls for the same webview
both missed the sessions map before either wrapped the SDK session, so
one Session facade got two SessionRuntimes. The overwritten runtime
leaked and kept broadcasting, doubling every streamed delta and tool
call in the view. Queue opens, attaches, and detaches per webviewId so
the second caller sees the first one's runtime.
Add a liveness watchdog on the management and HTTP tunnel WebSockets
(client ping every 30s, terminate after 300s without inbound activity)
so the client recovers when a relay redeploy drops connections without
a close frame. Treat registration failures after a successful session
as transient and keep backing off instead of stopping permanently.
* fix(agent-core-v2): clear the turn outcome when an undo rewinds the turn it describes
* fix(agent-core-v2): clear the turn outcome too when an undo outruns the tracked anchors
* fix(agent-core-v2): reconcile the persisted turn outcome against the replayed wire on restore
* fix(agent-core-v2): keep the persisted outcome when an undo rewinds only later turns
---------
Co-authored-by: kimi-agent-bot <kimi-agent-bot@users.noreply.github.com>
The drain probe treated any callTool failure as proof the transport close
had been processed, but a stdin write error (EPIPE) can win the race
against the child's exit notification, so the listener could be registered
before the close was buffered and the synchronous replay never fired.
Break the drain loop only on errors that are impossible before the SDK's
_onclose ran ('Not connected' / 'Connection closed' / the transport's
not-running guard).
Also drop the assertion that the replayed reason contains the child's
final stderr: the reason snapshots the stderr buffer at close time, which
can legitimately race delivery of the last stderr chunk (reproduced 2/40
under CPU load). Tail capture itself stays covered by the stderrSnapshot
assertion. Finally, flush the fixture's banner through the stderr write
callback before process.exit so the write cannot be truncated.
Co-authored-by: kimi-agent-bot <kimi-agent-bot@users.noreply.github.com>
- turn.started now derives the attachment file id from the kimi-file URL when the media part carries no id, so prompt images uploaded through the global file library stay attached in the live transcript instead of vanishing until the post-turn heal
- an explicit id must still match the URL file id, and non-kimi-file URLs are still ignored
- restore the turn.started prompt-attachment regression coverage dropped by the model-as-container refactor and extend it to the id-less kimi-file form
* docs: rework web guide, interaction and getting-started pages (zh/en)
* docs: rename guides/server to guides/web to match the reworked page
* docs: neutralize screenshot workspace names and sync en web guide to zh
* docs: trim web UI screenshot to a single neutral workspace
* fix(kap-server): remove undone turns from the live transcript projection
* fix(agent-core-v2): report the earliest removed turn id on conversation undo
* fix(agent-core-v2): spill oversized tool outputs and surface dropped content
* fix(agent-core-v2): preserve spill fields through tool result normalization
normalizeToolResult rebuilds every tool result with a field whitelist,
which stripped untruncatedOutput / untruncatedOutputTotalChars /
spillExempt before ToolResultTruncationService could see them: the
spill-on-truncation path never fired for Bash/Grep/FetchURL/WebSearch,
and reads of spill files were not exempted from re-spilling.
Pass the three engine-internal fields through, and add executor-level
integration tests that run a retainFullOutput tool and a spill-exempt
result through the real ToolResultTruncationService.
* refactor(agent-core-v2): drop banned JSDoc and fix harness error typing
main banned JSDoc in comment-free packages (#3226); remove the doc
blocks on the new contract fields and on isSpillFilePath. Type the
harness scripted stream error as Error to satisfy only-throw-error
under oxlint --type-aware.
* fix(agent-core-v2): preserve completion status when spilling output
* fix(agent-core-v2): mirror dedupe reminders into the spill suffix
appendReminder additions lived only in the final output, so they were
dropped when the spill pointer replaced it; mirror the reminder into
untruncatedOutputSuffix for retained results, widening ToolDedupeResult
to ExecutableToolResult plus its message field. Also stop claiming the
full output was saved when retention capped out, narrow spillExempt to
'true' per the optional-property convention, and pass traceId directly
in the harness.
* fix(agent-core-v2): prefer persisted Bash task logs
* refactor(agent-core-v2): unify tool-result truncation in the spill pipeline
Route every tool result through ToolResultTruncationService.truncateForModel
as the single model-context decision point: spillExempt pass-through, the
50k char budget, per-line shaping, spill persistence with a 10MB retention
cap, and append-or-replace pointer rendering. Tools no longer declare
truncation options; sources keep only memory-safety caps.
- rename ToolResultBuilder to ToolOutputAccumulator and drop its options
- mcp keeps only its media pipeline and shares the unified 50k budget
- bash persists foreground logs at the spill threshold and reuses them as
spill.outputPath only within the retention budget
- carry completion/error messages in spill.suffix so retention capping
cannot drop them
- render a bounded preview when spill persistence fails
- suppress suffix lines already present inline in append mode
- call out text-only persistence when media parts stay attached
* fix(agent-core-v2): preserve success status in spilled output
* fix(agent-core-v2): reuse the complete task log for spilled bash output beyond 10MB
* Update tool-result-spill.md
Signed-off-by: 7Sageer <sag77r@hotmail.com>
---------
Signed-off-by: 7Sageer <sag77r@hotmail.com>
v2 engine status events carry contextTokens/maxContextTokens but never
contextUsage, so appState.contextUsage was only refreshed by getStatus
pulls and then went stale while the token counts kept updating live.
The /usage panel and footer render the ratio as a bar but recompute the
percentage text from the counts, so a stale ratio showed as a bar that
disagreed with the percentage (e.g. bar ~74% next to "18% (180k / 1M)"
after compaction or a model switch).
Recompute the ratio from the post-patch token counts whenever a status
update touches contextTokens or maxContextTokens without carrying an
explicit contextUsage. v1 events carry the ratio and are unaffected.
Co-authored-by: kimi-agent-bot <kimi-agent-bot@users.noreply.github.com>
* fix(kap-server): report run_in_background on the task wire
The /tasks wire now carries the task's detached flag as
run_in_background (schema in both the kap-server local copy and the
public protocol package). A running foreground subagent used to be
indistinguishable from a background one on this surface — clients that
defaulted the missing field to true would treat it as background.
* chore: add changeset for the run_in_background wire fix
* fix(kap-server): make run_in_background a required wire field
The field is always emitted (ghost-restored records pre-dating it read
true: the persisted store only lists terminal-and-detached or running
tasks, which all carry a concrete flag). Making the contract required
means a producer that omits it fails as an ordinary protocol error
instead of clients silently re-interpreting the row as foreground
* fix(protocol): keep run_in_background optional in the public task schema
The public schema types the agent-core v1 task service too, which does
not emit the field — making it required there is a breaking protocol
change (and broke agent-core's typecheck). kap-server's own local
schema stays required: it is the sole writer of the /tasks response
and always emits. Consumers apply the foreground fallback when the
field is absent
* fix(kimi-code): render newlines instead of literal backslash-n in rc output
* fix(kimi-code): print plain URL in rc output when hyperlinks are unsupported
* feat(kimi-code): add remote control web tunnel
Add CLI and TUI entry points for exposing the local web UI remotely.
Bridge HTTP and WebSocket traffic with local authentication and reconnect handling.
* fix(kimi-code): prevent remote control websocket crash
* fix(kimi-code): align websocket dependency versions
* fix(kimi-code): harden remote control connection setup
Reconnect when management closes during the HTTP tunnel handshake.
Reject non-loopback Remote Control binds whose CSP blocks path bootstrap.
* fix(kimi-code): fix remote control rewriting, caching, and WS frame loss
* feat(kimi-code): add remote control QR output
* build: update pnpm dependencies hash
* refactor(kimi-code): remove the --allow-remote-terminals flag
* feat(kimi-code): add remote control lock, rc command, and QR fixes
* fix(kap-server): broadcast user prompts to all session clients on submit
- agent-core-v2: emit prompt.submitted (status running|queued) at enqueue and prompt.started when the turn launches
- kap-server: project prompt.submitted/prompt.started into transcript prompt entities and the live transcript REST response
- update flake.nix pnpmDeps hash for the PR lockfile
* fix(node-sdk): drop v2-only prompt.started from SDK event stream
- event-mapper: add prompt.started to the dropped v2-only prompt lifecycle types (parity with submitted/completed/aborted/steered)
- cli test: assert only visible sub-commands and stub the experimental flag env for determinism
* ci(pkg-pr-new): post custom install comment for npm 12 compatibility
* feat(kimi-code): render remote control QR as inline image on capable terminals
* feat(kimi-code): improve remote control terminal output
- add onboarding, security, device management, and help guidance
- show compact clickable links and QR image fallback details
- report relay and remote device connection lifecycle
* test(agent-core-v2): update tool event snapshot
* revert(ci): keep preview workflow unchanged in rc pr
---------
Co-authored-by: liruifengv <liruifeng1024@gmail.com>
- retry every failed LLM request indefinitely in runRequest when
KIMI_CODE_INFINITE_RETRY is set, covering turn steps and operation
requests such as compaction
- keep projection recovery ahead of the infinite retry branch, honor
Retry-After, and keep abort effective during backoff waits
- exclude context overflow from infinite retry so the deterministic
turn-level and compaction-level overflow recovery paths still run
- extract retryBackoffDelay for single-attempt backoff computation
* fix(tui): render /plugins marketplace before version lookups resolve
The Third-party/Official tabs waited on the slowest GitHub
releases/latest lookup before painting any catalog row, with no
timeout (undici defaults: 10s connect, 300s headers) and no caching,
so a stalled connection to github.com left the panel on "Loading
marketplace…" for minutes on every /plugins open.
Load in two phases: render the catalog as soon as it is parsed, then
resolve latest versions in the background (5s per-lookup timeout,
per-entry failures degrade to a missing badge) and refresh when they
land. Update badges appear slightly later; row order is unaffected
since sorting only depends on installed state.
* refactor(tui): move marketplace version lookup timeout to constants
Per AGENTS.md, application constants live in src/constant/ — moves
MARKETPLACE_VERSION_LOOKUP_TIMEOUT_MS next to the other marketplace
constants in constant/app.ts.
* fix(tui): resolve marketplace versions before built-in injection
Phase 1 injected built-in capability rows into the marketplace before
phase 2 ran, masking the matching catalog entries' GitHub sources
behind capability:<id> rows — so installed built-ins could never
receive update badges (the pre-change resolve-then-inject ordering
preserved them).
Keep the raw parsed catalog for phase 2, re-apply withBuiltInEntries
after versions resolve (resolved versions flow onto capability rows),
and keep the built-ins-only fallback when the catalog is unreachable.
* fix(tui): surface marketplace parse errors instead of masking them
The phase-1 catch converted every failure into a built-ins-only loaded
marketplace, hiding malformed-catalog errors behind a silently empty
Curated tab. Restore the error state for all phase-1 failures — the
panel already keeps built-in capability rows installable in the
Official tab while the error is displayed.
---------
Co-authored-by: kimi-agent-bot <kimi-agent-bot@users.noreply.github.com>
- replace the Agent-scoped DI service with an eager non-durable Agent Runtime; the date_change injection provider registration now lives in an actor effect owned by the actor lifecycle, and the seed memo moves from the dateChange.seed state key into machine context
- honor eager: true for non-durable runtimes in AgentRuntimeSet so consumer-less runtimes still materialize
* fix(kimi-code): persist picked thinking effort up to the model's default effort
The persistence gate kept the model's top declared effort session-only
unconditionally, so users whose delivered default_effort is the top tier
(e.g. max) could never save an explicit pick of it. Compare the pick
against the model's default_effort instead, using support_efforts as the
strength ordering: picks above the default stay session-only, picks at
or below it persist. Models without a declared default keep the
historical top-tier rule. The same change lands in the VS Code
extension's mirrored logic.
* docs(kimi-code): document the effective-default ceiling for effort persistence
Clarify in both apps' comments, the changeset, and the config docs that
the persistence ceiling is the model's effective default effort, whether
declared via the catalog / overrides or synthesized by the protocol
profile inference (Claude models resolve to high, so an xhigh pick is
session-only there). Pin the inference path with tests in both apps.
* fix(vscode): resolve the save-config model with its provider type
Mirror the TUI's effectiveModelForHost: without the provider type the
Anthropic fallback profile (e.g. claude-latest) never matches, so the
inferred default effort that gates persistence was missed and an
above-default pick could persist where the TUI keeps it session-only.
* Delete .changeset/persist-effort-up-to-model-default.md
Signed-off-by: 7Sageer <sag77r@hotmail.com>
* fix(vscode): seed the persisted effort with the effective-default ceiling
* fix(vscode): project webview models with the provider type
* fix(kimi-code): apply a session-only effort pick to the runtime in the /provider flow
* fix(vscode): update the persisted-effort seed on model-switch saves
* docs(kimi-code): drop the default_effort persistence-ceiling note
---------
Signed-off-by: 7Sageer <sag77r@hotmail.com>
* fix(agent-core-v2): keep agent lifecycle context active through scope teardown
* fix(agent-core-v2): deactivate agents after scope-units teardown
* fix(kap-server): install process handlers only after successful startup
* fix(agent-core-v2): let the teardown finalizer own create-failure deactivation
* fix(agent-core-v2): await asynchronous scope-units teardown before deactivation
* fix(agent-core-v2): await agent scope teardown before completing removal
* fix(agent-core-v2): mark fire-and-forget scope disposals after awaitable dispose
* fix(agent-core-v2): return the in-flight promise from repeated disposeAsync
* fix(agent-core-v2): await child containers and keep kap-server handlers through shutdown
* fix(tower): remove command queue
* feat(agent-core-v2): support an explicit base branch in TowerInit
* fix(kimi-code): keep tower objective order across a mid-turn compaction
* feat(agent-core-v2): add abandoned tower mission status to release stale scopes
* chore: consolidate tower changesets into one feature entry
* chore: consolidate tower changesets into one feature entry
---------
Co-authored-by: konghuanjun <konghuanjun@moonshot.ai>
Add a dedicated [swarm] config section so AgentSwarm subagent timeouts no longer follow [subagent] timeout_ms: timeout_ms (default 7200000, i.e. 2 hours; 0 = no timeout) with the KIMI_CODE_SWARM_TIMEOUT_MS env override, mirroring the [subagent] section. Deliberate behavior change with no fallback: a value previously set in [subagent] timeout_ms to cover swarms needs to move to [swarm]. Print mode (kimi -p) keeps its no wall-clock cap semantics: [swarm] timeout_ms also defaults to 0 there unless explicitly set. Docs updated in both locales (config-files, env-vars, tools) and the config manifest regenerated.
- define the AgentSkill contract and SkillRuntime (activate /
promptWithSkills / recordModelToolActivation) with a lazy, non-durable
provider; recordActivation dispatches SkillActivated directly and the
skillKey / SkillActivate relay is gone
- allow agent runtime descriptors to omit logic (durable definitions
still require it), making skill the first pure-API domain
- featurize the skill domain: app/skillCatalog,
workspace/workspaceSkillCatalog, session/sessionSkillCatalog,
agent/skill, and agent/tools/skill move under src/features/skill;
the static Skill tool registration and the AgentSkillService are gone
- resolve the runtime at the edge: kap-server routes and node-sdk
activateSkill go through IAgentLifecycleService.resolve, and the
klient dispatcher keeps the agentSkillService wire name over a
per-agent view
* fix(transcript): fold mid-turn task notifications into the current turn on cold rebuild
* chore: changeset for the notification fold fix
* fix(transcript): key the notification fold on persisted task-turn boundaries, not the previous message role
* fix(transcript): collect background_task turn origins too, and fall back when the wire has no turn.started records
* fix(transcript): fold consecutive task notifications into the same turn
* fix(transcript): normalize folded notification text to the live title/body form
* fix(transcript): stop folded notification text before child blocks, preserve legacy background_task turns absent from the boundary set
* fix(transcript): truncate folded notification text at the first child-block tag, not just the tag lines
* fix(transcript): drop folded notifications without a persisted step, truncate only at output blocks
* fix(transcript): attach mid-turn task notifications to the following step, cold and live
* fix(transcript): keep other tasks' notifications in task-origin turns
* fix(transcript): derive task-turn boundaries from durable turn.prompt records
* feat(transcript): carry subagent model and thinking effort on task entities
* fix(transcript): mirror turn liveness into meta.activity, live and cold
* fix(transcript): populate the prompts entity from prompt.accepted/queued engine events
* fix(transcript): reconcile liveness and the prompt queue at backfill from the live loop state
* fix(transcript): include the prompts entity in the REST transcript response
* fix(agent-core-v2): publish prompt.accepted on the event bus
* test(transcript): add the contract-level e2e covering every entity the client renders from
* fix(transcript): guard the prompt backfill against missing services; align stream expectations with prompt.accepted on the bus
* test(agent-core-v2): re-record event stream snapshots with prompt.accepted published
* fix(transcript): settle the spawned agent row when its lifecycle redirects to the task row
* test(transcript): move the contract e2e timeout to the describe arg (jest lint)
* fix(transcript): declare task model fields in the wire schema, carry prompt content on accepted, normalize queued content
- transcriptTaskSchema declares model/thinkingEffort: Zod strips
undeclared keys, so schema-driven REST/WS consumers lost both fields
the projector now populates.
- PromptAccepted carries the admitted content (it is the only event a
first-turn prompt ever emits, and the bare id left the prompts entity
permanently partial) — projected with userMessageId and the public
content shape via projectPromptContentParts, same as queued and the
live backfill.
- Regenerate the wire manifest and re-record the affected event-stream
snapshots.
* fix(transcript): preserve task model fields across termination and accepted prompt details across queueing
- onTaskLifecycle carried resultSummary/usage/error/stateReason but
dropped model/thinkingEffort: a completed detached-Agent row lost the
metadata spawned set while running.
- prompt.queued rebuilt the entity from scratch, discarding the
userMessageId and createdAt that prompt.accepted had just stamped —
build the queued update from prev.
* fix(transcript): keep prompt.accepted out of the public v1 event stream
The observable marker made the broadcaster forward every accepted
prompt to v1 WS clients, but events-zod has no accepted variant (v1
surfaces submission through the service-synthesized prompt.submitted)
and the SDK mapper didn't drop it — schema-driven clients could reject
the frame. Drop it at the WS edge and in the SDK's dropped set; the
transcript projection keeps consuming it internally.
* fix(transcript): derive cold task-turn boundaries through undo anchor replays
* fix(transcript): flush trailing folded notifications into the open turn
* fix(transcript): drop trailing buffered notifications to match the live projector
* chore: split transcript changesets per logical change
* fix(transcript): parse only the generated Title/Severity header lines in folded notifications