Files
LaodingBot/README.md
2026-02-21 23:01:39 +08:00

87 lines
2.4 KiB
Markdown

# LaodingBot (MVP)
Go-based personal Telegram Agent with:
- Telegram polling transport
- OpenAI-compatible LLM client
- SQLite conversation memory + simple compression
- Tool registry with built-in `file` and `shell` tools
- Default-deny security policy via allowlists
- Soul markdown loading for bot personality
- Skills markdown loading for capability context
- ReAct decision loop with automatic tool execution
Now supports mutually exclusive message channels:
- `telegram` (long polling)
- `feishu` (official SDK websocket long connection)
## Quick Start
1. Prepare env variables (see `configs/env.sample`).
- The app auto-loads `configs/env` (or `.env`) if present.
- You can also set `CONFIG_ENV_FILE=/path/to/env`.
- Process environment variables override file values.
2. Choose exactly one channel with `MESSAGE_CHANNEL=telegram|feishu`.
- If `telegram`: set `TELEGRAM_BOT_TOKEN`, keep `FEISHU_*` empty.
- If `feishu`: set `FEISHU_APP_ID` and `FEISHU_APP_SECRET`, keep `TELEGRAM_BOT_TOKEN` empty.
3. Set log level with `LOG_LEVEL=debug|info|warn|error`.
4. Configure knowledge and reasoning:
- `SOUL_PATH` for bot personality markdown.
- `SKILLS_DIR` for skills markdown directory.
- `REACT_MAX_STEPS` for maximum ReAct steps.
5. Create runtime directories:
```bash
mkdir -p data workspace
```
6. Run:
```bash
go mod tidy
go run ./cmd/bot
```
## Telegram Usage
- Normal text: forwarded to LLM with compressed recent memory.
- Agent uses ReAct loop and may call tools automatically before final answer.
- Tool call command:
```text
/tool <name> <input>
```
Examples:
```text
/tool shell pwd
/tool file read ./workspace/note.txt
/tool file write ./workspace/note.txt
hello world
```
## Feishu Usage
- Bot uses Feishu official SDK long connection (`ws`) to subscribe `im.message.receive_v1` text events.
- Received text is forwarded to the same agent pipeline and replied back to the same chat.
## Knowledge Files
- Soul file default path: `bot_context/soul.md`
- Skills directory default path: `skills/`
- Add new markdown files into `skills/` to describe capabilities; they are loaded at startup.
## Security Notes
- `shell` only allows commands listed in `ALLOWED_COMMANDS`.
- `file` only allows paths inside `ALLOWED_DIRS`.
- Working directory for shell is limited by `WORK_DIR`.
## Next Iteration
- Add skill runtime (process-level hot-plug via RPC)
- Add bootstrap pipeline (generate -> vet/test -> sandbox run -> register)
- Add approval gate for risky commands