cang-ying/engines/image-api-bridge.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

65 lines
2.2 KiB
JavaScript
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.

#!/usr/bin/env node
/**
* image-api-bridge.js · Python ↔ Node 图片API桥接
* D144 · 铸渊 ICE-GL-ZY001
*
* Python 通过 subprocess 调用本脚本stdin 输入 JSON 命令stdout 输出 JSON 结果。
* 解决 char-hero-design-packer.py 依赖 JS image-api-adapter 的问题。
*
* 用法:
* echo '{"action":"generate_character_ref","charId":"CHAR-003","l0":"...","l1":"..."}' | node image-api-bridge.js
* echo '{"action":"generate_image","prompt":"...","size":"2048x2048","filename":"test.png"}' | node image-api-bridge.js
*/
// 桥接模式:所有日志输出到 stderrstdout 只输出最终 JSON 结果
console.log = (...args) => process.stderr.write(args.join(' ') + '\n');
console.warn = (...args) => process.stderr.write(args.join(' ') + '\n');
console.error = (...args) => process.stderr.write(args.join(' ') + '\n');
const { generateImage, generateCharacterRef } = require('./image-api-adapter');
let input = '';
process.stdin.setEncoding('utf8');
process.stdin.on('data', chunk => input += chunk);
process.stdin.on('end', async () => {
try {
const req = JSON.parse(input || '{}');
let result;
switch (req.action) {
case 'generate_character_ref': {
const { charId, l0, l1 } = req;
if (!charId) throw new Error('缺少 charId');
result = await generateCharacterRef({
charId,
l0Descriptor: l0 || '中国古代修仙少年16岁亚洲面孔',
l1Config: l1 ? { clothing: l1 } : undefined,
});
break;
}
case 'generate_image': {
const { prompt, size, filename, outputPath } = req;
if (!prompt) throw new Error('缺少 prompt');
result = await generateImage({ prompt, size, filename, outputPath });
break;
}
default:
throw new Error(`未知操作: ${req.action}`);
}
process.stdout.write(JSON.stringify({ ok: true, data: result }) + '\n');
process.exit(0);
} catch (err) {
process.stdout.write(JSON.stringify({ ok: false, error: err.message }) + '\n');
process.exit(1);
}
});
// stdin 已关闭pipe 模式),直接触发 end
if (process.stdin.isTTY) {
process.stderr.write('用法: echo \'{"action":"..."}\' | node image-api-bridge.js\n');
process.exit(1);
}