Commit graph

893 commits

Author SHA1 Message Date
_Kerman
5dd08b2426 refactor(agent-core-v2): simplify PermissionApprovalResultContext 2026-07-06 15:58:35 +08:00
_Kerman
bf5d7faa0c Merge branch 'kimi-code-v2' of https://github.com/MoonshotAI/kimi-code into kimi-code-v2 2026-07-06 15:57:31 +08:00
7Sageer
4aa50c0de9 feat(agent-core-v2): track mcp_connected/mcp_failed telemetry 2026-07-06 15:23:04 +08:00
7Sageer
4b84de2093 fix(agent-core-v2): align mcp media output with v1 2026-07-06 15:02:10 +08:00
haozhe.yang
7544de5d72 refactor(agent-core-v2): introduce wire model/op state engine
- add wire/ L2 domain: defineModel/defineOp primitives, OP_REGISTRY with DuplicateOpError guard, IWireService + WireService (dispatch/replay/signal/flush) and per-scope tokens
- extract per-domain *Ops + Models (goal, plan, profile, task, turn, usage, full/micro compaction, permission mode/rules, skill, swarm, tool state, user tool, context memory/size, cron, todo); services shrink to pure apply + wire dispatch
- drop legacy agent/record service superseded by the wire engine; dissolve llmProtocol/kosong into llmProtocol
- propagate wire emissions through protocol events and the server-v2 WS broadcaster
- add *-wire, store, and op-uniqueness lint tests; update existing tests and di-scope docs
2026-07-06 14:43:33 +08:00
7Sageer
bba9f4489f fix(server-v2): treat loopback origins as same-origin for WS upgrade
A browser behind a same-machine dev proxy (e.g. Vite on localhost:5175)
sends Origin localhost while the upstream server is bound to 127.0.0.1;
the two are not string-equal so the WS upgrade was rejected with 403.
Treat loopback<->loopback (localhost / 127.0.0.1 / [::1] / *.localhost)
as same-origin. Public cross-origin is unchanged, auth (401) is unchanged.
2026-07-06 14:17:03 +08:00
7Sageer
cb7be13f9a fix(server-v2): honor before_id cursor in GET /sessions pagination
Apply before_id/after_id id-cursors and page_size in the route handler
(FileSessionIndex does not implement a cursor, so page over its
recency-sorted result). Unknown cursor resolves to an empty terminal
page so clients cannot spin on a cursor the server cannot advance,
which caused the boot-time request storm on GET /api/v1/sessions.
2026-07-06 14:17:03 +08:00
haozhe.yang
82d7718ef5 fix(agent-core-v2): register TodoListTool via registerTool to break self-cycle
SessionTodoService (Session scope, eager) created TodoListTool with
createInstance inside bindAgent, which also ran from the constructor
catch-up loop. TodoListTool injects ISessionTodoService, so when an agent
already existed this re-entered the in-progress SessionTodoService and
threw a sessionTodoService -> sessionTodoService CyclicDependencyError.

Contribute TodoListTool through the module-level registerTool used by every
other builtin; AgentBuiltinToolsRegistrar instantiates it per agent on the
Agent scope, where the parent ISessionTodoService is already constructed.
SessionTodoService now only binds the stale-todo reminder and the main
agent todo.set resumer.
2026-07-06 11:29:26 +08:00
haozhe.yang
2f625b7b3e refactor(agent-core-v2): drop execContext domain, fold cwd into ISessionContext
- move the session's seeded cwd onto ISessionContext (set in sessionLifecycle)
  and delete the IExecContext value plus the session/execContext domain
- remove the dead envLayers/withEnv/withCwd surface; the process runner keeps
  only per-call options.env, matching v1 Kaos behaviour (no producer ever
  populated layers)
- drop the unused IExecContext injection from rpcService
- remove the public execContext re-export (no in-repo consumers) and update the
  layer map, the DI x Scope diagram source, and tests/harness (cwd now via
  TestAgentOptions.cwd)
2026-07-06 10:52:32 +08:00
haozhe.yang
c225a60f86 refactor(agent-core-v2): drop unwired session warning service
- remove ISessionWarningService/SessionWarningService skeleton, its barrel and test; the server-v2 warnings route already returns [] and nothing in v2 wired the service
- relocate SessionErrors codes to src/session/errors.ts so the redundant session/session/ directory is gone, and update the errors facade and package index exports
2026-07-06 09:12:43 +08:00
haozhe.yang
4a99a8dffe refactor(agent-core-v2): move edit capability to app scope and colocate EditTool
- add App-scope IFileEditService (textModel/editService/fileEdit) over IHostFileSystem, returning a domain-neutral FileEditResult
- turn EditTool into an Agent-scope adapter registered under app/edit/tools, injecting IFileEditService and mapping FileEditResult to ExecutableToolResult
- migrate edit tests to build EditTool through the container
2026-07-06 08:51:02 +08:00
haozhe.yang
8ec5f1901f refactor(agent-core-v2): rename agentFs domain to sessionFs
The Session-scoped fs facade backs the Web UI edge surface
(/api/v1 fs routes and /api/v2 fs:* actions), not the Agent -- the
Agent uses the os file tools instead. The `agentFs` name was a
leftover from when the interface was IAgentFileSystem.

