Thanks to visit codestin.com
Credit goes to github.com

Skip to content
forked from HKUDS/nanobot

"🐈 nanobot: The Ultra-Lightweight Clawdbot"

License

Notifications You must be signed in to change notification settings

Atarasin/nanobot

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

234 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

nanobot

nanobot: Ultra-Lightweight Personal AI Assistant

PyPI Downloads Python License Feishu WeChat Discord

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

⚑️ 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-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 β€’ Trends Develop β€’ Deploy β€’ Scale Schedule β€’ Automate β€’ Organize Learn β€’ Memory β€’ Reasoning

πŸ“¦ Install

Install from source (latest features, recommended for development)

git clone https://github.com/HKUDS/nanobot.git
cd nanobot
pip install -e .

Install with uv (stable, fast)

uv tool install nanobot-ai

Install from PyPI (stable)

pip install nanobot-ai

πŸš€ Quick Start

Tip

Set your API key in ~/.nanobot/config.json. Get API keys: OpenRouter (Global) Β· DashScope (Qwen) Β· Brave Search (optional, for web search)

1. Initialize

nanobot onboard

2. Configure (~/.nanobot/config.json)

For OpenRouter - recommended for global users:

{
  "providers": {
    "openrouter": {
      "apiKey": "sk-or-v1-xxx"
    }
  },
  "agents": {
    "defaults": {
      "model": "anthropic/claude-opus-4-5"
    }
  }
}

3. Chat

nanobot agent -m "What is 2+2?"

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

πŸ–₯️ Local Models (vLLM)

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

1. Start your vLLM server

vllm serve meta-llama/Llama-3.1-8B-Instruct --port 8000

2. Configure (~/.nanobot/config.json)

{
  "providers": {
    "vllm": {
      "apiKey": "dummy",
      "apiBase": "http://localhost:8000/v1"
    }
  },
  "agents": {
    "defaults": {
      "model": "meta-llama/Llama-3.1-8B-Instruct"
    }
  }
}

3. Chat

nanobot agent -m "Hello from my local LLM!"

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, DingTalk, Slack, Email, or QQ β€” anytime, anywhere.

Channel Setup
Telegram Easy (just a token)
Discord Easy (bot token + intents)
WhatsApp Medium (scan QR)
Feishu Medium (app credentials)
DingTalk Medium (app credentials)
Slack Medium (bot + app tokens)
Email Medium (IMAP/SMTP credentials)
QQ Easy (app credentials)
Telegram (Recommended)

1. Create a bot

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

2. Configure

{
  "channels": {
    "telegram": {
      "enabled": true,
      "token": "YOUR_BOT_TOKEN",
      "allowFrom": ["YOUR_USER_ID"]
    }
  }
}

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

nanobot gateway
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

{
  "channels": {
    "discord": {
      "enabled": true,
      "token": "YOUR_BOT_TOKEN",
      "allowFrom": ["YOUR_USER_ID"]
    }
  }
}

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

nanobot gateway
WhatsApp

Requires Node.js β‰₯18.

1. Link device

nanobot channels login
# Scan QR with WhatsApp β†’ Settings β†’ Linked Devices

2. Configure

{
  "channels": {
    "whatsapp": {
      "enabled": true,
      "allowFrom": ["+1234567890"]
    }
  }
}

3. Run (two terminals)

# Terminal 1
nanobot channels login

# Terminal 2
nanobot gateway
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

{
  "channels": {
    "feishu": {
      "enabled": true,
      "appId": "cli_xxx",
      "appSecret": "xxx",
      "encryptKey": "",
      "verificationToken": "",
      "allowFrom": []
    }
  }
}

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

nanobot gateway

[!TIP] Feishu uses WebSocket to receive messages β€” no webhook or public IP needed!

QQ (QQ私聊)

Uses botpy SDK with WebSocket β€” no public IP required.

1. Create a QQ bot

  • Visit QQ Open Platform
  • Create a new bot application
  • Get AppID and Secret from "Developer Settings"

2. Configure

{
  "channels": {
    "qq": {
      "enabled": true,
      "appId": "YOUR_APP_ID",
      "secret": "YOUR_APP_SECRET",
      "allowFrom": []
    }
  }
}

allowFrom: Leave empty for public access, or add user openids to restrict access. Example: "allowFrom": ["user_openid_1", "user_openid_2"]

