cang-ying/tools/test-wan-api.js
铸渊 ICE-GL-ZY001 a2e5214f03 LL-172-20260707 · cang-ying 仓初始化 · 苍耳+鉴影的干净之家
铸渊 ICE-GL-ZY001
LL-172-20260707
冰朔委托: 新建第 5 子仓, 给苍耳(人类主控) + 鉴影(人格体) 专用
原 guanghulab/video-ai-system/ 东西太多(225 文件) · 找不到 · 乱

迁移:
  ⊢ 16 个核心 .hdlp (VA-GATE / VA-LIGHTHOUSE / VA-BROADCAST / VA-SYSTEM-STATUS 等)
  ⊢ 17 个子目录 (agents/engines/protocols/tasks/tools/assets/knowledge/memory/docs/config/brain/director-brain/experience/feedback/issues/plans/reference-analysis)

排除:
  ⊢ outputs/ (视频产物)
  ⊢ test-input/ test-output/ (测试)
  ⊢ data/ (临时数据)
  ⊢ preview-001/002 (旧产片)
  ⊢ 旧分镜/旧提示词/旧导演编码

后续:
  ⊢ 老仓 guanghulab/video-ai-system/ 改写为已迁出占位
  ⊢ 苍耳+鉴影 写新东西进本仓
  ⊢ GLOBAL-SEARCH 加 cang-ying 仓库

铸渊 ICE-GL-ZY001 · 2026-07-07 D167
冰朔 ICE-GL∞ 主权
2026-07-07 10:20:10 +08:00

118 lines
3.3 KiB
JavaScript
Raw Permalink 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.

/**
* 万相API测试脚本
* D140 · 铸渊 ICE-GL-ZY001
*
* 验证万相2.7文生视频API配置与参数是否正常
* 默认 dry-run不会提交付费生成任务。
*
* 用法:
* node tools/test-wan-api.js
* node tools/test-wan-api.js --paid-once
*/
const {
submitT2VTask,
queryWanTask,
API_KEY,
WAN_T2V_SPEC,
BASE_URL,
preflightCheckT2V,
} = require('../engines/wan-api-adapter');
async function main() {
console.log('=== 万相2.7 API 测试 ===\n');
const paidOnce = process.argv.includes('--paid-once');
// 1. 检查密钥
if (!API_KEY) {
console.error('❌ ALIYUN_BAILIAN_API_KEY 未配置');
console.error(' 请在 video-ai-system/.env 中设置');
process.exit(1);
}
console.log('✅ API Key 已配置');
console.log('✅ 模型:', WAN_T2V_SPEC.model);
console.log('✅ Base URL:', BASE_URL);
// 2. 构造一个简单的测试任务
const testPrompt = '一只小猫在月光下奔跑,毛发随风飘动,背景是星空和湖泊,电影级画面';
console.log('\n📝 测试提示词:', testPrompt);
console.log('⏱ 时长: 5秒 分辨率: 720P 比例: 16:9\n');
const preflight = preflightCheckT2V({
prompt: testPrompt,
duration: 5,
resolution: '720P',
ratio: '16:9',
});
if (!preflight.valid) {
console.error('❌ 预校验失败:', preflight.errors.join('; '));
process.exit(1);
}
if (!paidOnce) {
console.log('✅ 预校验通过');
if (preflight.warnings.length > 0) {
console.log('⚠️ 预校验提醒:', preflight.warnings.join('; '));
}
console.log('\nDRY-RUN未提交真实万相任务不产生费用。');
console.log('如需真实付费烟测,请确认预算后运行: node tools/test-wan-api.js --paid-once');
process.exit(0);
}
console.log('⚠️ --paid-once 已开启:将提交一次真实万相任务,可能产生费用。\n');
try {
const { taskId, preflight: paidPreflight } = await submitT2VTask({
prompt: testPrompt,
duration: 5,
resolution: '720P',
ratio: '16:9',
});
console.log('\n✅ 任务提交成功!');
console.log(' Task ID:', taskId);
console.log(' 预校验:', paidPreflight.valid ? '通过' : '失败');
// 3. 轮询查询
console.log('\n⏳ 轮询查询中...\n');
let pollCount = 0;
const maxPolls = 80;
while (pollCount < maxPolls) {
pollCount++;
await new Promise(r => setTimeout(r, 15000)); // 15秒间隔
const result = await queryWanTask(taskId);
if (result.status === 'completed') {
console.log('\n🎉 视频生成成功!');
console.log(' 视频URL:', result.videoUrl);
console.log(' 元数据:', JSON.stringify(result.videoMeta, null, 2));
process.exit(0);
}
if (result.status === 'failed') {
console.error('\n❌ 生成失败:', result.error);
console.error(' 原始响应:', JSON.stringify(result.rawResponse, null, 2).substring(0, 500));
process.exit(1);
}
// 仍在生成
const elapsed = pollCount * 15;
console.log(` [${elapsed}s] 生成中... (task: ${taskId.substring(0, 8)}...)`);
}
console.error('\n⏰ 轮询超时');
process.exit(1);
} catch (err) {
console.error('\n❌ 测试失败:', err.message);
process.exit(1);
}
}
main();