feat: add ReAct agent loop and build-time config (mimi_secrets.h)

Rewrite agent_loop.c with ReAct tool use loop: LLM call → tool
execution → repeat until end_turn (max 10 iterations). Add tool
guidance to system prompt. Add set_search_key CLI command.

Add mimi_secrets.h for build-time credentials with highest priority
over NVS/CLI values. All modules (wifi, telegram, llm, proxy,
web_search) check build-time secrets first, fall back to NVS.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
crispyberry
2026-02-07 00:37:43 +08:00
parent 2fe81b8ee1
commit 0e1da79b74
9 changed files with 255 additions and 57 deletions

View File

@@ -13,7 +13,7 @@
static const char *TAG = "telegram";
static char s_bot_token[128] = {0};
static char s_bot_token[128] = MIMI_SECRET_TG_TOKEN;
static int64_t s_update_offset = 0;
/* HTTP response accumulator */
@@ -257,13 +257,15 @@ static void telegram_poll_task(void *arg)
esp_err_t telegram_bot_init(void)
{
/* Load token from NVS */
nvs_handle_t nvs;
esp_err_t err = nvs_open(MIMI_NVS_TG, NVS_READONLY, &nvs);
if (err == ESP_OK) {
size_t len = sizeof(s_bot_token);
nvs_get_str(nvs, MIMI_NVS_KEY_TG_TOKEN, s_bot_token, &len);
nvs_close(nvs);
/* Build-time secret takes highest priority */
if (s_bot_token[0] == '\0') {
nvs_handle_t nvs;
esp_err_t err = nvs_open(MIMI_NVS_TG, NVS_READONLY, &nvs);
if (err == ESP_OK) {
size_t len = sizeof(s_bot_token);
nvs_get_str(nvs, MIMI_NVS_KEY_TG_TOKEN, s_bot_token, &len);
nvs_close(nvs);
}
}
if (s_bot_token[0]) {