Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
66b53f9
fix: avoid global litellm.api_base pollution and add DingTalk group c…
El-Chiang Feb 9, 2026
8a6dfa9
feat(dingtalk): include conversation title in group messages and logs
El-Chiang Feb 9, 2026
4d1bdde
feat: add MCP tool support, skills, and misc improvements
El-Chiang Feb 10, 2026
0ea2a82
Merge branch 'main' of https://github.com/HKUDS/nanobot
El-Chiang Feb 10, 2026
f5a1cc4
feat: add skills
El-Chiang Feb 11, 2026
5b31d6c
feat: add HTTP channel for synchronous request-response communication
El-Chiang Feb 11, 2026
ea997f9
feat: add media/image support to DingTalk channel and message tool
El-Chiang Feb 11, 2026
ffebede
fix: improve agent loop robustness on empty responses
El-Chiang Feb 11, 2026
a3c219f
feat: add LLM response summary logging
El-Chiang Feb 11, 2026
84bf5a5
docs: add MCP server documentation to README
El-Chiang Feb 11, 2026
bc67597
chore: add CLAUDE.md and feature specs
El-Chiang Feb 11, 2026
0c1741e
Merge branch 'main' of https://github.com/HKUDS/nanobot
El-Chiang Feb 11, 2026
95adc68
fix: add MCP connection timeout and improve HTTP channel response enc…
El-Chiang Feb 11, 2026
22c25af
feat: add extended thinking/effort support, memory subdir config, and…
El-Chiang Feb 12, 2026
6f36723
fix: persist tool use summary in session history
El-Chiang Feb 12, 2026
f550968
feat: add file-based logging for troubleshooting
El-Chiang Feb 12, 2026
bc335bf
refactor: store tool_use_summary as virtual tool call instead of XML …
El-Chiang Feb 12, 2026
d7905cd
feat: add meme support to journal skill and log tool use summary
El-Chiang Feb 12, 2026
c1e9462
🐱 kaguya was here (bot PR)
El-Chiang Feb 12, 2026
bb1de31
chore: update gitignore to exclude pem files and ds store
El-Chiang Feb 12, 2026
4e36ab0
fix: harden litellm fallback and realign session history windows
El-Chiang Feb 12, 2026
a91ae6f
feat: add media/image support and reply_to for Telegram channel
El-Chiang Feb 13, 2026
f2bb96e
feat: add [SILENT] marker to suppress duplicate outbound messages
El-Chiang Feb 13, 2026
5b8216c
feat: add bot message filtering for Discord channel
El-Chiang Feb 13, 2026
fdd6257
docs: add Discord bot message filtering config to README
El-Chiang Feb 13, 2026
1c5c404
feat: update ignore
El-Chiang Feb 13, 2026
4de74ae
Merge branch 'kaguya-bot-pr'
El-Chiang Feb 13, 2026
18ec325
feat: 支持发送 sticker
El-Chiang Feb 14, 2026
33cbbfa
feat: skills 迁移
El-Chiang Feb 14, 2026
27bf8cb
fix: stabilize telegram message_time handling and logging previews
El-Chiang Feb 14, 2026
54d9b2e
feat: add provider stream defaults and outbound delivery ack
El-Chiang Feb 16, 2026
ae8432c
feat: 修改上下文条数
El-Chiang Feb 16, 2026
4d5cbff
merge: 完成冲突整合并补充 e2e 回归,修复 Telegram 代理与 memory 导入
El-Chiang Feb 16, 2026
e9b10f5
refactor: update time markers and remove unused regex pattern
El-Chiang Feb 17, 2026
b68e3b9
feat: add sliding-window memory consolidation and tg silent outbound
El-Chiang Feb 18, 2026
c93ceae
feat: inbound message collect buffer
El-Chiang Feb 18, 2026
2f81d9d
feat: add GET /api/status endpoint to HTTP channel
El-Chiang Feb 18, 2026
2ac6dc0
fix: reset status to idle on SILENT outbound
El-Chiang Feb 18, 2026
192c865
fix: exclude token events from status logs, keep stats only
El-Chiang Feb 18, 2026
6a0b778
merge: upstream/main v0.1.4 with local features preserved
El-Chiang Feb 19, 2026
df9171e
fix: disable intermediate progress broadcast on IM channels
El-Chiang Feb 19, 2026
19caaf2
fix: restrict progress streaming to natural language
El-Chiang Feb 19, 2026
9c1f73c
revert: undo natural-language-only progress streaming
El-Chiang Feb 19, 2026
737187a
refactor: move progress visibility control to channel layer
El-Chiang Feb 19, 2026
5b3286c
feat: 优化 system prompt
El-Chiang Feb 19, 2026
e1782eb
merge upstream/main: pin deps, codex routing fix, feishu media, shell…
El-Chiang Feb 20, 2026
d5d5135
fix: disable consolidation temporarily, minor cleanup
El-Chiang Feb 21, 2026
3fe2d44
merge: sync upstream/main and resolve conflicts
El-Chiang Feb 24, 2026
ffdb4b2
fix(loop): treat placeholder empty responses as blank output
El-Chiang Feb 24, 2026
36d49e4
fix(loop): suppress empty fallback text on external channels
El-Chiang Feb 24, 2026
62f8983
feat: 增加 dingtalk 不走代理配置
El-Chiang Feb 25, 2026
8544d8b
fix: 修复钉钉消息预览功能
El-Chiang Feb 25, 2026
15877a2
refactor: remove yuque-reply skill and improve telegram error handling
El-Chiang Feb 26, 2026
1ae4739
refactor: move Current Time section to end of system prompt
El-Chiang Feb 26, 2026
bfc98b3
feat: 提示词优化
El-Chiang Feb 26, 2026
4f54418
merge: sync upstream/main and resolve conflicts
El-Chiang Feb 26, 2026
10897fb
chore: 更新 spec 格式
El-Chiang Feb 26, 2026
32fbac2
feat: normalize litellm usage cache metrics
El-Chiang Feb 26, 2026
019b1e5
feat: support heartbeat-specific model and interval config
El-Chiang Feb 26, 2026
0c34cbd
feat: add dedicated model and provider support for memory consolidati…
El-Chiang Feb 27, 2026
3862d85
fix: route heartbeat/cron notifications into target session history
kaguya-nanobot[bot] Feb 27, 2026
2f5520a
Merge pull request #3 from El-Chiang/fix/heartbeat-cron-history-injec…
El-Chiang Feb 27, 2026
24f2c85
feat: add codex command description
El-Chiang Feb 27, 2026
ed32986
Merge branch 'main' of https://github.com/El-Chiang/nanobot
El-Chiang Feb 27, 2026
56761f0
Merge branch 'main' of https://github.com/HKUDS/nanobot into merge-up…
El-Chiang Mar 1, 2026
54d29ff
Merge upstream/main (2026-03-01): 39 commits including web proxy, thi…
El-Chiang Mar 1, 2026
ddc6c6d
refactor: add TYPE_CHECKING imports and clean up type annotations
El-Chiang Mar 1, 2026
32cc5db
fix: delete current_time in user message
El-Chiang Mar 2, 2026
c96711e
feat(telegram): streaming response via sendMessageDraft for private c…
El-Chiang Mar 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .codex/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
commit_attribution = "Codex(gpt-5.3-codex) <noreply@openai.com>"
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ __pycache__/
poetry.lock
.pytest_cache/
botpy.log
tests/
*.pem
.DS_Store
.tmp_home/
62 changes: 62 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# CLAUDE.md

