diff --git a/README.md b/README.md index a13933a..26f5177 100644 --- a/README.md +++ b/README.md @@ -149,6 +149,7 @@ MimiClaw uses Anthropic's tool use protocol — Claude can call tools during a c | Tool | Description | |------|-------------| | `web_search` | Search the web via Brave Search API for current information | +| `get_current_time` | Fetch current date/time via HTTP and set the system clock | To enable web search, set a [Brave Search API key](https://brave.com/search/api/) in your config file or via CLI (`set_search_key`). diff --git a/README_CN.md b/README_CN.md index d3ba396..982c46c 100644 --- a/README_CN.md +++ b/README_CN.md @@ -171,6 +171,7 @@ MimiClaw 使用 Anthropic 的 tool use 协议 — Claude 在对话中可以调 | 工具 | 说明 | |------|------| | `web_search` | 通过 Brave Search API 搜索网页,获取实时信息 | +| `get_current_time` | 通过 HTTP 获取当前日期和时间,并设置系统时钟 | 启用网页搜索需要设置 [Brave Search API key](https://brave.com/search/api/),在配置文件或 CLI(`set_search_key`)中设置。 diff --git a/main/agent/agent_loop.c b/main/agent/agent_loop.c index 6cc3039..c4bab2a 100644 --- a/main/agent/agent_loop.c +++ b/main/agent/agent_loop.c @@ -100,6 +100,15 @@ static void agent_loop_task(void *arg) ESP_LOGI(TAG, "Processing message from %s:%s", msg.channel, msg.chat_id); + /* Send "working" indicator */ + { + mimi_msg_t status = {0}; + strncpy(status.channel, msg.channel, sizeof(status.channel) - 1); + strncpy(status.chat_id, msg.chat_id, sizeof(status.chat_id) - 1); + status.content = strdup("mimi\xF0\x9F\x98\x97is working..."); + if (status.content) message_bus_push_outbound(&status); + } + /* 1. Build system prompt */ context_build_system_prompt(system_prompt, MIMI_CONTEXT_BUF_SIZE); diff --git a/main/agent/context_builder.c b/main/agent/context_builder.c index 034d4d8..7a89f46 100644 --- a/main/agent/context_builder.c +++ b/main/agent/context_builder.c @@ -4,7 +4,6 @@ #include #include -#include #include "esp_log.h" #include "cJSON.h" @@ -30,26 +29,18 @@ esp_err_t context_build_system_prompt(char *buf, size_t size) { size_t off = 0; - /* Identity header */ - time_t now; - time(&now); - struct tm tm; - localtime_r(&now, &tm); - char time_str[64]; - strftime(time_str, sizeof(time_str), "%Y-%m-%d %H:%M (%A)", &tm); - off += snprintf(buf + off, size - off, "# MimiClaw\n\n" "You are MimiClaw, a personal AI assistant running on an ESP32-S3 device.\n" "You communicate through Telegram and WebSocket.\n\n" - "## Current Time\n%s\n\n" "Be helpful, accurate, and concise.\n\n" "## Available Tools\n" "You have access to the following tools:\n" "- web_search: Search the web for current information. " - "Use this when you need up-to-date facts, news, weather, or anything beyond your training data.\n\n" - "Use tools when needed. Provide your final answer as text after using tools.\n", - time_str); + "Use this when you need up-to-date facts, news, weather, or anything beyond your training data.\n" + "- get_current_time: Get the current date and time. " + "You do NOT have an internal clock — always use this tool when you need to know the time or date.\n\n" + "Use tools when needed. Provide your final answer as text after using tools.\n"); /* Bootstrap files */ off = append_file(buf, size, off, MIMI_SOUL_FILE, "Personality");