Commit graph

1062 commits

Author SHA1 Message Date
7Sageer
d5e1d76fc2 fix(agent-core-v2): align v1.4 wire parity 2026-07-08 14:33:17 +08:00
_Kerman
bc043792e8 fix(agent-core-v2): inherit caller permission mode for subagents
Subagents created via the Agent tool or AgentSwarm fell back to the
default `manual` permission mode because CreateAgentOptions offered no
way to seed one, so write/execute tool calls inside a subagent prompted
for approval even when the parent ran in auto/yolo.

Add an optional permissionMode to CreateAgentOptions and have the Agent
tool and AgentSwarm pass the caller's current mode when creating a
child.
2026-07-08 13:04:39 +08:00
_Kerman
40f871fa49 chore: remove unused permission rules hooks 2026-07-08 11:42:06 +08:00
haozhe.yang
a8b83e932e chore: reference @moonshot-ai/kap-server in v2 changesets
The v2 server package is @moonshot-ai/kap-server, but three changesets still referenced the old @moonshot-ai/server-v2 name, which no longer exists in the workspace.
2026-07-08 10:56:31 +08:00
haozhe.yang
07f3460a47 fix(nix): update pnpmDeps hash 2026-07-08 10:55:35 +08:00
haozhe.yang
f054fe9a21 feat(kap-server): log envelope code instead of HTTP status
- add custom onSend/onResponse access logging that records the envelope code
- disable Fastify built-in request logging (every response is HTTP 200)
- drop pino-pretty; logger always emits newline-delimited JSON
- rename dev:server-v2 script to dev:kap-server
2026-07-08 10:47:32 +08:00
haozhe.yang
b71cf5e751 feat(status): restore consistent session status context window
- bridge split v2 status slices into one combined `agent.status.updated`
  event via a LegacyStatus derived model at the kap-server edge, so a
  usage-only event no longer overwrites the live context window with a
  stale zero
- fall back to the configured default model's context window when the
  agent has no model bound yet, so fresh sessions don't show "0/0"
- use `size` (measured + estimated) for the live context token count to
  mirror v1's `context.tokenCount`
- export `defineDerivedModel` / `DerivedModelDef` from agent-core-v2
2026-07-08 10:46:32 +08:00
haozhe.yang
c7ea60a01a fix(kap-server): buffer and coalesce outbound ws deltas
- add a per-connection outbound send buffer in WsConnectionV1; sendFrame
  enqueues and a flush drains on a 16ms interval or once 64 frames queue
- coalesce adjacent volatile assistant/thinking deltas for the same
  session/agent/turn into one frame, keeping the first offset/seq so
  client alignment is unchanged
- defer flushing while socket.bufferedAmount exceeds a 1MiB high-water
  mark, merging new deltas into the queued frame instead of growing it
- flush remaining frames on close to avoid truncating the tail of a stream
- expose flushIntervalMs / maxBatchSize / highWaterMarkBytes via registerWsV1
2026-07-08 10:02:35 +08:00
haozhe.yang
79ffb7b347 chore: fix lint issues across packages
- remove unused imports and variables
- add void to floating promises
- drop redundant return-await
- bind unbound method references
- replace == null with strict null/undefined checks
- add explicit sort comparators and Array.from helpers
- rename background_tasks capability to tasks
- migrate event sink to event bus in tests
2026-07-07 23:37:34 +08:00
haozhe.yang
5b57a3297a feat(cli): run kimi -p on agent-core-v2 behind experimental flag
- add PromptHarness/PromptSession interfaces so the print driver is
  decoupled from the concrete SDK harness/session
- add an in-process agent-core-v2 harness (bootstrap + session +
  prompt/goal/permission adapters) under cli/v2/
- adapt v2 IEventBus events to the v1 Event union, with unit tests
- select the engine in createPromptHarness via isKimiV2Enabled()
  (KIMI_CODE_EXPERIMENTAL_FLAG), lazy-importing v2 off the default path
2026-07-07 23:37:03 +08:00
haozhe.yang
8706beded2 fix(kap-server): restore session lifecycle broadcasts
Forward event.session.created to WS clients (it was published on the core
bus but never forwarded) and re-emit event.session.status_changed(running)
on turn.started. v2 derives session status via ISessionActivity, a pure pull
that publishes nothing, so these v1 broadcasts were dropped: clients that
did not issue a create never learned the session existed, and the running
transition never reached kimi-web, whose Stop button is gated on
session.status === 'running'. Mirrors v1's SessionService status emission
and isGlobalSessionEvent fan-out.
2026-07-07 23:37:03 +08:00
haozhe.yang
0e286cb257 fix(agent-core-v2): anchor plan path to workDir when profile cwd is empty
server-v2 binds the main agent via profile:setModel without a cwd, so
the profile cwd is empty and planFilePathFor() produced a relative path
like plan/<id>.md. The plan-mode guard compares that against the Write
tool's workDir-resolved absolute path with strict equality, so it denied
every write to the plan file; the relative path also landed in
process.cwd() instead of the session workDir, breaking ExitPlanMode.

