@biunow/agent-biutalk 2.0.0 → 2.0.2

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 (93) hide show
  1. package/_shared/lib/panel-llm.mjs +82 -0
  2. package/_shared/lib/panel-settings.mjs +16 -0
  3. package/_shared/scripts/.logs/2026-11-27T15-12-16-216Z.log +401 -0
  4. package/_shared/scripts/run-quiet.mjs +66 -0
  5. package/_shared/scripts/stage.mjs +105 -0
  6. package/_shared/studio/composer.css +55 -45
  7. package/_shared/studio/composer.js +198 -103
  8. package/bin/server.js +59 -6
  9. package/manifest.json +3 -3
  10. package/package.json +1 -1
  11. package/skills/biutalk/EXEC.md +29 -6
  12. package/skills/biutalk/SKILL.md +4 -0
  13. package/skills/biutalk/scripts/run-quiet.mjs +66 -0
  14. package/skills/biutalk/scripts/stage.mjs +105 -0
  15. package/skills/biutalk/scripts/stages.json +31 -0
  16. package/studio/app.js +45 -11
  17. package/studio/composer.css +55 -45
  18. package/studio/composer.js +198 -103
  19. package/studio/index.html +4 -4
  20. package/_shared/.tmp-panel-smoke/art/smoke.mp4 +0 -0
  21. package/_shared/.tmp-panel-smoke/art-pipe/out/biuart-01_cave-mwq5kfpm.mp4 +0 -0
  22. package/_shared/.tmp-panel-smoke/art-pipe/panel-delivery.json +0 -7
  23. package/_shared/.tmp-panel-smoke/reel-pipe/film/index.html +0 -7
  24. package/_shared/.tmp-panel-smoke/reel-pipe/film/main.js +0 -68
  25. package/_shared/.tmp-panel-smoke/reel-pipe/film/panel-beats.json +0 -20
  26. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/CREDITS +0 -20
  27. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/build.sh +0 -17
  28. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/ease.js +0 -43
  29. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/events.json +0 -1
  30. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/film.js +0 -533
  31. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/fonts/OFL-Archivo.txt +0 -93
  32. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/fonts/OFL-DMSerifDisplay.txt +0 -93
  33. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/fonts/OFL-UnifrakturMaguntia.txt +0 -94
  34. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/fonts/fonts.css +0 -3
  35. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/index.html +0 -6
  36. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/lines.json +0 -10
  37. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/main.js +0 -15
  38. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/mix.py +0 -116
  39. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/music/score.py +0 -168
  40. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/music/score_meta.json +0 -59
  41. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/score.json +0 -235
  42. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/stills/styleframe.jpg +0 -0
  43. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/tools/fonts.sh +0 -17
  44. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/tools/subs.py +0 -11
  45. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/tools/words.py +0 -20
  46. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/voices/dur.json +0 -10
  47. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/voices/words.json +0 -213
  48. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/voices/words_rel.json +0 -56
  49. package/_shared/.tmp-panel-smoke/reel-pipe/style-ref.json +0 -5
  50. package/_shared/.tmp-panel-smoke/reel-pipe2/film/index.html +0 -7
  51. package/_shared/.tmp-panel-smoke/reel-pipe2/film/main.js +0 -68
  52. package/_shared/.tmp-panel-smoke/reel-pipe2/film/panel-beats.json +0 -20
  53. package/_shared/.tmp-panel-smoke/reel-pipe2/out/video.mp4 +0 -0
  54. package/_shared/.tmp-panel-smoke/reel-pipe2/panel-delivery.json +0 -8
  55. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/CREDITS +0 -20
  56. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/build.sh +0 -17
  57. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/ease.js +0 -43
  58. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/events.json +0 -1
  59. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/film.js +0 -533
  60. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/fonts/OFL-Archivo.txt +0 -93
  61. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/fonts/OFL-DMSerifDisplay.txt +0 -93
  62. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/fonts/OFL-UnifrakturMaguntia.txt +0 -94
  63. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/fonts/fonts.css +0 -3
  64. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/index.html +0 -6
  65. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/lines.json +0 -10
  66. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/main.js +0 -15
  67. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/mix.py +0 -116
  68. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/music/score.py +0 -168
  69. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/music/score_meta.json +0 -59
  70. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/score.json +0 -235
  71. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/stills/styleframe.jpg +0 -0
  72. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/tools/fonts.sh +0 -17
  73. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/tools/subs.py +0 -11
  74. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/tools/words.py +0 -20
  75. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/voices/dur.json +0 -10
  76. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/voices/words.json +0 -213
  77. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/voices/words_rel.json +0 -56
  78. package/_shared/.tmp-panel-smoke/reel-pipe2/style-ref.json +0 -5
  79. package/_shared/.tmp-panel-smoke/remo-pipe/brief.md +0 -2
  80. package/_shared/.tmp-panel-smoke/remo-pipe/remo-job.json +0 -4
  81. package/_shared/.tmp-panel-smoke/remo-pipe2/brief.md +0 -1
  82. package/_shared/.tmp-panel-smoke/remo-pipe2/out/final.mp4 +0 -0
  83. package/_shared/.tmp-panel-smoke/remo-pipe2/panel-delivery.json +0 -8
  84. package/_shared/.tmp-panel-smoke/remo-pipe2/remo-job.json +0 -4
  85. package/_shared/.tmp-panel-smoke/vibe-pipe-ok/ep00-demo.mp4 +0 -0
  86. package/_shared/.tmp-panel-smoke/vibe-pipe-ok/out/ep00-demo.mp4 +0 -0
  87. package/_shared/.tmp-panel-smoke/vibe-pipe-ok/panel-delivery.json +0 -7
  88. package/_shared/.tmp-panel-smoke/vibe-pipe-ok/publish.json +0 -10
  89. package/_shared/.tmp-panel-smoke/vibe-still.jpg +0 -0
  90. package/_shared/.tmp-panel-smoke/vibe-still.log +0 -6
  91. package/_shared/.tmp-panel-smoke/vibe-still.log.err +0 -0
  92. package/_shared/.tmp-panel-smoke/vibe-still2.log +0 -26
  93. package/_shared/.tmp-panel-smoke/vibe-still2.log.err +0 -0
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * 一步到底的闸门聚合器:把 EXEC 里"要连着敲 3–6 条命令"的阶段压成一条。
4
+ *
5
+ * node stage.mjs pre --project . --engine "$ENGINE" [--ep <EP>]
6
+ * node stage.mjs post --project . --video out/final.mp4 [--ep <EP>] [--job job.json]
7
+ *
8
+ * 为什么:每次工具调用都会把整段上下文重发一遍,模型侧的 token 大致按「轮数²」涨。
9
+ * 把 5 条命令并成 1 条,等于把这一阶段的轮数从 5 降到 1;子命令输出也只回摘要。
10
+ *
11
+ * 配置在同目录 stages.json;`{engine}` `{project}` `{ep}` `{video}` `{job}` 会被替换。
12
+ * 输出固定 ≤8 行:一条总判定 + 每个失败项一行 `code hint`。
13
+ */
14
+ import fs from 'node:fs';
15
+ import path from 'node:path';
16
+ import { spawn } from 'node:child_process';
17
+ import { fileURLToPath } from 'node:url';
18
+
19
+ const here = path.dirname(fileURLToPath(import.meta.url));
20
+ const argv = process.argv.slice(2);
21
+ const stageName = argv.find((a) => !a.startsWith('--')) || '';
22
+ const opt = (name, fallback = '') => {
23
+ const i = argv.indexOf(name);
24
+ return i >= 0 && argv[i + 1] && !argv[i + 1].startsWith('--') ? argv[i + 1] : fallback;
25
+ };
26
+
27
+ const project = path.resolve(opt('--project', process.cwd()));
28
+ const engine = opt('--engine', process.env.ENGINE_ROOT || '');
29
+ const ep = opt('--ep', '');
30
+ const video = opt('--video', '');
31
+ const job = opt('--job', '');
32
+
33
+ if (!stageName) {
34
+ console.error('usage: node stage.mjs <stage> [--project .] [--engine DIR] [--ep ID] [--video FILE] [--job FILE]');
35
+ process.exit(2);
36
+ }
37
+
38
+ const cfgFile = path.join(here, 'stages.json');
39
+ if (!fs.existsSync(cfgFile)) {
40
+ console.error(`missing ${cfgFile}`);
41
+ process.exit(2);
42
+ }
43
+ const cfg = JSON.parse(fs.readFileSync(cfgFile, 'utf8').replace(/^\uFEFF/, ''));
44
+ const steps = cfg.stages?.[stageName];
45
+ if (!Array.isArray(steps) || !steps.length) {
46
+ console.error(`unknown stage "${stageName}"; have: ${Object.keys(cfg.stages || {}).join(', ')}`);
47
+ process.exit(2);
48
+ }
49
+
50
+ const vars = { engine, project, ep, video, job, skill: here };
51
+ const fill = (value) => String(value).replace(/\{(\w+)\}/g, (m, key) => (vars[key] ?? m));
52
+
53
+ function run(step) {
54
+ const [label, cmd, ...rest] = step;
55
+ const args = rest.map(fill);
56
+ return new Promise((resolve) => {
57
+ const child = spawn(cmd, args, { cwd: project, stdio: ['ignore', 'pipe', 'pipe'], windowsHide: true });
58
+ let out = '';
59
+ let err = '';
60
+ child.stdout.on('data', (c) => { out += c.toString(); });
61
+ child.stderr.on('data', (c) => { err += c.toString(); });
62
+ child.once('error', (e) => resolve({ label, code: 127, out: '', err: e.message }));
63
+ child.once('close', (code) => resolve({ label, code: code ?? 1, out, err }));
64
+ });
65
+ }
66
+
67
+ /** 从任意子命令输出里抠失败提示:优先 hint/detail 字段,退化到错误行。 */
68
+ function digest(text) {
69
+ const hints = [];
70
+ for (const m of text.matchAll(/"(?:hint|detail)"\s*:\s*"((?:[^"\\]|\\.)*)"/g)) {
71
+ const value = m[1].replace(/\\"/g, '"').replace(/\\\\/g, '\\');
72
+ if (value && value.length < 300) hints.push(value);
73
+ if (hints.length >= 5) break;
74
+ }
75
+ const okFlag = /"ok"\s*:\s*true/.test(text);
76
+ return { ok: okFlag, hints };
77
+ }
78
+
79
+ const started = Date.now();
80
+ const lines = [];
81
+ let failed = false;
82
+
83
+ for (const step of steps) {
84
+ if (failed) break;
85
+ const result = await run(step);
86
+ const combined = `${result.out}${result.err}`;
87
+ const info = digest(result.out) || digest(combined);
88
+ const ok = info.ok && result.code === 0;
89
+ if (!ok) {
90
+ failed = true;
91
+ if (info.hints.length) {
92
+ for (const hint of info.hints.slice(0, 4)) lines.push(`${result.label}: ${hint}`);
93
+ } else {
94
+ const tail = combined.split(/\r?\n/).filter(Boolean).slice(-3);
95
+ lines.push(`${result.label} exit=${result.code}`);
96
+ for (const t of tail) lines.push(` ${t.slice(0, 200)}`);
97
+ }
98
+ }
99
+ }
100
+
101
+ const seconds = ((Date.now() - started) / 1000).toFixed(1);
102
+ const head = failed ? `[stage] ${stageName} FAIL ${seconds}s` : `[stage] ${stageName} ok ${seconds}s (${steps.length} 步)`;
103
+ console.log(head);
104
+ for (const line of lines) console.log(` ${line}`);
105
+ process.exit(failed ? 1 : 0);
@@ -112,26 +112,26 @@ button:disabled { cursor: not-allowed; opacity: .5; }
112
112
  width: 100%; min-height: 190px; border: 0; resize: vertical; outline: 0;