3. Run

nanobot gateway

[!TIP] QQ bot currently supports private messages only. Group chat support coming soon!

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

{
  "channels": {
    "dingtalk": {
      "enabled": true,
      "clientId": "YOUR_APP_KEY",
      "clientSecret": "YOUR_APP_SECRET",
      "allowFrom": []
    }
  }
}

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

3. Run

nanobot gateway
Slack

Uses Socket Mode β€” no public URL required.

1. Create a Slack app

  • Go to Slack API β†’ Create New App
  • OAuth & Permissions: Add bot scopes: chat:write, reactions:write, app_mentions:read
  • Install to your workspace and copy the Bot Token (xoxb-...)
  • Socket Mode: Enable it and generate an App-Level Token (xapp-...) with connections:write scope
  • Event Subscriptions: Subscribe to message.im, message.channels, app_mention

2. Configure

{
  "channels": {
    "slack": {
      "enabled": true,
      "botToken": "xoxb-...",
      "appToken": "xapp-...",
      "groupPolicy": "mention"
    }
  }
}

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

3. Run

nanobot gateway
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. [email protected])
  • 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.
{
  "channels": {
    "email": {
      "enabled": true,
      "consentGranted": true,
      "imapHost": "imap.gmail.com",
      "imapPort": 993,
      "imapUsername": "[email protected]",
      "imapPassword": "your-app-password",
      "smtpHost": "smtp.gmail.com",
      "smtpPort": 587,
      "smtpUsername": "[email protected]",
      "smtpPassword": "your-app-password",
      "fromAddress": "[email protected]",
      "allowFrom": ["[email protected]"]
    }
  }
}

3. Run

nanobot gateway

βš™οΈ 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.
Provider Purpose Get 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
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:

ProviderSpec(
    name="myprovider",                   # config field name
    keywords=("myprovider", "mymodel"),  # model-name keywords for auto-matching
    env_key="MYPROVIDER_API_KEY",        # env var for LiteLLM
    display_name="My Provider",          # shown in `nanobot status`
    litellm_prefix="myprovider",         # auto-prefix: model β†’ myprovider/model
    skip_prefixes=("myprovider/",),      # don't double-prefix
)

Step 2. Add a field to ProvidersConfig in nanobot/config/schema.py:

class ProvidersConfig(BaseModel):
    ...
    myprovider: ProviderConfig = ProviderConfig()

That's it! Environment variables, model prefixing, config matching, and nanobot status display will all work automatically.

Common ProviderSpec options:

Field Description Example
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.

Option Default Description
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

Command Description
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)
# Add a job
nanobot cron add --name "daily" --message "Good morning!" --cron "0 9 * * *"
nanobot cron add --name "hourly" --message "Check status" --every 3600

# List jobs
nanobot cron list

# Remove a job
nanobot cron remove <job_id>

🐳 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:

# Build the image
docker build -t nanobot .

# Initialize config (first time only)
docker run -v ~/.nanobot:/root/.nanobot --rm nanobot onboard

# Edit config on host to add API keys
vim ~/.nanobot/config.json

# Run gateway (connects to Telegram/WhatsApp)
docker run -v ~/.nanobot:/root/.nanobot -p 18790:18790 nanobot gateway

# Or run a single command
docker run -v ~/.nanobot:/root/.nanobot --rm nanobot agent -m "Hello!"
docker run -v ~/.nanobot:/root/.nanobot --rm nanobot status

πŸ“ 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/       # πŸ“± WhatsApp integration
β”œβ”€β”€ bus/            # 🚌 Message routing
β”œβ”€β”€ cron/           # ⏰ Scheduled tasks
β”œβ”€β”€ heartbeat/      # πŸ’“ Proactive wake-up
β”œβ”€β”€ providers/      # πŸ€– LLM providers (OpenRouter, etc.)
β”œβ”€β”€ session/        # πŸ’¬ Conversation sessions
β”œβ”€β”€ config/         # βš™οΈ Configuration
└── cli/            # πŸ–₯️ Commands

🀝 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

⭐ Star History

Thanks for visiting ✨ nanobot!

Views

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

About

"🐈 nanobot: The Ultra-Lightweight Clawdbot"

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 94.1%
  • TypeScript 2.7%
  • Shell 2.4%
  • Other 0.8%