@biunow/agent-biutalk 1.1.7 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/_shared/.tmp-panel-smoke/art/smoke.mp4 +0 -0
  2. package/_shared/.tmp-panel-smoke/art-pipe/out/biuart-01_cave-mwq5kfpm.mp4 +0 -0
  3. package/_shared/.tmp-panel-smoke/art-pipe/panel-delivery.json +7 -0
  4. package/_shared/.tmp-panel-smoke/reel-pipe/film/index.html +7 -0
  5. package/_shared/.tmp-panel-smoke/reel-pipe/film/main.js +68 -0
  6. package/_shared/.tmp-panel-smoke/reel-pipe/film/panel-beats.json +20 -0
  7. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/CREDITS +20 -0
  8. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/build.sh +17 -0
  9. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/ease.js +43 -0
  10. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/events.json +1 -0
  11. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/film.js +533 -0
  12. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/fonts/OFL-Archivo.txt +93 -0
  13. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/fonts/OFL-DMSerifDisplay.txt +93 -0
  14. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/fonts/OFL-UnifrakturMaguntia.txt +94 -0
  15. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/fonts/fonts.css +3 -0
  16. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/index.html +6 -0
  17. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/lines.json +10 -0
  18. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/main.js +15 -0
  19. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/mix.py +116 -0
  20. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/music/score.py +168 -0
  21. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/music/score_meta.json +59 -0
  22. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/score.json +235 -0
  23. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/stills/styleframe.jpg +0 -0
  24. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/tools/fonts.sh +17 -0
  25. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/tools/subs.py +11 -0
  26. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/tools/words.py +20 -0
  27. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/voices/dur.json +10 -0
  28. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/voices/words.json +213 -0
  29. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/voices/words_rel.json +56 -0
  30. package/_shared/.tmp-panel-smoke/reel-pipe/style-ref.json +5 -0
  31. package/_shared/.tmp-panel-smoke/reel-pipe2/film/index.html +7 -0
  32. package/_shared/.tmp-panel-smoke/reel-pipe2/film/main.js +68 -0
  33. package/_shared/.tmp-panel-smoke/reel-pipe2/film/panel-beats.json +20 -0
  34. package/_shared/.tmp-panel-smoke/reel-pipe2/out/video.mp4 +0 -0
  35. package/_shared/.tmp-panel-smoke/reel-pipe2/panel-delivery.json +8 -0
  36. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/CREDITS +20 -0
  37. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/build.sh +17 -0
  38. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/ease.js +43 -0
  39. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/events.json +1 -0
  40. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/film.js +533 -0
  41. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/fonts/OFL-Archivo.txt +93 -0
  42. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/fonts/OFL-DMSerifDisplay.txt +93 -0
  43. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/fonts/OFL-UnifrakturMaguntia.txt +94 -0
  44. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/fonts/fonts.css +3 -0
  45. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/index.html +6 -0
  46. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/lines.json +10 -0
  47. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/main.js +15 -0
  48. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/mix.py +116 -0
  49. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/music/score.py +168 -0
  50. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/music/score_meta.json +59 -0
  51. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/score.json +235 -0
  52. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/stills/styleframe.jpg +0 -0
  53. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/tools/fonts.sh +17 -0
  54. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/tools/subs.py +11 -0
  55. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/tools/words.py +20 -0
  56. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/voices/dur.json +10 -0
  57. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/voices/words.json +213 -0
  58. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/voices/words_rel.json +56 -0
  59. package/_shared/.tmp-panel-smoke/reel-pipe2/style-ref.json +5 -0
  60. package/_shared/.tmp-panel-smoke/remo-pipe/brief.md +2 -0
  61. package/_shared/.tmp-panel-smoke/remo-pipe/remo-job.json +4 -0
  62. package/_shared/.tmp-panel-smoke/remo-pipe2/brief.md +1 -0
  63. package/_shared/.tmp-panel-smoke/remo-pipe2/out/final.mp4 +0 -0
  64. package/_shared/.tmp-panel-smoke/remo-pipe2/panel-delivery.json +8 -0
  65. package/_shared/.tmp-panel-smoke/remo-pipe2/remo-job.json +4 -0
  66. package/_shared/.tmp-panel-smoke/vibe-pipe-ok/ep00-demo.mp4 +0 -0
  67. package/_shared/.tmp-panel-smoke/vibe-pipe-ok/out/ep00-demo.mp4 +0 -0
  68. package/_shared/.tmp-panel-smoke/vibe-pipe-ok/panel-delivery.json +7 -0
  69. package/_shared/.tmp-panel-smoke/vibe-pipe-ok/publish.json +10 -0
  70. package/_shared/.tmp-panel-smoke/vibe-still.jpg +0 -0
  71. package/_shared/.tmp-panel-smoke/vibe-still.log +6 -0
  72. package/_shared/.tmp-panel-smoke/vibe-still.log.err +0 -0
  73. package/_shared/.tmp-panel-smoke/vibe-still2.log +26 -0
  74. package/_shared/.tmp-panel-smoke/vibe-still2.log.err +0 -0
  75. package/_shared/lib/film-locate.mjs +203 -0
  76. package/_shared/lib/voice-catalog.mjs +127 -0
  77. package/_shared/scripts/apply-upload-limits.mjs +62 -0
  78. package/_shared/scripts/patch-film-hosts.mjs +233 -0
  79. package/_shared/scripts/patch-voice-options.mjs +41 -0
  80. package/_shared/scripts/sync-local-agents.mjs +67 -0
  81. package/_shared/scripts/wire-film-bridge.mjs +24 -0
  82. package/_shared/scripts/wire-voice-plus.mjs +68 -0
  83. package/_shared/studio/assert-panel-permit.mjs +67 -0
  84. package/_shared/studio/composer.css +559 -0
  85. package/_shared/studio/composer.js +728 -0
  86. package/_shared/studio/optimize-prompt.mjs +84 -0
  87. package/_shared/studio/optimize-prompt.test.mjs +47 -0
  88. package/_shared/studio/recipes.mjs +87 -0
  89. package/_shared/studio/select-menu.js +450 -0
  90. package/_shared/studio/to-english-prompt.mjs +165 -0
  91. package/_shared/studio/to-english-prompt.test.mjs +72 -0
  92. package/bin/server.js +22 -22
  93. package/data/looks.json +8 -0
  94. package/lib/film-bridge.mjs +1 -0
  95. package/lib/host.mjs +131 -264
  96. package/lib/voice-bridge.mjs +2 -0
  97. package/manifest.json +4 -3
  98. package/package.json +1 -1
  99. package/skills/biutalk/EXEC.md +69 -0
  100. package/skills/biutalk/SKILL.md +12 -10
  101. package/skills/biutalk/scripts/doctor.mjs +124 -0
  102. package/skills/biutalk/scripts/qc.mjs +129 -0
  103. package/skills/biutalk/scripts/scaffold.mjs +205 -0
  104. package/studio/app.js +16 -1
  105. package/studio/composer.css +94 -0
  106. package/studio/composer.js +257 -9
  107. package/studio/index.html +5 -1
  108. package/studio/to-english-prompt.mjs +16 -0
