feat(phase2): complete P1 tasks - Channels, Triggers, Skills CRUD and UI enhancements

Phase 2 P1 Tasks Completed:

API Layer (gateway-client.ts, gatewayStore.ts):
- Add Channels CRUD: getChannel, createChannel, updateChannel, deleteChannel
- Add Triggers CRUD: getTrigger, createTrigger, updateTrigger, deleteTrigger
- Add Skills CRUD: getSkill, createSkill, updateSkill, deleteSkill
- Add Scheduled Tasks API: createScheduledTask, deleteScheduledTask, toggleScheduledTask
- Add loadModels action for dynamic model list

UI Components:
- ModelsAPI.tsx: Dynamic model loading from API with loading/error states
- SchedulerPanel.tsx: Full CreateJobModal with cron/interval/once scheduling
- SecurityStatus.tsx: Loading states, error handling, retry functionality
- WorkflowEditor.tsx: New workflow creation/editing modal (new file)
- WorkflowHistory.tsx: Workflow execution history viewer (new file)
- WorkflowList.tsx: Integrated editor and history access

Configuration:
- Add 4 Hands TOML configs: clip, collector, predictor, twitter

Documentation (SYSTEM_ANALYSIS.md):
- Update API coverage: 65% → 89% (53/62 endpoints)
- Update UI completion: 85% → 92%
- Mark Phase 2 P1 tasks as completed
- Update technical debt cleanup status

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
iven
2026-03-15 01:38:34 +08:00
parent 1f9b6553fc
commit 5599c1a4db
15 changed files with 3216 additions and 296 deletions

133
hands/clip.HAND.toml Normal file
View File

@@ -0,0 +1,133 @@
# Clip Hand - 视频处理和编辑能力包
#
# OpenFang Hand 配置
# 这个 Hand 提供视频处理、剪辑和格式转换能力
[hand]
name = "clip"
version = "1.0.0"
description = "视频处理和编辑能力包 - 支持剪辑、转码、生成竖屏视频"
author = "ZCLAW Team"
# Hand 类型
type = "automation"
# 是否需要人工审批才能执行
requires_approval = false
# 默认超时时间(秒)
timeout = 600
# 最大并发执行数
max_concurrent = 2
# 能力标签
tags = ["video", "editing", "transcoding", "vertical-video", "media"]
[hand.config]
# 输出格式配置
default_format = "mp4" # mp4, webm, gif
default_resolution = "1080p"
# 视频编码设置
video_codec = "h264"
audio_codec = "aac"
bitrate = "auto"
# 生成竖屏视频
vertical_mode = false
vertical_aspect = "9:16"
# 临时文件存储
temp_dir = "/tmp/zclaw/clip"
cleanup_after_complete = true
[hand.triggers]
# 触发器配置
manual = true
schedule = true
webhook = true
# 事件触发器
[[hand.triggers.events]]
type = "file.uploaded"
pattern = "\\.(mp4|mov|avi|mkv|webm)$"
priority = 8
[[hand.triggers.events]]
type = "chat.intent"
pattern = "剪辑|视频|转码|竖屏|clip|video|edit"
priority = 5
[hand.permissions]
# 权限要求
requires = [
"file.read",
"file.write",
"process.execute"
]
# RBAC 角色要求
roles = ["operator.read", "operator.write"]
# 速率限制
[hand.rate_limit]
max_requests = 10
window_seconds = 3600 # 1 hour
# 审计配置
[hand.audit]
log_inputs = true
log_outputs = true
retention_days = 14
# 参数定义
[[hand.parameters]]
name = "inputPath"
label = "输入路径"
type = "text"
required = true
description = "视频文件路径或 URL"
[[hand.parameters]]
name = "outputFormat"
label = "输出格式"
type = "select"
required = false
default = "mp4"
options = ["mp4", "webm", "gif"]
[[hand.parameters]]
name = "trimStart"
label = "开始时间"
type = "number"
required = false
description = "剪辑开始时间(秒)"
[[hand.parameters]]
name = "trimEnd"
label = "结束时间"
type = "number"
required = false
description = "剪辑结束时间(秒)"
# 工作流步骤
[[hand.workflow]]
id = "validate"
name = "验证输入"
description = "检查视频文件格式和可用性"
[[hand.workflow]]
id = "analyze"
name = "分析视频"
description = "获取视频元数据(时长、分辨率、编码)"
[[hand.workflow]]
id = "process"
name = "处理视频"
description = "执行剪辑、转码等操作"
[[hand.workflow]]
id = "output"
name = "输出结果"
description = "保存处理后的视频文件"

135
hands/collector.HAND.toml Normal file
View File

