feat(robot_agent): 基于 libhttp 的 DeepSeek 视觉机器人 agent 骨架

- 工具循环:capture_image / get_robot_status / spawn_subagent
- 子代理:技能超集(run_command 带超时截断、read_file / write_file)
- V4L2 摄像头抓帧:MJPEG 优先零转码,YUYV+libjpeg 回退,/dev/video* 自动探测
- 时间戳注入:system prompt 会话级当前时间 + 工具结果执行时间
- CLI:--prompt-file / --camera / --camera-device / --model / --max-turns
This commit is contained in:
qing committed 2026-08-21 14:47:29 +00:00
1 parent 2dc79f0637
commit 7e44025671
12 files changed
+1132

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
#pragma once
#include <boost/json.hpp>
#include "tools.hpp"
#include <string>
namespace json = boost::json;
struct AgentConfig {
std::string model;
std::string endpoint;
std::string api_key;
std::string camera_path; // 非空 = 模拟摄像头(读文件)
std::string camera_device; // 真实摄像头设备(默认 /dev/video0)
int max_turns = 8;
};
// 运行工具循环,直到模型给出最终回答并返回其文本。失败抛 std::runtime_error。
// log_tag 用于区分不同代理的工具日志(输出到 stderr)。
std::string run_chat_loop(const AgentConfig& cfg,
const std::string& system_prompt,
const std::string& user_question,
const ToolRegistry& registry,
const std::string& log_tag);
// 消息构造(主代理与子代理共用)
json::object user_text_msg(const std::string& text);
json::object user_image_msg(const std::string& text, const std::string& data_url);
json::object tool_result_msg(const std::string& call_id, const std::string& text);
json::value build_tools_spec(const ToolRegistry& registry);