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>
- 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
- 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
- Remove ITerminalBackend abstraction and NotImplementedTerminalBackend
- Move node-pty spawn logic into IHostTerminalService implementation
- Drop server-v2 direct node-pty dependency (now via agent-core-v2)
- Update tests and server-v2 wiring to use IHostTerminalService directly
- Rewrite server-v2 terminal test model seed after model resolver refactor
- rename ToolStore to ToolState
- rename CronTaskStore to CronTaskPersistence
- rename SkillCatalogStore to SkillDiscovery
- rename WorkspaceStore to WorkspacePersistence
- rename IFileStore to IFileService and update server call sites
- add ServerClient under src/v2: typed /api/v2 resource tree over HTTP
plus events over WebSocket, with core/session/agent scopes and a v1
escape hatch for the legacy REST surface
- add resource modules (core/session/agent/events), a manifest mirroring
the server-v2 actionMap, shared types, and transport (HttpRpc,
rpcProxy, V2Socket)
- expose @moonshot-ai/server-v2/contract (actionMap + channel helpers)
so the SDK drift test stays in lockstep with the server surface
- add an in-process smoke test and the vitest raw-text/hash-imports
plugins needed to import server-v2 source from the e2e tests
- add optional bearer token support to the legacy HttpClient and document
the two-client package layout
- add Session-scoped ISessionBtwService/SessionBtwService that forks the
main agent into a side-question child agent (tools disabled,
side-channel reminder) via IAgentLifecycleService.fork('main')
- remove startBtw from AgentAPI (core-api) and ISessionLegacyService;
the server-v2 POST /sessions/{id}/btw route now resolves
ISessionBtwService directly
- add a unit test for SessionBtwService
- make IScopeHandle generic over LifecycleScope and add IAppScopeHandle /
ISessionScopeHandle / IAgentScopeHandle so session and agent handles cannot
be passed to each other's parameters at compile time
- thread the aliases through IAgentLifecycleService / ISessionLifecycleService
and their consumers (sessionLegacy, messageLegacy, server-v2 mainAgent and
skills), narrowing at the lifecycle boundary
- dep-graph viewer: render scope-mismatch (token registered at a scope the
caller cannot see) distinctly from a genuinely missing implementation
- add IAgentRecordService: append(record) fans out to durable persistence,
live broadcast, and replay capture via per-type facets
(toLive/toReplay/resume/blobs); signal(event) emits live-only events
- remove IAgentEventSinkService; fold live emission into IAgentRecordService
- migrate all agent domains to record.append/signal/define
- server-v2 subscribes to agent events via IAgentRecordService
- delete dead createLoopEventDispatcher
- AgentRecordMap extends WireRecordMap so record types stay on WireRecordMap
- add config-driven model catalog refresh scheduler (interval / on-start)
- refresh all providers and add the single-provider refresh endpoint
- broadcast model_catalog.changed to session subscribers
- finish wiring route handlers, middleware, and auth services
- align route and websocket tests with the authenticated server model
- rename service interfaces and implementations to carry the Session/Agent
scope prefix and Service suffix (e.g. IApprovalService ->
ISessionApprovalService, ApprovalService -> SessionApprovalService)
- rename LifecycleScope.Core to App in the DI base
- update DI createDecorator keys to match the new identifiers
- propagate the renames through server-v2 routes/transport, examples, docs,
and the agent-core-dev skill
- stamp `msg_<ulid>` on every message entering IContextMemory and persist it
in the context.splice wire record, so ids survive restore
- carry the provider response id as `providerMessageId` on assistant messages
- thread `promptMessageId` from prompt -> turn -> turn.started ->
InFlightTurnTracker, so snapshot `current_prompt_id` comes from the native
path instead of post-hoc enrichment
- project real ids on the wire and look up messages by id; drop the positional
parseMessageId
- make the v1 prompt_id equal its user message id
- add MessageLegacyService (agent-core-v2 L7 edge adapter) implementing the
v1 GET /sessions/{sid}/messages contract on top of the native services
- cold sessions: load + restore the main agent wire log and read the full
transcript from IReplayBuilderService; live sessions keep reading
IContextMemory
- rewrite the messages route as a thin adapter over the legacy service
- register the message.not_found (40403) error code in protocol and
agent-core-v2
- forward undo and archive results from ISessionLegacyService instead of
re-paginating undo in the route and hardcoding the archive response
- drop the AUTH_TOKEN_MISSING error mapping that v1 does not declare
- move the ContextMessage -> Message projection into agent-core-v2 so
the session legacy service owns the undo response shape
The v2 readiness probe returned a simplified snapshot: default_model was
hardcoded to null, providers_count counted only oauth providers, and
managed_provider was synthesized from any authenticated provider. Mirror
v1's AuthSummaryService.get() through a new L7 edge adapter.
- add IAuthLegacyService projecting provider/config/oauth state into the
v1 AuthSummary wire shape; the native IAuthSummaryService keeps serving
/api/v2 untouched
- default_model reads the configured defaultModel
- providers_count counts every configured provider
- managed_provider reflects managed:kimi-code cached-token state and is
null when that provider is absent
- ready matches v1 (providers >= 1, default model set, not revoked)
- register authLegacy at L7 in the domain-layer map
- read .git/HEAD and peel ref: refs/heads/<branch> to populate branch
- resolve the real git dir through a .git worktree/submodule file
- keep detached HEAD and unreadable files as branch: null
- add branch-resolution tests for slash branches, detached HEAD, and worktrees
- surface custom metadata in session index summaries so child sessions can be filtered without per-session document reads
- add ISessionLegacyService.createChild/listChildren: children are forks tagged with parent_session_id + child_session_kind, listed by those markers
- wire GET/POST /sessions/{id}/children and GET /sessions/{id}/warnings, reusing the protocol schemas and mapping session.not_found / session.fork_active_turn
- register the sessionLegacy domain at L7 in the domain-layer check
Bring the v1 WebSocket protocol to server-v2 so web clients get gap-free
sync across reconnects instead of silently losing events.
- per-session durable event journal with monotonic seq + epoch, recovered
across restarts
- SessionEventBroadcaster: single per-session fan-out, durable/volatile
classification, and cursor-based replay (buffer_overflow / epoch_changed)
- WsConnectionV1: client_hello / subscribe with cursors, replay or
resync_required, and ack carrying authoritative server cursors
- GET /sessions/:id/snapshot: atomic-at-a-watermark state and in-flight turn
- IAgentLifecycleService: onDidCreate / onDidDispose for agent discovery
- GET /connections: list live WebSocket clients
- register @fastify/swagger before routes and serve GET /openapi.json
- add v2-specific openapi transform for multipart upload, binary downloads, and the fs-action/question oneOf dispatchers
- project the session-action dispatcher into archive only (v2 registers a subset of v1 routes)
- reuse protocol wire schemas, no inline re-declaration
- add GET /sessions/{session_id}/skills and POST .../{name}:activate, mirroring the v1 wire contract and protocol schemas
- gate both endpoints on activated (live) sessions via ISessionLifecycleService; when persisted but not live, return 40401 with a "you need to activate it first" hint
- resolve ISkillCatalog for listing and the main agent's IAgentSkillService for activation; map skill.not_found to 40415 and skill.type_unsupported to 40912
- export IAgentSkillService and ISkillCatalog from agent-core-v2
- expose /api/v1/sessions/{sid}/fs:* mirror routes backed by the
Session-scoped IFsService (list, read, list_many, stat, stat_many,
mkdir, search, grep, git_status, diff, open, open-in, reveal) plus the
fs/{path}:download stream
- extend agent-core-v2 IFsService with list/read/stat/mkdir/resolve
methods and add fs.is_directory/is_binary/too_large/already_exists
error codes (protocol KimiErrorCode + FsErrors)
- seed IWorkspaceContext with the session work dir in session-lifecycle
so workspace-relative services resolve paths against the session root
- port fileLaunch lib for open/reveal/open-in
- IOAuthService/OAuthService now owns refreshOAuthProviderModels: the managed
OAuth provider's credential provisioning and server-side model refresh live
together in the auth domain.
- modelCatalog is back to a read-only catalog projection (listModels,
listProviders, getProvider, setDefaultModel); the OAuth refresh method and
its helpers are removed.
- server-v2 /providers:refresh_oauth route and the oauth example resolve
IOAuthService for the refresh.
- Move the refresh tests into test/auth and add the auth --> config edge to
the DI scope diagram.
- Add `kaos` domain (`IKaos` per session + `IKaosFactory`) wrapping
`@moonshot-ai/kaos`, so business code imports `#/kaos` instead of the
package directly.
- Back `agentFs` and `process` with `IKaos`; drop the per-domain
`IFileSystemBackend` / `IProcessBackend` interfaces and their
local/ssh stubs.
- Migrate `read-media`, `path-access`, `background/process-task`, and
`bootstrap` off direct kaos-package imports.
- Seed `IKaos` per session in `SessionLifecycleService` and expose
`agentFs` / `fs` on the server-v2 action map.
- Create the server-v2 main agent on demand (`ensureMainAgent`)
instead of failing requests when it is missing.
- replace the `/fs:action` parametric dispatcher with two routes that
mirror v1 (`/fs::browse`, `/fs::home`), so the wire path is the
single-colon `/api/v1/fs:browse` and `/api/v1/fs:home` that v1 serves
- update the folder-picker test to hit the single-colon URLs and assert
the double-colon form 404s, guarding against reintroducing the
parametric dispatcher
- bootstrap: storageSeed() now returns a per-token SyncDescriptor so
IStorageService / IAppendLogStorage / IAtomicDocumentStorage / IBlobStorage
each resolve to a distinct FileStorageService rooted at homeDir, instead of
sharing one instance. Keeps the roles independently routable.
- server-v2: drop the now-redundant durableStorageSeeds and rely on bootstrap()
for file-backed storage.
- add a regression test asserting the four tokens are distinct instances.
Port the v1 server's `/sessions/{sid}/tasks*` REST surface onto
agent-core-v2:
- GET /sessions/{sid}/tasks — list with optional `status` filter
- GET /sessions/{sid}/tasks/{tid} — get by id with optional
`with_output` / `output_bytes` preview
- POST /sessions/{sid}/tasks/{tid}:cancel — cancel with the
idempotent 40904 `{cancelled:false}` shape
The routes resolve the main agent's `IBackgroundService` through the
core -> session -> agent scope chain and project `BackgroundTaskInfo`
onto the protocol `BackgroundTask`, matching the v1 wire contract
(schemas, error codes, and messages). The `:cancel` suffix is parsed
via the shared `parseActionSuffix` helper.
Return turn_id from agent prompt and steer RPC/gateway methods, route
prompt submit/steer/undo/clear/cancel through IAgentRPCService in the
server-v2 action map, and cover prompt submission and missing-agent errors.
Add createdAt to parked interactions and keep a bounded recently-resolved
ledger so edge transports can distinguish duplicate resolves from unknown
ids. Cover the server-v2 approval duplicate-resolve path.
Replace the kosong domain with chatProvider, model, and modelRuntime
services, move model alias config and env overlay into model, and update
profile and LLM requester to resolve providers through IModelResolver and
IChatProviderFactory.
- GET /tools, GET /mcp/servers, POST /mcp/servers/{id}:restart
- resolve IToolRegistry / IMcpService from the most-recent session's
main agent; empty list / 40408 when no session is live
- project v2 models to the protocol wire shapes, matching
packages/server (source/status mapping, mcp_server_id, null input_schema)
- add GET /sessions/:sid/questions (list pending) and POST
/sessions/:sid/questions/:tail (resolve + :dismiss) on top of
IQuestionService / IInteractionService
- enrich the agent-core-v2 question domain with the rich in-process
model (QuestionItem / QuestionResult) and dismiss() so the v1 wire
can be projected faithfully
- reimplement the protocol <-> in-process adapter at the edge (no v1
agent-core import): synthesized item/option ids, allow_other,
expires_at, and the 5-kind answer flattening
- add GET /sessions/{sid}/messages (paginated, role-filtered) and GET /sessions/{sid}/messages/{message_id}
- thin wrapper over the main agent's IContextMemory, already exposed in the v2 action map
- port v1 id derivation, content mapping, pagination and role-filter semantics
- register the routes under /api/v1 and cover with tests
- add Core-scoped IModelCatalogService in agent-core-v2 covering
listModels, listProviders, getProvider, setDefaultModel, and
refreshOAuthProviderModels
- expose the v1-compatible /api/v1 models and providers catalog routes
in server-v2, mapping provider.not_found / model.not_found to the
numeric protocol error codes
- add IOAuthService.getCachedAccessToken for provider status detection
- register provider.not_found and model.not_found protocol error codes
- add `/sessions/{sid}/approvals` GET (list pending) and POST (resolve)
routes, backed by IApprovalService and IInteractionService; duplicate
resolves return 40902 via the kernel's recently-resolved window
- add `/workspaces` GET / POST / PATCH / DELETE routes, backed by
IWorkspaceRegistry, projecting v2 workspace records onto the v1 wire shape
- register both route groups in registerApiV1Routes
- add an agent-core-v2 interaction example that resolves the Session-scoped
kernel and approval/question facades through the scope tree
- map `workspaces:update` to IWorkspaceRegistry.update in the core actionMap
- cover the rename round-trip in rpc.test.ts
- sync the edge-exposure cheatsheet