nanobot

0

Описание

"🐈 nanobot: The Ultra-Lightweight OpenClaw" fork https://github.com/HKUDS/nanobot

Языки

  • Python87,3%
  • Shell5,5%
  • PowerShell4,4%
  • TypeScript2,1%
  • Dockerfile0,4%
  • JavaScript0,3%
2 месяца назад
2 месяца назад
2 месяца назад
README.md
nanobot

nanobot: Ultra-Lightweight Personal AI Assistant

PyPI Downloads Python License Feishu WeChat Discord

🐈 nanobot is an ultra-lightweight personal AI assistant inspired by OpenClaw

⚡️ Delivers core agent functionality in just ~4,000 lines of code — 99% smaller than Clawdbot's 430k+ lines.

📏 Real-time line count: 3,510 lines (run

bash core_agent_lines.sh
to verify anytime)

📢 News

  • 2026-02-10 🎉 Released v0.1.3.post6 with improvements! Check the updates notes and our roadmap.
  • 2026-02-09 💬 Added Slack, Email, and QQ support — nanobot now supports multiple chat platforms!
  • 2026-02-08 🔧 Refactored Providers—adding a new LLM provider now takes just 2 simple steps! Check here.
  • 2026-02-07 🚀 Released v0.1.3.post5 with Qwen support & several key improvements! Check here for details.
  • 2026-02-06 ✨ Added Moonshot/Kimi provider, Discord integration, and enhanced security hardening!
  • 2026-02-05 ✨ Added Feishu channel, DeepSeek provider, and enhanced scheduled tasks support!
  • 2026-02-04 🚀 Released v0.1.3.post4 with multi-provider & Docker support! Check here for details.
  • 2026-02-03 ⚡ Integrated vLLM for local LLM support and improved natural language task scheduling!
  • 2026-02-02 🎉 nanobot officially launched! Welcome to try 🐈 nanobot!

Key Features of nanobot:

🪶 Ultra-Lightweight: Just ~4,000 lines of core agent code — 99% smaller than Clawdbot.

🔬 Research-Ready: Clean, readable code that's easy to understand, modify, and extend for research.

⚡️ Lightning Fast: Minimal footprint means faster startup, lower resource usage, and quicker iterations.

💎 Easy-to-Use: One-click to deploy and you're ready to go.

🏗️ Architecture

nanobot architecture

✨ Features

📈 24/7 Real-Time Market Analysis

🚀 Full-Stack Software Engineer

📅 Smart Daily Routine Manager

📚 Personal Knowledge Assistant

Discovery • Insights • TrendsDevelop • Deploy • ScaleSchedule • Automate • OrganizeLearn • Memory • Reasoning

📦 Install

Install from source (latest features, recommended for development)

Install with uv (stable, fast)

Install from PyPI (stable)

🚀 Quick Start

Tip

Set your API key in

~/.nanobot/config.json
. Get API keys: OpenRouter (Global) · Brave Search (optional, for web search)

1. Initialize

2. Configure (

~/.nanobot/config.json
)

For OpenRouter - recommended for global users:

3. Chat

That's it! You have a working AI assistant in 2 minutes.

Update Without Losing Memory

Your agent's memory and local configuration are safely preserved during updates.

How it works:

  • Memory is stored in
    ~/.nanobot/workspace/
    (automatically ignored by git)
  • Your configuration in
    ~/.nanobot/config.json
    is local and won't be overwritten
  • Daily notes and long-term memory survive all updates

To update safely:

✅ Your memory, session history, and custom configurations remain intact.

Note

Local Models (vLLM)

Run nanobot with your own local models using vLLM or any OpenAI-compatible server.

1. Start your vLLM server

2. Configure (

~/.nanobot/config.json
)

3. Chat

Tip

The

apiKey
can be any non-empty string for local servers that don't require authentication.

💬 Chat Apps

Talk to your nanobot through Telegram, Discord, WhatsApp, Feishu, Mochat, DingTalk, Slack, Email, or QQ — anytime, anywhere.

