@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
@@ -112,7 +112,27 @@ 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; }
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
+
116
136
  .composer-foot {
117
137
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
118
138
  padding: 10px 12px 12px 14px; border-top: 1px solid #f0f0ed; flex-wrap: wrap;
@@ -151,6 +171,9 @@ button:disabled { cursor: not-allowed; opacity: .5; }
151
171
  }
152
172
  .size-label { font-size: 11px; color: var(--muted-2); margin-left: 4px; }
153
173
  .size-pick { width: 200px; flex: none; }
174
+ /* .sm{display:block} 会盖掉原生 [hidden];档位/尺寸按栏目显隐时必须压住 */
175
+ .size-pick[hidden],
176
+ .sm[hidden] { display: none !important; }
154
177
  .theme-pick { width: 186px; flex: none; }
155
178
  .primary {
156
179
  border: 0; background: var(--ink); color: var(--accent); border-radius: 99px;
@@ -310,9 +333,74 @@ button:disabled { cursor: not-allowed; opacity: .5; }
310
333
  color: #f4f1ea; font-size: 20px; line-height: 1; cursor: pointer;
311
334
  }
312
335
  .film-modal video { display: block; width: 100%; max-height: min(72vh, 640px); background: #000; }
336
+ /* 拆解结果弹层:跟随应用浅色主题,滚动条与卡片自绘 */
337
+ .film-modal.breakdown { padding: 28px; }
338
+ .film-modal.breakdown .film-modal-card {
339
+ width: min(1080px, 100%); max-height: min(88vh, 920px);
340
+ overflow: auto; overscroll-behavior: contain;
341
+ background: var(--paper); color: var(--ink);
342
+ border: 1px solid var(--line-strong); border-radius: 16px;
343
+ box-shadow: 0 24px 64px rgba(0, 0, 0, .28);
344
+ scrollbar-width: thin; scrollbar-color: rgba(0, 0, 0, .22) transparent;
345
+ }
346
+ .film-modal.breakdown .film-modal-card::-webkit-scrollbar { width: 10px; height: 10px; }
347
+ .film-modal.breakdown .film-modal-card::-webkit-scrollbar-track { background: transparent; }
348
+ .film-modal.breakdown .film-modal-card::-webkit-scrollbar-thumb {
349
+ background: rgba(0, 0, 0, .18); border-radius: 999px;
350
+ border: 3px solid transparent; background-clip: content-box;
351
+ }
352
+ .film-modal.breakdown .film-modal-card::-webkit-scrollbar-thumb:hover { background: rgba(0, 0, 0, .34); background-clip: content-box; }
353
+ .film-modal.breakdown .film-modal-bar {
354
+ position: sticky; top: 0; z-index: 3;
355
+ padding: 12px 16px; color: var(--ink);
356
+ background: rgba(246, 246, 243, .94); backdrop-filter: blur(8px);
357
+ border-bottom: 1px solid var(--line);
358
+ }
359
+ .film-modal.breakdown .film-modal-x { color: var(--ink-soft); }
360
+ .film-modal.breakdown .film-modal-x:hover { background: var(--paper-2); }
361
+ .breakdown-body { padding: 2px 16px 22px; }
362
+ .bd-group { margin-top: 20px; }
363
+ .bd-group h3 {
364
+ display: flex; align-items: center; gap: 8px; margin: 0 0 10px;
365
+ font-size: 12px; font-weight: 650; letter-spacing: .02em; color: var(--ink);
366
+ }
367
+ .bd-group h3::before { content: ''; width: 3px; height: 12px; border-radius: 2px; background: var(--accent-deep); }
368
+ .bd-img {
369
+ display: block; width: 100%; max-height: 460px; object-fit: contain;
370
+ margin-bottom: 12px; border-radius: 12px; cursor: zoom-in;
371
+ background: #fff; border: 1px solid var(--line);
372
+ transition: border-color .15s ease;
373
+ }
374
+ .bd-img:hover { border-color: var(--accent-deep); }
375
+ .bd-json {
376
+ margin: 0 0 12px; padding: 12px 14px; border-radius: 12px;
377
+ background: #fff; border: 1px solid var(--line); color: var(--ink-soft);
378
+ font-size: 12px; line-height: 1.75; white-space: pre-wrap; word-break: break-all;
379
+ }
380
+ .bd-empty { color: var(--ink-soft); font-size: 12px; }
381
+ .bd-actions { margin: 12px 0 2px; }
382
+ .bd-go {
383
+ border: 1px solid var(--accent-deep); border-radius: 999px; padding: 9px 20px; cursor: pointer;
384
+ background: var(--accent-soft); color: var(--ink); font-size: 12px; font-weight: 650;
385
+ transition: filter .15s ease;
386
+ }
387
+ .bd-go:hover { filter: brightness(.97); }
388
+ .bd-viewer {
389
+ position: fixed; inset: 0; z-index: 95; padding: 32px; cursor: zoom-out;
390
+ display: grid; place-items: center; background: rgba(12, 12, 12, .93);
391
+ }
392
+ .bd-viewer[hidden] { display: none; }
393
+ .bd-viewer img { max-width: 100%; max-height: 100%; border-radius: 8px; }
394
+ .asset.ref { background: var(--accent-soft); border-color: var(--accent-deep); }
395
+ button.job-play {
396
+ appearance: none; border: 0; background: none; font: inherit; color: inherit;
397
+ cursor: pointer; padding: 0; text-align: left; width: 100%;
398
+ }
399
+ .job-fill { color: #8a877e; font-size: 11px; }
313
400
 
314
401
  /* SelectMenu */
315
402
  .sm { position: relative; display: block; min-width: 0; }
403
+ .sm[hidden] { display: none !important; }
316
404
  .sm-trigger {
317
405
  width: 100%; display: flex; align-items: center; gap: 8px; text-align: left;
318
406
  background: #fff; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
@@ -443,3 +531,29 @@ button:disabled { cursor: not-allowed; opacity: .5; }
443
531
  .sm-entry-err { flex: 1 0 100%; margin: 0; font-size: 11px; line-height: 1.3; color: var(--danger); }
444
532
 
445
533
  .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;
559
+ }
@@ -10,15 +10,36 @@
10
10
  .replace(/"/g, '"');
11
11
  }
12
12
 
13
- const MAX_UPLOAD_BYTES = 20 * 1024 * 1024;
13
+ // 本地 base64 JSON 上传:按类型分档(防呆,非云端配额)
14
+ const MB = 1024 * 1024;
15
+ const MAX_DOC_UPLOAD_BYTES = 50 * MB; // 图/文/PDF
16
+ const MAX_AUDIO_UPLOAD_BYTES = 100 * MB; // 音频
17
+ const MAX_VIDEO_UPLOAD_BYTES = 200 * MB; // 视频
18
+ const MAX_TOTAL_UPLOAD_BYTES = 250 * MB; // 单次任务合计
19
+ /** @deprecated 兼容旧引用:等同图文档上限 */
20
+ const MAX_UPLOAD_BYTES = MAX_DOC_UPLOAD_BYTES;
21
+
22
+ function uploadKind(file) {
23
+ const name = String(file?.name || '');
24
+ const type = String(file?.type || '');
25
+ if (type.startsWith('video/') || /\.(mp4|mov|webm|m4v)$/i.test(name)) return 'video';
26
+ if (type.startsWith('audio/') || /\.(mp3|wav|m4a|aac|flac|ogg)$/i.test(name)) return 'audio';
27
+ return 'doc';
28
+ }
29
+
30
+ function uploadCap(kind) {
31
+ if (kind === 'video') return { bytes: MAX_VIDEO_UPLOAD_BYTES, label: '200MB', title: '视频' };
32
+ if (kind === 'audio') return { bytes: MAX_AUDIO_UPLOAD_BYTES, label: '100MB', title: '音频' };
33
+ return { bytes: MAX_DOC_UPLOAD_BYTES, label: '50MB', title: '图文/PDF' };
34
+ }
14
35
 
15
36
  async function api(path, opts) {
16
37
  const res = await fetch(path, opts);
17
38
  const data = await res.json().catch(() => ({}));
18
39
  if (!res.ok) {
19
40
  const raw = data.error || res.statusText || '请求失败';
20
- if (res.status === 413 || /body too large/i.test(raw)) {
21
- throw new Error('附件超过 20MB,请压缩或裁短后再上传');
41
+ if (res.status === 413 || /body too large|附件过大/i.test(raw)) {
42
+ throw new Error('附件过大:图文/PDF≤50MB,音频≤100MB,视频≤200MB,合计≤250MB');
22
43
  }
23
44
  throw new Error(raw);
24
45
  }
@@ -28,9 +49,11 @@
28
49
  function uploadBlockReason(file, usedBytes) {
29
50
  const name = file?.name || '附件';
30
51
  const size = Number(file?.size) || 0;
31
- if (size > MAX_UPLOAD_BYTES) return `${name} 超过 20MB,请压缩或裁短后再上传`;
32
- if ((Number(usedBytes) || 0) + size > MAX_UPLOAD_BYTES) {
33
- return `附件合计超过 20MB,${name} 未加入`;
52
+ const kind = uploadKind(file);
53
+ const { bytes: cap, label, title } = uploadCap(kind);
54
+ if (size > cap) return `${name} 超过 ${label}(${title}),请压缩后再上传`;
55
+ if ((Number(usedBytes) || 0) + size > MAX_TOTAL_UPLOAD_BYTES) {
56
+ return `附件合计超过 250MB,${name} 未加入`;
34
57
  }
35
58
  return '';
36
59
  }
@@ -90,6 +113,126 @@
90
113
  return '/api/jobs/' + encodeURIComponent(id) + '/film';
91
114
  }
92
115
 
116
+ let jobDetailTimer = null;
117
+
118
+ function ensureJobDetailModal() {
119
+ let back = document.querySelector('.job-detail-modal');
120
+ if (back) return back;
121
+ back = document.createElement('div');
122
+ back.className = 'job-detail-modal film-modal';
123
+ back.hidden = true;
124
+ back.innerHTML = `
125
+ <div class="film-modal-card job-detail-card" role="dialog" aria-modal="true">
126
+ <div class="film-modal-bar">
127
+ <strong class="jd-title">任务详情</strong>
128
+ <button type="button" class="film-modal-x jd-close" aria-label="关闭">×</button>
129
+ </div>
130
+ <div class="job-detail-body">
131
+ <div class="jd-badge"></div>
132
+ <div class="jd-msg"></div>
133
+ <div class="bar jd-bar"><i></i></div>
134
+ <div class="jd-meta muted"></div>
135
+ <div class="jd-follow" hidden>
136
+ <p class="muted jd-follow-hint">成片二次修改在 DSH 执行;这里只发起对应对话。</p>
137
+ <div class="jd-follow-actions"></div>
138
+ </div>
139
+ <div class="jd-actions">
140
+ <button type="button" class="jd-refresh">刷新</button>
141
+ <button type="button" class="jd-dsh" hidden>在 DSH 打开对话</button>
142
+ </div>
143
+ </div>
144
+ </div>`;
145
+ document.body.appendChild(back);
146
+ const close = () => {
147
+ back.hidden = true;
148
+ if (jobDetailTimer) {
149
+ clearInterval(jobDetailTimer);
150
+ jobDetailTimer = null;
151
+ }
152
+ };
153
+ back.querySelector('.jd-close').addEventListener('click', close);
154
+ back.addEventListener('click', (e) => { if (e.target === back) close(); });
155
+ document.addEventListener('keydown', (e) => {
156
+ if (e.key === 'Escape' && !back.hidden) close();
157
+ });
158
+ return back;
159
+ }
160
+
161
+ const FOLLOWUP_ACTIONS = [
162
+ { id: 'narration', label: '改旁白', prompt: '请基于当前成片修改旁白文案,保持画幅与风格不变。' },
163
+ { id: 'voice', label: '换音色', prompt: '请按 brief.json 里的 voice / ttsVoice 重新配音并重渲染成片。' },
164
+ { id: 'subtitle', label: '加字幕', prompt: '请为当前成片补齐字幕并输出新成片。' },
165
+ { id: 'rerender', label: '重渲染', prompt: '请在不改创意的前提下重新渲染成片,交付新的 MP4 路径。' },
166
+ ];
167
+
168
+ function openDshSession(job, followPrompt) {
169
+ const sessionId = String(job.dshSessionId || '').trim();
170
+ if (!sessionId) {
171
+ window.alert('还没有 DSH 会话,请等创作接通后再试');
172
+ return;
173
+ }
174
+ window.parent.postMessage({
175
+ source: 'bn-studio',
176
+ type: 'open-session',
177
+ sessionId,
178
+ ...(followPrompt ? { draft: followPrompt } : {}),
179
+ }, '*');
180
+ }
181
+
182
+ function fillJobDetail(back, job) {
183
+ if (!back || !job) return;
184
+ const phase = phaseLabel(job);
185
+ back.querySelector('.jd-title').textContent = job.title || job.kind || '任务详情';
186
+ const badge = back.querySelector('.jd-badge');
187
+ badge.className = 'jd-badge badge ' + (phase.cls || '');
188
+ badge.textContent = phase.text + (job.progress != null ? ` · ${Number(job.progress) || 0}%` : '');
189
+ back.querySelector('.jd-msg').textContent = job.message || '暂无进度说明';
190
+ back.querySelector('.jd-bar i').style.width = `${Number(job.progress) || 0}%`;
191
+ const bits = [
192
+ job.screen ? `画幅 ${job.screen}` : '',
193
+ job.styleName || job.styleId || '',
194
+ job.voice && (job.voice.voiceName || job.voice.voiceId)
195
+ ? `音色 ${job.voice.voiceName || job.voice.voiceId}`
196
+ : '',
197
+ ].filter(Boolean);
198
+ back.querySelector('.jd-meta').textContent = bits.join(' · ');
199
+ const dshBtn = back.querySelector('.jd-dsh');
200
+ const sessionId = String(job.dshSessionId || '').trim();
201
+ dshBtn.hidden = !sessionId;
202
+ dshBtn.onclick = () => openDshSession(job);
203
+ const follow = back.querySelector('.jd-follow');
204
+ const followBox = back.querySelector('.jd-follow-actions');
205
+ const done = Boolean(job.outputMp4) || job.status === 'done' || job.phase === 'ready';
206
+ follow.hidden = !done || !sessionId;
207
+ followBox.innerHTML = '';
208
+ if (!follow.hidden) {
209
+ FOLLOWUP_ACTIONS.forEach((act) => {
210
+ const btn = document.createElement('button');
211
+ btn.type = 'button';
212
+ btn.className = 'jd-follow-btn';
213
+ btn.textContent = act.label;
214
+ btn.onclick = () => openDshSession(job, act.prompt);
215
+ followBox.appendChild(btn);
216
+ });
217
+ }
218
+ }
219
+
220
+ function openJobDetailModal(job) {
221
+ const back = ensureJobDetailModal();
222
+ fillJobDetail(back, job);
223
+ back.hidden = false;
224
+ const refresh = back.querySelector('.jd-refresh');
225
+ refresh.onclick = () => {
226
+ void api('/api/jobs/' + encodeURIComponent(job.id))
227
+ .then((data) => fillJobDetail(back, data.job || job))
228
+ .catch(() => {});
229
+ };
230
+ if (jobDetailTimer) clearInterval(jobDetailTimer);
231
+ if (job.status === 'running' || job.phase === 'dsh' || job.phase === 'inpanel') {
232
+ jobDetailTimer = setInterval(() => refresh.click(), 4000);
233
+ }
234
+ }
235
+
93
236
  function ensureFilmModal() {
94
237
  let back = document.querySelector('.film-modal');
95
238
  if (back) return back;
@@ -220,7 +363,7 @@
220
363
  <span class="badge ${phase.cls}">${esc(phase.text)}</span>
221
364
  ${meta ? `<span class="job-chip">${esc(meta)}</span>` : ''}
222
365
  <span class="job-actions">
223
- <button type="button" class="job-open" ${sessionId ? '' : 'disabled'} title="${sessionId ? '打开这次创作的对话' : '这次任务没有对话'}">任务详情</button>
366
+ <button type="button" class="job-open" title="查看任务进度">任务详情</button>
224
367
  <button type="button" class="job-del" title="从列表删除" aria-label="删除">×</button>
225
368
  </span>
226
369
  </div>
@@ -228,11 +371,11 @@
228
371
  <div class="m">${esc(j.message || '')}</div>
229
372
  <div class="bar"><i style="width:${Number(j.progress) || 0}%"></i></div>`;
230
373
  const openBtn = el.querySelector('.job-open');
231
- if (openBtn && sessionId) {
374
+ if (openBtn) {
232
375
  openBtn.addEventListener('click', (e) => {
233
376
  e.preventDefault();
234
377
  e.stopPropagation();
235
- window.parent.postMessage({ source: 'bn-studio', type: 'open-session', sessionId }, '*');
378
+ openJobDetailModal(j);
236
379
  });
237
380
  }
238
381
  el.addEventListener('click', () => {
@@ -285,6 +428,7 @@
285
428
  const RECIPE_LEVEL = { off: '无', optional: '可选', required: '必须' };
286
429
 
287
430
  function paintRecipe(state, recipe, hint, keepText) {
431
+ currentRecipe = recipe || null;
288
432
  const prompt = document.getElementById('prompt');
289
433
  let bar = document.getElementById('needBar');
290
434
  if (!bar && prompt) {
@@ -312,9 +456,11 @@
312
456
  }
313
457
  const narr = (recipe && recipe.narration) || 'optional';
314
458
  const att = (recipe && recipe.attachment) || 'optional';
459
+ const audio = recipe && recipe.audio;
315
460
  flags.innerHTML =
316
461
  `<span class="need-flag ${narr}">旁白 · ${RECIPE_LEVEL[narr] || narr}</span>` +
317
- `<span class="need-flag ${att}">附件 · ${RECIPE_LEVEL[att] || att}</span>`;
462
+ `<span class="need-flag ${att}">附件 · ${RECIPE_LEVEL[att] || att}</span>` +
463
+ (audio ? `<span class="need-flag ${audio}">音频驱动 · ${RECIPE_LEVEL[audio] || audio}</span>` : '');
318
464
  const text = String((recipe && recipe.prompt) || '').trim();
319
465
  if (prompt && text && !keepText) {
320
466
  prompt.value = text;
@@ -332,12 +478,115 @@
332
478
  return (line || fallback || '未命名成片').slice(0, 120);
333
479
  }
334
480
 
481
+ async function openVoicePicker(state, onPicked) {
482
+ const data = await api('/api/voice-options').catch(() => null);
483
+ const channels = (data && data.channels) || [];
484
+ if (!channels.length) throw new Error('语音目录不可用,请先在面板设置里配置语音');
485
+ if (!global.SelectMenu || typeof global.SelectMenu.mount !== 'function') {
486
+ throw new Error('下拉组件未加载');
487
+ }
488
+ const back = document.createElement('div');
489
+ back.className = 'film-modal voice-picker-modal';
490
+ back.innerHTML = `
491
+ <div class="film-modal-card job-detail-card" role="dialog" aria-modal="true">
492
+ <div class="film-modal-bar">
493
+ <strong>选择语音</strong>
494
+ <button type="button" class="film-modal-x" aria-label="关闭">×</button>
495
+ </div>
496
+ <div class="job-detail-body">
497
+ <label class="vp-field"><span>通道</span><div class="vp-channel"></div></label>
498
+ <label class="vp-field"><span>音色</span><div class="vp-voice"></div></label>
499
+ <p class="muted vp-hint"></p>
500
+ <div class="jd-actions">
501
+ <button type="button" class="jd-refresh vp-clear">清除选择</button>
502
+ <button type="button" class="primary vp-ok">确定</button>
503
+ </div>
504
+ </div>
505
+ </div>`;
506
+ document.body.appendChild(back);
507
+ const hint = back.querySelector('.vp-hint');
508
+ const current = state.voice || {};
509
+ let channelId = current.channel || (channels.find((c) => c.enabled) || channels[0] || {}).id || '';
510
+ let voiceId = current.voiceId || '';
511
+ const channelHost = back.querySelector('.vp-channel');
512
+ const voiceHost = back.querySelector('.vp-voice');
513
+ const channelMenu = global.SelectMenu.mount(channelHost, {
514
+ size: 'md',
515
+ value: channelId,
516
+ options: channels.map((ch) => ({
517
+ value: ch.id,
518
+ label: ch.label + (ch.enabled ? '' : '(未配置)'),
519
+ })),
520
+ onChange: (v) => {
521
+ channelId = v;
522
+ fillVoices(true);
523
+ },
524
+ });
525
+ let voiceMenu = null;
526
+ const fillVoices = (reset) => {
527
+ const ch = channels.find((c) => c.id === channelId);
528
+ hint.textContent = (ch && ch.hint) || '';
529
+ const opts = (ch && ch.voices ? ch.voices : []).map((v) => ({
530
+ value: v.id,
531
+ label: v.label || v.name || v.id,
532
+ }));
533
+ if (reset || !opts.some((o) => o.value === voiceId)) {
534
+ voiceId = (opts.some((o) => o.value === current.voiceId) && !reset)
535
+ ? current.voiceId
536
+ : (ch && ch.defaultVoiceId && opts.some((o) => o.value === ch.defaultVoiceId)
537
+ ? ch.defaultVoiceId
538
+ : (opts[0] && opts[0].value) || '');
539
+ }
540
+ voiceHost.innerHTML = '';
541
+ voiceMenu = global.SelectMenu.mount(voiceHost, {
542
+ size: 'md',
543
+ value: voiceId,
544
+ options: opts.length ? opts : [{ value: '', label: '暂无音色' }],
545
+ onChange: (v) => { voiceId = v; },
546
+ });
547
+ channelMenu.setValue(channelId, true);
548
+ };
549
+ fillVoices(false);
550
+ const close = () => back.remove();
551
+ back.querySelector('.film-modal-x').onclick = close;
552
+ back.addEventListener('click', (e) => { if (e.target === back) close(); });
553
+ back.querySelector('.vp-clear').onclick = () => {
554
+ state.voice = null;
555
+ if (onPicked) onPicked(null);
556
+ close();
557
+ };
558
+ back.querySelector('.vp-ok').onclick = () => {
559
+ const ch = channels.find((c) => c.id === channelId);
560
+ const v = (ch && ch.voices || []).find((x) => x.id === voiceId);
561
+ if (!v) {
562
+ window.alert('请选择可用音色');
563
+ return;
564
+ }
565
+ state.voice = {
566
+ channel: ch.id,
567
+ voiceId: v.id,
568
+ voiceName: v.name || v.label || v.id,
569
+ rate: ch.rate || 0,
570
+ provider: ch.provider || '',
571
+ engine: ch.engine || '',
572
+ };
573
+ if (onPicked) onPicked(state.voice);
574
+ close();
575
+ };
576
+ }
577
+
335
578
  global.Composer = {
336
579
  esc,
337
580
  api,
338
581
  fileToBase64,
339
582
  uploadBlockReason,
340
583
  MAX_UPLOAD_BYTES,
584
+ MAX_DOC_UPLOAD_BYTES,
585
+ MAX_AUDIO_UPLOAD_BYTES,
586
+ MAX_VIDEO_UPLOAD_BYTES,
587
+ MAX_TOTAL_UPLOAD_BYTES,
588
+ uploadKind,
589
+ uploadCap,
341
590
  phaseLabel,
342
591
  bindPlusMenu,
343
592
  bindCount,
@@ -345,5 +594,135 @@
345
594
  addChip,
346
595
  titleFromPrompt,
347
596
  paintRecipe,
597
+ claimCasePrompt,
598
+ openJobDetailModal,
599
+ openVoicePicker,
348
600
  };
601
+
602
+ let casePromptText = '';
603
+ let studioReadyForCase = false;
604
+
605
+ function writeCasePrompt() {
606
+ const prompt = document.getElementById('prompt');
607
+ const text = String(casePromptText || '').trim();
608
+ if (!studioReadyForCase || !prompt || !text || prompt.value === text) return;
609
+ prompt.value = text;
610
+ prompt.dispatchEvent(new Event('input'));
611
+ }
612
+
613
+ window.addEventListener('message', (event) => {
614
+ if (event.source !== window.parent) return;
615
+ const data = event.data || {};
616
+ if (data.type !== 'bn-case-prompt') return;
617
+ casePromptText = String(data.prompt || '');
618
+ writeCasePrompt();
619
+ });
620
+
621
+ function claimCasePrompt() {
622
+ studioReadyForCase = true;
623
+ writeCasePrompt();
624
+ }
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
+
349
728
  })(window);
package/studio/index.html CHANGED
@@ -47,7 +47,11 @@
47
47
  <span class="plus-ico">↑</span>
48
48
  <span><strong>上传附件</strong><small>图片 / 视频 / 音频 / 文档</small></span>
49
49
  </button>
50
- <button type="button" id="paceToggle">
50
+ <button type="button" id="voiceBtn">
51
+ <span class="plus-ico">♪</span>
52
+ <span><strong>选择语音</strong><small>免费 / API / 复刻音色</small></span>
53
+ </button>
54
+ <button type="button" id="paceToggle">
51
55
  <span class="plus-ico">⏱</span>
52
56
  <span><strong>节奏</strong><small id="paceHint">1.0×</small></span>
53
57
  </button>