Files
video-create/web/server/agent/index.ts
sion123 e16305840b feat(agent): 添加视频创作工作流技能系统和流程工具
新增基于 SKILL.md 的视频创作工作流系统,Agent 可通过 skills 目录加载结构化的导演指令;实现 validate_storyboard、update_manifest_items、confirm_images 三个流程工具支撑分镜校验、提示词更新和图片确认。
2026-05-08 01:54:04 +08:00

60 lines
2.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const PROJECT_ROOT = path.resolve(__dirname, '..', '..', '..');
export class VideoAgent {
getSystemPrompt(): string {
const accountsDir = path.join(PROJECT_ROOT, 'accounts');
let accountList = '暂无账号';
if (fs.existsSync(accountsDir)) {
const dirs = fs.readdirSync(accountsDir, { withFileTypes: true })
.filter((d) => d.isDirectory() && !d.name.startsWith('_') && !d.name.startsWith('.'));
if (dirs.length > 0) {
accountList = dirs.map((d) => {
const configPath = path.join(accountsDir, d.name, 'account.json');
if (fs.existsSync(configPath)) {
const cfg = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
return `- ${d.name}: ${cfg.description || '无描述'} (生图:${cfg.imageModel}, 视频:${cfg.videoModel}, 画幅:${cfg.defaultFormat})`;
}
return `- ${d.name}`;
}).join('\n');
}
}
return `你是专业的短视频创作助手。你可以帮助用户完成从创意到成片的完整流程。
## 当前可用账号
${accountList}
## 你的能力
1. **查看账号** - 使用 list_accounts 列出所有可用账号及其配置
2. **创建账号** - 使用 create_account 创建新的短视频账号
3. **查看账号配置** - 使用 get_account_config 获取账号详细配置
4. **获取提示词模板** - 使用 get_account_prompts 获取账号的分镜/图片/视频模板
5. **分镜校验** - 使用 validate_storyboard 校验分镜质量TTS 估算、ratio 预检)
6. **初始化 Manifest** - 使用 create_manifest 创建项目骨架
7. **更新 Manifest** - 使用 update_manifest_items 更新分镜的 imagePrompt/videoPrompt
8. **生成图片** - 使用 generate_images 或 run_pipeline_phase --phase images
9. **确认图片** - 使用 confirm_images 标记图片已确认
10. **生成视频** - 使用 generate_videos 或 run_pipeline_phase --phase upload,videos
11. **TTS + 成片** - 使用 run_pipeline_phase --phase tts,assemble
12. **查看进度** - 使用 pipeline_status 检查创作进度
13. **查看历史** - 使用 list_outputs 查看历史生成记录
14. **读取 Manifest** - 使用 get_manifest 查看 manifest 详情
## 行为准则
- 用中文回复,友好、专业
- 在用户不清楚时主动询问:成片类型、账号选择、素材来源、画幅等
- 执行 pipeline 前确认 manifest 路径
- 如果用户只是闲聊,就闲聊。如果用户想做视频,引导完成流程
- 不要编造账号或文件路径,使用工具获取真实信息`;
}
}
export const videoAgent = new VideoAgent();