kimi-code/packages/node-sdk
2026-10-20 18:17:29 +08:00
..
scripts chore: checkpoint pre-migration state (old agent-core/harness-core API and app wiring) 2026-10-20 18:17:29 +08:00
src chore: checkpoint pre-migration state (old agent-core/harness-core API and app wiring) 2026-10-20 18:17:29 +08:00
test chore: checkpoint pre-migration state (old agent-core/harness-core API and app wiring) 2026-10-20 18:17:29 +08:00
api-extractor.json refactor: remove packages/kosong (#3819) 2026-09-16 16:25:44 +08:00
CHANGELOG.md ci: release packages (#3456) 2026-09-02 17:18:07 +08:00
package.json chore: checkpoint pre-migration state (old agent-core/harness-core API and app wiring) 2026-10-20 18:17:29 +08:00
README.md chore: checkpoint pre-migration state (old agent-core/harness-core API and app wiring) 2026-10-20 18:17:29 +08:00
tsconfig.api-extractor.json Kimi For Coding 2026-05-22 15:54:50 +08:00
tsconfig.dts.json chore: checkpoint pre-migration state (old agent-core/harness-core API and app wiring) 2026-10-20 18:17:29 +08:00
tsconfig.json chore: checkpoint pre-migration state (old agent-core/harness-core API and app wiring) 2026-10-20 18:17:29 +08:00
tsdown.config.ts refactor: remove packages/kosong (#3819) 2026-09-16 16:25:44 +08:00
vitest.config.ts test: stabilize the full suite on macOS developer machines (#3643) 2026-09-08 16:21:16 +08:00

@moonshot-ai/kimi-code-sdk

The TypeScript SDK for Kimi Code.

Part of the Kimi Code monorepo.

This package is a composition layer over @moonshot-ai/agent-core (v3) and @moonshot-ai/harness-core: createKimiHarness mounts the Kimi feature set (profiles, skills, MCP, permission, compaction, session export, models.dev, plugins, ...) onto a filesystem-backed session space and returns a single harness object. It is v3-backed end to end — there is no v2 compatibility surface: the old Session / Event / config-RPC API was removed, and every capability is reached through the facades below.

Quickstart

import { createUserMessage } from '@moonshot-ai/agent-core';
import { createKimiHarness } from '@moonshot-ai/kimi-code-sdk';

const harness = await createKimiHarness({ workDir: process.cwd() });
try {
  await harness.ensureConfigFile();
  const session = await harness.createSession();
  const result = await session.main.run(createUserMessage('Say hello.'));
  console.log(result.outcome);
} finally {
  await harness.close();
}

createKimiHarness options: workDir (required), homeDir, configPath, identity, version, userAgent, uiMode ('interactive' | 'print' — print mode makes permission non-interactive), skillDirs, additionalDirs, telemetry, onOAuthRefresh.

Harness surface

  • harness.config — typed config facade over config.toml: get(name), set(name, value, target?), replace(sections, target?), reload(), diagnostics().
  • harness.auth — OAuth/managed-auth facade: login, logout, status, getCachedAccessToken, getManagedUsage, feedback upload helpers.
  • harness.trust — workspace trust store (isTrusted(workDir), ...).
  • harness.app — the underlying agent-core AppHandle; resolve feature facades (PermissionRef, GoalRef, ModelsDevRef, McpRef, ...) and manage sessions directly when the convenience methods are not enough.
  • harness.homeDir / workDir / configPath.
  • harness.track(event, properties) / harness.setTelemetryContext(patch) — telemetry hooks (a no-op client unless one is injected).
  • harness.ensureConfigFile(), harness.close().

Sessions

  • harness.createSession(input?) / harness.resumeSession(id) / harness.forkSession(fromId) → KimiSession.
  • harness.listSessions() / harness.deleteSession(id) / harness.renameSession(id, title) / harness.exportSession(id, opts).
  • session.id, session.handle (the v3 SessionHandle — agent registry and session-tier events), session.main (the main AgentHandle: run, on, wait, resolve, setConfig, setRequester), session.close().

Agent and session event types (AgentEmitted, turn/tool/llm events), message helpers (createUserMessage), and feature facade tokens come from @moonshot-ai/agent-core / @moonshot-ai/harness-core directly; this package does not re-wrap them.

License

MIT