What Is the Kimi-Inspect App? A Complete Guide to Debugging Kimi Code
Kimi-inspect is a web-based debugger UI that connects to a running kap-server (the Kimi Code engine) via its /api/v1/debug RPC surface, providing live visibility into workspaces, sessions, agents, and the scoped Dependency-Injection registry.
The kim-inspect application serves as the primary observability tool for developers working with the MoonshotAI/kimi-code repository. It transforms raw engine state into an interactive dashboard, enabling real-time inspection of internal runtime structures without stopping or modifying the server.
Core Purpose of Kimi-Inspect
According to the repository README, kim-inspect functions as "a read/trigger window into a running Kimi Code engine." This dual capability—observation and limited manipulation—makes it essential for development workflows.
The app communicates with kap-server through a dedicated debug RPC surface exposed at /api/v1/debug. This endpoint provides structured access to internal state that would otherwise require log parsing or debugger attachment.
Main Inspector Views
The kim-inspect UI organizes functionality into five primary views, accessible through a left-hand navigation rail defined in [apps/kimi-inspect/src/components/NavRail.tsx](https://github.com/MoonshotAI/kimi-code/blob/main/apps/kimi-inspect/src/components/NavRail.tsx).
Chat Workspace View
Displays active sessions with per-session chat histories and Agent-scope service panels. This view lets developers trace conversation flow and inspect agent-specific service bindings in real time.
Search View
Implements full-text, cross-session search via POST /api/v1/search. The implementation in [apps/kimi-inspect/src/components/SearchView.tsx](https://github.com/MoonshotAI/kimi-code/blob/main/apps/kimi-inspect/src/components/SearchView.tsx) exposes transcript and message content across all tracked sessions, with hit navigation directly into chat context.
Model Catalog View
Enumerates all configured providers and models, including detailed inspector panels for model provenance, capabilities, and runtime parameters.
App / Workspace Services View
Provides reflection of services at two DI scope levels:
- App scope: Global singleton services
- Workspace scope: Per-workspace service instances
The view uses the VS Code-style proxy channel implementation in [apps/kimi-inspect/src/channel/ProxyChannel.ts](https://github.com/MoonshotAI/kimi-code/blob/main/apps/kimi-inspect/src/channel/ProxyChannel.ts) to enumerate scoped services dynamically.
DI Inspection View
The most technically sophisticated view, implemented in [apps/kimi-inspect/src/components/DiInspectionView.tsx](https://github.com/MoonshotAI/kimi-code/blob/main/apps/kimi-inspect/src/components/DiInspectionView.tsx). This surface exposes:
- Unit tree: Hierarchical view of instantiated DI units
- Dependency graph: Visual representation of service relationships
- Cascade history: Lifecycle event tracking (provide, update, dispose)
- Pending units: Queued or blocked unit initializations
Data Synchronization Architecture
Kimi-inspect maintains state consistency through two mechanisms:
- Polling refresh: React Query with a 15-second interval for baseline data
- Event-driven updates: Subscription to
event.di.unit_changedfor immediate DI view invalidation
This hybrid approach balances freshness with server load, ensuring the DI inspection view reflects lifecycle changes without aggressive polling.
Multi-Server Support
The application includes automatic server discovery through a "Server Switcher" header dropdown. This enables developers to:
- Detect multiple kap-server instances on the network
- Switch contexts without restarting the inspector
- Compare state across different engine versions or configurations
Practical Usage Patterns
Starting the Debug Pipeline
# Terminal 1: Start kap-server with debug endpoints enabled
pnpm dev:v1 --debug-endpoints
# Terminal 2: Launch the inspector with auto-discovery
pnpm --filter @moonshot-ai/kimi-inspect dev
The --debug-endpoints flag (or --debug in v2) activates the /api/v1/debug surface that kim-inspect requires.
Programmatic Search Navigation
import { openSearchHit } from '@moonshot-ai/kimi-inspect/src/components/SearchView';
// Navigate from search result to specific chat location
openSearchHit({
sessionId: 'sess-123',
agentId: '',
turn: 42,
stepId: 'step-7',
});
This pattern enables custom tooling to inject search results into the inspector's active view.
Forcing DI State Refresh
import { klient } from './connection';
import { IDebugLedgerService } from '@moonshot-ai/agent-core-v2/debug';
// Manual refresh after lifecycle operations
klient.core(IDebugLedgerService).refresh();
While the UI polls automatically, explicit refresh triggers immediate synchronization after destructive operations like unit disposal.
Key Implementation Files
Summary
- Kimi-inspect is the dedicated debugger for kap-server, exposing internal state through a web UI
- Connects via
/api/v1/debugRPC surface with read and limited trigger capabilities - Five primary views: Chat Workspace, Search, Model Catalog, App/Workspace Services, and DI Inspection
- Uses 15s polling plus
event.di.unit_changedsubscription for state synchronization - Supports multi-server discovery and switching without restart
- Core files located in
apps/kimi-inspect/with clear separation between connection, view, and channel layers
Frequently Asked Questions
How do I enable the debug surface that kim-inspect requires?
Start kap-server with the --debug-endpoints flag (v1) or --debug flag (v2). Without this, the /api/v1/debug RPC surface remains inactive and kim-inspect cannot connect.
Can kim-inspect modify running services or only observe them?
The UI is primarily read-oriented but supports limited trigger operations. Through the DI Inspection view, you can invoke service actions including unprovide, update, and dispose—useful for testing dependency cascade behavior without code changes.
Does kim-inspect work with multiple kap-server instances simultaneously?
Yes. The Server Switcher dropdown in the header automatically discovers available servers and allows instant context switching. This supports workflows like comparing v1 and v2 engine behavior or debugging production versus development configurations.
What triggers updates in the DI Inspection view?
Two mechanisms: the 15-second React Query polling interval provides baseline synchronization, while the event.di.unit_changed websocket/event subscription pushes immediate updates when DI lifecycle events occur.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →