# What Is the Kimi-Inspect App? A Complete Guide to Debugging Kimi Code

> Learn how to debug Kimi code with the kimi-inspect app. This guide explains its purpose as a web-based debugger UI for live visibility into workspaces, sessions, and more.

- Repository: [Moonshot AI/kimi-code](https://github.com/MoonshotAI/kimi-code)
- Tags: deep-dive
- Published: 2026-08-14

---

**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](https://github.com/MoonshotAI/kimi-code/blob/main/apps/kimi-inspect/README.md), 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)](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)](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)](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)](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:

1. **Polling refresh**: React Query with a 15-second interval for baseline data
2. **Event-driven updates**: Subscription to `event.di.unit_changed` for 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

```bash

# 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

```tsx
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

```tsx
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

| File Path | Responsibility |
|-----------|---------------|
| [[`apps/kimi-inspect/README.md`](https://github.com/MoonshotAI/kimi-code/blob/main/apps/kimi-inspect/README.md)](https://github.com/MoonshotAI/kimi-code/blob/main/apps/kimi-inspect/README.md) | Documentation and view overview |
| [[`apps/kimi-inspect/src/App.tsx`](https://github.com/MoonshotAI/kimi-code/blob/main/apps/kimi-inspect/src/App.tsx)](https://github.com/MoonshotAI/kimi-code/blob/main/apps/kimi-inspect/src/App.tsx) | Application shell, connection management, view routing |
| [[`apps/kimi-inspect/src/components/NavRail.tsx`](https://github.com/MoonshotAI/kimi-code/blob/main/apps/kimi-inspect/src/components/NavRail.tsx)](https://github.com/MoonshotAI/kimi-code/blob/main/apps/kimi-inspect/src/components/NavRail.tsx) | Left-hand view selector |
| [[`apps/kimi-inspect/src/components/DiInspectionView.tsx`](https://github.com/MoonshotAI/kimi-code/blob/main/apps/kimi-inspect/src/components/DiInspectionView.tsx)](https://github.com/MoonshotAI/kimi-code/blob/main/apps/kimi-inspect/src/components/DiInspectionView.tsx) | DI debug surface implementation |
| [[`apps/kimi-inspect/src/components/SearchView.tsx`](https://github.com/MoonshotAI/kimi-code/blob/main/apps/kimi-inspect/src/components/SearchView.tsx)](https://github.com/MoonshotAI/kimi-code/blob/main/apps/kimi-inspect/src/components/SearchView.tsx) | Cross-session search UI |
| [[`apps/kimi-inspect/src/channel/ProxyChannel.ts`](https://github.com/MoonshotAI/kimi-code/blob/main/apps/kimi-inspect/src/channel/ProxyChannel.ts)](https://github.com/MoonshotAI/kimi-code/blob/main/apps/kimi-inspect/src/channel/ProxyChannel.ts) | Scoped service enumeration |
| [[`apps/kimi-inspect/package.json`](https://github.com/MoonshotAI/kimi-code/blob/main/apps/kimi-inspect/package.json)](https://github.com/MoonshotAI/kimi-code/blob/main/apps/kimi-inspect/package.json) | Build configuration and scripts |

## Summary

- **Kimi-inspect** is the dedicated debugger for kap-server, exposing internal state through a web UI
- Connects via `/api/v1/debug` RPC 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_changed` subscription 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.