feat: 添加时区设置功能,默认时区改为 CST-8
Some checks failed
Build / idf-build (push) Has been cancelled
Build & Release / build (push) Has been cancelled

- 新增 set_timezone LLM 工具,支持通过对话设置时区
- 新增 set_timezone / timezone_show CLI 命令
- 默认时区从 PST 改为 CST-8(中国标准时间 UTC+8)
- 支持 POSIX 格式和 18 个城市名映射(Asia/Shanghai 等)
- 时区通过 NVS 持久化存储(system_config namespace)
- config_show 中显示当前时区配置
- 更新 changelog.md 和 taolun.md 文档
This commit is contained in:
2026-04-01 00:50:41 +08:00
parent eedc6757d8
commit 7dc4122778
24 changed files with 645 additions and 52 deletions

View File

@@ -57,9 +57,17 @@ Telegram App (User)
│ Anthropic Messages API (HTTPS)
│ + Brave Search API (HTTPS)
───────────┐ ┌──────────────┐
│ Claude API │ │ Brave Search │
───────────┘ └──────────────┘
┌───────────┐ ┌──────────────┐ ┌──────────────┐
│ Claude API │ │ Brave Search │ │ Tavily Search│
└───────────┘ └──────────────┘ └──────────────┘
┌───────────┐ ┌──────────────┐
│ OpenAI API │ │ SiliconFlow │
└───────────┘ └──────────────┘
┌───────────┐ ┌──────────────┐
│ Volcengine │ │ Feishu Bot │
└───────────┘ └──────────────┘
```
---
@@ -106,15 +114,21 @@ main/
├── wifi/
│ ├── wifi_manager.h WiFi STA lifecycle API
│ └── wifi_manager.c Event handler, exponential backoff
│ └── wifi_manager.c Event handler, exponential backoff (timer-based retry)
├── telegram/
│ ├── telegram_bot.h Bot init/start, send_message API
── telegram_bot.c Long polling loop, JSON parsing, message splitting
├── channels/
│ ├── telegram/
│ ├── telegram_bot.h Bot init/start, send_message API
│ │ └── telegram_bot.c Long polling loop, JSON parsing, message splitting
│ └── feishu/
│ ├── feishu_bot.h Feishu bot API
│ └── feishu_bot.c WebSocket event handling, message send/recv
├── llm/
│ ├── llm_proxy.h llm_chat() + llm_chat_tools() API, tool_use types
── llm_proxy.c Anthropic Messages API (non-streaming), tool_use parsing
── llm_proxy.c Multi-provider LLM (Anthropic + OpenAI-compatible)
│ ├── llm_provider.h Provider registry + configuration API
│ └── llm_provider.c Provider configs: anthropic, openai, siliconflow, volcengine
├── agent/
│ ├── agent_loop.h Agent task init/start
@@ -125,8 +139,17 @@ main/
├── tools/
│ ├── tool_registry.h Tool definition struct, register/dispatch API
│ ├── tool_registry.c Tool registration, JSON schema builder, dispatch by name
│ ├── tool_web_search.h Web search tool API
── tool_web_search.c Brave Search API via HTTPS (direct + proxy)
│ ├── tool_web_search.h Web search tool API (Tavily + Brave)
── tool_web_search.c Brave/Tavily Search API via HTTPS
│ ├── tool_get_time.h Time tool API
│ ├── tool_get_time.c HTTP Date header parsing for time sync
│ ├── tool_cron.h Cron tool API
│ ├── tool_cron.c Cron job management
│ ├── tool_files.h File tool API
│ ├── tool_files.c read/write/edit/list files on SPIFFS
│ ├── tool_gpio.h GPIO tool API
│ ├── tool_gpio.c GPIO read/write
│ └── gpio_policy.c GPIO pin allowlist policy
├── memory/
│ ├── memory_store.h Long-term + daily memory API
@@ -140,12 +163,29 @@ main/
├── proxy/
│ ├── http_proxy.h Proxy connection API
│ └── http_proxy.c HTTP CONNECT tunnel + TLS via esp_tls
│ └── http_proxy.c HTTP CONNECT tunnel + SOCKS5 tunnel + TLS
├── cli/
│ ├── serial_cli.h CLI init API
│ └── serial_cli.c esp_console REPL with debug/maintenance commands
├── cron/
│ ├── cron_service.h Cron job API
│ └── cron_service.c Cron scheduler, job persistence, execution
├── heartbeat/
│ ├── heartbeat.h Heartbeat API
│ └── heartbeat.c Periodic heartbeat messages
├── onboard/
│ ├── wifi_onboard.h WiFi onboarding portal API
│ ├── wifi_onboard.c Captive portal + Soft AP + HTTP config page
│ └── onboard_html.h Embedded HTML/CSS/JS for setup page
├── skills/
│ ├── skill_loader.h Skill loader API
│ └── skill_loader.c Load skill files from SPIFFS
└── ota/
├── ota_manager.h OTA update API
└── ota_manager.c esp_https_ota wrapper
@@ -158,9 +198,13 @@ main/
| Task | Core | Priority | Stack | Description |
|--------------------|------|----------|--------|--------------------------------------|
| `tg_poll` | 0 | 5 | 12 KB | Telegram long polling (30s timeout) |
| `agent_loop` | 1 | 6 | 12 KB | Message processing + Claude API call |
| `outbound` | 0 | 5 | 8 KB | Route responses to Telegram / WS |
| `feishu_ws` | 0 | 5 | 12 KB | Feishu WebSocket event handling |
| `agent_loop` | 1 | 6 | 24 KB | Message processing + LLM API call |
| `outbound` | 0 | 5 | 12 KB | Route responses to channels |
| `serial_cli` | 0 | 3 | 4 KB | USB serial console REPL |
| `onboard_dns` | 0 | 5 | 4 KB | DNS hijack for captive portal |
| `cron_check` | 0 | 4 | 4 KB | Cron job scheduler |
| `heartbeat` | 0 | 4 | 4 KB | Periodic heartbeat |
| httpd (internal) | 0 | 5 | — | WebSocket server (esp_http_server) |
| wifi_event (IDF) | 0 | 8 | — | WiFi event handling (ESP-IDF) |
@@ -225,20 +269,66 @@ Session files are JSONL (one JSON object per line):
## Configuration
All configuration is done exclusively through `mimi_secrets.h` at build time. There is no runtime configuration — changing any setting requires `idf.py fullclean && idf.py build`.
Configuration uses a multi-layer priority system:
| Define | Description |
|------------------------------|-----------------------------------------|
| `MIMI_SECRET_WIFI_SSID` | WiFi SSID |
| `MIMI_SECRET_WIFI_PASS` | WiFi password |
| `MIMI_SECRET_TG_TOKEN` | Telegram Bot API token |
| `MIMI_SECRET_API_KEY` | Anthropic API key |
| `MIMI_SECRET_MODEL` | Model ID (default: claude-opus-4-6) |
| `MIMI_SECRET_PROXY_HOST` | HTTP proxy hostname/IP (optional) |
| `MIMI_SECRET_PROXY_PORT` | HTTP proxy port (optional) |
| `MIMI_SECRET_SEARCH_KEY` | Brave Search API key (optional) |
### Build-time (`mimi_secrets.h`)
Highest priority. Set in `mimi_secrets.h` (copy from `mimi_secrets.h.example`).
NVS is still initialized (required by ESP-IDF WiFi internals) but is not used for application configuration.
| Define | Description |
|-------------------------------------|--------------------------------------------|
| `MIMI_SECRET_WIFI_SSID` | WiFi SSID |
| `MIMI_SECRET_WIFI_PASS` | WiFi password |
| `MIMI_SECRET_TG_TOKEN` | Telegram Bot API token |
| `MIMI_SECRET_FEISHU_APP_ID` | Feishu App ID |
| `MIMI_SECRET_FEISHU_APP_SECRET` | Feishu App Secret |
| `MIMI_SECRET_API_KEY` | Generic LLM API key (fallback) |
| `MIMI_SECRET_MODEL` | Model ID (default: claude-opus-4-5) |
| `MIMI_SECRET_MODEL_PROVIDER` | LLM provider: anthropic/openai/siliconflow/volcengine |
| `MIMI_SECRET_ANTHROPIC_API_KEY` | Anthropic-specific API key |
| `MIMI_SECRET_OPENAI_API_KEY` | OpenAI-specific API key |
| `MIMI_SECRET_SILICONFLOW_API_KEY` | SiliconFlow (硅基流动) API key |
| `MIMI_SECRET_SILICONFLOW_BASE_URL` | SiliconFlow Base URL |
| `MIMI_SECRET_VOLCENGINE_API_KEY` | Volcengine (火山引擎) API key |
| `MIMI_SECRET_VOLCENGINE_BASE_URL` | Volcengine Base URL |
| `MIMI_SECRET_PROXY_HOST` | HTTP proxy hostname/IP (optional) |
| `MIMI_SECRET_PROXY_PORT` | HTTP proxy port (optional) |
| `MIMI_SECRET_PROXY_TYPE` | Proxy type: http/socks5 |
| `MIMI_SECRET_SEARCH_KEY` | Brave Search API key (optional) |
| `MIMI_SECRET_TAVILY_KEY` | Tavily Search API key (optional) |
### Runtime (NVS + Onboard Portal)
Set via serial CLI or the onboard configuration portal (192.168.4.1).
| CLI Command | Description |
|------------------------------------|--------------------------------------|
| `wifi_set <SSID> <Password>` | Set WiFi credentials |
| `set_tg_token <Token>` | Set Telegram Bot token |
| `set_api_key <Key>` | Set generic LLM API key |
| `set_model_provider <Provider>` | Set provider: anthropic/openai/siliconflow/volcengine |
| `set_model <Model>` | Set model name |
| `set_siliconflow_key <Key>` | Set SiliconFlow-specific API key |
| `set_siliconflow_url <URL>` | Set SiliconFlow Base URL |
| `set_volcengine_key <Key>` | Set Volcengine-specific API key |
| `set_volcengine_url <URL>` | Set Volcengine Base URL |
| `config_show` | Show current config (masked) |
| `config_reset` | Reset to build-time defaults |
### Priority Order (highest → lowest)
1. NVS runtime config (CLI or onboard portal)
2. Provider-specific NVS key (e.g. `siliconflow_api_key`)
3. Provider-specific build-time config (e.g. `MIMI_SECRET_SILICONFLOW_API_KEY`)
4. Generic build-time config (`MIMI_SECRET_API_KEY`, `MIMI_SECRET_MODEL_PROVIDER`)
## Supported LLM Providers
| Provider | API Compatible | Default Endpoint |
|-------------|----------------|-------------------------------------------------------|
| anthropic | Anthropic | https://api.anthropic.com/v1/messages |
| openai | OpenAI | https://api.openai.com/v1/chat/completions |
| siliconflow | OpenAI | https://api.siliconflow.cn/v1/chat/completions |
| volcengine | OpenAI | https://ark.cn-beijing.volces.com/api/v3/chat/completions |
All OpenAI-compatible providers use Bearer token authentication and the same message format.
---