Make the plan path always absolute, falling back to the session workDir
(the same root the file tools resolve against) when the profile cwd is
empty.
2026-07-07 23:37:03 +08:00
haozhe.yang
e6b90d95f5 fix(kap-server): route prompt submits by agent_id
`resolveLegacy` always resolved the main agent, ignoring `agent_id` in the
prompt submission body. A `/btw <question>` submit carries the forked
side-channel child's `agent_id`, so it was answered in the main view instead
of the right-side BTW panel.

Resolve the agent named by `agent_id` (falling back to `main`), and return
40401 for an unknown agent id. Add regression tests for side-channel routing
and the unknown-agent case.
2026-07-07 23:37:03 +08:00
7Sageer
7b041a8e03 fix: enforce v2 auth readiness checks 2026-07-07 22:27:14 +08:00
_Kerman
07f3f1cc36 refactor: align permission mode injection 2026-07-07 22:10:26 +08:00
_Kerman
22e6413ff1 chore: remove unused file 2026-07-07 21:13:25 +08:00
haozhe.yang
554d998b16 Merge remote-tracking branch 'origin/main' into kimi-code-v2 2026-07-07 21:08:35 +08:00
haozhe.yang
e300a89795 feat(kap-server): register instances when multi_server flag is on
- gate startServer on KIMI_CODE_EXPERIMENTAL_MULTI_SERVER: register under server/instances/ and rely on port+1 retry for coexistence, or take the legacy single-instance lock when off
- release/update the chosen handle on close, boot refusal, and after bind so the advertised port stays accurate
- export the instance registry API from the package barrel
- fix session.meta.updated to dispatch under the real session id instead of '__global__' so auto-titled and renamed sessions update in clients
2026-07-07 21:06:01 +08:00
haozhe.yang
0157b058d6 feat(multi-server): add shared-home instance registry behind flag
- add `multi_server` experimental flag in agent-core-v2 and wire it into the package barrel
- add kap-server instance registry that writes per-server files under server/instances/ with heartbeat and stale-pid sweep
- thread PromptOrigin through AgentTurnService.launch and emit it on turn.started
- drop the error field from cancelled loop/turn results and use userCancellationReason in promptLegacy
2026-07-07 21:06:01 +08:00
_Kerman
c23e0fc9e0 Merge branch 'kimi-code-v2' of https://github.com/MoonshotAI/kimi-code into kimi-code-v2 2026-07-07 21:05:47 +08:00
_Kerman
5a7a2361e0 fix: plan service 2026-07-07 21:04:23 +08:00
7Sageer
a6dad2507f fix: align v2 prompt auth readiness 2026-07-07 20:54:07 +08:00
_Kerman
d8f54b8530 Merge branch 'kimi-code-v2' of https://github.com/MoonshotAI/kimi-code into kimi-code-v2 2026-07-07 20:51:56 +08:00
_Kerman
07d631c94c refactor(agent-core-v2): extract plan-mode injection and move reminder prompts to markdown 2026-07-07 20:50:25 +08:00
qer
11c6a37ce0
fix(web): dismiss stale connection error toast after ws reconnect (#1474) 2026-07-07 20:47:56 +08:00
7Sageer
2065ae4615
fix(telemetry): gate unsafe numeric telemetry values (#1478)
- Drop numeric telemetry properties whose absolute value exceeds Number.MAX_SAFE_INTEGER before enqueue, and reject them again during payload assembly as a backstop.

- Omit constrained_memory_bytes when process.constrainedMemory() is not a safe non-negative integer so Linux no-cgroup sentinels do not overflow int64 parsing downstream.

- Add telemetry tests for unsafe numeric properties and constrained_memory_bytes filtering.
2026-07-07 20:32:02 +08:00
haozhe.yang
4d23a80e1d feat(agent-core-v2): cascade context size measurement
- cascade context_size.measured when context memory clears, undoes, compacts, or splices the measured prefix
- add context memory tests for measured prefix reset and rebase behavior
- fix lint issues around task tool side-effect imports, web fetch type cycle, and unused imports
2026-07-07 20:28:13 +08:00
_Kerman
91374d5ac5 chore: remove unused methods 2026-07-07 20:25:24 +08:00
_Kerman
f839095fc0 test(agent-core-v2): port remaining agent swarm tests
Restore the enforced-requirements paragraph in the AgentSwarm tool description and assert it, cover the AgentSwarm exclusive-deny and swarm-mode-approve permission policies, and add resolveSwarmMaxConcurrency plus AgentRunBatch swarmItem forwarding tests.
2026-07-07 20:18:31 +08:00
Luyu Cheng
d1a964fba9
fix: forbid model-driven goal pauses (#1476) 2026-07-07 20:02:43 +08:00
_Kerman
6710f1eb34 Merge branch 'kimi-code-v2' of https://github.com/MoonshotAI/kimi-code into kimi-code-v2 2026-07-07 20:02:35 +08:00
_Kerman
8c47266633 refactor(agent-core-v2): remove unused toolState service
The opaque per-key tool store (IAgentToolState / ToolStoreModel / updateStore) had no remaining producer or consumer in v2: its only real user, the todo list, was migrated to the dedicated session/todo domain (ISessionTodoService, TodoModel, todo.set). Drop the domain, its index exports, and the dangling references in kap-server actionMap, server-e2e resources, the test harness, ResumedAgentState, and the DI-scope docs. Replay silently skips the now-unregistered tools.update_store record type.
2026-07-07 19:58:20 +08:00
haozhe.yang
f8103e877f docs(agent-core-dev): drop barrels, rename server-v2 to kap-server
- replace per-domain `index.ts` barrel guidance with precise leaf imports in `src/index.ts`
- update server-align docs from `packages/server-v2` to `packages/kap-server`
- adjust flag, implement, orient, service-authoring, telemetry examples accordingly
2026-07-07 19:53:34 +08:00
_Kerman
e9b9705e5b chore: remove unused retry trigger 2026-07-07 19:48:21 +08:00
_Kerman
60b8a3f24a fix(agent-core-v2): minor updates / naming changes 2026-07-07 19:44:04 +08:00
_Kerman
f9691470e1 Merge remote-tracking branch 'origin/kimi-code-v2' into kimi-code-v2
Reconciled with upstream de-barrel refactor (direct imports, removed per-domain barrels) and the loop-context interface rename. Kept the agent-run hook slot host on IAgentLifecycleService (run by mirrorAgentRun, observed by the Session-scope externalHooks adapter) and dropped the standalone IAgentRunHooksService, resolving conflicts in agentLifecycle, mirrorAgentRun, both externalHooks adapters, and the affected tests.
2026-07-07 19:43:17 +08:00
_Kerman
a3c6968454 refactor(agent-core-v2): host agent-run hook slots on IAgentLifecycleService
Move the requester-side agent-run hook slots (onWillStartAgentTask / onDidStopAgentTask) onto IAgentLifecycleService, the service whose run mirrorAgentRun wraps. mirrorAgentRun now resolves IAgentLifecycleService to run the slots, and the Session-scope SessionExternalHooksService observes them to translate into SubagentStart / SubagentStop external hook commands.

This removes the standalone Agent-scope IAgentRunHooksService (runHooks.ts) and the SubagentStart/Stop observation from the Agent-scope AgentExternalHooksService, so the slot host lives on the service that runs the agent task and the external-hooks adapters only observe. ISessionExternalHooksService becomes an empty observer token (it still registers SessionStart/SessionEnd via sessionLifecycle).

Update affected tests, IAgentLifecycleService stubs, and the DI Scope x Domain dependency map (puml + regenerated svg).
2026-07-07 19:23:48 +08:00
_Kerman
2a9e2194e4 refactor(agent-core-v2): rename loop context interfaces 2026-07-07 18:59:38 +08:00
7Sageer
ebd25a4a55
chore(telemetry): sample system metrics every 5 minutes (#1472)
Raise SystemMetricsCollector's default sampling interval from 30s to 5min to reduce the frequency of system_metrics telemetry events.
2026-07-07 18:33:24 +08:00
haozhe.yang
304883ab81 refactor(kap-server): rename server-v2 package to kap-server
- rename packages/server-v2 to packages/kap-server and update every
  @moonshot-ai/server-v2 reference across apps, packages, flake.nix,
  and build scripts
- remove the experimental `kimi v2` CLI prefix and its tests from the
  apps/kimi-code main entry
- add legacy BackgroundTask protocol types and the `blocked` turn
  interrupt reason for cross-engine compatibility
2026-07-07 16:56:19 +08:00
liruifengv
ee385456d0
refactor(web): migrate icons to unplugin-icons (#1467)
* refactor(web): migrate icons to unplugin-icons

Replace the hand-written gen-icon-data.mjs + @iconify/utils runtime
rendering with unplugin-icons build-time imports. The public API
(<Icon name>, iconSvg, IconName, SIZE_PX, NAME_TO_REMIX) is unchanged;
127+ call sites are untouched.

- add unplugin-icons@^23.0.0 (devDep) + Vite Icons() plugin (compiler: vue3)
- rewrite src/lib/icons.ts: static ~icons/ri/* imports (component + ?raw)
  for 56 distinct Remix icons across 59 IconName entries
- Icon.vue renders <component :is> with unknown-name fallback
- append ICON_GROUPS export for DesignSystemView catalog
- DesignSystemView: v-for catalog, remove legacy-script references
- delete gen-icon-data.mjs, gen-icon-catalog.mjs, icon-data.ts,
  gen:icons script
- remove @iconify/vue and @iconify/utils from dependencies; move
  @iconify-json/ri to devDependencies
- drop Icon.vue from check-style ICON_EXEMPT (no hand-written <svg>)

* refactor(web): drop unused NAME_TO_REMIX icon mapping

NAME_TO_REMIX was a Record<IconName, string> table introduced to map
internal icon names to their ri: ids. After the unplugin-icons migration
it has no production consumers — only icons.test.ts imported it (for two
drift tests) and DesignSystemView mentioned it in descriptive copy. The
ICONS table already conveys the same ri: id via each entry's paired
component + ?raw imports (e.g. RiFolderOpenLine / RawFolderOpenLine).

- remove NAME_TO_REMIX const from src/lib/icons.ts (-63 lines)
- remove NAME_TO_REMIX import + describe block from icons.test.ts
- update DesignSystemView §02 copy: describe the import-pair idiom and
  stop claiming ICON_GROUPS is sourced from NAME_TO_REMIX

* chore: add changeset for web icon migration

* chore(nix): bump pnpmDeps hash for unplugin-icons

Adding unplugin-icons changed pnpm-lock.yaml, so the fixed-output
pnpmDeps derivation hash is stale. Update to the hash reported by the
Nix Build CI run.
2026-07-07 16:44:56 +08:00
haozhe.yang
957c493136 Merge remote-tracking branch 'origin/kimi-code-v2' into feat/de-barrel-agent-core-v2 2026-07-07 16:41:46 +08:00
haozhe.yang
6dca7eaf1b Merge remote-tracking branch 'origin/kimi-code-v2' into feat/de-barrel-agent-core-v2 2026-07-07 16:41:19 +08:00
7Sageer
5590da391b fix(agent-core-v2): align strict projection and kimi thinking 2026-07-07 16:25:57 +08:00
qer
2a44ae075a
chore: update 0.23.1 changelog (#1469)
Some checks are pending
CI / build (push) Waiting to run
CI / test (push) Waiting to run
CI / test-pi-tui (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
Release / Release (push) Waiting to run
Release / Deploy docs (push) Blocked by required conditions
Release / Native release artifact (push) Blocked by required conditions
Release / Desktop release artifact (push) Blocked by required conditions
Release / Publish native release assets (push) Blocked by required conditions
2026-07-07 16:22:40 +08:00
7Sageer
1de5e625ee fix: align agent-core-v2 llm protocol 2026-07-07 16:21:26 +08:00
haozhe.yang
3dcb8ef4dd refactor(agent-core-v2): remove barrel re-exports in favor of direct imports
- delete per-directory index.ts barrel files across src/ submodules
- update src and test imports to reference concrete module files directly
- rename a few index.ts entry files to named modules (migration.ts, providers.ts, builtin.ts)
- rewire src/index.ts to export from concrete modules instead of directory barrels
- add patch changeset noting the production-build fix
2026-07-07 16:13:52 +08:00
_Kerman
cf9bca54e4 refactor(agent-core-v2): replace contextSize getStatus with ranged get
IAgentContextSizeService.getStatus() becomes get(start?, end?) returning { size, measured, estimated } where size = measured + estimated. start/end follow Array.prototype.slice semantics (default whole context, negative indices count from the end, inverted range is empty). Update consumers, the context:status action binding, tests, and the edge-exposure cheatsheet.
2026-07-07 16:06:05 +08:00
_Kerman
1a7b26472b refactor: full compaction types 2026-07-07 15:58:30 +08:00
liruifengv
063bce2a2f
fix(agent-core): hide console window when running hooks on Windows (#1466)
Pass windowsHide:true when spawning the hook process so a visible console
no longer flashes and steals focus on Windows. The Bash-tool path was
already hardened (KAOS buildLocalSpawnOptions); the hook runner missed the
flag even though its own taskkill helper already set it.

Extract the spawn options into a pure builder and add a regression test
asserting windowsHide, mirroring the existing KAOS spawn-options test.

Relates to #1298.
2026-07-07 15:55:47 +08:00