自主 Hands

LibreFang 的核心创新——预构建的自主能力包,独立运行,通过 LLM Agent 执行任务,无需人工干预。


概述

Hands 是 LibreFang 的独特功能,它们是自主工作的 Agent,可以:

  • 通过 LLM 驱动的 Agent 自动执行任务
  • 处理复杂的多步骤工作流
  • 通过 settings 配置(提供者、模型、API Key 等)
  • 支持单 Agent 或多 Agent 模式

内置 Hands

Hand功能类型
ClipYouTube 视频下载、剪辑、字幕生成多 Agent
Lead每日潜在客户发现、信息丰富、0-100 评分、去重多 Agent
CollectorOSINT 情报收集、变更检测、知识图谱多 Agent
Predictor超级预测引擎、置信区间、反向模式单 Agent
Researcher深度自主研究、CRAAP 可信度评估、APA 引用多 Agent
Twitter自主 X/Twitter 账号管理、多种内容格式、审批队列多 Agent
BrowserWeb 自动化、Playwright、强制购买审批单 Agent
Analytics业务分析、KPI 追踪、自动化报告多 Agent
ApiTester自动化 API 测试、合约验证、回归检测单 Agent
DevOpsCI/CD 监控、部署自动化、基础设施告警多 Agent
LinkedInLinkedIn 档案监控、外展自动化多 Agent
RedditReddit 社区监控、帖子排期、情感追踪多 Agent
Strategist战略分析、竞争情报、场景规划多 Agent
Trader市场数据监控、信号生成、投资组合追踪多 Agent

CLI 命令

Hand 管理

# 列出所有可用的 Hands
librefang hand list

# 显示当前活跃的 Hand 实例
librefang hand active

# 查看指定 Hand 的状态
librefang hand status clip

# 查看 Hand 详细信息
librefang hand info clip

# 从磁盘重新加载 Hand 定义
librefang hand reload

激活生命周期

# 激活 Hand
librefang hand activate clip

# 暂停运行中的 Hand
librefang hand pause clip

# 恢复已暂停的 Hand
librefang hand resume clip

# 停用 Hand
librefang hand deactivate clip

配置

# 查看 Hand 当前设置
librefang hand settings clip

# 设置配置值
librefang hand set clip stt_provider groq

交互

# 与活跃的 Hand 进行交互式对话
librefang hand chat clip

依赖管理

# 检查依赖状态
librefang hand check-deps clip

# 安装缺失的依赖
librefang hand install-deps clip

本地安装

# 从本地目录安装 Hand
librefang hand install ./my-hand

Hand 状态

状态说明
Active运行中,Agent 已生成
Paused已暂停,可恢复
Error发生错误,需要干预
Inactive未激活

HAND.toml 格式

单 Agent Hand

id = "my-hand"
version = "1.0.0"
name = "My Hand"
description = "这个 Hand 做什么"
category = "content"
icon = "M"
tools = ["shell_exec", "web_fetch"]

[[requires]]
key = "ffmpeg"
label = "FFmpeg must be installed"
requirement_type = "binary"
check_value = "ffmpeg"

[[settings]]
key = "quality"
label = "Output Quality"
setting_type = "select"
default = "high"

[[settings.options]]
value = "high"
label = "High (1080p)"

[[settings.options]]
value = "low"
label = "Low (480p)"

[agent]
name = "my-hand-agent"
description = "Processes tasks"
system_prompt = "You are a task processing agent."

[agent.model]
provider = "anthropic"
model = "claude-sonnet-4-20250514"
max_tokens = 4096
temperature = 0.7

[dashboard]
metrics = []

[routing]
aliases = ["my-hand", "process"]
weak_aliases = ["task", "automate"]

多 Agent Hand

id = "research"
version = "2.0.0"
name = "Research Hand"
description = "多 Agent 研究系统"
category = "content"
tools = ["web_fetch"]

[agents.planner]
coordinator = true
invoke_hint = "Use planner for task decomposition"
name = "planner-agent"
description = "Plans research tasks"
model = "default"
system_prompt = "You plan and coordinate research tasks."

[agents.analyst]
name = "analyst-agent"
description = "Analyzes and synthesizes data"
provider = "groq"
model = "llama-3.3-70b-versatile"
system_prompt = "You analyze data and produce insights."

[dashboard]
metrics = []

旧版扁平格式(向后兼容)

单 Agent Hand 可以使用扁平字段代替 [agent.model]

[agent]
name = "my-agent"
description = "Simple agent"
provider = "anthropic"
model = "claude-sonnet-4-20250514"
max_tokens = 4096
temperature = 0.7
system_prompt = "You are a helpful agent."

REST API 端点

Hand 发现

端点方法说明
/api/handsGET列出所有已注册的 Hands 及状态
/api/hands/activeGET列出当前活跃的 Hand 实例
/api/hands/{hand_id}GET获取指定 Hand 的详情
/api/hands/{hand_id}/activatePOST激活 Hand(生成 Agent)
/api/hands/{hand_id}/check-depsPOST检查依赖可用性
/api/hands/{hand_id}/install-depsPOST安装缺失的依赖
/api/hands/reloadPOST从磁盘重新加载 Hand 定义

Hand 配置

端点方法说明
/api/hands/{hand_id}/settingsGET获取当前 Hand 配置
/api/hands/{hand_id}/settingsPUT更新 Hand 配置

实例生命周期

端点方法说明
/api/hands/instances/{id}/pausePOST暂停运行中的 Hand 实例
/api/hands/instances/{id}/resumePOST恢复已暂停的 Hand 实例
/api/hands/instances/{id}DELETE停用并移除 Hand 实例
/api/hands/instances/{id}/messagePOST向 Hand 实例发送消息

示例:激活并对话

# 激活
curl -X POST http://127.0.0.1:4545/api/hands/clip/activate

# 发送消息
curl -X POST http://127.0.0.1:4545/api/hands/instances/<instance-id>/message \
  -H "Content-Type: application/json" \
  -d '{"message": "下载这个视频并生成字幕"}'