- rename src/session/agentFs -> src/session/sessionFs (and tests)
- update #/session/agentFs imports and the 'agentFs' domain string
- update check-domain-layers entries, header/cross-ref comments, docs
- rename the misleading planService `agentFs` field to `hostFs`
  (it is an IHostFileSystem)
2026-07-06 08:43:27 +08:00
haozhe.yang
6ff2f62035 refactor(log): unify logging under _base/log as per-scope ILogService
- move logging to _base/log (contract, plain sinks, BoundLogger, AppLogService);
  drop Service suffix from new-able classes (RotatingFileWriter/FileLogWriter)
- single ILogService token: App and Session each bind an implementation, so
  consumers inject @ILogService and the scope picks the sink; remove
  ILogWriterService and ISessionLogService
- App log defaults to the global rotating file (fixes TUI console pollution and
  the ignored KIMI_LOG_LEVEL), with every sink routed through the redacting formatter
- Agent scope falls back to the Session logger (multiple agents share one session
  log file, so a single sink avoids rotate races)
2026-07-06 07:04:40 +08:00
_Kerman
95c7d99c11 Merge branch 'kimi-code-v2' of https://github.com/MoonshotAI/kimi-code into kimi-code-v2 2026-07-05 20:01:18 +08:00
haozhe.yang
ac9f528fd8 refactor(agent-core-v2): re-layer skill catalog around discovery + sink
- merge ISkillDiscovery into a single discover(roots); Global and Project
  differ only by which roots are passed (root resolution moved to
  userRoots/projectRoots, reusable without a Session)
- replace IGlobalSkillCatalog with pluggable ISkillSource producers
  (builtin/user at App, workspace/plugin at Session) that push into the
  Session skill sink
- SessionSkillCatalogService is now a priority-ordered merge sink
  (plugin > workspace > user > builtin) with ready/onDidChange, plus
  set/remove for future ad-hoc sources; fixes builtin wrongly winning
  name collisions over user
- renderSkillPrompt takes sessionId as an argument instead of baking it
  into the merged catalog value
- rename globalSkillCatalog -> skillCatalog; update the DI x Scope puml
  and the domain-layer map
2026-07-05 18:58:58 +08:00
haozhe.yang
66e766e0e0 refactor(agent-core-v2): unify storage layer on IFileSystemStorageService
- collapse Storage role tokens (IStorageService/IAtomicDocumentStorage/
  IAppendLogStorage/IBlobStorage) onto the single IFileSystemStorageService
  byte layer, with Store facades (append-log, atomic document, blob) above it
- rename AtomicDocumentStore to JsonAtomicDocumentStore and update IBlobStore
  references in server-v2
- add gen:contract-types script and tsconfig.contract.json for generating
  contract types, and ignore the .contract-types-tmp build dir
- document the storage read/write model in docs/rw-model-design.md and refresh
  the dep-graph analyzer and agent-core-dev skill docs
- update test stubs and server-v2 start/files to match
2026-07-05 13:47:04 +08:00
_Kerman
641a16618f refactor: move task notification XML renderer 2026-07-04 22:02:07 +08:00
_Kerman
9a869d94ad style: normalize agent-core-v2 service interface layout
Align all DI service contracts on _serviceBrand first, a blank line, methods and properties, then hooks last when present.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-04 17:54:21 +08:00
_Kerman
14e3c769f3 refactor: objectify agent loop run options 2026-07-04 17:30:38 +08:00
_Kerman
0d9d91f584 fix: remove TurnStartedEvent.origin 2026-07-04 17:23:52 +08:00
_Kerman
c0c9f155da fix: restore prompt id in server-v2 snapshots 2026-07-04 17:14:50 +08:00
_Kerman
8705d502f0 refactor: remove PromptOrigin from IAgentTurnService.launch
Turn origin is tracked on context messages instead; drop it from the turn launch API and wire records.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-04 17:03:45 +08:00
_Kerman
0d8b9f96ef refactor: remove promptMessageId from turn lifecycle
Turn no longer carries or emits the triggering message id; prompt and goal
callers keep message identity in context memory instead.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-04 16:24:17 +08:00
_Kerman
b71b2d20c2 refactor: ExecutableToolResult 2026-07-04 15:53:37 +08:00
_Kerman
86a7db1b35 refactor: remove lastEndedReason 2026-07-04 15:43:26 +08:00
_Kerman
14b5d581d8 refactor: promptService 2026-07-04 15:36:05 +08:00
_Kerman
589c6b6cf0 fix: rework steer 2026-07-04 15:32:17 +08:00
_Kerman
2471ae088f feat: simplify turn service 2026-07-04 15:04:06 +08:00
_Kerman
95901922e4 refactor: simplify loop and turn 2026-07-04 14:15:06 +08:00
_Kerman
4c2c3956fe refactor: generalize loop error recovery hook 2026-07-04 13:49:22 +08:00
_Kerman
58516f4900 feat: allow multi-shot hook 2026-07-04 13:11:40 +08:00
_Kerman
cc53ae6dd7 refactor: unify turn continuation handling 2026-07-04 12:22:14 +08:00
haozhe.yang
f060872ffc Merge remote-tracking branch 'origin/kimi-code-v2' into kimi-code-v2 2026-07-04 09:08:14 +08:00
haozhe.yang
b3ac27e79a refactor(agent-core-v2): make todo session-shared and wire-only
- move todo from agent scope (`IAgentTodoListService`) to session scope
  (`ISessionTodoService`); the list is now shared across every agent in a
  session instead of per-agent.