## 项目简介

nanobot — 超轻量个人 AI 助手框架,核心代码约 3,500 行。Python 3.11+,MIT 协议。

配置文件:`~/.nanobot/config.json`,工作区:`~/.nanobot/workspace/`

## 全局命令

- 每次功能变更、bug 修复、代码合并等都采用 SDD,在 `specs/` 下新增/维护对应规格文档,命名统一为 `YYYY-MM-DD_描述`。

## 常用命令

```bash
# 安装
pip install -e .
pip install -e ".[dev]"

# 运行
nanobot agent -m "..." # 单条消息
nanobot agent # 交互式对话
nanobot gateway # 启动所有渠道
nanobot status # 查看配置状态

# 测试 & 检查
pytest
ruff check nanobot/
ruff format nanobot/
```

## 代码规范

- 全异步:所有 I/O 使用 `async`/`await`
- Tool 返回错误字符串,不抛异常
- 日志用 `loguru`(`from loguru import logger`)
- Ruff:line-length 100, target py311, select E/F/I/N/W, ignore E501
- pytest:`asyncio_mode = "auto"`
- 构建系统:hatchling

## 核心架构

```
Channel → InboundMessage → MessageBus → AgentLoop → LLM + Tools 循环 → OutboundMessage → Channel
```

关键模块:
- `agent/loop.py` — 主循环,接收消息、构建上下文、调用 LLM、执行工具
- `agent/context.py` — 组装 system prompt(身份 → bootstrap 文件 → 记忆 → 技能)
- `agent/memory.py` — 记忆管理,日记在 `memory/daily/YYYY-MM-DD.md`,长期记忆在 `MEMORY.md`
- `agent/skills.py` — 技能发现与加载(内置 `nanobot/skills/` + 用户 `~/.nanobot/workspace/skills/`)
- `agent/tools/` — 工具系统,继承 `Tool` 基类,实现 `name`/`description`/`parameters`/`execute()`
- `channels/` — 渠道适配,继承 `BaseChannel`,实现 `start()`/`stop()`/`send()`
- `providers/` — LLM 提供商,基于 LiteLLM,`ProviderSpec` 自动路由
- `config/schema.py` — Pydantic v2 配置模型