@@ -0,0 +1,135 @@
# Collector Hand - 数据收集和聚合能力包
#
# OpenFang Hand 配置
# 这个 Hand 提供自动化数据收集、网页抓取和聚合能力
[hand]
name = "collector"
version = "1.0.0"
description = "数据收集和聚合能力包 - 自动抓取、解析和结构化数据"
author = "ZCLAW Team"
# Hand 类型
type = "data"
# 是否需要人工审批才能执行
requires_approval = false
# 默认超时时间(秒)
timeout = 300
# 最大并发执行数
max_concurrent = 5
# 能力标签
tags = ["data", "scraping", "collection", "aggregation", "web"]
[hand.config]
# 请求配置
user_agent = "ZCLAW-Collector/1.0"
request_timeout = 30
retry_count = 3
retry_delay = 5
# 分页处理
max_pages = 100
pagination_delay = 1 # 秒
# 输出配置
default_output_format = "json" # json, csv, xlsx
output_dir = "/tmp/zclaw/collector"
# 反爬虫设置
respect_robots_txt = true
rate_limit_per_second = 2
[hand.triggers]
# 触发器配置
manual = true
schedule = true
webhook = true
# 事件触发器
[[hand.triggers.events]]
type = "schedule.cron"
pattern = "0 */6 * * *" # 每6小时
priority = 5
[[hand.triggers.events]]
type = "chat.intent"
pattern = "收集|抓取|爬取|采集|scrape|collect|crawl"
priority = 5
[hand.permissions]
# 权限要求
requires = [
"web.fetch",
"file.read",
"file.write"
]
# RBAC 角色要求
roles = ["operator.read", "operator.write"]
# 速率限制
[hand.rate_limit]
max_requests = 50
window_seconds = 3600 # 1 hour
# 审计配置
[hand.audit]
log_inputs = true
log_outputs = true
retention_days = 30
# 参数定义
[[hand.parameters]]
name = "targetUrl"
label = "目标 URL"
type = "text"
required = true
description = "要抓取的网页 URL"
[[hand.parameters]]
name = "selector"
label = "CSS 选择器"
type = "text"
required = false
description = "要提取的元素 CSS 选择器"
[[hand.parameters]]
name = "outputFormat"
label = "输出格式"
type = "select"
required = false
default = "json"
options = ["json", "csv", "xlsx"]
[[hand.parameters]]
name = "pagination"
label = "跟踪分页"
type = "boolean"
required = false
default = false
description = "是否自动跟踪分页链接"
# 工作流步骤
[[hand.workflow]]
id = "fetch"
name = "获取页面"
description = "下载目标网页内容"
[[hand.workflow]]
id = "parse"
name = "解析内容"
description = "使用选择器提取目标数据"
[[hand.workflow]]
id = "transform"
name = "转换数据"
description = "清理和结构化提取的数据"
[[hand.workflow]]
id = "export"
name = "导出结果"
description = "保存为指定格式的文件"

143
hands/predictor.HAND.toml Normal file
View File

@@ -0,0 +1,143 @@
# Predictor Hand - 预测分析能力包
#
# OpenFang Hand 配置
# 这个 Hand 提供预测分析、趋势预测和数据建模能力
[hand]
name = "predictor"
version = "1.0.0"
description = "预测分析能力包 - 执行回归、分类和时间序列预测"
author = "ZCLAW Team"
# Hand 类型
type = "data"
# 是否需要人工审批才能执行
requires_approval = false
# 默认超时时间(秒)
timeout = 600
# 最大并发执行数
max_concurrent = 2
# 能力标签
tags = ["prediction", "analytics", "forecasting", "ml", "statistics"]
[hand.config]
# 模型配置
default_model = "auto" # auto, regression, classification, timeseries
model_storage = "/tmp/zclaw/predictor/models"
# 训练配置
train_test_split = 0.8
cross_validation = 5
# 输出配置
output_format = "report" # report, json, chart
include_visualization = true
confidence_level = 0.95
# 特征工程
auto_feature_selection = true
max_features = 50
[hand.triggers]
# 触发器配置
manual = true
schedule = true
webhook = false
# 事件触发器
[[hand.triggers.events]]
type = "data.updated"
pattern = ".*(forecast|predict|analyze).*"
priority = 7
[[hand.triggers.events]]
type = "chat.intent"
pattern = "预测|分析|趋势|forecast|predict|analyze|trend"
priority = 5
[hand.permissions]
# 权限要求
requires = [
"file.read",
"file.write",
"compute.ml"
]
# RBAC 角色要求
roles = ["operator.read", "operator.write"]
# 速率限制
[hand.rate_limit]
max_requests = 20
window_seconds = 3600 # 1 hour
# 审计配置
[hand.audit]
log_inputs = true
log_outputs = true
retention_days = 30
# 参数定义
[[hand.parameters]]
name = "dataSource"
label = "数据源"
type = "text"
required = true
description = "数据文件路径或 URL"
[[hand.parameters]]
name = "model"
label = "模型类型"
type = "select"
required = true
options = ["regression", "classification", "timeseries"]
description = "预测模型的类型"
[[hand.parameters]]
name = "targetColumn"
label = "目标列"
type = "text"
required = true
description = "要预测的目标变量列名"
[[hand.parameters]]
name = "featureColumns"
label = "特征列"
type = "text"
required = false
description = "用于预测的特征列(逗号分隔,留空自动选择)"
# 工作流步骤
[[hand.workflow]]
id = "load"
name = "加载数据"
description = "读取和验证输入数据"
[[hand.workflow]]
id = "preprocess"
name = "数据预处理"
description = "清洗数据、处理缺失值、特征工程"
[[hand.workflow]]
id = "train"
name = "训练模型"
description = "训练预测模型并进行交叉验证"
[[hand.workflow]]
id = "evaluate"
name = "评估模型"
description = "计算模型性能指标"
[[hand.workflow]]
id = "predict"
name = "执行预测"
description = "使用训练好的模型进行预测"
[[hand.workflow]]
id = "report"
name = "生成报告"
description = "生成包含可视化的分析报告"

