@biunow/agent-biutalk 1.1.7 → 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.
- package/_shared/.tmp-panel-smoke/art/smoke.mp4 +0 -0
- package/_shared/.tmp-panel-smoke/art-pipe/out/biuart-01_cave-mwq5kfpm.mp4 +0 -0
- package/_shared/.tmp-panel-smoke/art-pipe/panel-delivery.json +7 -0
- package/_shared/.tmp-panel-smoke/reel-pipe/film/index.html +7 -0
- package/_shared/.tmp-panel-smoke/reel-pipe/film/main.js +68 -0
- package/_shared/.tmp-panel-smoke/reel-pipe/film/panel-beats.json +20 -0
- package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/CREDITS +20 -0
- package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/build.sh +17 -0
- package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/ease.js +43 -0
- package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/events.json +1 -0
- package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/film.js +533 -0
- package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/fonts/OFL-Archivo.txt +93 -0
- package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/fonts/OFL-DMSerifDisplay.txt +93 -0
- package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/fonts/OFL-UnifrakturMaguntia.txt +94 -0
- package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/fonts/fonts.css +3 -0
- package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/index.html +6 -0
- package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/lines.json +10 -0
- package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/main.js +15 -0
- package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/mix.py +116 -0
- package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/music/score.py +168 -0
- package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/music/score_meta.json +59 -0
- package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/score.json +235 -0
- package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/stills/styleframe.jpg +0 -0
- package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/tools/fonts.sh +17 -0
- package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/tools/subs.py +11 -0
- package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/tools/words.py +20 -0
- package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/voices/dur.json +10 -0
- package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/voices/words.json +213 -0
- package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/voices/words_rel.json +56 -0
- package/_shared/.tmp-panel-smoke/reel-pipe/style-ref.json +5 -0
- package/_shared/.tmp-panel-smoke/reel-pipe2/film/index.html +7 -0
- package/_shared/.tmp-panel-smoke/reel-pipe2/film/main.js +68 -0
- package/_shared/.tmp-panel-smoke/reel-pipe2/film/panel-beats.json +20 -0
- package/_shared/.tmp-panel-smoke/reel-pipe2/out/video.mp4 +0 -0
- package/_shared/.tmp-panel-smoke/reel-pipe2/panel-delivery.json +8 -0
- package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/CREDITS +20 -0
- package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/build.sh +17 -0
- package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/ease.js +43 -0
- package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/events.json +1 -0
- package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/film.js +533 -0
- package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/fonts/OFL-Archivo.txt +93 -0
- package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/fonts/OFL-DMSerifDisplay.txt +93 -0
- package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/fonts/OFL-UnifrakturMaguntia.txt +94 -0
- package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/fonts/fonts.css +3 -0
- package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/index.html +6 -0
- package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/lines.json +10 -0
- package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/main.js +15 -0
- package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/mix.py +116 -0
- package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/music/score.py +168 -0
- package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/music/score_meta.json +59 -0
- package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/score.json +235 -0
- package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/stills/styleframe.jpg +0 -0
- package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/tools/fonts.sh +17 -0
- package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/tools/subs.py +11 -0
- package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/tools/words.py +20 -0
- package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/voices/dur.json +10 -0
- package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/voices/words.json +213 -0
- package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/voices/words_rel.json +56 -0
- package/_shared/.tmp-panel-smoke/reel-pipe2/style-ref.json +5 -0
- package/_shared/.tmp-panel-smoke/remo-pipe/brief.md +2 -0
- package/_shared/.tmp-panel-smoke/remo-pipe/remo-job.json +4 -0
- package/_shared/.tmp-panel-smoke/remo-pipe2/brief.md +1 -0
- package/_shared/.tmp-panel-smoke/remo-pipe2/out/final.mp4 +0 -0
- package/_shared/.tmp-panel-smoke/remo-pipe2/panel-delivery.json +8 -0
- package/_shared/.tmp-panel-smoke/remo-pipe2/remo-job.json +4 -0
- package/_shared/.tmp-panel-smoke/vibe-pipe-ok/ep00-demo.mp4 +0 -0
- package/_shared/.tmp-panel-smoke/vibe-pipe-ok/out/ep00-demo.mp4 +0 -0
- package/_shared/.tmp-panel-smoke/vibe-pipe-ok/panel-delivery.json +7 -0
- package/_shared/.tmp-panel-smoke/vibe-pipe-ok/publish.json +10 -0
- package/_shared/.tmp-panel-smoke/vibe-still.jpg +0 -0
- package/_shared/.tmp-panel-smoke/vibe-still.log +6 -0
- package/_shared/.tmp-panel-smoke/vibe-still.log.err +0 -0
- package/_shared/.tmp-panel-smoke/vibe-still2.log +26 -0
- package/_shared/.tmp-panel-smoke/vibe-still2.log.err +0 -0
- package/_shared/lib/film-locate.mjs +203 -0
- package/_shared/lib/voice-catalog.mjs +127 -0
- package/_shared/scripts/apply-upload-limits.mjs +62 -0
- package/_shared/scripts/patch-film-hosts.mjs +233 -0
- package/_shared/scripts/patch-voice-options.mjs +41 -0
- package/_shared/scripts/sync-local-agents.mjs +67 -0
- package/_shared/scripts/wire-film-bridge.mjs +24 -0
- package/_shared/scripts/wire-voice-plus.mjs +68 -0
- package/_shared/studio/assert-panel-permit.mjs +67 -0
- package/_shared/studio/composer.css +559 -0
- package/_shared/studio/composer.js +728 -0
- package/_shared/studio/optimize-prompt.mjs +84 -0
- package/_shared/studio/optimize-prompt.test.mjs +47 -0
- package/_shared/studio/recipes.mjs +87 -0
- package/_shared/studio/select-menu.js +450 -0
- package/_shared/studio/to-english-prompt.mjs +165 -0
- package/_shared/studio/to-english-prompt.test.mjs +72 -0
- package/bin/server.js +22 -22
- package/data/looks.json +8 -0
- package/lib/film-bridge.mjs +1 -0
- package/lib/host.mjs +131 -264
- package/lib/voice-bridge.mjs +2 -0
- package/manifest.json +4 -3
- package/package.json +1 -1
- package/skills/biutalk/EXEC.md +69 -0
- package/skills/biutalk/SKILL.md +12 -10
- package/skills/biutalk/scripts/doctor.mjs +124 -0
- package/skills/biutalk/scripts/qc.mjs +129 -0
- package/skills/biutalk/scripts/scaffold.mjs +205 -0
- package/studio/app.js +16 -1
- package/studio/composer.css +94 -0
- package/studio/composer.js +257 -9
- package/studio/index.html +5 -1
- package/studio/to-english-prompt.mjs +16 -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(/</g, '<')
|
|
76
|
+
.replace(/>/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 & 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,
|
|
@@ -14,6 +15,7 @@ import {
|
|
|
14
15
|
runCommand,
|
|
15
16
|
} from '../lib/host.mjs';
|
|
16
17
|
import { audienceLine, modelTitle, toEnglishPrompt } from '../studio/to-english-prompt.mjs';
|
|
18
|
+
import { normalizeVoicePick, voiceKickoffLine } from '../lib/voice-bridge.mjs';
|
|
17
19
|
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
18
20
|
const recipeFile = [
|
|
19
21
|
path.join(root, 'studio', 'recipes.mjs'),
|
|
@@ -34,14 +36,7 @@ function presentLook(look) {
|
|
|
34
36
|
};
|
|
35
37
|
}
|
|
36
38
|
|
|
37
|
-
const LOOKS =
|
|
38
|
-
{ id: 'paper', name: 'Paper', desc: '手绘友好,默认' },
|
|
39
|
-
{ id: 'clean', name: 'Clean', desc: '产品与商务' },
|
|
40
|
-
{ id: 'chalk', name: 'Chalk', desc: '教学黑板' },
|
|
41
|
-
{ id: 'blueprint', name: 'Blueprint', desc: '工程蓝图' },
|
|
42
|
-
{ id: 'midnight', name: 'Midnight', desc: '开发者工具' },
|
|
43
|
-
{ id: 'editorial', name: 'Editorial', desc: '评论/历史/财经' },
|
|
44
|
-
];
|
|
39
|
+
const LOOKS = JSON.parse(fs.readFileSync(path.join(root, 'data', 'looks.json'), 'utf8'));
|
|
45
40
|
|
|
46
41
|
// id 与 explainroo FORMATS 对齐;三档 9:16 分辨率相同但安全区不同(抖音/视频号/小红书)
|
|
47
42
|
const SIZES = [
|
|
@@ -150,6 +145,7 @@ createAgentServer({
|
|
|
150
145
|
}
|
|
151
146
|
const urls = Array.isArray(body.urls) ? body.urls.map(String).filter(Boolean).slice(0, 20) : [];
|
|
152
147
|
const pace = Math.min(1.6, Math.max(0.7, Number(body.pace) || 1));
|
|
148
|
+
const voicePick = normalizeVoicePick(body.voice);
|
|
153
149
|
let promptEn;
|
|
154
150
|
let titleEn = title;
|
|
155
151
|
try {
|
|
@@ -169,6 +165,7 @@ createAgentServer({
|
|
|
169
165
|
pace,
|
|
170
166
|
urls,
|
|
171
167
|
prompt,
|
|
168
|
+
...(voicePick ? { voice: voicePick } : {}),
|
|
172
169
|
status: 'running',
|
|
173
170
|
progress: 5,
|
|
174
171
|
message: '准备项目',
|
|
@@ -184,6 +181,7 @@ createAgentServer({
|
|
|
184
181
|
prompt: promptEn,
|
|
185
182
|
urls,
|
|
186
183
|
projectSlug,
|
|
184
|
+
...(voicePick ? { voice: voicePick } : {}),
|
|
187
185
|
createdAt: new Date().toISOString(),
|
|
188
186
|
};
|
|
189
187
|
writeJson(path.join(projectDir, 'brief.json'), brief);
|
|
@@ -217,8 +215,7 @@ createAgentServer({
|
|
|
217
215
|
void (async () => {
|
|
218
216
|
const bump = async (progress, message, extra = {}) => {
|
|
219
217
|
jobs.update(job.id, { progress, message, ...extra });
|
|
220
|
-
await
|
|
221
|
-
taskId: jobs.get(job.id)?.panelTaskId,
|
|
218
|
+
await reportJobProgress(cfg, jobs, job.id, {
|
|
222
219
|
title: `BiuTalk · ${title}`,
|
|
223
220
|
progress,
|
|
224
221
|
message,
|
|
@@ -258,11 +255,12 @@ createAgentServer({
|
|
|
258
255
|
'Follow the biutalk skill and finish the explainer film.',
|
|
259
256
|
`Project folder: ${projectPath}`,
|
|
260
257
|
`Read brief.json. Theme ${look}. Size ${size}. Pace ${pace}.`,
|
|
258
|
+
voiceKickoffLine(voicePick),
|
|
261
259
|
audienceLine(prompt),
|
|
262
260
|
`Creative brief: ${promptEn}`,
|
|
263
|
-
'
|
|
261
|
+
'Read skills/biutalk/EXEC.md and follow it: doctor → scaffold → script.md → scenes.js → voice → check → still/sheet → render --draft → render → verify.',
|
|
264
262
|
'When done, tell me the MP4 path.',
|
|
265
|
-
].join('\n');
|
|
263
|
+
].filter(Boolean).join('\n');
|
|
266
264
|
const kickoff = path.join(projectDir, 'START_IN_DSH.md');
|
|
267
265
|
fs.writeFileSync(
|
|
268
266
|
kickoff,
|
|
@@ -293,6 +291,9 @@ createAgentServer({
|
|
|
293
291
|
title: `BiuTalk · ${title}`,
|
|
294
292
|
});
|
|
295
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;
|
|
296
297
|
const sessionId = kick?.kickoff?.sessionId || kick?.sessionId || null;
|
|
297
298
|
const existingFilm = findLatestMp4(projectPath);
|
|
298
299
|
if (existingFilm) {
|
|
@@ -309,8 +310,7 @@ createAgentServer({
|
|
|
309
310
|
dshSessionId: sessionId,
|
|
310
311
|
kickoffOk: kicked,
|
|
311
312
|
});
|
|
312
|
-
await
|
|
313
|
-
taskId: jobs.get(job.id)?.panelTaskId,
|
|
313
|
+
await reportJobProgress(cfg, jobs, job.id, {
|
|
314
314
|
progress: 100,
|
|
315
315
|
message,
|
|
316
316
|
done: true,
|
|
@@ -318,22 +318,23 @@ createAgentServer({
|
|
|
318
318
|
});
|
|
319
319
|
} else {
|
|
320
320
|
const message = kicked
|
|
321
|
-
? '已接通 DSH · 创作中,成片将显示在此'
|
|
321
|
+
? inpanel ? '面板内跑 · 管线执行中,成片将显示在此' : '已接通 DSH · 创作中,成片将显示在此'
|
|
322
322
|
: '工程已就绪 · 自动开拍未成功,可打开 START_IN_DSH.md';
|
|
323
323
|
jobs.update(job.id, {
|
|
324
324
|
status: 'running',
|
|
325
|
-
progress: kicked ? 55 : 40,
|
|
326
|
-
phase: kicked ? 'dsh' : 'brief',
|
|
325
|
+
progress: kicked || inpanel ? 55 : 40,
|
|
326
|
+
phase: inpanel ? 'inpanel' : kicked ? 'dsh' : 'brief',
|
|
327
327
|
message,
|
|
328
328
|
artifact: projectPath,
|
|
329
329
|
projectPath,
|
|
330
330
|
kickoff,
|
|
331
331
|
dshSessionId: sessionId,
|
|
332
|
+
panelJobId,
|
|
332
333
|
kickoffOk: kicked,
|
|
334
|
+
mode: kickMode,
|
|
333
335
|
});
|
|
334
|
-
await
|
|
335
|
-
|
|
336
|
-
progress: kicked ? 55 : 40,
|
|
336
|
+
await reportJobProgress(cfg, jobs, job.id, {
|
|
337
|
+
progress: kicked || inpanel ? 55 : 40,
|
|
337
338
|
message,
|
|
338
339
|
artifact: projectPath,
|
|
339
340
|
});
|
|
@@ -345,8 +346,7 @@ createAgentServer({
|
|
|
345
346
|
} catch (error) {
|
|
346
347
|
const msg = error?.message || String(error);
|
|
347
348
|
jobs.update(job.id, { status: 'failed', message: msg, error: msg, progress: 100 });
|
|
348
|
-
await
|
|
349
|
-
taskId: jobs.get(job.id)?.panelTaskId,
|
|
349
|
+
await reportJobProgress(cfg, jobs, job.id, {
|
|
350
350
|
progress: 100,
|
|
351
351
|
failed: true,
|
|
352
352
|
error: msg,
|
package/data/looks.json
ADDED
|
@@ -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';
|