What Are the Dependencies for the Kimi-Code Packages? Complete Monorepo Reference
The Kimi-Code monorepo declares dependencies for each TypeScript package in dedicated package.json manifests under packages/, ranging from LLM SDKs like @anthropic-ai/sdk and openai to infrastructure libraries like node-pty, ssh2, and zod for schema validation.
The MoonshotAI/kimi-code repository is organized as a TypeScript monorepo where distinct functional areas are encapsulated in separate packages. Understanding the dependencies for the kimi-code packages is essential for contributors and integrators, as each module pins its specific runtime requirements in its own manifest, from the core agent engine to the terminal UI renderer.
Core Agent Engine Dependencies
The agent engines form the heart of the system and pull in the most extensive dependency trees for validation, networking, and execution.
Agent Core (V1)
In packages/agent-core/package.json, the foundational unified agent engine relies on Zod for schema validation alongside networking and filesystem utilities. Runtime dependencies include:
- LLM and Protocol Integration:
@moonshot-ai/kosong,@moonshot-ai/protocol,@modelcontextprotocol/sdk,@moonshot-ai/kaos,@moonshot-ai/kimi-code-oauth - Execution Environment:
node-pty,nunjucks - Media and File Processing:
@jsquash/webp,chokidar,ignore,jimp,js-yaml,smol-toml,tar,yauzl - Networking:
undici,socks,open - Validation and Parsing:
ajv,linkedom,@mozilla/readability,picomatch,proper-lockfile,regexp.escape,zod - Utilities:
@antfu/utils,pathe,retry,ulid
Agent Core V2
Located in packages/agent-core-v2/package.json, the DI-scope version extends the V1 dependency set to support additional LLM providers and internal tooling:
- Additional LLM SDKs:
@anthropic-ai/sdk,@google/genai,openai - Internal Extensions:
@moonshot-ai/minidb,@moonshot-ai/tree-sitter-bash
LLM Provider Abstraction Layer
The @moonshot-ai/kosong package normalizes access to multiple LLM APIs. According to packages/kosong/package.json, it depends on:
@anthropic-ai/sdk@google/genaiopenaizodzod-to-json-schema
This layer ensures type-safe schema generation across Anthropic, Google, and OpenAI models while normalizing their disparate APIs.
Data Layer and SDK Packages
Transcript
The @moonshot-ai/transcript package maintains isomorphic data contracts for transcript operations with minimal footprint. As defined in packages/transcript/package.json, it requires only Zod for runtime validation of transcript schemas.
Kimi-Code SDK (Node SDK)
The public TypeScript SDK (@moonshot-ai/kimi-code-sdk) declared in packages/node-sdk/package.json provides archive creation and TOML handling through:
@antfu/utilssmol-tomlyazlzod
Terminal UI and Infrastructure Utilities
Pi-TUI
The @moonshot-ai/pi-tui terminal UI rendering library depends on get-east-asian-width for CJK width calculations and Marked for Markdown rendering, as specified in packages/pi-tui/package.json.
OAuth Toolkit
The @moonshot-ai/kimi-code-oauth package manages lock-file based token persistence using proper-lockfile in packages/oauth/package.json.
Kaos Execution Environment
The @moonshot-ai/kaos abstraction layer in packages/kaos/package.json provides path utilities via pathe and remote execution capabilities through ssh2.
Dependency-Free Packages
Two core packages operate without external runtime dependencies, implementing functionality in pure TypeScript:
@moonshot-ai/minidb: An embedded JSON document store used for global search indexing, defined inpackages/minidb/package.json.@moonshot-ai/protocol: Shared REST and WebSocket API type definitions located inpackages/protocol/package.json.
Working with Dependencies in Practice
When consuming these packages, the declared dependencies surface at runtime through specific import patterns.
To instantiate the V2 agent engine with OpenAI and Anthropic providers:
import { Agent } from '@moonshot-ai/agent-core-v2';
import { OpenAIProvider } from '@moonshot-ai/kosong/openai';
import { AnthropicProvider } from '@moonshot-ai/kosong/anthropic';
const agent = new Agent({
provider: new OpenAIProvider({ apiKey: process.env.OPENAI_API_KEY! }),
});
agent.addTool({
name: 'summarize',
description: 'Summarize a text block',
// The request is validated by `zod` (runtime dependency)
schema: z.object({ text: z.string() }),
});
For terminal UI rendering with Marked integration:
import { render } from '@moonshot-ai/pi-tui';
import { marked } from 'marked'; // pulled in via pi-tui deps
const markdown = '# Hello\nThis is a **Kimi** TUI demo.';
render(marked(markdown));
To launch a session using the SDK:
import { createClient } from '@moonshot-ai/kimi-code-sdk';
const client = createClient({ url: 'http://localhost:58627' });
await client.sessions.create({ name: 'demo' });
Summary
- Agent Core V1 (
packages/agent-core/package.json) provides the base engine with validation, networking, and filesystem utilities includingzod,ajv,node-pty, andundici. - Agent Core V2 (
packages/agent-core-v2/package.json) adds first-party LLM SDKs for Anthropic, Google, and OpenAI alongside@moonshot-ai/minidband@moonshot-ai/tree-sitter-bash. - Kosong (
packages/kosong/package.json) abstracts LLM providers with dependencies on@anthropic-ai/sdk,@google/genai,openai, andzod-to-json-schema. - Pure TypeScript packages like
@moonshot-ai/minidband@moonshot-ai/protocolcarry zero external runtime dependencies. - SDK and TUI packages (
packages/node-sdk/package.json,packages/pi-tui/package.json) provide focused utility sets for ZIP archive handling (yazl) and Markdown rendering (marked), respectively.
Frequently Asked Questions
Which package contains the OpenAI and Anthropic SDK dependencies?
The @moonshot-ai/kosong package explicitly depends on @anthropic-ai/sdk, @google/genai, and openai in packages/kosong/package.json. Additionally, @moonshot-ai/agent-core-v2 includes these SDKs directly to support provider instantiation within the DI-scoped agent engine.
Are there any packages in the Kimi-Code monorepo without external dependencies?
Yes. According to the source manifests, both @moonshot-ai/minidb (the embedded JSON document store) and @moonshot-ai/protocol (shared API type definitions) are implemented in pure TypeScript and declare no external runtime dependencies in packages/minidb/package.json and packages/protocol/package.json.
How does the Kimi-Code SDK handle archive creation?
The @moonshot-ai/kimi-code-sdk package relies on the yazl library for ZIP archive generation, alongside smol-toml for TOML parsing and zod for runtime type safety, as declared in packages/node-sdk/package.json.
What dependency is used for terminal UI Markdown rendering?
The @moonshot-ai/pi-tui package depends on marked for Markdown-to-HTML conversion within the terminal interface, as specified in packages/pi-tui/package.json. It also uses get-east-asian-width to properly calculate character widths for CJK text rendering.
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 →