156
hands/twitter.HAND.toml Normal file
View File

@@ -0,0 +1,156 @@
# Twitter Hand - Twitter/X 自动化能力包
#
# OpenFang Hand 配置
# 这个 Hand 提供 Twitter/X 平台的自动化操作和互动能力
[hand]
name = "twitter"
version = "1.0.0"
description = "Twitter/X 自动化能力包 - 发推文、搜索、分析和互动"
author = "ZCLAW Team"
# Hand 类型
type = "communication"
# 是否需要人工审批才能执行
# 发推文等敏感操作需要审批
requires_approval = true
# 默认超时时间(秒)
timeout = 120
# 最大并发执行数
max_concurrent = 3
# 能力标签
tags = ["twitter", "social", "automation", "engagement", "marketing"]
[hand.config]
# API 配置
api_version = "v2"
rate_limit_mode = "strict" # strict, relaxed
# 发推配置
max_tweet_length = 280
auto_shorten_urls = true
url_shortener = "none" # none, bitly, custom
# 搜索配置
search_max_results = 100
search_include_metrics = true
# 互动配置
max_daily_likes = 50
max_daily_retweets = 25
max_daily_follows = 30
# 安全设置
allow_sensitive_content = false
filter_spam = true
[hand.triggers]
# 触发器配置
manual = true
schedule = true
webhook = true
# 事件触发器
[[hand.triggers.events]]
type = "schedule.cron"
pattern = "0 9,12,18 * * *" # 每天3次
priority = 5
[[hand.triggers.events]]
type = "chat.intent"
pattern = "推特|发推|tweet|twitter|x\\.com"
priority = 5
[hand.permissions]
# 权限要求
requires = [
"twitter.read",
"twitter.write",
"twitter.engage"
]
# RBAC 角色要求
roles = ["operator.read", "operator.write", "social.manage"]
# 速率限制(严格遵循 Twitter API 限制)
[hand.rate_limit]
max_requests = 100
window_seconds = 900 # 15 minutes
# 审计配置
[hand.audit]
log_inputs = true
log_outputs = true
retention_days = 90 # 社交媒体操作保留更长时间
# 参数定义
[[hand.parameters]]
name = "action"
label = "操作类型"
type = "select"
required = true
options = ["post", "search", "analyze", "engage"]
description = "要执行的 Twitter 操作"
[[hand.parameters]]
name = "content"
label = "内容"
type = "textarea"
required = false
description = "推文内容或搜索查询"
[[hand.parameters]]
name = "schedule"
label = "计划时间"
type = "text"
required = false
description = "ISO 日期时间或 'now'"
[[hand.parameters]]
name = "mediaUrls"
label = "媒体 URL"
type = "text"
required = false
description = "附加媒体的 URL逗号分隔最多4个"
# 工作流步骤(根据操作类型)
[[hand.workflow]]
id = "validate"
name = "验证请求"
description = "检查操作权限和参数有效性"
[[hand.workflow]]
id = "prepare"
name = "准备内容"
description = "处理内容、缩短 URL、附加媒体"
[[hand.workflow]]
id = "execute"
name = "执行操作"
description = "调用 Twitter API 执行操作"
[[hand.workflow]]
id = "verify"
name = "验证结果"
description = "确认操作成功并记录结果"
# 操作特定的工作流
[[hand.workflow.post]]
steps = ["validate", "prepare", "execute", "verify"]
approval_required = true
[[hand.workflow.search]]
steps = ["validate", "execute", "verify"]
approval_required = false
[[hand.workflow.analyze]]
steps = ["validate", "execute", "verify"]
approval_required = false
[[hand.workflow.engage]]
steps = ["validate", "execute", "verify"]
approval_required = true