## 扩展方式

- **添加工具**:创建 `agent/tools/xxx.py` 继承 `Tool`,在 `AgentLoop._register_default_tools()` 注册
- **添加技能**:创建 `nanobot/skills/xxx/SKILL.md`(YAML frontmatter + markdown 指令)
- **添加渠道**:创建 `channels/xxx.py` 继承 `BaseChannel`,在 `config/schema.py` 加配置
- **添加提供商**:在 `providers/registry.py` 加 `ProviderSpec`,在 `config/schema.py` 加配置
58 changes: 58 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# CLAUDE.md

## 项目简介

nanobot — 超轻量个人 AI 助手框架,核心代码约 3,500 行。Python 3.11+,MIT 协议。

配置文件:`~/.nanobot/config.json`,工作区:`~/.nanobot/workspace/`

## 常用命令

```bash
# 安装
pip install -e .
pip install -e ".[dev]"

# 运行
nanobot agent -m "..." # 单条消息
nanobot agent # 交互式对话
nanobot gateway # 启动所有渠道
nanobot status # 查看配置状态

# 测试 & 检查
pytest
ruff check nanobot/
ruff format nanobot/
```

## 代码规范

- 全异步:所有 I/O 使用 `async`/`await`
- Tool 返回错误字符串,不抛异常
- 日志用 `loguru`(`from loguru import logger`)
- Ruff:line-length 100, target py311, select E/F/I/N/W, ignore E501
- pytest:`asyncio_mode = "auto"`
- 构建系统:hatchling

## 核心架构

```
Channel → InboundMessage → MessageBus → AgentLoop → LLM + Tools 循环 → OutboundMessage → Channel
```

关键模块:
- `agent/loop.py` — 主循环,接收消息、构建上下文、调用 LLM、执行工具
- `agent/context.py` — 组装 system prompt(身份 → bootstrap 文件 → 记忆 → 技能)
- `agent/memory.py` — 记忆管理,日记在 `memory/daily/YYYY-MM-DD.md`,长期记忆在 `MEMORY.md`
- `agent/skills.py` — 技能发现与加载(内置 `nanobot/skills/` + 用户 `~/.nanobot/workspace/skills/`)
- `agent/tools/` — 工具系统,继承 `Tool` 基类,实现 `name`/`description`/`parameters`/`execute()`
- `channels/` — 渠道适配,继承 `BaseChannel`,实现 `start()`/`stop()`/`send()`
- `providers/` — LLM 提供商,基于 LiteLLM,`ProviderSpec` 自动路由
- `config/schema.py` — Pydantic v2 配置模型

## 扩展方式