113
113
  padding: 18px 22px 8px; font-size: 15px; line-height: 1.7; background: transparent; color: var(--ink);
114
114
  }
115
- .composer textarea::placeholder { color: #a3a39f; }
116
-
117
- .prompt-stage { position: relative; }
118
- .prompt-stage textarea { padding-bottom: 48px; }
119
- .optimize {
120
- position: absolute; right: 14px; bottom: 12px; z-index: 2;
121
- border: 1px solid var(--line-strong); background: #fff; color: var(--ink);
122
- border-radius: 999px; padding: 6px 12px; font-size: 12px; font-weight: 650;
123
- box-shadow: 0 1px 2px rgb(0 0 0 / 6%);
124
- }
125
- .optimize:hover { background: var(--accent-soft); border-color: var(--accent-deep); }
126
- .optimize.is-locked { opacity: .55; }
127
- .optimize.is-locked:hover { background: #fff; border-color: var(--line-strong); }
128
- .optimize-tip {
129
- position: absolute; right: 14px; bottom: 48px; z-index: 3;
130
- background: #111; color: #fff; border-radius: 10px; padding: 8px 10px;
131
- font-size: 12px; line-height: 1.4; white-space: nowrap;
132
- box-shadow: 0 8px 24px rgb(0 0 0 / 18%);
133
- }
134
- .optimize-tip[hidden] { display: none !important; }
115
+ .composer textarea::placeholder { color: #a3a39f; }
116
+
117
+ .prompt-stage { position: relative; }
118
+ .prompt-stage textarea { padding-bottom: 48px; }
119
+ .optimize {
120
+ position: absolute; right: 14px; bottom: 12px; z-index: 2;
121
+ border: 1px solid var(--line-strong); background: #fff; color: var(--ink);
122
+ border-radius: 999px; padding: 6px 12px; font-size: 12px; font-weight: 650;
123
+ box-shadow: 0 1px 2px rgb(0 0 0 / 6%);
124
+ }
125
+ .optimize:hover { background: var(--accent-soft); border-color: var(--accent-deep); }
126
+ .optimize.is-locked { opacity: .55; }
127
+ .optimize.is-locked:hover { background: #fff; border-color: var(--line-strong); }
128
+ .optimize-tip {
129
+ position: absolute; right: 14px; bottom: 48px; z-index: 3;
130
+ background: #111; color: #fff; border-radius: 10px; padding: 8px 10px;
131
+ font-size: 12px; line-height: 1.4; white-space: nowrap;
132
+ box-shadow: 0 8px 24px rgb(0 0 0 / 18%);
133
+ }
134
+ .optimize-tip[hidden] { display: none !important; }
135
135
 
136
136
  .composer-foot {
137
137
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
@@ -392,6 +392,16 @@ button:disabled { cursor: not-allowed; opacity: .5; }
392
392
  .bd-viewer[hidden] { display: none; }
393
393
  .bd-viewer img { max-width: 100%; max-height: 100%; border-radius: 8px; }
394
394
  .asset.ref { background: var(--accent-soft); border-color: var(--accent-deep); }
395
+ /* 附件角色:+ 弹窗的二级菜单(参考素材 / 口播录音 / 配乐 / 文稿)与素材角色标签 */
396
+ .role-menu { position: fixed; width: 260px; z-index: 40; bottom: auto; }
397
+ .role-menu > button .plus-ico { width: 22px; height: 22px; font-size: 12px; border-radius: 7px; }
398
+ .asset .role-tag {
399
+ font-size: 10px; color: var(--muted-2); border: 1px solid var(--line);
400
+ border-radius: 99px; padding: 0 5px; margin-left: 2px;
401
+ }
402
+ .asset.voice { background: #e8f2ff; }
403
+ .asset.music { background: #f1ecff; }
404
+ .asset.doc { background: #f3f1e8; }
395
405
  button.job-play {
396
406
  appearance: none; border: 0; background: none; font: inherit; color: inherit;
397
407
  cursor: pointer; padding: 0; text-align: left; width: 100%;
@@ -531,29 +541,29 @@ button.job-play {
531
541
  .sm-entry-err { flex: 1 0 100%; margin: 0; font-size: 11px; line-height: 1.3; color: var(--danger); }
532
542
 
533
543
  .file-hidden { position: absolute; width: 0; height: 0; opacity: 0; pointer-events: none; }
534
-
535
- .job-detail-card { width: min(520px, 100%); background: #fff; color: var(--ink); }
536
- .job-detail-card .film-modal-bar { color: var(--ink); border-bottom: 1px solid var(--line); }
537
- .job-detail-card .film-modal-x { color: var(--ink-soft); }
538
- .job-detail-body { padding: 14px 16px 18px; display: grid; gap: 10px; }
539
- .job-detail-body .jd-msg { font-size: 13px; line-height: 1.5; white-space: pre-wrap; }
540
- .job-detail-body .jd-meta { font-size: 11px; white-space: pre-wrap; word-break: break-all; }
541
- .job-detail-body .jd-follow { display: grid; gap: 8px; padding-top: 4px; border-top: 1px dashed var(--line); }
542
- .job-detail-body .jd-follow-hint { margin: 0; font-size: 11.5px; }
543
- .job-detail-body .jd-follow-actions { display: flex; flex-wrap: wrap; gap: 6px; }
544
- .job-detail-body .jd-follow-btn {
545
- border: 1px solid var(--line); background: #fff; border-radius: 8px;
546
- padding: 6px 10px; font: inherit; font-size: 12px; cursor: pointer;
547
- }
548
- .job-detail-body .jd-follow-btn:hover { border-color: var(--ink); }
549
- .job-detail-body .jd-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
550
- .job-detail-body .jd-actions button {
551
- border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 7px 12px; font-size: 12px;
552
- }
553
- .job-detail-body .jd-actions .primary, .voice-picker-modal .primary {
554
- background: var(--ink); color: #fff; border-color: var(--ink);
555
- }
556
- .vp-field { display: grid; gap: 6px; font-size: 12px; }
557
- .vp-field select {
558
- width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font: inherit; background: #fff;
544
+
545
+ .job-detail-card { width: min(520px, 100%); background: #fff; color: var(--ink); }
546
+ .job-detail-card .film-modal-bar { color: var(--ink); border-bottom: 1px solid var(--line); }
547
+ .job-detail-card .film-modal-x { color: var(--ink-soft); }
548
+ .job-detail-body { padding: 14px 16px 18px; display: grid; gap: 10px; }
549
+ .job-detail-body .jd-msg { font-size: 13px; line-height: 1.5; white-space: pre-wrap; }
550
+ .job-detail-body .jd-meta { font-size: 11px; white-space: pre-wrap; word-break: break-all; }
551
+ .job-detail-body .jd-follow { display: grid; gap: 8px; padding-top: 4px; border-top: 1px dashed var(--line); }
552
+ .job-detail-body .jd-follow-hint { margin: 0; font-size: 11.5px; }
553
+ .job-detail-body .jd-follow-actions { display: flex; flex-wrap: wrap; gap: 6px; }
554
+ .job-detail-body .jd-follow-btn {
555
+ border: 1px solid var(--line); background: #fff; border-radius: 8px;
556
+ padding: 6px 10px; font: inherit; font-size: 12px; cursor: pointer;
557
+ }
558
+ .job-detail-body .jd-follow-btn:hover { border-color: var(--ink); }
559
+ .job-detail-body .jd-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
560
+ .job-detail-body .jd-actions button {
561
+ border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 7px 12px; font-size: 12px;
562
+ }
563
+ .job-detail-body .jd-actions .primary, .voice-picker-modal .primary {
564
+ background: var(--ink); color: #fff; border-color: var(--ink);
565
+ }
566
+ .vp-field { display: grid; gap: 6px; font-size: 12px; }
567
+ .vp-field select {
568
+ width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font: inherit; background: #fff;
559
569
  }
@@ -106,6 +106,97 @@
106
106
  sync();
107
107
  }
108
108
 
109
+ /** 附件的角色标签:所有 Studio 共用一套名字,避免五个面板各叫各的。 */
110
+ const ROLE_LABEL = {
111
+ ref: '参考',
112
+ media: '素材',
113
+ character: '人物',
114
+ voice: '口播',
115
+ music: '配乐',
116
+ doc: '文档',
117
+ script: '文稿',
118
+ lyrics: '歌词',
119
+ subtitle: '字幕',
120
+ };
121
+
122
+ function roleLabel(role) {
123
+ return ROLE_LABEL[role] || '';
124
+ }
125
+
126
+ let openRoleMenu = null;
127
+
128
+ /** + 菜单里的二级“附件角色”菜单(参考素材 / 口播录音 / 配乐 / 文稿 …)。 */
129
+ function bindRoleMenu(anchor, items, onPick) {
130
+ if (openRoleMenu) {
131
+ openRoleMenu.close();
132
+ openRoleMenu = null;
133
+ }
134
+ if (!items || !items.length) return null;
135
+ const menu = document.createElement('div');
136
+ menu.className = 'plus-menu role-menu';
137
+ items.forEach((item) => {
138
+ const btn = document.createElement('button');
139
+ btn.type = 'button';
140
+ btn.innerHTML =
141
+ `<span class="plus-ico">${esc(item.icon || '·')}</span>` +
142
+ `<span><strong>${esc(item.label)}</strong><small>${esc(item.hint || '')}</small></span>`;
143
+ btn.addEventListener('click', (e) => {
144
+ e.preventDefault();
145
+ e.stopPropagation();
146
+ close();
147
+ onPick(item);
148
+ });
149
+ menu.appendChild(btn);
150
+ });
151
+ document.body.appendChild(menu);
152
+ const rect = anchor.getBoundingClientRect();
153
+ const width = 260;
154
+ const left = Math.min(rect.right + 8, Math.max(8, window.innerWidth - width - 8));
155
+ const top = Math.min(Math.max(8, rect.top - 6), Math.max(8, window.innerHeight - menu.offsetHeight - 8));
156
+ menu.style.position = 'fixed';
157
+ menu.style.left = `${left}px`;
158
+ menu.style.top = `${top}px`;
159
+ menu.style.width = `${width}px`;
160
+ const close = () => {
161
+ menu.remove();
162
+ document.removeEventListener('click', onDocClick);
163
+ document.removeEventListener('keydown', onKey);
164
+ openRoleMenu = null;
165
+ };
166
+ const onDocClick = () => close();
167
+ const onKey = (e) => {
168
+ if (e.key === 'Escape') close();
169
+ };
170
+ setTimeout(() => {
171
+ document.addEventListener('click', onDocClick);
172
+ document.addEventListener('keydown', onKey);
173
+ }, 0);
174
+ openRoleMenu = { close };
175
+ return openRoleMenu;
176
+ }
177
+
178
+ /** 按角色取文件:设置 accept → 弹选择框 → 回传 { role, files }。 */
179
+ function pickFilesByRole(input, role, accept, onPicked) {
180
+ if (!input) return;
181
+ if (input.__roleHandler) {
182
+ input.removeEventListener('change', input.__roleHandler);
183
+ input.__roleHandler = null;
184
+ }
185
+ if (accept) input.setAttribute('accept', accept);
186
+ else input.removeAttribute('accept');
187
+ input.dataset.role = role;
188
+ const handler = () => {
189
+ input.removeEventListener('change', handler);
190
+ input.__roleHandler = null;
191
+ const files = Array.from(input.files || []);
192
+ input.value = '';
193
+ if (files.length) onPicked(role, files);
194
+ };
195
+ input.__roleHandler = handler;
196
+ input.addEventListener('change', handler);
197
+ input.click();
198
+ }
199
+
109
200
  let filmSelectedId = '';
110
201
  let selectedJobId = '';
111
202
 
@@ -590,6 +681,10 @@
590
681
  phaseLabel,
591
682
  bindPlusMenu,
592
683
  bindCount,
684
+ bindRoleMenu,
685
+ pickFilesByRole,
686
+ roleLabel,
687
+ ROLE_LABEL,
593
688
  renderJobs,
594
689
  addChip,
595
690
  titleFromPrompt,
@@ -622,107 +717,107 @@
622
717
  studioReadyForCase = true;
623
718
  writeCasePrompt();
624
719
  }
625
- let currentRecipe = null;
626
-
627
- let optimizeMember = false;
628
- let optimizeTipTimer = 0;
629
-
630
- function showOptimizeTip(message) {
631
- const tip = document.getElementById('optimizeTip');
632
- if (!tip) return;
633
- tip.hidden = false;
634
- tip.textContent = message;
635
- window.clearTimeout(optimizeTipTimer);
636
- optimizeTipTimer = window.setTimeout(() => {
637
- tip.hidden = true;
638
- }, 2600);
639
- }
640
-
641
- async function onOptimizePrompt() {
642
- const btn = document.getElementById('optimizeBtn');
643
- const prompt = document.getElementById('prompt');
644
- if (!btn || !prompt) return;
645
- if (!optimizeMember) {
646
- showOptimizeTip('会员专属,请先开通会员');
647
- return;
648
- }
649
- if (btn.dataset.busy === '1') return;
650
- btn.dataset.busy = '1';
651
- const previous = btn.textContent;
652
- btn.textContent = '优化中';
653
- try {
654
- const recipe = currentRecipe || {};
655
- const data = await api('/api/optimize-prompt', {
656
- method: 'POST',
657
- headers: { 'content-type': 'application/json' },
658
- body: JSON.stringify({
659
- text: prompt.value,
660
- templatePrompt: recipe.prompt || '',
661
- narration: recipe.narration || '',
662
- attachment: recipe.attachment || '',
663
- }),
664
- });
665
- const next = String((data && data.prompt) || '').trim();
666
- if (!next) throw new Error('没有得到可用的提示词');
667
- prompt.value = next;
668
- prompt.dispatchEvent(new Event('input'));
669
- if (data && data.kept) showOptimizeTip('没选模板,按你写的原文出片');
670
- } catch (error) {
671
- const message = (error && error.message) || '无法优化提示词';
672
- if (message.indexOf('会员专属') >= 0) {
673
- optimizeMember = false;
674
- btn.classList.add('is-locked');
675
- btn.setAttribute('aria-disabled', 'true');
676
- showOptimizeTip('会员专属,请先开通会员');
677
- } else {
678
- const err = document.getElementById('err');
679
- if (err) {
680
- err.hidden = false;
681
- err.textContent = message;
682
- } else {
683
- showOptimizeTip(message);
684
- }
685
- }
686
- } finally {
687
- btn.dataset.busy = '';
688
- btn.textContent = previous || '优化提示词';
689
- }
690
- }
691
-
692
- function mountOptimize() {
693
- const prompt = document.getElementById('prompt');
694
- if (!prompt || document.getElementById('optimizeBtn')) return;
695
- const stage = document.createElement('div');
696
- stage.className = 'prompt-stage';
697
- prompt.parentNode.insertBefore(stage, prompt);
698
- stage.appendChild(prompt);
699
- const btn = document.createElement('button');
700
- btn.type = 'button';
701
- btn.id = 'optimizeBtn';
702
- btn.className = 'optimize is-locked';
703
- btn.setAttribute('aria-disabled', 'true');
704
- btn.textContent = '优化提示词';
705
- const tip = document.createElement('div');
706
- tip.id = 'optimizeTip';
707
- tip.className = 'optimize-tip';
708
- tip.hidden = true;
709
- stage.appendChild(btn);
710
- stage.appendChild(tip);
711
- btn.addEventListener('click', () => {
712
- void onOptimizePrompt();
713
- });
714
- fetch('/api/health')
715
- .then((res) => res.json())
716
- .then((data) => {
717
- optimizeMember = !!(data && data.member === true);
718
- btn.classList.toggle('is-locked', !optimizeMember);
719
- btn.setAttribute('aria-disabled', optimizeMember ? 'false' : 'true');
720
- })
721
- .catch(() => {
722
- optimizeMember = false;
723
- });
724
- }
725
-
726
- mountOptimize();
727
-
720
+ let currentRecipe = null;
721
+
722
+ let optimizeMember = false;
723
+ let optimizeTipTimer = 0;
724
+
725
+ function showOptimizeTip(message) {
726
+ const tip = document.getElementById('optimizeTip');
727
+ if (!tip) return;
728
+ tip.hidden = false;
729
+ tip.textContent = message;
730
+ window.clearTimeout(optimizeTipTimer);
731
+ optimizeTipTimer = window.setTimeout(() => {
732
+ tip.hidden = true;
733
+ }, 2600);
734
+ }
735
+
736
+ async function onOptimizePrompt() {
737
+ const btn = document.getElementById('optimizeBtn');
738
+ const prompt = document.getElementById('prompt');
739
+ if (!btn || !prompt) return;
740
+ if (!optimizeMember) {
741
+ showOptimizeTip('会员专属,请先开通会员');
742
+ return;
743
+ }
744
+ if (btn.dataset.busy === '1') return;
745
+ btn.dataset.busy = '1';
746
+ const previous = btn.textContent;
747
+ btn.textContent = '优化中';
748
+ try {
749
+ const recipe = currentRecipe || {};
750
+ const data = await api('/api/optimize-prompt', {
751
+ method: 'POST',
752
+ headers: { 'content-type': 'application/json' },
753
+ body: JSON.stringify({
754
+ text: prompt.value,
755
+ templatePrompt: recipe.prompt || '',
756
+ narration: recipe.narration || '',
757
+ attachment: recipe.attachment || '',
758
+ }),
759
+ });
760
+ const next = String((data && data.prompt) || '').trim();
761
+ if (!next) throw new Error('没有得到可用的提示词');
762
+ prompt.value = next;
763
+ prompt.dispatchEvent(new Event('input'));
764
+ if (data && data.kept) showOptimizeTip('没选模板,按你写的原文出片');
765
+ } catch (error) {
766
+ const message = (error && error.message) || '无法优化提示词';
767
+ if (message.indexOf('会员专属') >= 0) {
768
+ optimizeMember = false;
769
+ btn.classList.add('is-locked');
770
+ btn.setAttribute('aria-disabled', 'true');
771
+ showOptimizeTip('会员专属,请先开通会员');
772
+ } else {
773
+ const err = document.getElementById('err');
774
+ if (err) {
775
+ err.hidden = false;
776
+ err.textContent = message;
777
+ } else {
778
+ showOptimizeTip(message);
779
+ }
780
+ }
781
+ } finally {
782
+ btn.dataset.busy = '';
783
+ btn.textContent = previous || '优化提示词';
784
+ }
785
+ }
786
+
787
+ function mountOptimize() {
788
+ const prompt = document.getElementById('prompt');
789
+ if (!prompt || document.getElementById('optimizeBtn')) return;
790
+ const stage = document.createElement('div');
791
+ stage.className = 'prompt-stage';
792
+ prompt.parentNode.insertBefore(stage, prompt);
793
+ stage.appendChild(prompt);
794
+ const btn = document.createElement('button');
795
+ btn.type = 'button';
796
+ btn.id = 'optimizeBtn';
797
+ btn.className = 'optimize is-locked';
798
+ btn.setAttribute('aria-disabled', 'true');
799
+ btn.textContent = '优化提示词';
800
+ const tip = document.createElement('div');
801
+ tip.id = 'optimizeTip';
802
+ tip.className = 'optimize-tip';
803
+ tip.hidden = true;
804
+ stage.appendChild(btn);
805
+ stage.appendChild(tip);
806
+ btn.addEventListener('click', () => {
807
+ void onOptimizePrompt();
808
+ });
809
+ fetch('/api/health')
810
+ .then((res) => res.json())
811
+ .then((data) => {
812
+ optimizeMember = !!(data && data.member === true);
813
+ btn.classList.toggle('is-locked', !optimizeMember);
814
+ btn.setAttribute('aria-disabled', optimizeMember ? 'false' : 'true');
815
+ })
816
+ .catch(() => {
817
+ optimizeMember = false;
818
+ });
819
+ }
820
+
821
+ mountOptimize();
822
+
728
823
  })(window);
package/bin/server.js CHANGED
@@ -31,7 +31,7 @@ function presentLook(look) {
31
31
  recipe: recipeView(findRecipe(RECIPES, [look.id, look.name, look.desc]), {
32
32
  narration: 'required',
33
33
  attachment: 'optional',
34
- hint: '成片自带解说,不用上传录音。参考材料可以不附。',
34
+ hint: '成片自带解说;想用自己的声音就从 + 上传「旁白录音」。参考材料可以不附。',
35
35
  }),
36
36
  };
37
37
  }
@@ -106,11 +106,41 @@ async function saveUploads(workspace, jobId, files) {
106
106
  const safe = f.name.replace(/[^\w.\-()\u4e00-\u9fff]+/g, '_').slice(0, 120);
107
107
  const dest = path.join(dir, safe);
108
108
  fs.writeFileSync(dest, Buffer.from(f.dataBase64, 'base64'));
109
- saved.push({ name: safe, path: dest, kind: f.kind || 'file' });
109
+ saved.push({ name: safe, path: dest, kind: f.kind || 'file', role: f.role || 'media' });
110
110
  }
111
111
  return saved;
112
112
  }
113
113
 
114
+ /**
115
+ * 附件落位:explainroo 只从工程目录的 assets/ 读素材。
116
+ * 媒体/录音/配乐 → <工程>/assets/;文档 → <项目>/docs/(只给 Agent 读,不进引擎)。
117
+ */
118
+ function placeUploads(projectDir, projectPath, uploads) {
119
+ const assetDir = ensureDir(path.join(projectPath, 'assets'));
120
+ const docDir = ensureDir(path.join(projectDir, 'docs'));
121
+ const sameDir = path.resolve(projectDir) === path.resolve(projectPath);
122
+ const placed = [];
123
+ for (const up of uploads) {
124
+ const isDoc = up.role === 'doc';
125
+ const dir = isDoc ? docDir : assetDir;
126
+ let dest = path.join(dir, up.name);
127
+ if (fs.existsSync(dest)) {
128
+ const ext = path.extname(up.name);
129
+ const stem = path.basename(up.name, ext);
130
+ dest = path.join(dir, `${stem}-${Date.now().toString(36)}${ext}`);
131
+ }
132
+ if (path.resolve(dest) !== path.resolve(up.path)) fs.copyFileSync(up.path, dest);
133
+ placed.push({
134
+ name: path.basename(dest),
135
+ role: up.role,
136
+ kind: up.kind,
137
+ path: dest,
138
+ rel: isDoc ? (sameDir ? `docs/${path.basename(dest)}` : `../docs/${path.basename(dest)}`) : `assets/${path.basename(dest)}`,
139
+ });
140
+ }
141
+ return placed;
142
+ }
143
+
114
144
  createAgentServer({
115
145
  root,
116
146
  api: async ({ req, res, pathname, cfg, jobs, sendJson, readJsonBody }) => {
@@ -152,8 +182,9 @@ createAgentServer({
152
182
  promptEn = await toEnglishPrompt(prompt);
153
183
  titleEn = await modelTitle(title, prompt, promptEn);
154
184
  } catch {
155
- sendJson(res, 503, { error: '英文提示词没有生成,请再试一次' });
156
- return true;
185
+ // 翻译失败(面板大模型未配置且 MyMemory 不可用)时降级:保留中文提示词继续生成,避免阻断用户
186
+ promptEn = prompt;
187
+ titleEn = title;
157
188
  }
158
189
  const projectSlug = `${slugify(title)}-${Date.now().toString(36)}`;
159
190
 
@@ -191,7 +222,7 @@ createAgentServer({
191
222
  );
192
223
 
193
224
  const uploads = await saveUploads(cfg.workspace, job.id, body.files);
194
- brief.uploads = uploads.map((u) => ({ name: u.name, kind: u.kind }));
225
+ brief.uploads = uploads.map((u) => ({ name: u.name, kind: u.kind, role: u.role }));
195
226
  writeJson(path.join(projectDir, 'brief.json'), brief);
196
227
 
197
228
  const permitRes = await requestRunPermit(cfg, { projectPath: projectDir, jobId: job.id });
@@ -251,11 +282,33 @@ createAgentServer({
251
282
  projectPath = videoPath;
252
283
  }
253
284
 
285
+ // 附件落位:引擎只认工程目录里的 assets/,文档放项目 docs/ 供 Agent 读。
286
+ const placed = placeUploads(projectDir, projectPath, uploads);
287
+ brief.assets = placed.map((p) => ({ name: p.name, role: p.role, kind: p.kind, path: p.rel }));
288
+ brief.uploadDir = path.join(projectDir, 'assets', 'uploads');
289
+ writeJson(path.join(projectDir, 'brief.json'), brief);
290
+ if (path.resolve(projectPath) !== path.resolve(projectDir)) {
291
+ writeJson(path.join(projectPath, 'brief.json'), brief);
292
+ }
293
+
294
+ const byRole = (role) => placed.filter((p) => p.role === role);
295
+ const mediaAssets = byRole('media');
296
+ const voiceAssets = byRole('voice');
297
+ const musicAssets = byRole('music');
298
+ const docAssets = byRole('doc');
299
+ const assetLines = [
300
+ ...mediaAssets.map((p) => `Asset (image/video): ${p.rel}`),
301
+ ...voiceAssets.map((p) => `Narration recording (use as-is, provider "recording"): ${p.rel} — do not synthesize over it.`),
302
+ ...musicAssets.map((p) => `Music (user-licensed): ${p.rel} — set music.src, duck under narration.`),
303
+ ...docAssets.map((p) => `Document (facts only, not renderable): ${p.rel}`),
304
+ ];
305
+
254
306
  const kickoffPrompt = [
255
307
  'Follow the biutalk skill and finish the explainer film.',
256
308
  `Project folder: ${projectPath}`,
257
309
  `Read brief.json. Theme ${look}. Size ${size}. Pace ${pace}.`,
258
- voiceKickoffLine(voicePick),
310
+ ...assetLines,
311
+ voicePick && !voiceAssets.length ? voiceKickoffLine(voicePick) : '',
259
312
  audienceLine(prompt),
260
313
  `Creative brief: ${promptEn}`,
261
314
  'Read skills/biutalk/EXEC.md and follow it: doctor → scaffold → script.md → scenes.js → voice → check → still/sheet → render --draft → render → verify.',
package/manifest.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "schemaVersion": 1,
3
3
  "id": "biutalk",
4
4
  "name": "BiuTalk",
5
- "version": "2.0.0",
5
+ "version": "2.0.2",
6
6
  "publisher": "Biunow",
7
7
  "description": "BiuTalk 解说视频 Studio:模板、尺寸、附件与本地渲染引擎。",
8
8
  "entry": {
@@ -48,8 +48,8 @@
48
48
  "requiresEntitlement": "export"
49
49
  },
50
50
  "integrity": {
51
- "sha256": "573d415d25944080682c802819a8bbeee6c1f7cc82747d853afb066e9b16dd5b",
52
- "signature": "TZiertAVK9k1WRdfPGUuYsqaQEGp57lKOEEvWBejTK7+KCRhUc7aRsnVvNYgJSep7fGqU82+vsMzj3dVVGiCBg==",
51
+ "sha256": "19bc0940cbcf7999563eb85f7d4e0ada65b3d3a5ccc96454c6e644bf9ec9a512",
52
+ "signature": "aq5RRRrOQ7or2EAdos2IsEgrCde6oA+IfCsYyV++4YEMvgfh7Wo9JpfT++U878l3hXNbjqvo4QD8EK8kj983DA==",
53
53
  "signedBy": "publisher-key"
54
54
  }
55
55
  }