ChannelSetup
TelegramEasy (just a token)
DiscordEasy (bot token + intents)
WhatsAppMedium (scan QR)
FeishuMedium (app credentials)
MochatMedium (claw token + websocket)
DingTalkMedium (app credentials)
SlackMedium (bot + app tokens)
EmailMedium (IMAP/SMTP credentials)
QQEasy (app credentials)
Telegram (Recommended)

1. Create a bot

  • Open Telegram, search
    @BotFather
  • Send
    /newbot
    , follow prompts
  • Copy the token

2. Configure

You can find your User ID in Telegram settings. It is shown as

@yourUserId
. Copy this value without the
@
symbol
and paste it into the config file.

3. Run

Mochat (Claw IM)

Uses Socket.IO WebSocket by default, with HTTP polling fallback.

1. Ask nanobot to set up Mochat for you

Simply send this message to nanobot (replace

xxx@xxx
with your real email):

Read https://raw.githubusercontent.com/HKUDS/MoChat/refs/heads/main/skills/nanobot/skill.md and register on MoChat. My Email account is xxx@xxx Bind me as your owner and DM me on MoChat.

nanobot will automatically register, configure

~/.nanobot/config.json
, and connect to Mochat.

2. Restart gateway

That's it — nanobot handles the rest!


Manual configuration (advanced)

If you prefer to configure manually, add the following to

~/.nanobot/config.json
:

Keep

claw_token
private. It should only be sent in
X-Claw-Token
header to your Mochat API endpoint.

Discord

1. Create a bot

2. Enable intents

  • In the Bot settings, enable MESSAGE CONTENT INTENT
  • (Optional) Enable SERVER MEMBERS INTENT if you plan to use allow lists based on member data

3. Get your User ID

  • Discord Settings → Advanced → enable Developer Mode
  • Right-click your avatar → Copy User ID

4. Configure

5. Invite the bot

  • OAuth2 → URL Generator
  • Scopes:
    bot
  • Bot Permissions:
    Send Messages
    ,
    Read Message History
  • Open the generated invite URL and add the bot to your server

6. Run

WhatsApp

Requires Node.js ≥18.

1. Link device

2. Configure

3. Run (two terminals)

Feishu (飞书)

Uses WebSocket long connection — no public IP required.

1. Create a Feishu bot

  • Visit Feishu Open Platform
  • Create a new app → Enable Bot capability
  • Permissions: Add
    im:message
    (send messages)
  • Events: Add
    im.message.receive_v1
    (receive messages)
    • Select Long Connection mode (requires running nanobot first to establish connection)
  • Get App ID and App Secret from "Credentials & Basic Info"
  • Publish the app

2. Configure

encryptKey
and
verificationToken
are optional for Long Connection mode.
allowFrom
: Leave empty to allow all users, or add
["ou_xxx"]
to restrict access.

3. Run

Tip

Feishu uses WebSocket to receive messages — no webhook or public IP needed!

QQ (QQ单聊)

Uses botpy SDK with WebSocket — no public IP required. Currently supports private messages only.

1. Register & create bot

  • Visit QQ Open Platform → Register as a developer (personal or enterprise)
  • Create a new bot application
  • Go to 开发设置 (Developer Settings) → copy AppID and AppSecret

2. Set up sandbox for testing

  • In the bot management console, find 沙箱配置 (Sandbox Config)
  • Under 在消息列表配置, click 添加成员 and add your own QQ number
  • Once added, scan the bot's QR code with mobile QQ → open the bot profile → tap "发消息" to start chatting

3. Configure

  • allowFrom
    : Leave empty for public access, or add user openids to restrict. You can find openids in the nanobot logs when a user messages the bot.
  • For production: submit a review in the bot console and publish. See QQ Bot Docs for the full publishing flow.

4. Run

Now send a message to the bot from QQ — it should respond!

DingTalk (钉钉)

Uses Stream Mode — no public IP required.