@@ -0,0 +1,26 @@
1
+ Bundling 6%
2
+ Bundling 21%
3
+ Bundling 32%
4
+ Bundling 43%
5
+ Bundling 54%
6
+ Bundling 65%
7
+ Bundling 70%
8
+ Bundling 75%
9
+ Bundling 80%
10
+ Bundling 85%
11
+ Bundling 91%
12
+ Bundling 98%
13
+ Bundling 100%
14
+ Copying public dir 10.8 MB
15
+ Copying public dir 18 MB
16
+ Copying public dir 18 MB
17
+ Copying public dir 21.5 MB
18
+ Getting composition
19
+ ⚡️ Cached bundle. Subsequent renders will be faster.
20
+ Composition ep00-demo
21
+ Format jpeg
22
+ Output e:\BiunowPanel\Agents\products\_shared\.tmp-panel-smoke\vibe-still.jpg
23
+ Rendered 0/1
24
+ Rendered 0/1
25
+ Rendered 1/1
26
+ + e:\BiunowPanel\Agents\products\_shared\.tmp-panel-smoke\vibe-still.jpg
File without changes
@@ -0,0 +1,203 @@
1
+ /**
2
+ * 成片定位:不依赖固定文件名。
3
+ * - 同目录改名(final.mp4 → xxx-master.mp4)
4
+ * - 二次生成(更新的 mtime / 新文件优先)
5
+ * - 工程目录优先,引擎 films/runs 仅作回落且按 job 亲和打分
6
+ */
7
+ import fs from 'node:fs';
8
+ import path from 'node:path';
9
+
10
+ export function isIntermediateMp4(filePath) {
11
+ const base = path.basename(String(filePath || '')).toLowerCase();
12
+ if (!base) return true;
13
+ if (base === 'merged.mp4' || /^seg[-_]\d+\.mp4$/.test(base)) return true;
14
+ if (/^draft([-.]|$)/.test(base)) return true;
15
+ if (/^preview([-.]|$)/.test(base)) return true;
16
+ const parts = String(filePath || '').split(/[/\\]/).map((part) => part.toLowerCase());
17
+ if (parts.includes('build') || parts.includes('segments') || parts.includes('tmp') || parts.includes('temp')) {
18
+ return true;
19
+ }
20
+ return base === 'video.mp4' && parts.at(-2) === 'out';
21
+ }
22
+
23
+ function filmStat(filePath) {
24
+ try {
25
+ const st = fs.statSync(filePath);
26
+ if (!st.isFile()) return null;
27
+ return { path: filePath, mtime: st.mtimeMs, size: st.size };
28
+ } catch {
29
+ return null;
30
+ }
31
+ }
32
+
33
+ /** 记录路径丢失或改名:同目录下 stem 前缀匹配,取最新。 */
34
+ export function rescueMissingFilm(filePath) {
35
+ const file = String(filePath || '');
36
+ if (!file) return '';
37
+ const live = filmStat(file);
38
+ if (live && !isIntermediateMp4(live.path)) return live.path;
39
+ const dir = path.dirname(file);
40
+ if (!fs.existsSync(dir)) return '';
41
+ const stem = path.basename(file, path.extname(file)).toLowerCase();
42
+ if (!stem) return '';
43
+ let best = null;
44
+ let names = [];
45
+ try {
46
+ names = fs.readdirSync(dir);
47
+ } catch {
48
+ return '';
49
+ }
50
+ for (const name of names) {
51
+ if (!/\.mp4$/i.test(name)) continue;
52
+ const lower = name.toLowerCase();
53
+ // 前缀或「去尾缀」相近:final / final-v2 / final_master
54
+ if (!(lower.startsWith(stem) || stem.startsWith(path.basename(lower, '.mp4')))) continue;
55
+ const full = path.join(dir, name);
56
+ if (isIntermediateMp4(full)) continue;
57
+ const st = filmStat(full);
58
+ if (!st) continue;
59
+ if (!best || st.mtime > best.mtime) best = st;
60
+ }
61
+ return best ? best.path : '';
62
+ }
63
+
64
+ function collectMp4(rootDir, maxDepth) {
65
+ const found = [];
66
+ if (!rootDir || !fs.existsSync(rootDir)) return found;
67
+ const walk = (dir, depth) => {
68
+ if (depth > maxDepth) return;
69
+ let entries;
70
+ try {
71
+ entries = fs.readdirSync(dir, { withFileTypes: true });
72
+ } catch {
73
+ return;
74
+ }
75
+ for (const ent of entries) {
76
+ if (ent.name === 'node_modules' || ent.name === '.git' || ent.name === '.venv' || ent.name === '.agents') continue;
77
+ const full = path.join(dir, ent.name);
78
+ if (ent.isDirectory()) walk(full, depth + 1);
79
+ else if (ent.isFile() && /\.mp4$/i.test(ent.name)) {
80
+ const st = filmStat(full);
81
+ if (st) found.push(st);
82
+ }
83
+ }
84
+ };
85
+ walk(rootDir, 0);
86
+ return found;
87
+ }
88
+
89
+ function scoreHit(hit, job) {
90
+ if (!hit || isIntermediateMp4(hit.path)) return -Infinity;
91
+ let score = hit.mtime;
92
+ const p = hit.path.replace(/\\/g, '/').toLowerCase();
93
+ const proj = String(job?.projectPath || '').replace(/\\/g, '/').toLowerCase();
94
+ const id = String(job?.id || '').toLowerCase();
95
+ const slug = String(job?.filmSlug || job?.title || '').toLowerCase().slice(0, 48);
96
+ if (proj && (p === proj || p.startsWith(proj.endsWith('/') ? proj : `${proj}/`))) score += 1e15;
97
+ if (id && p.includes(id)) score += 1e14;
98
+ if (slug && slug.length >= 4 && p.includes(slug.replace(/[^a-z0-9\u4e00-\u9fff]+/gi, '').slice(0, 24))) {
99
+ score += 1e12;
100
+ }
101
+ const base = path.basename(hit.path).toLowerCase();
102
+ if (base === 'final.mp4' || base === 'film.mp4' || /^final[-_.]/i.test(base)) score += 1e10;
103
+ return score;
104
+ }
105
+
106
+ function pickFilm(found, job) {
107
+ const usable = (found || []).filter((hit) => hit && !isIntermediateMp4(hit.path));
108
+ if (!usable.length) return null;
109
+ usable.sort((a, b) => scoreHit(b, job) - scoreHit(a, job));
110
+ return usable[0];
111
+ }
112
+
113
+ export function findLatestMp4(rootDir, { maxDepth = 8, sinceMs = 0, job = null } = {}) {
114
+ const since = Number(sinceMs) || 0;
115
+ const found = collectMp4(rootDir, maxDepth).filter((hit) => !since || hit.mtime >= since);
116
+ return pickFilm(found, job);
117
+ }
118
+
119
+ export function locateFilm(roots, job = null) {
120
+ const found = [];
121
+ for (const root of roots || []) {
122
+ const dir = typeof root === 'string' ? root : root?.dir;
123
+ const sinceMs = typeof root === 'string' ? 0 : Number(root?.sinceMs) || 0;
124
+ const maxDepth = typeof root === 'string' ? 8 : root?.maxDepth || 8;
125
+ found.push(...collectMp4(dir, maxDepth).filter((hit) => !sinceMs || hit.mtime >= sinceMs));
126
+ }
127
+ return pickFilm(found, job);
128
+ }
129
+
130
+ function pushRoot(roots, dir, sinceMs = 0, maxDepth = 8) {
131
+ if (!dir) return;
132
+ const norm = path.resolve(dir);
133
+ if (roots.some((root) => path.resolve(typeof root === 'string' ? root : root.dir) === norm)) return;
134
+ roots.push({ dir: norm, sinceMs, maxDepth });
135
+ }
136
+
137
+ /** 收集候选根:工程目录优先,引擎 films/runs、工作区 films、当前成片目录作回落。 */
138
+ export function locateJobFilm(job, cfg) {
139
+ if (!job) return null;
140
+ const roots = [];
141
+ if (Array.isArray(job.filmRoots)) {
142
+ for (const root of job.filmRoots) pushRoot(roots, typeof root === 'string' ? root : root?.dir, 0, 8);
143
+ }
144
+ const projectPath = job.projectPath
145
+ || (job.artifact && !String(job.artifact).toLowerCase().endsWith('.mp4') ? job.artifact : '');
146
+ pushRoot(roots, projectPath, 0, 10);
147
+ if (projectPath) {
148
+ pushRoot(roots, path.join(projectPath, 'out'), 0, 4);
149
+ pushRoot(roots, path.join(projectPath, 'runs'), 0, 8);
150
+ }
151
+ const sinceMs = Date.parse(job.createdAt);
152
+ const since = Number.isFinite(sinceMs) ? sinceMs - 60_000 : 0;
153
+ if (cfg?.workspace) {
154
+ pushRoot(roots, path.join(cfg.workspace, 'films'), since, 6);
155
+ }
156
+ if (cfg?.engineRoot && Number.isFinite(sinceMs)) {
157
+ pushRoot(roots, path.join(cfg.engineRoot, 'films'), since, 6);
158
+ pushRoot(roots, path.join(cfg.engineRoot, 'runs'), since, 8);
159
+ }
160
+ const current = String(job.outputMp4 || '');
161
+ if (current) pushRoot(roots, path.dirname(current), 0, 2);
162
+
163
+ return locateFilm(roots, job);
164
+ }
165
+
166
+ /**
167
+ * 选定应展示的成片:
168
+ * 1) 现路径仍在 → 与扫描结果比 mtime,较新者胜(二次生成)
169
+ * 2) 现路径丢失 → rescue 改名 / 全量 locate
170
+ */
171
+ export function chooseDeliverableFilm(job, cfg) {
172
+ if (!job) return null;
173
+ const located = locateJobFilm(job, cfg);
174
+ const recorded = String(job.outputMp4 || '');
175
+ let current = recorded ? filmStat(recorded) : null;
176
+ if (current && isIntermediateMp4(current.path)) current = null;
177
+
178
+ if (!current && recorded) {
179
+ const rescued = rescueMissingFilm(recorded);
180
+ if (rescued) current = filmStat(rescued);
181
+ }
182
+
183
+ if (!located) return current;
184
+ if (!current) return located;
185
+ if (located.path === current.path) return located;
186
+ // 二次生成或改名后的新文件:mtime 不早于旧文件则采用
187
+ if (located.mtime + 500 >= current.mtime) return located;
188
+ return current;
189
+ }
190
+
191
+ export function filmHitFields(hit, messagePrefix = '成片已就绪') {
192
+ if (!hit?.path) return null;
193
+ return {
194
+ status: 'done',
195
+ progress: 100,
196
+ phase: 'film',
197
+ message: `${messagePrefix} · ${path.basename(hit.path)}`,
198
+ outputMp4: hit.path,
199
+ artifact: hit.path,
200
+ filmBytes: hit.size,
201
+ filmAt: new Date().toISOString(),
202
+ };
203
+ }
@@ -0,0 +1,127 @@
1
+ /** Normalize Studio-picked voice for brief.json / kickoff. */
2
+ export function normalizeVoicePick(raw) {
3
+ if (!raw || typeof raw !== 'object') return null;
4
+ const voiceId = String(raw.voiceId || '').trim();
5
+ if (!voiceId) return null;
6
+ return {
7
+ channel: String(raw.channel || 'free'),
8
+ voiceId,
9
+ voiceName: String(raw.voiceName || voiceId),
10
+ rate: Number(raw.rate) || 0,
11
+ provider: String(raw.provider || ''),
12
+ engine: String(raw.engine || ''),
13
+ };
14
+ }
15
+
16
+ export function voiceKickoffLine(voice) {
17
+ if (!voice?.voiceId) return '';
18
+ return `Voice (hard): channel=${voice.channel || 'free'} id=${voice.voiceId} name=${voice.voiceName || ''} rate=${voice.rate ?? 0}. Prefer this for TTS / narration.`;
19
+ }
20
+
21
+ /** 免费 EdgeTTS 常用音色(面板无 Electron 时用静态表)。 */
22
+ export const FREE_VOICES = [
23
+ { id: 'zh-CN-XiaoxiaoNeural', name: '晓晓', language: '中文(简体)', gender: 'Female' },
24
+ { id: 'zh-CN-YunxiNeural', name: '云希', language: '中文(简体)', gender: 'Male' },
25
+ { id: 'zh-CN-YunyangNeural', name: '云扬', language: '中文(简体)', gender: 'Male' },
26
+ { id: 'zh-CN-XiaoyiNeural', name: '晓伊', language: '中文(简体)', gender: 'Female' },
27
+ { id: 'zh-CN-YunjianNeural', name: '云健', language: '中文(简体)', gender: 'Male' },
28
+ { id: 'zh-CN-XiaochenNeural', name: '晓辰', language: '中文(简体)', gender: 'Female' },
29
+ { id: 'zh-CN-XiaohanNeural', name: '晓涵', language: '中文(简体)', gender: 'Female' },
30
+ { id: 'zh-CN-XiaomengNeural', name: '晓梦', language: '中文(简体)', gender: 'Female' },
31
+ { id: 'zh-CN-XiaomoNeural', name: '晓墨', language: '中文(简体)', gender: 'Female' },
32
+ { id: 'zh-CN-XiaoqiuNeural', name: '晓秋', language: '中文(简体)', gender: 'Female' },
33
+ { id: 'zh-CN-XiaoruiNeural', name: '晓睿', language: '中文(简体)', gender: 'Female' },
34
+ { id: 'zh-CN-XiaoshuangNeural', name: '晓双', language: '中文(简体)', gender: 'Female' },
35
+ { id: 'zh-CN-XiaoxuanNeural', name: '晓萱', language: '中文(简体)', gender: 'Female' },
36
+ { id: 'zh-CN-XiaoyanNeural', name: '晓颜', language: '中文(简体)', gender: 'Female' },
37
+ { id: 'zh-CN-XiaoyouNeural', name: '晓悠', language: '中文(简体)', gender: 'Female' },
38
+ { id: 'zh-CN-XiaozhenNeural', name: '晓甄', language: '中文(简体)', gender: 'Female' },
39
+ { id: 'zh-CN-YunfengNeural', name: '云枫', language: '中文(简体)', gender: 'Male' },
40
+ { id: 'zh-CN-YunhaoNeural', name: '云皓', language: '中文(简体)', gender: 'Male' },
41
+ { id: 'zh-CN-YunxiaNeural', name: '云夏', language: '中文(简体)', gender: 'Male' },
42
+ { id: 'zh-CN-YunyeNeural', name: '云野', language: '中文(简体)', gender: 'Male' },
43
+ { id: 'zh-CN-YunzeNeural', name: '云泽', language: '中文(简体)', gender: 'Male' },
44
+ { id: 'zh-TW-HsiaoChenNeural', name: '曉臻', language: '中文(繁体)', gender: 'Female' },
45
+ { id: 'zh-TW-YunJheNeural', name: '雲哲', language: '中文(繁体)', gender: 'Male' },
46
+ { id: 'en-US-JennyNeural', name: 'Jenny', language: 'English (US)', gender: 'Female' },
47
+ { id: 'en-US-GuyNeural', name: 'Guy', language: 'English (US)', gender: 'Male' },
48
+ { id: 'en-US-AriaNeural', name: 'Aria', language: 'English (US)', gender: 'Female' },
49
+ { id: 'en-GB-SoniaNeural', name: 'Sonia', language: 'English (UK)', gender: 'Female' },
50
+ { id: 'ja-JP-NanamiNeural', name: '七海', language: '日本語', gender: 'Female' },
51
+ { id: 'ja-JP-KeitaNeural', name: '圭太', language: '日本語', gender: 'Male' },
52
+ ];
53
+
54
+ export const VOICE_RATES = [
55
+ { value: -30, label: '慢' },
56
+ { value: 0, label: '中' },
57
+ { value: 30, label: '快' },
58
+ ];
59
+
60
+ /** 从 PANEL_VOICE_* 环境变量拼 Studio 可选音色。 */
61
+ export function buildVoiceOptionsFromEnv(env = process.env) {
62
+ const freeEnabled = env.PANEL_VOICE_SYSTEM_ENABLED !== '0';
63
+ const freeVoiceId = String(env.PANEL_VOICE_SYSTEM_VOICE_ID || 'zh-CN-XiaoxiaoNeural');
64
+ const freeVoiceName = String(env.PANEL_VOICE_SYSTEM_VOICE_NAME || '');
65
+ const freeRate = Number(env.PANEL_VOICE_SYSTEM_RATE || 0) || 0;
66
+ const freeEngine = String(env.PANEL_VOICE_SYSTEM_ENGINE || 'edge-tts');
67
+
68
+ const apiProvider = String(env.PANEL_VOICE_THIRD_PROVIDER || '').trim();
69
+ const apiKey = String(env.PANEL_VOICE_THIRD_API_KEY || '').trim();
70
+ const apiVoiceId = String(env.PANEL_VOICE_THIRD_VOICE_ID || '').trim();
71
+ const apiEnabled = !!(apiProvider && apiProvider !== 'none' && apiKey);
72
+
73
+ let cloneVoices = [];
74
+ try {
75
+ cloneVoices = JSON.parse(String(env.PANEL_VOICE_CLONE_VOICES || '[]'));
76
+ if (!Array.isArray(cloneVoices)) cloneVoices = [];
77
+ } catch {
78
+ cloneVoices = [];
79
+ }
80
+ const cloneEnabled = env.PANEL_VOICE_CLONE_ENABLED === '1' && cloneVoices.length > 0;
81
+
82
+ const channels = [
83
+ {
84
+ id: 'free',
85
+ label: '免费语音',
86
+ enabled: freeEnabled,
87
+ engine: freeEngine,
88
+ rate: freeRate,
89
+ voices: FREE_VOICES.map((v) => ({
90
+ id: v.id,
91
+ name: v.name,
92
+ label: `${v.name} · ${v.language}`,
93
+ language: v.language,
94
+ gender: v.gender,
95
+ channel: 'free',
96
+ })),
97
+ defaultVoiceId: freeVoiceId,
98
+ defaultVoiceName: freeVoiceName || FREE_VOICES.find((v) => v.id === freeVoiceId)?.name || freeVoiceId,
99
+ },
100
+ {
101
+ id: 'api',
102
+ label: 'API 通道',
103
+ enabled: apiEnabled,
104
+ provider: apiProvider,
105
+ voices: apiEnabled && apiVoiceId
106
+ ? [{ id: apiVoiceId, name: apiVoiceId, label: `${apiProvider} · ${apiVoiceId}`, channel: 'api' }]
107
+ : [],
108
+ defaultVoiceId: apiVoiceId || '',
109
+ hint: apiEnabled ? '' : '请先在面板设置里配置 API 通道',
110
+ },
111
+ {
112
+ id: 'clone',
113
+ label: '声音复刻',
114
+ enabled: cloneEnabled,
115
+ voices: cloneVoices.map((v) => ({
116
+ id: String(v.voiceId || v.id || ''),
117
+ name: String(v.name || v.voiceId || v.id || ''),
118
+ label: String(v.name || v.voiceId || v.id || ''),
119
+ channel: 'clone',
120
+ samplePath: v.samplePath || '',
121
+ })).filter((v) => v.id),
122
+ hint: cloneEnabled ? '' : '请先在面板设置里启用并添加复刻音色',
123
+ },
124
+ ];
125
+
126
+ return { channels, rates: VOICE_RATES };
127
+ }
@@ -0,0 +1,62 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+
5
+ const products = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..');
6
+ const sharedComposer = path.join(products, '_shared', 'studio', 'composer.js');
7
+ const agents = ['biuremtion', 'biureel', 'biutalk', 'biuvibe', 'biuart'];
8
+
9
+ const bodyBlock = `export async function readBody(req, limit = 32 * 1024 * 1024) {
10
+ const chunks = [];
11
+ let size = 0;
12
+ for await (const chunk of req) {
13
+ size += chunk.length;
14
+ if (size > limit) throw Object.assign(new Error('body too large'), { status: 413 });
15
+ chunks.push(chunk);
16
+ }
17
+ return Buffer.concat(chunks);
18
+ }
19
+
20
+ export async function readJsonBody(req) {
21
+ // 本地上传:视频≤200MB base64 后约 267MB;合计≤250MB,JSON body 放宽到 300MB
22
+ let buf;
23
+ try {
24
+ buf = await readBody(req, 300 * 1024 * 1024);
25
+ } catch (error) {
26
+ if (error.status === 413) {
27
+ throw Object.assign(new Error('附件过大:图文/PDF≤50MB,音频≤100MB,视频≤200MB,合计≤250MB'), { status: 413 });
28
+ }
29
+ throw error;
30
+ }
31
+ if (!buf.length) return {};
32
+ return JSON.parse(buf.toString('utf8'));
33
+ }
34
+ `;
35
+
36
+ for (const id of agents) {
37
+ const dest = path.join(products, id, 'studio', 'composer.js');
38
+ fs.copyFileSync(sharedComposer, dest);
39
+ console.log('composer →', id);
40
+
41
+ // nested _shared copy from earlier sync (if any)
42
+ const nested = path.join(products, id, '_shared', 'studio', 'composer.js');
43
+ if (fs.existsSync(nested)) fs.copyFileSync(sharedComposer, nested);
44
+
45
+ const host = path.join(products, id, 'lib', 'host.mjs');
46
+ let src = fs.readFileSync(host, 'utf8');
47
+ const re = /export async function readBody\(req, limit = 32 \* 1024 \* 1024\) \{[\s\S]*?export async function readJsonBody\(req\) \{[\s\S]*?return JSON\.parse\(buf\.toString\('utf8'\)\);\n\}/;
48
+ if (!re.test(src)) throw new Error(`readJsonBody block missing in ${id}`);
49
+ src = src.replace(re, bodyBlock.trimEnd());
50
+ fs.writeFileSync(host, src);
51
+ console.log('host body →', id);
52
+ }
53
+
54
+ // biuremtion acceptHint
55
+ const server = path.join(products, 'biuremtion', 'bin', 'server.js');
56
+ let serverSrc = fs.readFileSync(server, 'utf8');
57
+ serverSrc = serverSrc.replace(
58
+ /acceptHint: '[^']*'/,
59
+ "acceptHint: '文本 / PDF / 图片(≤50MB) / 音频(≤100MB) / 口播视频(≤200MB);合计≤250MB。口播视频走 talking-head-b-roll;仅音频则按时长驱动 Remotion。'",
60
+ );
61
+ fs.writeFileSync(server, serverSrc);
62
+ console.log('biuremtion acceptHint updated');
@@ -0,0 +1,233 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+
5
+ const here = path.dirname(fileURLToPath(import.meta.url));
6
+ const products = path.resolve(here, '..', '..');
7
+ const agents = ['biuremtion', 'biureel', 'biutalk', 'biuvibe', 'biuart'];
8
+
9
+ const sharedImport =
10
+ "import { isIntermediateMp4, rescueMissingFilm, findLatestMp4, locateFilm, locateJobFilm, chooseDeliverableFilm, filmHitFields } from '../../_shared/lib/film-locate.mjs';\n";
11
+
12
+ const reExport = `
13
+ export { isIntermediateMp4, rescueMissingFilm, findLatestMp4, locateFilm, locateJobFilm, chooseDeliverableFilm, filmHitFields };
14
+
15
+ `;
16
+
17
+ const watchFn = `/** 监视成片:支持改名 / 二次生成;首次就绪后仍短时跟踪更新的文件。 */
18
+ export function watchForFilm(cfg, jobs, jobId, {
19
+ projectPath,
20
+ title,
21
+ intervalMs = 4000,
22
+ timeoutMs = 2 * 60 * 60 * 1000,
23
+ followNewerMs = 20 * 60 * 1000,
24
+ } = {}) {
25
+ const started = Date.now();
26
+ let firstReadyAt = 0;
27
+ const adopt = async (hit) => {
28
+ if (!hit?.path) return false;
29
+ const job = jobs.get(jobId);
30
+ if (!job) return false;
31
+ if (job.outputMp4 === hit.path && job.status === 'done' && job.phase === 'film') return true;
32
+ const fields = filmHitFields(hit);
33
+ jobs.update(jobId, fields);
34
+ await reportJobProgress(cfg, jobs, jobId, {
35
+ title: title || jobs.get(jobId)?.title,
36
+ progress: 100,
37
+ message: fields.message,
38
+ done: true,
39
+ artifact: hit.path,
40
+ });
41
+ if (!firstReadyAt) firstReadyAt = Date.now();
42
+ return true;
43
+ };
44
+ const tick = async () => {
45
+ const job = jobs.get(jobId);
46
+ if (!job || job.status === 'failed' || job.status === 'cancelled') return;
47
+ const probe = { ...job, projectPath: projectPath || job.projectPath, artifact: job.artifact };
48
+ const hit = chooseDeliverableFilm(probe, cfg);
49
+ if (hit) {
50
+ const changed = hit.path !== String(job.outputMp4 || '');
51
+ await adopt(hit);
52
+ const followUntil = (firstReadyAt || Date.now()) + followNewerMs;
53
+ if (Date.now() < followUntil || changed) {
54
+ setTimeout(() => void tick(), intervalMs);
55
+ return;
56
+ }
57
+ return;
58
+ }
59
+ if (Date.now() - started > timeoutMs) {
60
+ jobs.update(jobId, {
61
+ status: 'done',
62
+ progress: 100,
63
+ phase: 'stalled',
64
+ message: '等待成片超时 · 可打开工程目录或 DSH 会话查看',
65
+ });
66
+ await reportJobProgress(cfg, jobs, jobId, {
67
+ progress: 100,
68
+ message: '等待成片超时',
69
+ done: true,
70
+ artifact: projectPath || job.projectPath,
71
+ });
72
+ return;
73
+ }
74
+ if (job.status === 'running' || job.phase === 'dsh' || job.phase === 'inpanel') {
75
+ jobs.update(jobId, {
76
+ phase: job.phase === 'inpanel' ? 'inpanel' : 'dsh',
77
+ message: job.kickoffOk === false
78
+ ? (job.message || '等待手动开拍 / 成片')
79
+ : (job.message && String(job.message).includes('面板') ? job.message : '创作中 · 完成后将自动显示成片'),
80
+ progress: Math.min(90, Math.max(Number(job.progress) || 50, 50)),
81
+ });
82
+ await reportJobProgress(cfg, jobs, jobId, {
83
+ progress: jobs.get(jobId)?.progress ?? 55,
84
+ message: jobs.get(jobId)?.message,
85
+ });
86
+ }
87
+ setTimeout(() => void tick(), intervalMs);
88
+ };
89
+ setTimeout(() => void tick(), intervalMs);
90
+ }
91
+
92
+ `;
93
+
94
+ function ensureImport(src) {
95
+ src = src.replace(/import \{ isIntermediateMp4[\s\S]*?film-locate\.mjs';\n?/g, '');
96
+ if (src.includes("film-locate.mjs")) return src;
97
+ const lines = src.split('\n');
98
+ let lastImport = -1;
99
+ for (let i = 0; i < lines.length; i += 1) {
100
+ if (lines[i].startsWith('import ')) lastImport = i;
101
+ }
102
+ if (lastImport < 0) throw new Error('no import');
103
+ lines.splice(lastImport + 1, 0, sharedImport.trimEnd());
104
+ return lines.join('\n');
105
+ }
106
+
107
+ function stripOldFilmFns(src) {
108
+ const patterns = [
109
+ /\/\*\* 分段和无声中间片[\s\S]*?(?=export function watchForFilm)/,
110
+ /\/\*\* Lemo 的 out\/video\.mp4[\s\S]*?(?=export function watchForFilm)/,
111
+ /export function isIntermediateMp4[\s\S]*?(?=export function watchForFilm)/,
112
+ ];
113
+ for (const re of patterns) {
114
+ if (re.test(src)) return src.replace(re, reExport);
115
+ }
116
+ throw new Error('could not strip old film helpers');
117
+ }
118
+
119
+ function patchWatch(src) {
120
+ const start = src.indexOf('export function watchForFilm');
121
+ const end = src.indexOf('export function runCommand', start);
122
+ if (start < 0 || end < 0) throw new Error('watch/runCommand not found');
123
+ return `${src.slice(0, start)}${watchFn}${src.slice(end)}`;
124
+ }
125
+
126
+ function patchStartup(src) {
127
+ const re = /\/\/ 进程重启后:[\s\S]*?\n for \(const j of jobs\.list\(\)\) \{[\s\S]*?\n \}\n\n const server/;
128
+ const next = `// 进程重启后:重扫成片(改名/二次生成/路径失效),否则恢复 watch
129
+ for (const j of jobs.list()) {
130
+ const hit = chooseDeliverableFilm(j, cfg);
131
+ const missing = j.outputMp4 && !fs.existsSync(j.outputMp4);
132
+ const bad = j.outputMp4 && isIntermediateMp4(j.outputMp4);
133
+ const shouldAdopt = hit && (
134
+ missing || bad || !j.outputMp4 || j.outputMp4 !== hit.path
135
+ || j.status === 'running'
136
+ );
137
+ if (shouldAdopt && hit) {
138
+ const fields = filmHitFields(hit);
139
+ jobs.update(j.id, fields);
140
+ if (j.status === 'running') {
141
+ void reportJobProgress(cfg, jobs, j.id, {
142
+ title: j.title,
143
+ progress: 100,
144
+ message: fields.message,
145
+ done: true,
146
+ artifact: hit.path,
147
+ });
148
+ }
149
+ continue;
150
+ }
151
+ const waiting = j.status === 'running' || (j.outputMp4 && isIntermediateMp4(j.outputMp4));
152
+ if (!waiting) continue;
153
+ const projectPath = j.projectPath || (j.artifact && !String(j.artifact).endsWith('.mp4') ? j.artifact : null);
154
+ if (projectPath && fs.existsSync(projectPath)) {
155
+ jobs.update(j.id, {
156
+ phase: 'dsh',
157
+ message: '进程已恢复 · 继续等待成片',
158
+ progress: Math.min(90, Math.max(Number(j.progress) || 50, 50)),
159
+ });
160
+ watchForFilm(cfg, jobs, j.id, { projectPath, title: j.title });
161
+ } else {
162
+ jobs.update(j.id, {
163
+ status: 'failed',
164
+ phase: 'orphaned',
165
+ message: '进程中断 · 无法恢复监视(工程目录缺失)',
166
+ progress: Number(j.progress) || 0,
167
+ });
168
+ void reportJobProgress(cfg, jobs, j.id, {
169
+ progress: Number(j.progress) || 0,
170
+ message: '进程中断 · 任务已标记失败',
171
+ failed: true,
172
+ error: 'agent process restarted without project path',
173
+ });
174
+ }
175
+ }
176
+
177
+ const server`;
178
+ if (!re.test(src)) throw new Error('startup loop not found');
179
+ return src.replace(re, next);
180
+ }
181
+
182
+ function patchJobsList(src) {
183
+ const re = /if \(pathname === '\/api\/jobs' && req\.method === 'GET'\) \{\s*return sendJson\(res, 200, \{ jobs: jobs\.list\(\)\.map\(fillFromBrief\) \}\);\s*\}/;
184
+ const next = `if (pathname === '/api/jobs' && req.method === 'GET') {
185
+ const list = jobs.list().map((j) => {
186
+ const hit = chooseDeliverableFilm(j, cfg);
187
+ if (hit && (!j.outputMp4 || !fs.existsSync(j.outputMp4) || isIntermediateMp4(j.outputMp4) || hit.path !== j.outputMp4)) {
188
+ jobs.update(j.id, filmHitFields(hit));
189
+ return fillFromBrief(jobs.get(j.id) || j);
190
+ }
191
+ return fillFromBrief(j);
192
+ });
193
+ return sendJson(res, 200, { jobs: list });
194
+ }`;
195
+ if (!re.test(src)) throw new Error('jobs list route not found');
196
+ return src.replace(re, next);
197
+ }
198
+
199
+ function patchFilmRoute(src) {
200
+ const re = /if \(req\.method === 'GET' && \/\^\\\/api\\\/jobs\\\/\[\^\/\]\+\\\/film\$\/\.test\(pathname\)\) \{[\s\S]*?return serveLocalFile\(req, res, file\);\s*\}/;
201
+ const next = `if (req.method === 'GET' && /^\\/api\\/jobs\\/[^/]+\\/film$/.test(pathname)) {
202
+ const id = decodeURIComponent(pathname.slice('/api/jobs/'.length, -'/film'.length));
203
+ const job = jobs.get(id);
204
+ if (!job) return sendJson(res, 404, { error: 'job not found' });
205
+ let file = String(job.outputMp4 || '');
206
+ if (!file || !fs.existsSync(file) || isIntermediateMp4(file)) {
207
+ const hit = chooseDeliverableFilm(job, cfg);
208
+ if (hit) {
209
+ jobs.update(id, filmHitFields(hit));
210
+ file = hit.path;
211
+ }
212
+ }
213
+ if (!file || !file.toLowerCase().endsWith('.mp4') || !fs.existsSync(file)) {
214
+ return sendJson(res, 404, { error: '成片还没有' });
215
+ }
216
+ return serveLocalFile(req, res, file);
217
+ }`;
218
+ if (!re.test(src)) throw new Error('film route not found');
219
+ return src.replace(re, next);
220
+ }
221
+
222
+ for (const id of agents) {
223
+ const file = path.join(products, id, 'lib', 'host.mjs');
224
+ let src = fs.readFileSync(file, 'utf8');
225
+ src = ensureImport(src);
226
+ src = stripOldFilmFns(src);
227
+ src = patchWatch(src);
228
+ src = patchStartup(src);
229
+ src = patchJobsList(src);
230
+ src = patchFilmRoute(src);
231
+ fs.writeFileSync(file, src);
232
+ console.log('ok', id);
233
+ }