feat: wire feishu into app and cli
Signed-off-by: Asklv <boironic@gmail.com>
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
#include "serial_cli.h"
|
#include "serial_cli.h"
|
||||||
#include "mimi_config.h"
|
#include "mimi_config.h"
|
||||||
#include "wifi/wifi_manager.h"
|
#include "wifi/wifi_manager.h"
|
||||||
#include "telegram/telegram_bot.h"
|
#include "channels/telegram/telegram_bot.h"
|
||||||
|
#include "channels/feishu/feishu_bot.h"
|
||||||
#include "llm/llm_proxy.h"
|
#include "llm/llm_proxy.h"
|
||||||
#include "memory/memory_store.h"
|
#include "memory/memory_store.h"
|
||||||
#include "memory/session_mgr.h"
|
#include "memory/session_mgr.h"
|
||||||
@@ -72,6 +73,26 @@ static int cmd_set_tg_token(int argc, char **argv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --- set_feishu_creds command --- */
|
||||||
|
static struct {
|
||||||
|
struct arg_str *app_id;
|
||||||
|
struct arg_str *app_secret;
|
||||||
|
struct arg_end *end;
|
||||||
|
} feishu_creds_args;
|
||||||
|
|
||||||
|
static int cmd_set_feishu_creds(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int nerrors = arg_parse(argc, argv, (void **)&feishu_creds_args);
|
||||||
|
if (nerrors != 0) {
|
||||||
|
arg_print_errors(stderr, feishu_creds_args.end, argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
feishu_set_credentials(feishu_creds_args.app_id->sval[0],
|
||||||
|
feishu_creds_args.app_secret->sval[0]);
|
||||||
|
printf("Feishu credentials saved.\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* --- set_api_key command --- */
|
/* --- set_api_key command --- */
|
||||||
static struct {
|
static struct {
|
||||||
struct arg_str *key;
|
struct arg_str *key;
|
||||||
@@ -619,6 +640,18 @@ esp_err_t serial_cli_init(void)
|
|||||||
};
|
};
|
||||||
esp_console_cmd_register(&tg_token_cmd);
|
esp_console_cmd_register(&tg_token_cmd);
|
||||||
|
|
||||||
|
/* set_feishu_creds */
|
||||||
|
feishu_creds_args.app_id = arg_str1(NULL, NULL, "<app_id>", "Feishu App ID");
|
||||||
|
feishu_creds_args.app_secret = arg_str1(NULL, NULL, "<app_secret>", "Feishu App Secret");
|
||||||
|
feishu_creds_args.end = arg_end(2);
|
||||||
|
esp_console_cmd_t feishu_creds_cmd = {
|
||||||
|
.command = "set_feishu_creds",
|
||||||
|
.help = "Set Feishu app credentials (app_id app_secret)",
|
||||||
|
.func = &cmd_set_feishu_creds,
|
||||||
|
.argtable = &feishu_creds_args,
|
||||||
|
};
|
||||||
|
esp_console_cmd_register(&feishu_creds_cmd);
|
||||||
|
|
||||||
/* set_api_key */
|
/* set_api_key */
|
||||||
api_key_args.key = arg_str1(NULL, NULL, "<key>", "LLM API key");
|
api_key_args.key = arg_str1(NULL, NULL, "<key>", "LLM API key");
|
||||||
api_key_args.end = arg_end(1);
|
api_key_args.end = arg_end(1);
|
||||||
|
|||||||
12
main/mimi.c
12
main/mimi.c
@@ -12,7 +12,8 @@
|
|||||||
#include "mimi_config.h"
|
#include "mimi_config.h"
|
||||||
#include "bus/message_bus.h"
|
#include "bus/message_bus.h"
|
||||||
#include "wifi/wifi_manager.h"
|
#include "wifi/wifi_manager.h"
|
||||||
#include "telegram/telegram_bot.h"
|
#include "channels/telegram/telegram_bot.h"
|
||||||
|
#include "channels/feishu/feishu_bot.h"
|
||||||
#include "llm/llm_proxy.h"
|
#include "llm/llm_proxy.h"
|
||||||
#include "agent/agent_loop.h"
|
#include "agent/agent_loop.h"
|
||||||
#include "memory/memory_store.h"
|
#include "memory/memory_store.h"
|
||||||
@@ -78,6 +79,13 @@ static void outbound_dispatch_task(void *arg)
|
|||||||
} else {
|
} else {
|
||||||
ESP_LOGI(TAG, "Telegram send success for %s (%d bytes)", msg.chat_id, (int)strlen(msg.content));
|
ESP_LOGI(TAG, "Telegram send success for %s (%d bytes)", msg.chat_id, (int)strlen(msg.content));
|
||||||
}
|
}
|
||||||
|
} else if (strcmp(msg.channel, MIMI_CHAN_FEISHU) == 0) {
|
||||||
|
esp_err_t send_err = feishu_send_message(msg.chat_id, msg.content);
|
||||||
|
if (send_err != ESP_OK) {
|
||||||
|
ESP_LOGE(TAG, "Feishu send failed for %s: %s", msg.chat_id, esp_err_to_name(send_err));
|
||||||
|
} else {
|
||||||
|
ESP_LOGI(TAG, "Feishu send success for %s (%d bytes)", msg.chat_id, (int)strlen(msg.content));
|
||||||
|
}
|
||||||
} else if (strcmp(msg.channel, MIMI_CHAN_WEBSOCKET) == 0) {
|
} else if (strcmp(msg.channel, MIMI_CHAN_WEBSOCKET) == 0) {
|
||||||
esp_err_t ws_err = ws_server_send(msg.chat_id, msg.content);
|
esp_err_t ws_err = ws_server_send(msg.chat_id, msg.content);
|
||||||
if (ws_err != ESP_OK) {
|
if (ws_err != ESP_OK) {
|
||||||
@@ -121,6 +129,7 @@ void app_main(void)
|
|||||||
ESP_ERROR_CHECK(wifi_manager_init());
|
ESP_ERROR_CHECK(wifi_manager_init());
|
||||||
ESP_ERROR_CHECK(http_proxy_init());
|
ESP_ERROR_CHECK(http_proxy_init());
|
||||||
ESP_ERROR_CHECK(telegram_bot_init());
|
ESP_ERROR_CHECK(telegram_bot_init());
|
||||||
|
ESP_ERROR_CHECK(feishu_bot_init());
|
||||||
ESP_ERROR_CHECK(llm_proxy_init());
|
ESP_ERROR_CHECK(llm_proxy_init());
|
||||||
ESP_ERROR_CHECK(tool_registry_init());
|
ESP_ERROR_CHECK(tool_registry_init());
|
||||||
ESP_ERROR_CHECK(cron_service_init());
|
ESP_ERROR_CHECK(cron_service_init());
|
||||||
@@ -149,6 +158,7 @@ void app_main(void)
|
|||||||
/* Start network-dependent services */
|
/* Start network-dependent services */
|
||||||
ESP_ERROR_CHECK(agent_loop_start());
|
ESP_ERROR_CHECK(agent_loop_start());
|
||||||
ESP_ERROR_CHECK(telegram_bot_start());
|
ESP_ERROR_CHECK(telegram_bot_start());
|
||||||
|
ESP_ERROR_CHECK(feishu_bot_start());
|
||||||
cron_service_start();
|
cron_service_start();
|
||||||
heartbeat_start();
|
heartbeat_start();
|
||||||
ESP_ERROR_CHECK(ws_server_start());
|
ESP_ERROR_CHECK(ws_server_start());
|
||||||
|
|||||||
Reference in New Issue
Block a user