1. Create a DingTalk bot

  • Visit DingTalk Open Platform
  • Create a new app -> Add Robot capability
  • Configuration:
    • Toggle Stream Mode ON
  • Permissions: Add necessary permissions for sending messages
  • Get AppKey (Client ID) and AppSecret (Client Secret) from "Credentials"
  • Publish the app

2. Configure

allowFrom
: Leave empty to allow all users, or add
["staffId"]
to restrict access.

3. Run

Slack

Uses Socket Mode — no public URL required.

1. Create a Slack app

  • Go to Slack APICreate New App → "From scratch"
  • Pick a name and select your workspace

2. Configure the app

  • Socket Mode: Toggle ON → Generate an App-Level Token with
    connections:write
    scope → copy it (
    xapp-...
    )
  • OAuth & Permissions: Add bot scopes:
    chat:write
    ,
    reactions:write
    ,
    app_mentions:read
  • Event Subscriptions: Toggle ON → Subscribe to bot events:
    message.im
    ,
    message.channels
    ,
    app_mention
    → Save Changes
  • App Home: Scroll to Show Tabs → Enable Messages Tab → Check "Allow users to send Slash commands and messages from the messages tab"
  • Install App: Click Install to Workspace → Authorize → copy the Bot Token (
    xoxb-...
    )

3. Configure nanobot

4. Run

DM the bot directly or @mention it in a channel — it should respond!

Tip

  • groupPolicy
    :
    "mention"
    (default — respond only when @mentioned),
    "open"
    (respond to all channel messages), or
    "allowlist"
    (restrict to specific channels).
  • DM policy defaults to open. Set
    "dm": {"enabled": false}
    to disable DMs.
Email

Give nanobot its own email account. It polls IMAP for incoming mail and replies via SMTP — like a personal email assistant.

1. Get credentials (Gmail example)

  • Create a dedicated Gmail account for your bot (e.g.
    my-nanobot@gmail.com
    )
  • Enable 2-Step Verification → Create an App Password
  • Use this app password for both IMAP and SMTP

2. Configure

  • consentGranted
    must be
    true
    to allow mailbox access. This is a safety gate — set
    false
    to fully disable.
  • allowFrom
    : Leave empty to accept emails from anyone, or restrict to specific senders.
  • smtpUseTls
    and
    smtpUseSsl
    default to
    true
    /
    false
    respectively, which is correct for Gmail (port 587 + STARTTLS). No need to set them explicitly.
  • Set
    "autoReplyEnabled": false
    if you only want to read/analyze emails without sending automatic replies.

3. Run

⚙️ Configuration

Config file:

~/.nanobot/config.json

Providers

Tip

  • Groq provides free voice transcription via Whisper. If configured, Telegram voice messages will be automatically transcribed.
  • Zhipu Coding Plan: If you're on Zhipu's coding plan, set
    "apiBase": "https://open.bigmodel.cn/api/coding/paas/v4"
    in your zhipu provider config.
  • MiniMax (Mainland China): If your API key is from MiniMax's mainland China platform (minimaxi.com), set
    "apiBase": "https://api.minimaxi.com/v1"
    in your minimax provider config.
ProviderPurposeGet API Key
openrouter
LLM (recommended, access to all models)openrouter.ai
anthropic
LLM (Claude direct)console.anthropic.com
openai
LLM (GPT direct)platform.openai.com
deepseek
LLM (DeepSeek direct)platform.deepseek.com
groq
LLM + Voice transcription (Whisper)console.groq.com
gemini
LLM (Gemini direct)aistudio.google.com
minimax
LLM (MiniMax direct)platform.minimax.io
aihubmix
LLM (API gateway, access to all models)aihubmix.com
dashscope
LLM (Qwen)dashscope.console.aliyun.com
moonshot
LLM (Moonshot/Kimi)platform.moonshot.cn
zhipu
LLM (Zhipu GLM)open.bigmodel.cn
vllm
LLM (local, any OpenAI-compatible server)
Adding a New Provider (Developer Guide)

nanobot uses a Provider Registry (

nanobot/providers/registry.py
) as the single source of truth. Adding a new provider only takes 2 steps — no if-elif chains to touch.

