Zhin.js

Zhin.js

Write once in TypeScript. Run your bot across 20+ chat platforms.
File-based commands, cross-platform JSX cards, leak-free hot reload, and opt-in AI agents — managed from the browser.
QQ · WeChat · WeCom · DingTalk · Lark · Discord · Telegram · Slack · KOOK · LINE · …

CI npm npm downloads Node License: MIT codecov Docs

English · 简体中文

Documentation · Plugin Authoring · Operator Guide · Live Demo · Remote Console · Contributing

--- > **Running a bot without writing code?** Jump to the [Operator & Group Admin Guide](./docs/en/customer/index.md) or try the [Live Demo](https://demo.zhin.dev). Building plugins or adapters in TypeScript? Start right below or browse [Plugin Authoring](./docs/en/authoring/define-plugin.md). ## 30-Second Quick Start No platform account and no model key required (Node.js **≥22.19.0**, pnpm 9+): ```bash npm create zhin-app my-bot -- -y --adapter sandbox cd my-bot pnpm dev # zhin start --foreground: management gateway + your bot, hot reload ``` 1. **Finish setup in the Console**: open the Console link printed in the terminal (`https://console.zhin.dev/?apiBaseUrl=…#token=…`; the bootstrap token after `#` never leaves your browser). Keep the default SQLite database and create the owner account. 2. **Chat with the Sandbox**: in the Console, open **Conversations → Sandbox** and send `/hello`. (The standalone page `http://127.0.0.1:8068/sandbox` works without signing in only before step 1; once the owner exists it needs a Console API token, issued under your user name → **Personal settings** (`/account`) and pasted into the box at the top right.) 3. **Run it in the background**: `npx zhin start` (then `zhin status`, `zhin logs -f`, `zhin stop`). Full walkthrough: [Quick start](./docs/en/getting-started/index.md) · Something wrong? Run `npx zhin doctor`. > [!IMPORTANT] > **Upgrading an existing bot from 1.1.13 or earlier?** The Runtime now only accepts `configVersion: 2`. Stop the Bot first, upgrade `zhin.js` / `@zhin.js/cli` to the latest, then run `zhin migrate instances` (preview) and `zhin migrate instances --apply` (backs up first). Full steps and restore: [Upgrading to configVersion 2](./docs/en/operations/upgrades.md#configversion-2). > > **Upgrading from single-process `zhin runtime start`?** `zhin start` now runs a long-lived management gateway that supervises the bot; Console accounts replace `http.tokens`. Install `@zhin.js/gateway` with the same release of `zhin.js` / `@zhin.js/cli` and follow [Upgrading to the management gateway](./docs/en/migrations/management-gateway.md). ## Why Zhin.js? Zhin.js is a TypeScript framework for **bots that live in chat apps** — community bots, personal assistants, notification and support bots, and governed AI chat assistants. - **One codebase, 20+ platforms.** Adapters translate each platform into one unified message model. One bot can host multiple accounts across multiple platforms simultaneously. - **A feature is a file.** Drop a file in `commands/`, `middlewares/`, `components/`, `schedules/`, or `tools/` and it registers automatically — zero wiring boilerplate. - **Generation-isolated hot reload.** Save a file and Zhin atomically swaps in a new Generation. In-flight messages finish on the previous version; if new code throws on startup, the previous version keeps serving without downtime. - **Small by default (<10MB), AI when you want it.** The IM core needs no LLM dependencies. Add AI agents, tools, 3-layer Markdown memory, and MCP anytime with `npx zhin setup --ai`. - **Browser Console & Server-Driven Blueprints included.** Manage accounts, edit schema-driven forms, replay AI decisions, and trigger emergency stops from [console.zhin.dev](https://console.zhin.dev). Plugins author pure TypeScript `definePageBlueprint` pages (`pages//index.ts` — zero `.tsx`, zero `esbuild` bundling) that render in Web Console and project into IM cards (`projectBlueprintToImCard`) or CLI TUI panels (`projectBlueprintToCliPanel`). > Zhin is **not** an in-editor coding agent (like Cursor or Claude Code). Its AI stack is purpose-built for chat platforms, group permissions, and multi-user conversations. ## Show, Don't Tell: 3 Killer Features ### 1. Command + Cross-Platform JSX Card & Interactive Button Write interactive cards once in JSX (`commands/poll/index.tsx`). On platforms that support buttons, users click directly; on plain-text platforms, Zhin automatically degrades `