- **添加工具**:创建 `agent/tools/xxx.py` 继承 `Tool`,在 `AgentLoop._register_default_tools()` 注册
- **添加技能**:创建 `nanobot/skills/xxx/SKILL.md`(YAML frontmatter + markdown 指令)
- **添加渠道**:创建 `channels/xxx.py` 继承 `BaseChannel`,在 `config/schema.py` 加配置
- **添加提供商**:在 `providers/registry.py` 加 `ProviderSpec`,在 `config/schema.py` 加配置
81 changes: 79 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,13 +287,18 @@ If you prefer to configure manually, add the following to `~/.nanobot/config.jso

**4. Configure**

By default, nanobot ignores all bot-originated messages. To consume other bots' messages, set `allowBotMessages` to `true`.
Self-messages from this bot and webhook messages are always ignored to prevent loops.

```json
{
"channels": {
"discord": {
"enabled": true,
"token": "YOUR_BOT_TOKEN",
"allowFrom": ["YOUR_USER_ID"]
"allowFrom": ["YOUR_USER_ID"],
"allowBotMessages": true,
"allowBotFrom": ["OTHER_BOT_USER_ID"]
}
}
}
Expand Down Expand Up @@ -656,8 +661,24 @@ Config file: `~/.nanobot/config.json`
> - **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.
> - **Per-provider stream default**: set `"defaultStream": true` (or `false`) inside each provider block.
> - **VolcEngine Coding Plan**: If you're on VolcEngine's coding plan, set `"apiBase": "https://ark.cn-beijing.volces.com/api/coding/v3"` in your volcengine provider config.

```json
{
"providers": {
"openrouter": {
"apiKey": "sk-or-v1-xxx",
"defaultStream": true
},
"deepseek": {
"apiKey": "sk-xxx",
"defaultStream": false
}
}
}
```

| Provider | Purpose | Get API Key |
|----------|---------|-------------|
| `custom` | Any OpenAI-compatible endpoint (direct, no LiteLLM) | — |
Expand Down Expand Up @@ -896,6 +917,8 @@ MCP tools are automatically discovered and registered on startup. The LLM can us
| `nanobot provider login openai-codex` | OAuth login for providers |
| `nanobot channels login` | Link WhatsApp (scan QR) |
| `nanobot channels status` | Show channel status |
| `nanobot mcp list` | List configured MCP servers |
| `nanobot mcp tools` | Connect to MCP servers and list all discovered tools |

Interactive mode exits: `exit`, `quit`, `/exit`, `/quit`, `:q`, or `Ctrl+D`.

Expand All @@ -916,10 +939,44 @@ nanobot cron remove <job_id>

</details>

<details>
<summary><b>MCP Servers</b></summary>

nanobot supports [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) servers, allowing the agent to use external tools dynamically.

```bash
# List configured MCP servers
nanobot mcp list

# Connect to all servers and list discovered tools
nanobot mcp tools
```

Configure MCP servers in `~/.nanobot/config.json`:

```json
{
"mcp": {
"servers": {
"my-server": {
"command": "npx",
"args": ["-y", "@example/mcp-server"],
"env": {
"API_KEY": "xxx"
}
}
}
}
}
```

Once configured, MCP tools are automatically discovered and registered as `mcp__{server}__{tool_name}` — the agent can call them like any built-in tool.
</details>

<details>
<summary><b>Heartbeat (Periodic Tasks)</b></summary>

The gateway wakes up every 30 minutes and checks `HEARTBEAT.md` in your workspace (`~/.nanobot/workspace/HEARTBEAT.md`). If the file has tasks, the agent executes them and delivers results to your most recently active chat channel.
The gateway wakes up periodically (default: every 30 minutes) and checks `HEARTBEAT.md` in your workspace (`~/.nanobot/workspace/HEARTBEAT.md`). If the file has tasks, the agent executes them and delivers results to your most recently active chat channel.

**Setup:** edit `~/.nanobot/workspace/HEARTBEAT.md` (created automatically by `nanobot onboard`):

Expand All @@ -932,6 +989,22 @@ The gateway wakes up every 30 minutes and checks `HEARTBEAT.md` in your workspac

The agent can also manage this file itself — ask it to "add a periodic task" and it will update `HEARTBEAT.md` for you.

You can configure heartbeat interval and a dedicated model in `~/.nanobot/config.json`:

```json
{
"gateway": {
"heartbeat": {
"enabled": true,
"intervalS": 900,
"model": "openai/gpt-4o-mini"
}
}
}
```

`gateway.heartbeat.model` (when set) is used for both heartbeat decision and heartbeat task execution.

> **Note:** The gateway must be running (`nanobot gateway`) and you must have chatted with the bot at least once so it knows which channel to deliver to.

</details>
Expand Down Expand Up @@ -1090,3 +1163,7 @@ PRs welcome! The codebase is intentionally small and readable. 🤗
<p align="center">
<sub>nanobot is for educational, research, and technical exchange purposes only</sub>
</p>

---

🐱 *kaguya was here* - 我的第一个 bot PR
Loading