Step 1. Add a

ProviderSpec
entry to
PROVIDERS
in
nanobot/providers/registry.py
:

Step 2. Add a field to

ProvidersConfig
in
nanobot/config/schema.py
:

That's it! Environment variables, model prefixing, config matching, and

nanobot status
display will all work automatically.

Common

ProviderSpec
options:

FieldDescriptionExample
litellm_prefix
Auto-prefix model names for LiteLLM
"dashscope"
dashscope/qwen-max
skip_prefixes
Don't prefix if model already starts with these
("dashscope/", "openrouter/")
env_extras
Additional env vars to set
(("ZHIPUAI_API_KEY", "{api_key}"),)
model_overrides
Per-model parameter overrides
(("kimi-k2.5", {"temperature": 1.0}),)
is_gateway
Can route any model (like OpenRouter)
True
detect_by_key_prefix
Detect gateway by API key prefix
"sk-or-"
detect_by_base_keyword
Detect gateway by API base URL
"openrouter"
strip_model_prefix
Strip existing prefix before re-prefixing
True
(for AiHubMix)

Security

For production deployments, set

"restrictToWorkspace": true
in your config to sandbox the agent.

OptionDefaultDescription
tools.restrictToWorkspace
false
When
true
, restricts all agent tools (shell, file read/write/edit, list) to the workspace directory. Prevents path traversal and out-of-scope access.
channels.*.allowFrom
[]
(allow all)
Whitelist of user IDs. Empty = allow everyone; non-empty = only listed users can interact.

CLI Reference

CommandDescription
nanobot onboard
Initialize config & workspace
nanobot agent -m "..."
Chat with the agent
nanobot agent
Interactive chat mode
nanobot agent --no-markdown
Show plain-text replies
nanobot agent --logs
Show runtime logs during chat
nanobot gateway
Start the gateway
nanobot status
Show status
nanobot channels login
Link WhatsApp (scan QR)
nanobot channels status
Show channel status

Interactive mode exits:

exit
,
quit
,
/exit
,
/quit
,
:q
, or
Ctrl+D
.

Scheduled Tasks (Cron)

🐳 Docker

Tip

The

-v ~/.nanobot:/root/.nanobot
flag mounts your local config directory into the container, so your config and workspace persist across container restarts.

Build and run nanobot in a container:

📁 Project Structure

nanobot/ ├── agent/ # 🧠 Core agent logic │ ├── loop.py # Agent loop (LLM ↔ tool execution) │ ├── context.py # Prompt builder │ ├── memory.py # Persistent memory │ ├── skills.py # Skills loader │ ├── subagent.py # Background task execution │ └── tools/ # Built-in tools (incl. spawn) ├── skills/ # 🎯 Bundled skills (github, weather, tmux...) ├── channels/ # 📱 Chat channel integrations ├── bus/ # 🚌 Message routing ├── cron/ # ⏰ Scheduled tasks ├── heartbeat/ # 💓 Proactive wake-up ├── providers/ # 🤖 LLM providers (OpenRouter, etc.) ├── session/ # 💬 Conversation sessions ├── config/ # ⚙️ Configuration ├── cli/ # 🖥️ Commands └── workspace/ └── defaults/ # 📋 Default agent rules & instructions

Your custom rules go in

~/.nanobot/workspace/
— see RULES_MANAGEMENT.md for details.

🤝 Contribute & Roadmap

PRs welcome! The codebase is intentionally small and readable. 🤗

Roadmap — Pick an item and open a PR!

  • Voice Transcription — Support for Groq Whisper (Issue #13)
  • Multi-modal — See and hear (images, voice, video)
  • Long-term memory — Never forget important context
  • Better reasoning — Multi-step planning and reflection
  • More integrations — Calendar and more
  • Self-improvement — Learn from feedback and mistakes

Contributors

Contributors

⭐ Star History

Thanks for visiting ✨ nanobot!

Views

nanobot is for educational, research, and technical exchange purposes only