- persist every change as a `todo.set` record on the main agent's wire, which
  is the single source of truth and a replayable timeline; drop the agent
  tool-store `'todo'` key and the atomic-doc persistence store.
- bind `TodoListTool` and the stale reminder into every agent via
  `IAgentLifecycleService`, and register the `todo.set` resume resumer on the
  main agent.
- migrate `fullCompaction` to read `ISessionTodoService`; register the `todo`
  domain at L4 with a `todo>agentLifecycle` layer exception; refresh the DI
  scope/domain diagram.
2026-07-03 23:30:55 +08:00
_Kerman
483fc99696 Merge branch 'kimi-code-v2' of https://github.com/MoonshotAI/kimi-code into kimi-code-v2 2026-07-03 22:59:50 +08:00
_Kerman
0f77fa8a2e fix: full compaction 2026-07-03 22:59:42 +08:00
haozhe.yang
bcc9bc095f refactor(agent-core-v2): drop ISessionAgentFileSystem, use os layer
- remove the ISessionAgentFileSystem service and its node implementation
- extend IHostFileSystem with readText decode options and stat mtimeMs/ino
- route SessionFsService, profile context, media, and plan through IHostFileSystem
- drop the unused agentFs:* session REST endpoints from server-v2/server-e2e
2026-07-03 21:08:00 +08:00
haozhe.yang
80d65c7a85 refactor(agent-core-v2): split file tools and edit service
- route read/write/grep/glob through host fs and process services
- add TextModel/EditService with an os-backed FileEditService
- update file tool tests, exports, layer rules, and DI docs
2026-07-03 20:42:55 +08:00
_Kerman
5ccfe76546 fix: projector and ready promise 2026-07-03 20:11:54 +08:00
_Kerman
ec53d89739 fix: context injector and projector 2026-07-03 19:40:47 +08:00
_Kerman
87faa7897b Merge branch 'kimi-code-v2' of https://github.com/MoonshotAI/kimi-code into kimi-code-v2 2026-07-03 18:15:12 +08:00
_Kerman
b00027b912 fix: loop result 2026-07-03 18:15:06 +08:00
haozhe.yang
33fbbcb451 Merge remote-tracking branch 'origin/kimi-code-v2' into kimi-code-v2 2026-07-03 17:54:05 +08:00
_Kerman
6e4baf8dc2 Merge branch 'kimi-code-v2' of https://github.com/MoonshotAI/kimi-code into kimi-code-v2 2026-07-03 17:09:05 +08:00
_Kerman
030cf793d5 refactor: task instead of background task 2026-07-03 16:57:46 +08:00
haozhe.yang
b05c30e705 refactor(cron): consolidate cron domain into app/cron
- add app/cron barrel re-exporting the cron task record, persistence contract/service, and dependency-free algorithm lib (cron-expr, jitter, clock, format)
- move cronTask persistence files from app/cronPersistence into app/cron and drop the old cronPersistence barrel
- register the cron config section (KIMI_CRON_* env bindings) via configSection
- repoint cron tests from #/agent/cron and #/app/cronPersistence to #/app/cron
2026-07-03 16:53:54 +08:00
haozhe.yang
649ba03783 refactor(agent-core-v2): relocate builtin profile contributions
- move plan profile into plan domain profile/
- move agent/coder/explore profiles into agentLifecycle domain profile/
- add shared profile prompt helper and update barrel side-effect imports
2026-07-03 16:49:45 +08:00
_Kerman
0cc1329a25 Merge remote-tracking branch 'origin/main' into kimi-code-v2
# Conflicts:
#	package.json
#	packages/server/src/routes/prompts.ts
#	pnpm-lock.yaml
2026-07-03 15:48:13 +08:00
haozhe.yang
c7c4b50d8c refactor(agent-core-v2): flatten task module interface directory
- move task.ts from task/interface/ up to task/
- remove the task/interface/ barrel directory
- update imports in task barrel, taskService, and tests
2026-07-03 15:47:40 +08:00
haozhe.yang
b432d302d3 refactor(agent-core-v2): bind profile in spawn, drop compat barrels
- spawn now accepts `profile` and binds it, removing applyProfileToAgent
- delete app/storage, app/hostEnvironment, app/hostFs re-export barrels
- update consumers to import from persistence/interface and os/interface
- add AgentProfileService.bind tests
2026-07-03 15:43:17 +08:00