@biunow/agent-biutalk 1.1.6 → 1.1.8

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 (112) 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 +52 -36
  93. package/data/looks.json +8 -0
  94. package/lib/film-bridge.mjs +1 -0
  95. package/lib/host.mjs +149 -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 +17 -1
  105. package/studio/composer.css +115 -1
  106. package/studio/composer.js +389 -10
  107. package/studio/index.html +5 -1
  108. package/studio/optimize-prompt.mjs +84 -0
  109. package/studio/optimize-prompt.test.mjs +47 -0
  110. package/studio/recipes.mjs +1 -0
  111. package/studio/to-english-prompt.mjs +165 -0
  112. package/studio/to-english-prompt.test.mjs +72 -0
@@ -0,0 +1,165 @@
1
+ /** 把用户看到的中文提示词收成交给大模型的英文提示词。画风名保持原样,方便对上模板。 */
2
+
3
+ const REPLACEMENTS = [
4
+ [/there is no word of mouth/gi, 'no voiceover'],
5
+ [/no word of mouth/gi, 'no voiceover'],
6
+ [/word of mouth/gi, 'voiceover'],
7
+ [/no spoken words?/gi, 'no voiceover'],
8
+ [/without spoken words?/gi, 'no voiceover'],
9
+ [/no oral (?:broadcast|narration)/gi, 'no voiceover'],
10
+ [/without oral (?:broadcast|narration)/gi, 'with no voiceover'],
11
+ [/oral broadcast/gi, 'voiceover'],
12
+ [/there was no voiceover/gi, 'no voiceover'],
13
+ [/horizontal screen/gi, 'landscape frame'],
14
+ [/vertical screen/gi, 'portrait frame'],
15
+ ];
16
+
17
+ const SOURCE_FLAGS = [
18
+ [/没有口播|不要口播|无口播|没有旁白|不要旁白|无旁白|不依赖旁白|不要另起旁白|全程靠字幕/, 'No voiceover.'],
19
+ [/口播用你上传的录音|只用上传的录音/, 'Use the uploaded recording as the voiceover.'],
20
+ [/横屏/, 'Landscape frame.'],
21
+ [/竖屏/, 'Portrait frame.'],
22
+ [/中英字幕/, 'On-screen subtitles in Chinese and English.'],
23
+ [/必须的附件/, 'The required attachment is part of this film.'],
24
+ ];
25
+
26
+ export function filmLanguage(text) {
27
+ return /[\u4e00-\u9fff]/.test(String(text || '')) ? 'Chinese' : 'English';
28
+ }
29
+
30
+ export function audienceLine(text) {
31
+ const language = filmLanguage(text);
32
+ return `On-screen text and narration language: ${language}. Write the on-screen title and every spoken or written sentence in ${language}.`;
33
+ }
34
+
35
+ function enforceFlags(source, english) {
36
+ let out = polishEnglish(english);
37
+ for (const [pattern, sentence] of SOURCE_FLAGS) {
38
+ if (!pattern.test(source)) continue;
39
+ const key = sentence.replace(/\.$/, '').toLowerCase();
40
+ if (!out.toLowerCase().includes(key)) out = polishEnglish(`${out} ${sentence}`);
41
+ }
42
+ return out;
43
+ }
44
+
45
+ export async function modelTitle(title, source, englishBrief, fetchImpl = globalThis.fetch) {
46
+ const raw = String(title || '').trim();
47
+ const brief = String(englishBrief || '').trim();
48
+ if (raw && !/[\u4e00-\u9fff]/.test(raw)) return raw.slice(0, 120);
49
+ if ((!raw || String(source || '').trim().startsWith(raw)) && brief) {
50
+ const subject = brief.match(/Subject:\s*"([^"]+)"/);
51
+ if (subject && subject[1] && !/[\u4e00-\u9fff]/.test(subject[1])) return subject[1].replace(/[.。\s]+$/g, '').slice(0, 120);
52
+ const line = brief.replace(/^Use the [\s\S]+? style\.\s*/i, '').split('\n')[0].trim();
53
+ if (line && !/[\u4e00-\u9fff]/.test(line)) return line.slice(0, 120);
54
+ }
55
+ if (!raw) return 'Untitled';
56
+ const translated = await toEnglishPrompt(raw, fetchImpl);
57
+ return (translated || 'Untitled').slice(0, 120);
58
+ }
59
+
60
+ export function polishEnglish(text) {
61
+ let out = String(text || '');
62
+ for (const [pattern, to] of REPLACEMENTS) out = out.replace(pattern, to);
63
+ return out.replace(/[ \t]+/g, ' ').replace(/\s*\n\s*/g, '\n').trim();
64
+ }
65
+
66
+ export function parseMyMemory(payload) {
67
+ const data = typeof payload === 'string' ? JSON.parse(payload) : payload;
68
+ if (!data || Number(data.responseStatus) >= 400) return '';
69
+ const text = data.responseData && data.responseData.translatedText;
70
+ if (!text || /MYMEMORY WARNING|QUERY LENGTH LIMIT/i.test(text)) return '';
71
+ return String(text)
72
+ .replace(/"/g, '"')
73
+ .replace(/'|'/g, "'")
74
+ .replace(/&/g, '&')
75
+ .replace(/&lt;/g, '<')
76
+ .replace(/&gt;/g, '>')
77
+ .trim();
78
+ }
79
+
80
+ function chunks(text) {
81
+ const parts = String(text || '').split(/(?<=[。!?!?\n])/);
82
+ const out = [];
83
+ let buf = '';
84
+ const push = (value) => {
85
+ const piece = value.trim();
86
+ if (piece) out.push(piece);
87
+ };
88
+ for (const part of parts) {
89
+ const next = buf + part;
90
+ if (Buffer.byteLength(next, 'utf8') > 420 && buf) {
91
+ push(buf);
92
+ buf = part;
93
+ } else {
94
+ buf = next;
95
+ }
96
+ }
97
+ push(buf);
98
+ return out.flatMap((piece) => {
99
+ if (Buffer.byteLength(piece, 'utf8') <= 420) return [piece];
100
+ const chars = [...piece];
101
+ const slices = [];
102
+ let current = '';
103
+ for (const char of chars) {
104
+ if (Buffer.byteLength(current + char, 'utf8') > 420) {
105
+ slices.push(current);
106
+ current = char;
107
+ } else current += char;
108
+ }
109
+ if (current) slices.push(current);
110
+ return slices;
111
+ });
112
+ }
113
+
114
+ async function translatePiece(text, fetchImpl) {
115
+ const pieces = [];
116
+ for (const piece of chunks(text)) {
117
+ if (!/[\u4e00-\u9fff]/.test(piece)) {
118
+ pieces.push(piece);
119
+ continue;
120
+ }
121
+ const url = `https://api.mymemory.translated.net/get?q=${encodeURIComponent(piece)}&langpair=zh-CN|en`;
122
+ const res = await fetchImpl(url, { signal: AbortSignal.timeout(12000) });
123
+ if (!res.ok) throw new Error('英文提示词没有生成');
124
+ const english = polishEnglish(parseMyMemory(await res.json()));
125
+ if (!english || /[\u4e00-\u9fff]/.test(english)) throw new Error('英文提示词没有生成');
126
+ pieces.push(english);
127
+ }
128
+ const joined = polishEnglish(pieces.join(' '));
129
+ if (!joined) throw new Error('英文提示词没有生成');
130
+ return joined;
131
+ }
132
+
133
+ export async function toEnglishPrompt(text, fetchImpl = globalThis.fetch) {
134
+ const source = String(text || '').trim();
135
+ if (!source) return '';
136
+ if (!/[\u4e00-\u9fff]/.test(source)) return source;
137
+
138
+ // Prefer BN panel LLM settings when injected (PANEL_LLM_*).
139
+ // This file may live in products/_shared/studio or products/<agent>/studio.
140
+ try {
141
+ let panelTranslateToEnglish;
142
+ try {
143
+ ({ panelTranslateToEnglish } = await import('../lib/panel-llm.mjs'));
144
+ } catch {
145
+ ({ panelTranslateToEnglish } = await import('../../_shared/lib/panel-llm.mjs'));
146
+ }
147
+ const viaPanel = await panelTranslateToEnglish(source, fetchImpl);
148
+ if (viaPanel) return enforceFlags(source, polishEnglish(viaPanel));
149
+ } catch {
150
+ /* fall through to MyMemory */
151
+ }
152
+
153
+ const framed = source.match(/^用([\s\S]{1,40}?)讲「([^」]+)」\s*[。.]?\s*([\s\S]*)$/);
154
+ if (framed) {
155
+ const topicEn = (await translatePiece(framed[2], fetchImpl)).replace(/[.。\s]+$/g, '');
156
+ const tailEn = framed[3].trim() ? await translatePiece(framed[3], fetchImpl) : '';
157
+ return enforceFlags(source, `Use the ${framed[1].trim()} style. Subject: "${topicEn}".${tailEn ? ` ${tailEn}` : ''}`);
158
+ }
159
+ const ref = source.match(/^选\s*(ref\d+)\s*[。.]?\s*([\s\S]*)$/i);
160
+ if (ref) {
161
+ const body = ref[2].trim() ? await translatePiece(ref[2], fetchImpl) : '';
162
+ return enforceFlags(source, `Lock ${ref[1]}. ${body}`);
163
+ }
164
+ return enforceFlags(source, await translatePiece(source, fetchImpl));
165
+ }
@@ -0,0 +1,72 @@
1
+ import assert from 'node:assert/strict';
2
+ import test from 'node:test';
3
+ import { audienceLine, filmLanguage, modelTitle, parseMyMemory, polishEnglish, toEnglishPrompt } from './to-english-prompt.mjs';
4
+
5
+ test('已经是英文时不请求翻译', async () => {
6
+ let called = false;
7
+ const got = await toEnglishPrompt('Keep the sentences short.', async () => {
8
+ called = true;
9
+ return { ok: true, json: async () => ({}) };
10
+ });
11
+ assert.equal(got, 'Keep the sentences short.');
12
+ assert.equal(called, false);
13
+ });
14
+
15
+ test('模板句保留画风名,主题和后半句译成英文', async () => {
16
+ const fetchImpl = async (url) => {
17
+ const q = decodeURIComponent(url.split('q=')[1].split('&')[0]);
18
+ const translated = q.includes('古代人')
19
+ ? 'why everyone in antiquity wanted to be emperor'
20
+ : 'State the conclusion first in the firelight, then one memorable detail. No oral broadcast.';
21
+ return { ok: true, json: async () => ({ responseStatus: 200, responseData: { translatedText: translated } }) };
22
+ };
23
+ const got = await toEnglishPrompt(
24
+ '用灯火史话讲「古代人都想当皇帝」。火光里先给结论,再给一个能记住的细节,没有口播。',
25
+ fetchImpl,
26
+ );
27
+ assert.equal(got.includes('灯火史话'), true);
28
+ assert.equal(got.includes('why everyone in antiquity wanted to be emperor'), true);
29
+ assert.equal(got.includes('no voiceover'), true);
30
+ assert.equal(/[\u4e00-\u9fff]/.test(got.replace('灯火史话', '')), false);
31
+ });
32
+
33
+ test('口播被收成 voiceover', () => {
34
+ assert.equal(polishEnglish('There was no oral broadcast.'), 'no voiceover.');
35
+ assert.equal(polishEnglish('There is no word of mouth.'), 'no voiceover.');
36
+ });
37
+
38
+ test('原文里的没有口播,译文漏掉时也会补上', async () => {
39
+ const fetchImpl = async () => ({
40
+ ok: true,
41
+ json: async () => ({ responseStatus: 200, responseData: { translatedText: 'A short film about bees.' } }),
42
+ });
43
+ const got = await toEnglishPrompt('讲蜜蜂。没有口播。', fetchImpl);
44
+ assert.equal(got.includes('No voiceover.'), true);
45
+ });
46
+
47
+ test('片名从英文主题来,不再把中文原句交给模型', async () => {
48
+ let called = false;
49
+ const source = '用灯火史话讲「古代人都想当皇帝」。没有口播。';
50
+ const title = await modelTitle(
51
+ source.slice(0, 40),
52
+ source,
53
+ 'Use the 灯火史话 style. Subject: "why everyone wanted to be emperor". No voiceover.',
54
+ async () => {
55
+ called = true;
56
+ return { ok: true, json: async () => ({}) };
57
+ },
58
+ );
59
+ assert.equal(title, 'why everyone wanted to be emperor');
60
+ assert.equal(called, false);
61
+ });
62
+
63
+ test('解析翻译结果', () => {
64
+ assert.equal(parseMyMemory({ responseStatus: 200, responseData: { translatedText: 'Hello &amp; welcome' } }), 'Hello & welcome');
65
+ assert.equal(parseMyMemory({ responseStatus: 200, responseData: { translatedText: 'MYMEMORY WARNING: too long' } }), '');
66
+ });
67
+
68
+ test('成片语言跟着用户原文', () => {
69
+ assert.equal(filmLanguage('古代人都想当皇帝'), 'Chinese');
70
+ assert.equal(filmLanguage('airplane mode'), 'English');
71
+ assert.equal(audienceLine('古代人').includes('in Chinese'), true);
72
+ });
package/bin/server.js CHANGED
@@ -6,6 +6,7 @@ import {
6
6
  ensureDir,
7
7
  writeJson,
8
8
  reportProgress,
9
+ reportJobProgress,
9
10
  requestKickoff,
10
11
  requestRunPermit,
11
12
  seedSkillIntoProject,
@@ -13,6 +14,8 @@ import {
13
14
  findLatestMp4,
14
15
  runCommand,
15
16
  } from '../lib/host.mjs';
17
+ import { audienceLine, modelTitle, toEnglishPrompt } from '../studio/to-english-prompt.mjs';
18
+ import { normalizeVoicePick, voiceKickoffLine } from '../lib/voice-bridge.mjs';
16
19
  const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
17
20
  const recipeFile = [
18
21
  path.join(root, 'studio', 'recipes.mjs'),
@@ -33,14 +36,7 @@ function presentLook(look) {
33
36
  };
34
37
  }
35
38
 
36
- const LOOKS = [
37
- { id: 'paper', name: 'Paper', desc: '手绘友好,默认' },
38
- { id: 'clean', name: 'Clean', desc: '产品与商务' },
39
- { id: 'chalk', name: 'Chalk', desc: '教学黑板' },
40
- { id: 'blueprint', name: 'Blueprint', desc: '工程蓝图' },
41
- { id: 'midnight', name: 'Midnight', desc: '开发者工具' },
42
- { id: 'editorial', name: 'Editorial', desc: '评论/历史/财经' },
43
- ];
39
+ const LOOKS = JSON.parse(fs.readFileSync(path.join(root, 'data', 'looks.json'), 'utf8'));
44
40
 
45
41
  // id 与 explainroo FORMATS 对齐;三档 9:16 分辨率相同但安全区不同(抖音/视频号/小红书)
46
42
  const SIZES = [
@@ -69,19 +65,24 @@ function detectLanguage(text) {
69
65
  return /[\u4e00-\u9fff]/.test(String(text || '')) ? 'zh' : 'en';
70
66
  }
71
67
 
68
+ function spokenSeed(prompt, title) {
69
+ const text = String(prompt || '').trim();
70
+ const quoted = text.match(/「([^」]+)」/);
71
+ return String((quoted && quoted[1]) || text || title).replace(/\s+/g, ' ').trim().slice(0, 280);
72
+ }
73
+
72
74
  function writeStarterScript(videoPath, title, prompt, lang) {
73
- const brief = String(prompt || title).replace(/\s+/g, ' ').trim().slice(0, 280);
75
+ const spoken = spokenSeed(prompt, title);
74
76
  const zh = lang === 'zh';
75
77
  fs.writeFileSync(
76
78
  path.join(videoPath, 'script.md'),
77
79
  [
78
80
  `# ${title}`,
79
81
  '',
80
- zh ? '> BiuTalk 自动草稿,可在 Studio 继续改 script.md / scenes.js。' : '> BiuTalk draft — edit script.md / scenes.js to refine.',
81
- brief ? (zh ? `> 需求:${brief}` : `> Brief: ${brief}`) : '',
82
+ '> Spoken draft. Creative direction is in brief.json, not in this file.',
82
83
  '',
83
84
  '## hook',
84
- brief || (zh ? `今天讲一讲:${title}` : `Today we cover: ${title}`),
85
+ spoken || (zh ? `今天讲一讲:${title}` : `Today we cover: ${title}`),
85
86
  '',
86
87
  '## steps',
87
88
  zh
@@ -144,6 +145,16 @@ createAgentServer({
144
145
  }
145
146
  const urls = Array.isArray(body.urls) ? body.urls.map(String).filter(Boolean).slice(0, 20) : [];
146
147
  const pace = Math.min(1.6, Math.max(0.7, Number(body.pace) || 1));
148
+ const voicePick = normalizeVoicePick(body.voice);
149
+ let promptEn;
150
+ let titleEn = title;
151
+ try {
152
+ promptEn = await toEnglishPrompt(prompt);
153
+ titleEn = await modelTitle(title, prompt, promptEn);
154
+ } catch {
155
+ sendJson(res, 503, { error: '英文提示词没有生成,请再试一次' });
156
+ return true;
157
+ }
147
158
  const projectSlug = `${slugify(title)}-${Date.now().toString(36)}`;
148
159
 
149
160
  const job = jobs.create({
@@ -154,6 +165,7 @@ createAgentServer({
154
165
  pace,
155
166
  urls,
156
167
  prompt,
168
+ ...(voicePick ? { voice: voicePick } : {}),
157
169
  status: 'running',
158
170
  progress: 5,
159
171
  message: '准备项目',
@@ -162,19 +174,20 @@ createAgentServer({
162
174
  const projectDir = ensureDir(path.join(cfg.workspace, 'projects', job.id));
163
175
  const brief = {
164
176
  agent: 'biutalk',
165
- title,
177
+ title: titleEn,
166
178
  look,
167
179
  size,
168
180
  pace,
169
- prompt,
181
+ prompt: promptEn,
170
182
  urls,
171
183
  projectSlug,
184
+ ...(voicePick ? { voice: voicePick } : {}),
172
185
  createdAt: new Date().toISOString(),
173
186
  };
174
187
  writeJson(path.join(projectDir, 'brief.json'), brief);
175
188
  fs.writeFileSync(
176
189
  path.join(projectDir, 'PROMPT.md'),
177
- `# ${title}\n\n## 需求\n\n${prompt}\n\n## 参数\n\n- look: ${look}\n- size: ${size}\n- pace: ${pace}\n\n## 参考链接\n\n${urls.map((u) => `- ${u}`).join('\n') || '(无)'}\n`,
190
+ `# ${titleEn}\n\n## Creative brief\n\n${promptEn}\n\n## Settings\n\n- look: ${look}\n- size: ${size}\n- pace: ${pace}\n\n## Links\n\n${urls.map((u) => `- ${u}`).join('\n') || '(none)'}\n`,
178
191
  );
179
192
 
180
193
  const uploads = await saveUploads(cfg.workspace, job.id, body.files);
@@ -202,8 +215,7 @@ createAgentServer({
202
215
  void (async () => {
203
216
  const bump = async (progress, message, extra = {}) => {
204
217
  jobs.update(job.id, { progress, message, ...extra });
205
- await reportProgress(cfg, {
206
- taskId: jobs.get(job.id)?.panelTaskId,
218
+ await reportJobProgress(cfg, jobs, job.id, {
207
219
  title: `BiuTalk · ${title}`,
208
220
  progress,
209
221
  message,
@@ -240,20 +252,22 @@ createAgentServer({
240
252
  }
241
253
 
242
254
  const kickoffPrompt = [
243
- '按 biutalk skill 创作解说视频直到成片。',
244
- `项目目录:${projectPath}`,
245
- `阅读 brief.json;主题 ${look};尺寸 ${size};节奏 ${pace};语言 ${lang}。`,
246
- `需求:${prompt}`,
247
- '严格按 explainroo AGENTS.md:写好 script.md 与 scenes.js,再 voice → check → render。',
248
- '完成后告诉我 MP4 路径。',
249
- ].join('\n');
255
+ 'Follow the biutalk skill and finish the explainer film.',
256
+ `Project folder: ${projectPath}`,
257
+ `Read brief.json. Theme ${look}. Size ${size}. Pace ${pace}.`,
258
+ voiceKickoffLine(voicePick),
259
+ audienceLine(prompt),
260
+ `Creative brief: ${promptEn}`,
261
+ 'Read skills/biutalk/EXEC.md and follow it: doctor → scaffold → script.md → scenes.js → voice → check → still/sheet → render --draft → render → verify.',
262
+ 'When done, tell me the MP4 path.',
263
+ ].filter(Boolean).join('\n');
250
264
  const kickoff = path.join(projectDir, 'START_IN_DSH.md');
251
265
  fs.writeFileSync(
252
266
  kickoff,
253
267
  [
254
- '# 在 DSH 中继续(与直接导入 Agent 相同)',
268
+ '# Continue in DSH',
255
269
  '',
256
- '面板会自动在 DSH 对话中启用 **biutalk** skill 并发送下列需求;若未自动开拍,请手动粘贴:',
270
+ 'The panel enables the **biutalk** skill and sends the brief below. Paste it if shooting did not start:',
257
271
  '',
258
272
  '```',
259
273
  kickoffPrompt,
@@ -277,6 +291,9 @@ createAgentServer({
277
291
  title: `BiuTalk · ${title}`,
278
292
  });
279
293
  const kicked = !!(kick?.ok || kick?.kickoff?.ok);
294
+ const kickMode = kick?.kickoff?.mode || kick?.mode || 'dsh';
295
+ const inpanel = kickMode === 'inpanel' || kick?.kickoff?.reason === 'inpanel-preferred';
296
+ const panelJobId = kick?.kickoff?.jobId || kick?.jobId || null;
280
297
  const sessionId = kick?.kickoff?.sessionId || kick?.sessionId || null;
281
298
  const existingFilm = findLatestMp4(projectPath);
282
299
  if (existingFilm) {
@@ -293,8 +310,7 @@ createAgentServer({
293
310
  dshSessionId: sessionId,
294
311
  kickoffOk: kicked,
295
312
  });
296
- await reportProgress(cfg, {
297
- taskId: jobs.get(job.id)?.panelTaskId,
313
+ await reportJobProgress(cfg, jobs, job.id, {
298
314
  progress: 100,
299
315
  message,
300
316
  done: true,
@@ -302,22 +318,23 @@ createAgentServer({
302
318
  });
303
319
  } else {
304
320
  const message = kicked
305
- ? '已接通 DSH · 创作中,成片将显示在此'
321
+ ? inpanel ? '面板内跑 · 管线执行中,成片将显示在此' : '已接通 DSH · 创作中,成片将显示在此'
306
322
  : '工程已就绪 · 自动开拍未成功,可打开 START_IN_DSH.md';
307
323
  jobs.update(job.id, {
308
324
  status: 'running',
309
- progress: kicked ? 55 : 40,
310
- phase: kicked ? 'dsh' : 'brief',
325
+ progress: kicked || inpanel ? 55 : 40,
326
+ phase: inpanel ? 'inpanel' : kicked ? 'dsh' : 'brief',
311
327
  message,
312
328
  artifact: projectPath,
313
329
  projectPath,
314
330
  kickoff,
315
331
  dshSessionId: sessionId,
332
+ panelJobId,
316
333
  kickoffOk: kicked,
334
+ mode: kickMode,
317
335
  });
318
- await reportProgress(cfg, {
319
- taskId: jobs.get(job.id)?.panelTaskId,
320
- progress: kicked ? 55 : 40,
336
+ await reportJobProgress(cfg, jobs, job.id, {
337
+ progress: kicked || inpanel ? 55 : 40,
321
338
  message,
322
339
  artifact: projectPath,
323
340
  });
@@ -329,8 +346,7 @@ createAgentServer({
329
346
  } catch (error) {
330
347
  const msg = error?.message || String(error);
331
348
  jobs.update(job.id, { status: 'failed', message: msg, error: msg, progress: 100 });
332
- await reportProgress(cfg, {
333
- taskId: jobs.get(job.id)?.panelTaskId,
349
+ await reportJobProgress(cfg, jobs, job.id, {
334
350
  progress: 100,
335
351
  failed: true,
336
352
  error: msg,
@@ -0,0 +1,8 @@
1
+ [
2
+ { "id": "paper", "name": "Paper", "desc": "手绘友好,默认" },
3
+ { "id": "clean", "name": "Clean", "desc": "产品与商务" },
4
+ { "id": "chalk", "name": "Chalk", "desc": "教学黑板" },
5
+ { "id": "blueprint", "name": "Blueprint", "desc": "工程蓝图" },
6
+ { "id": "midnight", "name": "Midnight", "desc": "开发者工具" },
7
+ { "id": "editorial", "name": "Editorial", "desc": "评论/历史/财经" }
8
+ ]
@@ -0,0 +1 @@
1
+ export * from '../_shared/lib/film-locate.mjs';