@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.
Files changed (108) hide show
  1. package/_shared/.tmp-panel-smoke/art/smoke.mp4 +0 -0
  2. package/_shared/.tmp-panel-smoke/art-pipe/out/biuart-01_cave-mwq5kfpm.mp4 +0 -0
  3. package/_shared/.tmp-panel-smoke/art-pipe/panel-delivery.json +7 -0
  4. package/_shared/.tmp-panel-smoke/reel-pipe/film/index.html +7 -0
  5. package/_shared/.tmp-panel-smoke/reel-pipe/film/main.js +68 -0
  6. package/_shared/.tmp-panel-smoke/reel-pipe/film/panel-beats.json +20 -0
  7. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/CREDITS +20 -0
  8. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/build.sh +17 -0
  9. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/ease.js +43 -0
  10. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/events.json +1 -0
  11. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/film.js +533 -0
  12. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/fonts/OFL-Archivo.txt +93 -0
  13. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/fonts/OFL-DMSerifDisplay.txt +93 -0
  14. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/fonts/OFL-UnifrakturMaguntia.txt +94 -0
  15. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/fonts/fonts.css +3 -0
  16. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/index.html +6 -0
  17. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/lines.json +10 -0
  18. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/main.js +15 -0
  19. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/mix.py +116 -0
  20. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/music/score.py +168 -0
  21. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/music/score_meta.json +59 -0
  22. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/score.json +235 -0
  23. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/stills/styleframe.jpg +0 -0
  24. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/tools/fonts.sh +17 -0
  25. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/tools/subs.py +11 -0
  26. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/tools/words.py +20 -0
  27. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/voices/dur.json +10 -0
  28. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/voices/words.json +213 -0
  29. package/_shared/.tmp-panel-smoke/reel-pipe/style-demo/voices/words_rel.json +56 -0
  30. package/_shared/.tmp-panel-smoke/reel-pipe/style-ref.json +5 -0
  31. package/_shared/.tmp-panel-smoke/reel-pipe2/film/index.html +7 -0
  32. package/_shared/.tmp-panel-smoke/reel-pipe2/film/main.js +68 -0
  33. package/_shared/.tmp-panel-smoke/reel-pipe2/film/panel-beats.json +20 -0
  34. package/_shared/.tmp-panel-smoke/reel-pipe2/out/video.mp4 +0 -0
  35. package/_shared/.tmp-panel-smoke/reel-pipe2/panel-delivery.json +8 -0
  36. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/CREDITS +20 -0
  37. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/build.sh +17 -0
  38. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/ease.js +43 -0
  39. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/events.json +1 -0
  40. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/film.js +533 -0
  41. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/fonts/OFL-Archivo.txt +93 -0
  42. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/fonts/OFL-DMSerifDisplay.txt +93 -0
  43. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/fonts/OFL-UnifrakturMaguntia.txt +94 -0
  44. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/fonts/fonts.css +3 -0
  45. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/index.html +6 -0
  46. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/lines.json +10 -0
  47. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/main.js +15 -0
  48. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/mix.py +116 -0
  49. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/music/score.py +168 -0
  50. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/music/score_meta.json +59 -0
  51. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/score.json +235 -0
  52. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/stills/styleframe.jpg +0 -0
  53. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/tools/fonts.sh +17 -0
  54. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/tools/subs.py +11 -0
  55. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/tools/words.py +20 -0
  56. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/voices/dur.json +10 -0
  57. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/voices/words.json +213 -0
  58. package/_shared/.tmp-panel-smoke/reel-pipe2/style-demo/voices/words_rel.json +56 -0
  59. package/_shared/.tmp-panel-smoke/reel-pipe2/style-ref.json +5 -0
  60. package/_shared/.tmp-panel-smoke/remo-pipe/brief.md +2 -0
  61. package/_shared/.tmp-panel-smoke/remo-pipe/remo-job.json +4 -0
  62. package/_shared/.tmp-panel-smoke/remo-pipe2/brief.md +1 -0
  63. package/_shared/.tmp-panel-smoke/remo-pipe2/out/final.mp4 +0 -0
  64. package/_shared/.tmp-panel-smoke/remo-pipe2/panel-delivery.json +8 -0
  65. package/_shared/.tmp-panel-smoke/remo-pipe2/remo-job.json +4 -0
  66. package/_shared/.tmp-panel-smoke/vibe-pipe-ok/ep00-demo.mp4 +0 -0
  67. package/_shared/.tmp-panel-smoke/vibe-pipe-ok/out/ep00-demo.mp4 +0 -0
  68. package/_shared/.tmp-panel-smoke/vibe-pipe-ok/panel-delivery.json +7 -0
  69. package/_shared/.tmp-panel-smoke/vibe-pipe-ok/publish.json +10 -0
  70. package/_shared/.tmp-panel-smoke/vibe-still.jpg +0 -0
  71. package/_shared/.tmp-panel-smoke/vibe-still.log +6 -0
  72. package/_shared/.tmp-panel-smoke/vibe-still.log.err +0 -0
  73. package/_shared/.tmp-panel-smoke/vibe-still2.log +26 -0
  74. package/_shared/.tmp-panel-smoke/vibe-still2.log.err +0 -0
  75. package/_shared/lib/film-locate.mjs +203 -0
  76. package/_shared/lib/voice-catalog.mjs +127 -0
  77. package/_shared/scripts/apply-upload-limits.mjs +62 -0
  78. package/_shared/scripts/patch-film-hosts.mjs +233 -0
  79. package/_shared/scripts/patch-voice-options.mjs +41 -0
  80. package/_shared/scripts/sync-local-agents.mjs +67 -0
  81. package/_shared/scripts/wire-film-bridge.mjs +24 -0
  82. package/_shared/scripts/wire-voice-plus.mjs +68 -0
  83. package/_shared/studio/assert-panel-permit.mjs +67 -0
  84. package/_shared/studio/composer.css +559 -0
  85. package/_shared/studio/composer.js +728 -0
  86. package/_shared/studio/optimize-prompt.mjs +84 -0
  87. package/_shared/studio/optimize-prompt.test.mjs +47 -0
  88. package/_shared/studio/recipes.mjs +87 -0
  89. package/_shared/studio/select-menu.js +450 -0
  90. package/_shared/studio/to-english-prompt.mjs +165 -0
  91. package/_shared/studio/to-english-prompt.test.mjs +72 -0
  92. package/bin/server.js +22 -22
  93. package/data/looks.json +8 -0
  94. package/lib/film-bridge.mjs +1 -0
  95. package/lib/host.mjs +131 -264
  96. package/lib/voice-bridge.mjs +2 -0
  97. package/manifest.json +4 -3
  98. package/package.json +1 -1
  99. package/skills/biutalk/EXEC.md +69 -0
  100. package/skills/biutalk/SKILL.md +12 -10
  101. package/skills/biutalk/scripts/doctor.mjs +124 -0
  102. package/skills/biutalk/scripts/qc.mjs +129 -0
  103. package/skills/biutalk/scripts/scaffold.mjs +205 -0
  104. package/studio/app.js +16 -1
  105. package/studio/composer.css +94 -0
  106. package/studio/composer.js +257 -9
  107. package/studio/index.html +5 -1
  108. package/studio/to-english-prompt.mjs +16 -0
package/lib/host.mjs CHANGED
@@ -10,6 +10,8 @@ import { fileURLToPath } from 'node:url';
10
10
  import { spawn } from 'node:child_process';
11
11
  import crypto from 'node:crypto';
12
12
  import { optimizePrompt } from '../studio/optimize-prompt.mjs';
13
+ import { isIntermediateMp4, rescueMissingFilm, findLatestMp4, locateFilm, locateJobFilm, chooseDeliverableFilm, filmHitFields } from './film-bridge.mjs';
14
+ import { buildVoiceOptionsFromEnv } from './voice-bridge.mjs';
13
15
 
14
16
  export function env() {
15
17
  return {
@@ -100,13 +102,13 @@ export async function readBody(req, limit = 32 * 1024 * 1024) {
100
102
  }
101
103
 
102
104
  export async function readJsonBody(req) {
103
- // 20MB 原文件 base64 后约 27MB,留余量给文案和字段
105
+ // 本地上传:视频≤200MB base64 后约 267MB;合计≤250MB,JSON body 放宽到 300MB
104
106
  let buf;
105
107
  try {
106
- buf = await readBody(req, 30 * 1024 * 1024);
108
+ buf = await readBody(req, 300 * 1024 * 1024);
107
109
  } catch (error) {
108
110
  if (error.status === 413) {
109
- throw Object.assign(new Error('附件超过 20MB,请压缩或裁短后再上传'), { status: 413 });
111
+ throw Object.assign(new Error('附件过大:图文/PDF≤50MB,音频≤100MB,视频≤200MB,合计≤250MB'), { status: 413 });
110
112
  }
111
113
  throw error;
112
114
  }
@@ -251,6 +253,19 @@ export async function reportProgress(cfg, payload) {
251
253
  }
252
254
  }
253
255
 
256
+ /** 面板重载后会签发新 taskId,必须回填,避免后续进度再次创建镜像任务。 */
257
+ export async function reportJobProgress(cfg, jobs, jobId, payload) {
258
+ const result = await reportProgress(cfg, {
259
+ ...payload,
260
+ taskId: jobs.get(jobId)?.panelTaskId,
261
+ });
262
+ const taskId = String(result?.taskId || '').trim();
263
+ if (taskId && taskId !== jobs.get(jobId)?.panelTaskId) {
264
+ jobs.update(jobId, { panelTaskId: taskId });
265
+ }
266
+ return result;
267
+ }
268
+
254
269
  /** Ask panel host to open a DSH conversation with this Agent's skill + prompt. */
255
270
  export async function requestKickoff(cfg, payload) {
256
271
  if (!cfg.callbackUrl || !cfg.callbackToken) return null;
@@ -294,238 +309,84 @@ export async function requestRunPermit(cfg, { projectPath, jobId }) {
294
309
 
295
310
  /** Seed packaged skill into project so cwd-local DSH discovery finds it. */
296
311
  export function seedSkillIntoProject(projectDir, packageRoot, skillId) {
297
- const src = path.join(packageRoot, 'skills', skillId, 'SKILL.md');
298
- if (!projectDir || !fs.existsSync(src)) return null;
312
+ const src = path.join(packageRoot, 'skills', skillId);
313
+ if (!projectDir || !fs.existsSync(path.join(src, 'SKILL.md'))) return null;
299
314
  const destDir = ensureDir(path.join(projectDir, '.agents', 'skills', skillId));
300
- const dest = path.join(destDir, 'SKILL.md');
301
- fs.copyFileSync(src, dest);
302
- return dest;
315
+ // 整个 skill 目录一起播种:EXEC.md 与 scripts 才能被项目内 Agent 直接调用
316
+ fs.cpSync(src, destDir, { recursive: true, force: true });
317
+ return path.join(destDir, 'SKILL.md');
303
318
  }
304
319
 
305
320
  /** explainroo 的成片是 out/video.mp4。build/segments/seg-05.mp4 和 draft 渲完会删,不能当成片。 */
306
- export function isIntermediateMp4(filePath) {
307
- const base = path.basename(String(filePath || '')).toLowerCase();
308
- if (/^seg[-_]\d+\.mp4$/.test(base)) return true;
309
- if (/^draft([-.]|$)/.test(base)) return true;
310
- const parts = String(filePath || '').split(/[/\\]/).map((part) => part.toLowerCase());
311
- return parts.includes('build') || parts.includes('segments');
312
- }
313
321
 
314
- /** 记录里的文件被删掉或改名时,在同一目录找「原名开头」的现片。 */
315
- export function rescueMissingFilm(filePath) {
316
- const file = String(filePath || '');
317
- if (!file) return '';
318
- if (fs.existsSync(file) && !isIntermediateMp4(file)) return file;
319
- const dir = path.dirname(file);
320
- if (!fs.existsSync(dir)) return '';
321
- const stem = path.basename(file, path.extname(file)).toLowerCase();
322
- if (!stem) return '';
323
- let best = null;
324
- let names = [];
325
- try { names = fs.readdirSync(dir); } catch { return ''; }
326
- for (const name of names) {
327
- if (!name.toLowerCase().endsWith('.mp4')) continue;
328
- if (!name.toLowerCase().startsWith(stem)) continue;
329
- const full = path.join(dir, name);
330
- if (isIntermediateMp4(full)) continue;
331
- let st;
332
- try { st = fs.statSync(full); } catch { continue; }
333
- if (!st.isFile()) continue;
334
- if (!best || st.mtimeMs > best.mtimeMs) best = { path: full, mtimeMs: st.mtimeMs, size: st.size };
335
- }
336
- return best ? best.path : '';
337
- }
322
+ export { isIntermediateMp4, rescueMissingFilm, findLatestMp4, locateFilm, locateJobFilm, chooseDeliverableFilm, filmHitFields };
338
323
 
339
- function collectMp4(rootDir, maxDepth) {
340
- const found = [];
341
- if (!rootDir || !fs.existsSync(rootDir)) return found;
342
- const walk = (dir, depth) => {
343
- if (depth > maxDepth) return;
344
- let entries;
345
- try {
346
- entries = fs.readdirSync(dir, { withFileTypes: true });
347
- } catch {
348
- return;
349
- }
350
- for (const ent of entries) {
351
- if (ent.name === 'node_modules' || ent.name === '.git' || ent.name === '.venv') continue;
352
- const full = path.join(dir, ent.name);
353
- if (ent.isDirectory()) walk(full, depth + 1);
354
- else if (ent.isFile() && /\.mp4$/i.test(ent.name)) {
355
- try {
356
- const st = fs.statSync(full);
357
- found.push({ path: full, mtime: st.mtimeMs, size: st.size });
358
- } catch {
359
- /* skip */
360
- }
361
- }
362
- }
363
- };
364
- walk(rootDir, 0);
365
- return found;
366
- }
367
-
368
- function pickFilm(found) {
369
- if (!found.length) return null;
370
- found.sort((a, b) => {
371
- const ai = isIntermediateMp4(a.path) ? 1 : 0;
372
- const bi = isIntermediateMp4(b.path) ? 1 : 0;
373
- if (ai !== bi) return ai - bi;
374
- return b.mtime - a.mtime;
375
- });
376
- const best = found[0];
377
- if (!best || isIntermediateMp4(best.path)) return null;
378
- return best;
379
- }
380
-
381
- /** Newest deliverable MP4. Root-level `<name>.mp4` wins over `out/video.mp4`. */
382
- export function findLatestMp4(rootDir, { maxDepth = 6, sinceMs = 0 } = {}) {
383
- const since = Number(sinceMs) || 0;
384
- const found = collectMp4(rootDir, maxDepth).filter((hit) => !since || hit.mtime >= since);
385
- return pickFilm(found);
386
- }
387
-
388
- /** roots: directory string, or { dir, sinceMs, maxDepth }. */
389
- export function locateFilm(roots) {
390
- const found = [];
391
- for (const root of roots || []) {
392
- const dir = typeof root === 'string' ? root : root?.dir;
393
- const sinceMs = typeof root === 'string' ? 0 : Number(root?.sinceMs) || 0;
394
- const maxDepth = typeof root === 'string' ? 6 : root?.maxDepth || 6;
395
- found.push(...collectMp4(dir, maxDepth).filter((hit) => !sinceMs || hit.mtime >= sinceMs));
396
- }
397
- return pickFilm(found);
398
- }
399
-
400
- export function locateJobFilm(job, cfg) {
401
- if (!job) return null;
402
- const roots = Array.isArray(job.filmRoots) && job.filmRoots.length
403
- ? [...job.filmRoots]
404
- : [];
405
- const dir = job.projectPath || (job.artifact && !String(job.artifact).toLowerCase().endsWith('.mp4') ? job.artifact : '');
406
- if (dir && !roots.some((root) => (typeof root === 'string' ? root : root?.dir) === dir)) {
407
- roots.unshift({ dir, sinceMs: 0 });
408
- }
409
- const sinceMs = Date.parse(job.createdAt);
410
- if (cfg?.engineRoot && Number.isFinite(sinceMs)) {
411
- const engineFilms = path.join(cfg.engineRoot, 'films');
412
- if (!roots.some((root) => (typeof root === 'string' ? root : root?.dir) === engineFilms)) {
413
- roots.push({ dir: engineFilms, sinceMs });
414
- }
415
- }
416
- return locateFilm(roots);
417
- }
418
-
419
- /** Poll until an MP4 appears; updates job + panel progress. */
324
+ /** 监视成片:支持改名 / 二次生成;首次就绪后仍短时跟踪更新的文件。 */
420
325
  export function watchForFilm(cfg, jobs, jobId, {
421
326
  projectPath,
422
327
  title,
423
328
  intervalMs = 4000,
424
329
  timeoutMs = 2 * 60 * 60 * 1000,
330
+ followNewerMs = 20 * 60 * 1000,
425
331
  } = {}) {
426
332
  const started = Date.now();
333
+ let firstReadyAt = 0;
334
+ const adopt = async (hit) => {
335
+ if (!hit?.path) return false;
336
+ const job = jobs.get(jobId);
337
+ if (!job) return false;
338
+ if (job.outputMp4 === hit.path && job.status === 'done' && job.phase === 'film') return true;
339
+ const fields = filmHitFields(hit);
340
+ jobs.update(jobId, fields);
341
+ await reportJobProgress(cfg, jobs, jobId, {
342
+ title: title || jobs.get(jobId)?.title,
343
+ progress: 100,
344
+ message: fields.message,
345
+ done: true,
346
+ artifact: hit.path,
347
+ });
348
+ if (!firstReadyAt) firstReadyAt = Date.now();
349
+ return true;
350
+ };
427
351
  const tick = async () => {
428
352
  const job = jobs.get(jobId);
429
353
  if (!job || job.status === 'failed' || job.status === 'cancelled') return;
430
- const current = String(job.outputMp4 || '');
431
- if (current && fs.existsSync(current) && !isIntermediateMp4(current)) return;
432
- if (current && !fs.existsSync(current)) {
433
- const rescued = rescueMissingFilm(current);
434
- if (rescued) {
435
- const message = `成片已就绪 · ${path.basename(rescued)}`;
436
- const size = fs.statSync(rescued).size;
437
- jobs.update(jobId, {
438
- status: 'done',
439
- progress: 100,
440
- phase: 'film',
441
- message,
442
- outputMp4: rescued,
443
- artifact: rescued,
444
- filmBytes: size,
445
- filmAt: new Date().toISOString(),
446
- });
447
- await reportProgress(cfg, {
448
- taskId: jobs.get(jobId)?.panelTaskId,
449
- title: title || jobs.get(jobId)?.title,
450
- progress: 100,
451
- message,
452
- done: true,
453
- artifact: rescued,
454
- });
354
+ const probe = { ...job, projectPath: projectPath || job.projectPath, artifact: job.artifact };
355
+ const hit = chooseDeliverableFilm(probe, cfg);
356
+ if (hit) {
357
+ const changed = hit.path !== String(job.outputMp4 || '');
358
+ await adopt(hit);
359
+ const followUntil = (firstReadyAt || Date.now()) + followNewerMs;
360
+ if (Date.now() < followUntil || changed) {
361
+ setTimeout(() => void tick(), intervalMs);
455
362
  return;
456
363
  }
364
+ return;
457
365
  }
458
- const hit = locateJobFilm({ ...job, projectPath: projectPath || job.projectPath, artifact: job.artifact }, cfg);
459
- if (hit && !isIntermediateMp4(hit.path)) {
460
- const message = `成片已就绪 · ${path.basename(hit.path)}`;
366
+ if (Date.now() - started > timeoutMs) {
461
367
  jobs.update(jobId, {
462
368
  status: 'done',
463
369
  progress: 100,
464
- phase: 'film',
465
- message,
466
- outputMp4: hit.path,
467
- artifact: hit.path,
468
- filmBytes: hit.size,
469
- filmAt: new Date().toISOString(),
370
+ phase: 'stalled',
371
+ message: '等待成片超时 · 可打开工程目录或 DSH 会话查看',
470
372
  });
471
- await reportProgress(cfg, {
472
- taskId: jobs.get(jobId)?.panelTaskId,
473
- title: title || jobs.get(jobId)?.title,
373
+ await reportJobProgress(cfg, jobs, jobId, {
474
374
  progress: 100,
475
- message,
375
+ message: '等待成片超时',
476
376
  done: true,
477
- artifact: hit.path,
377
+ artifact: projectPath || job.projectPath,
478
378
  });
479
379
  return;
480
380
  }
481
- if (Date.now() - started > timeoutMs) {
482
- if (hit) {
483
- const message = `成片已就绪 · ${path.basename(hit.path)}`;
484
- jobs.update(jobId, {
485
- status: 'done',
486
- progress: 100,
487
- phase: 'film',
488
- message,
489
- outputMp4: hit.path,
490
- artifact: hit.path,
491
- filmBytes: hit.size,
492
- filmAt: new Date().toISOString(),
493
- });
494
- await reportProgress(cfg, {
495
- taskId: jobs.get(jobId)?.panelTaskId,
496
- title: title || jobs.get(jobId)?.title,
497
- progress: 100,
498
- message,
499
- done: true,
500
- artifact: hit.path,
501
- });
502
- } else {
503
- jobs.update(jobId, {
504
- status: 'done',
505
- progress: 100,
506
- phase: 'stalled',
507
- message: '等待成片超时 · 可打开工程目录或 DSH 会话查看',
508
- });
509
- await reportProgress(cfg, {
510
- taskId: jobs.get(jobId)?.panelTaskId,
511
- progress: 100,
512
- message: '等待成片超时',
513
- done: true,
514
- artifact: projectPath,
515
- });
516
- }
517
- return;
518
- }
519
- if (job.status === 'running' || job.phase === 'dsh') {
381
+ if (job.status === 'running' || job.phase === 'dsh' || job.phase === 'inpanel') {
520
382
  jobs.update(jobId, {
521
- phase: 'dsh',
383
+ phase: job.phase === 'inpanel' ? 'inpanel' : 'dsh',
522
384
  message: job.kickoffOk === false
523
385
  ? (job.message || '等待手动开拍 / 成片')
524
- : 'DSH 创作中 · 完成后将自动显示成片路径',
386
+ : (job.message && String(job.message).includes('面板') ? job.message : '创作中 · 完成后将自动显示成片'),
525
387
  progress: Math.min(90, Math.max(Number(job.progress) || 50, 50)),
526
388
  });
527
- await reportProgress(cfg, {
528
- taskId: jobs.get(jobId)?.panelTaskId,
389
+ await reportJobProgress(cfg, jobs, jobId, {
529
390
  progress: jobs.get(jobId)?.progress ?? 55,
530
391
  message: jobs.get(jobId)?.message,
531
392
  });
@@ -576,54 +437,33 @@ export function createAgentServer({ root, studioDir, api }) {
576
437
  const jobs = new JobStore(cfg.workspace);
577
438
  const studio = studioDir || path.join(root, 'studio');
578
439
 
579
- // 进程重启后:已有成片则收口;否则恢复 watch,避免面板/Studio 任务永远「处理中」
440
+ // 进程重启后:重扫成片(改名/二次生成/路径失效),否则恢复 watch
580
441
  for (const j of jobs.list()) {
581
- const filmMissing = j.outputMp4 && !fs.existsSync(j.outputMp4);
582
- const filmBad = j.outputMp4 && isIntermediateMp4(j.outputMp4);
583
- if (filmMissing || filmBad || (j.status === 'done' && !j.outputMp4)) {
584
- const rescued = filmMissing ? rescueMissingFilm(j.outputMp4) : '';
585
- const late = rescued
586
- ? { path: rescued, size: fs.statSync(rescued).size }
587
- : locateJobFilm(j, cfg);
588
- if (late && late.path && fs.existsSync(late.path) && !isIntermediateMp4(late.path)) {
589
- jobs.update(j.id, {
590
- status: 'done',
442
+ const hit = chooseDeliverableFilm(j, cfg);
443
+ const missing = j.outputMp4 && !fs.existsSync(j.outputMp4);
444
+ const bad = j.outputMp4 && isIntermediateMp4(j.outputMp4);
445
+ const shouldAdopt = hit && (
446
+ missing || bad || !j.outputMp4 || j.outputMp4 !== hit.path
447
+ || j.status === 'running'
448
+ );
449
+ if (shouldAdopt && hit) {
450
+ const fields = filmHitFields(hit);
451
+ jobs.update(j.id, fields);
452
+ if (j.status === 'running') {
453
+ void reportJobProgress(cfg, jobs, j.id, {
454
+ title: j.title,
591
455
  progress: 100,
592
- phase: 'film',
593
- message: `成片已就绪 · ${path.basename(late.path)}`,
594
- outputMp4: late.path,
595
- artifact: late.path,
596
- filmBytes: late.size,
597
- filmAt: new Date().toISOString(),
456
+ message: fields.message,
457
+ done: true,
458
+ artifact: hit.path,
598
459
  });
599
- continue;
600
460
  }
601
- if (j.status === 'done') continue;
461
+ continue;
602
462
  }
603
463
  const waiting = j.status === 'running' || (j.outputMp4 && isIntermediateMp4(j.outputMp4));
604
464
  if (!waiting) continue;
605
465
  const projectPath = j.projectPath || (j.artifact && !String(j.artifact).endsWith('.mp4') ? j.artifact : null);
606
- const hit = locateJobFilm(j, cfg);
607
- if (hit && !isIntermediateMp4(hit.path)) {
608
- jobs.update(j.id, {
609
- status: 'done',
610
- progress: 100,
611
- phase: 'film',
612
- message: `成片已就绪 · ${path.basename(hit.path)}`,
613
- outputMp4: hit.path,
614
- artifact: hit.path,
615
- filmBytes: hit.size,
616
- filmAt: new Date().toISOString(),
617
- });
618
- void reportProgress(cfg, {
619
- taskId: j.panelTaskId,
620
- title: j.title,
621
- progress: 100,
622
- message: `成片已就绪 · ${path.basename(hit.path)}`,
623
- done: true,
624
- artifact: hit.path,
625
- });
626
- } else if (projectPath && fs.existsSync(projectPath)) {
466
+ if (projectPath && fs.existsSync(projectPath)) {
627
467
  jobs.update(j.id, {
628
468
  phase: 'dsh',
629
469
  message: '进程已恢复 · 继续等待成片',
@@ -637,8 +477,7 @@ export function createAgentServer({ root, studioDir, api }) {
637
477
  message: '进程中断 · 无法恢复监视(工程目录缺失)',
638
478
  progress: Number(j.progress) || 0,
639
479
  });
640
- void reportProgress(cfg, {
641
- taskId: j.panelTaskId,
480
+ void reportJobProgress(cfg, jobs, j.id, {
642
481
  progress: Number(j.progress) || 0,
643
482
  message: '进程中断 · 任务已标记失败',
644
483
  failed: true,
@@ -674,33 +513,37 @@ export function createAgentServer({ root, studioDir, api }) {
674
513
  });
675
514
  }
676
515
 
516
+ if (pathname === '/api/voice-options' && req.method === 'GET') {
517
+ return sendJson(res, 200, buildVoiceOptionsFromEnv(process.env));
518
+ }
519
+
520
+
677
521
  if (pathname === '/api/jobs' && req.method === 'GET') {
678
- return sendJson(res, 200, { jobs: jobs.list().map(fillFromBrief) });
522
+ const list = jobs.list().map((j) => {
523
+ const hit = chooseDeliverableFilm(j, cfg);
524
+ if (hit && (!j.outputMp4 || !fs.existsSync(j.outputMp4) || isIntermediateMp4(j.outputMp4) || hit.path !== j.outputMp4)) {
525
+ jobs.update(j.id, filmHitFields(hit));
526
+ return fillFromBrief(jobs.get(j.id) || j);
527
+ }
528
+ return fillFromBrief(j);
529
+ });
530
+ return sendJson(res, 200, { jobs: list });
679
531
  }
680
532
  if (req.method === 'GET' && /^\/api\/jobs\/[^/]+\/film$/.test(pathname)) {
681
533
  const id = decodeURIComponent(pathname.slice('/api/jobs/'.length, -'/film'.length));
682
534
  const job = jobs.get(id);
683
- let file = job ? String(job.outputMp4 || '') : '';
684
- if (job && (!file || !fs.existsSync(file) || isIntermediateMp4(file))) {
685
- const rescued = file && !fs.existsSync(file) ? rescueMissingFilm(file) : '';
686
- const late = rescued
687
- ? { path: rescued, size: fs.statSync(rescued).size }
688
- : locateJobFilm(job, cfg);
689
- if (late && late.path && fs.existsSync(late.path) && !isIntermediateMp4(late.path)) {
690
- jobs.update(job.id, {
691
- status: 'done',
692
- progress: 100,
693
- phase: 'film',
694
- message: `成片已就绪 · ${path.basename(late.path)}`,
695
- outputMp4: late.path,
696
- artifact: late.path,
697
- filmBytes: late.size,
698
- filmAt: new Date().toISOString(),
699
- });
700
- file = late.path;
535
+ if (!job) return sendJson(res, 404, { error: 'job not found' });
536
+ let file = String(job.outputMp4 || '');
537
+ if (!file || !fs.existsSync(file) || isIntermediateMp4(file)) {
538
+ const hit = chooseDeliverableFilm(job, cfg);
539
+ if (hit) {
540
+ jobs.update(id, filmHitFields(hit));
541
+ file = hit.path;
701
542
  }
702
543
  }
703
- if (!file || !file.toLowerCase().endsWith('.mp4') || !fs.existsSync(file)) return sendJson(res, 404, { error: '成片还没有' });
544
+ if (!file || !file.toLowerCase().endsWith('.mp4') || !fs.existsSync(file)) {
545
+ return sendJson(res, 404, { error: '成片还没有' });
546
+ }
704
547
  return serveLocalFile(req, res, file);
705
548
  }
706
549
  if (pathname.startsWith('/api/jobs/') && req.method === 'GET') {
@@ -716,6 +559,30 @@ export function createAgentServer({ root, studioDir, api }) {
716
559
  return sendJson(res, 200, { ok: true, id });
717
560
  }
718
561
 
562
+
563
+ if (pathname === '/api/panel/run' && req.method === 'POST') {
564
+ try {
565
+ const { startPanelRun } = await import('../_shared/lib/panel-run-route.mjs');
566
+ const body = await readJsonBody(req);
567
+ const result = await startPanelRun({
568
+ cfg,
569
+ jobs,
570
+ packageRoot: root,
571
+ skillId: cfg.agentId,
572
+ body,
573
+ reportProgress,
574
+ reportJobProgress,
575
+ requestRunPermit,
576
+ seedSkillIntoProject,
577
+ ensureDir,
578
+ writeJson,
579
+ });
580
+ sendJson(res, 202, result);
581
+ } catch (error) {
582
+ sendJson(res, error.status || 400, { error: error.message || String(error), code: error.code });
583
+ }
584
+ return;
585
+ }
719
586
  if (pathname === '/api/optimize-prompt' && req.method === 'POST') {
720
587
  if (cfg.member !== true) {
721
588
  sendJson(res, 403, { error: '会员专属,请先开通会员' });
@@ -0,0 +1,2 @@
1
+ export { buildVoiceOptionsFromEnv, FREE_VOICES, VOICE_RATES, normalizeVoicePick, voiceKickoffLine } from '../_shared/lib/voice-catalog.mjs';
2
+
package/manifest.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "schemaVersion": 1,
3
3
  "id": "biutalk",
4
4
  "name": "BiuTalk",
5
- "version": "1.1.7",
5
+ "version": "1.1.8",
6
6
  "publisher": "Biunow",
7
7
  "description": "BiuTalk 解说视频 Studio:模板、尺寸、附件与本地渲染引擎。",
8
8
  "entry": {
@@ -18,6 +18,7 @@
18
18
  "shared": [
19
19
  "ffmpeg@7",
20
20
  "chromium@131",
21
+ "bn-npm@1",
21
22
  "biutalk-npm@1"
22
23
  ]
23
24
  },
@@ -47,8 +48,8 @@
47
48
  "requiresEntitlement": "export"
48
49
  },
49
50
  "integrity": {
50
- "sha256": "f50c7d71ad053a2530edf398c2c035f257e1445046600fc77a32f51e59504c97",
51
- "signature": "9pGkFz2T0NaQTUSGvORVZdqwLdpLPQ580nd2QSR36HND59S27l79+VpoUXHV+6JLF/FzjoiKARvYoe0+IAErCA==",
51
+ "sha256": "e059abe2a9bd9c9cba735468854160d3f8129ae84c57903aa1d23a92e4610e7d",
52
+ "signature": "aEV/nHAgM3C+RzlYJmH29PIrsDMXdhRs/YDfooym6iQbjS8NzYz8dbszEk5sqABCp3vr8kpJtC9Cr00IfQoNAA==",
52
53
  "signedBy": "publisher-key"
53
54
  }
54
55
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@biunow/agent-biutalk",
3
- "version": "1.1.7",
3
+ "version": "1.1.8",
4
4
  "description": "BiuTalk",
5
5
  "license": "UNLICENSED",
6
6
  "publishConfig": {
@@ -0,0 +1,69 @@
1
+ # BiuTalk 执行卡(先读这张)
2
+
3
+ 变量:`SKILL` = 本文件所在目录;`ENGINE` = `brief.json.engineRoot` 或面板 settings.engineRoots.biutalk;成片工程 = 含 `video.json` 的目录(通常是 `videos/<projectSlug>`)。
4
+
5
+ ## 0. 开工前
6
+ - 没有 `run-permit.json` 不许开工;直聊无 permit → `POST /agents/gate/begin` 后停止。
7
+ - `brief.json` 是合同:不追问 intake,不改 title / look / size / pace。
8
+ - 只读:`brief.json`、`PROMPT.md`、`PROJECT_CARD.md`。
9
+ - **禁止整份打开** `ENGINE/AGENTS.md`(71KB)。需要 API 细节时按关键词检索 20–40 行:
10
+ `rg -n "### Text|### Shapes|s\.box|s\.arrow" "$ENGINE/AGENTS.md"`(Windows 用 `Select-String -Context 2,12`)。
11
+ - 一次只写一个文件:先 `script.md`,再 `scenes.js`。
12
+
13
+ ## 1. 预检(必须 ok:true)
14
+ ```bash
15
+ node "$SKILL/scripts/doctor.mjs" --project . --engine "$ENGINE" --json
16
+ ```
17
+ `ok:false` 按 `hint` 修。模型未下载只在首次 `voice` 时联网拉取,不算失败。
18
+
19
+ ## 2. 工程骨架(幂等,只跑一次)
20
+ ```bash
21
+ node "$SKILL/scripts/scaffold.mjs" --project . --engine "$ENGINE" --json
22
+ ```
23
+ 输出 `projectPath`、`mainFile: scenes.js`、`scriptFile: script.md`。已有 `video.json` 不覆盖;重置才加 `--force`。
24
+
25
+ ## 3. 口播稿 script.md(先写,决定全片时长)
26
+ - 每镜 `## scene-id`,id 必须与 `scenes.js` 函数同名;从 `hook / steps / outro` 起步。
27
+ - 每镜 1–3 句、4–15 秒;全片 45–120 秒。中文约 200 字/分钟,英文 150 词/分钟。
28
+ - 短句、口语、只讲事实;不编数字,不用破折号、口号、三段排比。
29
+ - 每个句子至少一个 `[#marker]`,让画面按时切换。
30
+ - 易读错处写成 `{CLI|C L I}`、`{v2.1|version two point one}`、`{example.com|example dot com}`。
31
+ - 场景参数:`## intro {hold=1.5 min=3 transition=wipe}`;`>` 开头的行不朗读。
32
+
33
+ ## 4. 画面 scenes.js(只改这个文件)
34
+ - 一个函数一镜,所有元素给 `at`(秒 / 单词 / `#marker`),需要时给 `out`。
35
+ - 复用模板已有写法;禁止新建渲染器,禁止改引擎 `core/` 或 `video.json` 之外的配置。
36
+ - 布局在 `s.safe` 内:标题 80–110px,标签 40–56px,小字 ≥32px;同屏 ≤6 个元素;每 2–4 秒出现新变化。
37
+ - 常用 API:`s.title / s.subtitle / s.text({size,font,at,out})`、`s.box / s.icon / s.arrow(idA,idB)`、`s.number`、`s.row / s.col / s.grid`。
38
+ - 关键帧优先 `at: 'word'` 或 `at: '#marker'`,不要写死秒数。
39
+
40
+ ## 5. 配音 → 机检(不看图)
41
+ ```bash
42
+ node "$ENGINE/bin/explainroo.js" voice .
43
+ node "$ENGINE/bin/explainroo.js" check . --json
44
+ node "$SKILL/scripts/qc.mjs" --project . --engine "$ENGINE" --json
45
+ ```
46
+ `check` 的 error / warn 必须清零;`qc.ok:false` 只读 `findings[].hint` 修,不要描述图片。
47
+
48
+ 需要人看画面时只生成静帧和接触表,交给用户看:
49
+ ```bash
50
+ node "$ENGINE/bin/explainroo.js" still .
51
+ node "$ENGINE/bin/explainroo.js" sheet .
52
+ ```
53
+
54
+ ## 6. 草稿 → 终版 → 验收
55
+ ```bash
56
+ node "$ENGINE/bin/explainroo.js" render . --draft --workers 6
57
+ node "$SKILL/scripts/qc.mjs" --project . --engine "$ENGINE" --video ./out/draft.mp4 --json
58
+ node "$ENGINE/bin/explainroo.js" render . --workers 6
59
+ node "$ENGINE/bin/explainroo.js" verify . --json
60
+ ```
61
+ `qc.ok:true` 且 `verify` 无 error 才算完成;无音轨、响度偏差、黑帧按 hint 修。
62
+
63
+ ## 7. 交付
64
+ - 成片:`out/video.mp4`(多尺寸为 `out/video-<size>.mp4`),同目录带 `.srt` 和 `.cover.jpg`。
65
+ - 回复只给:路径、时长、分辨率、`qc.ok`、verify 的响度与口播清晰度。不贴渲染日志。
66
+
67
+ ## 硬禁令
68
+ - 不生图、不下载素材、不换主题;不整份读 AGENTS.md;不先渲整片;不加 watermark。
69
+ - 输出最多 20 行。
@@ -1,21 +1,23 @@
1
1
  ---
2
2
  name: biutalk
3
- description: Create narrated explainer videos with the explainroo engine from a BN Panel brief or a user topic. Use when the user opens BiuTalk Studio, mentions explainer/解说视频, or points at a workspace brief.json / READY_FOR_AGENT.md / START_IN_DSH.md.
3
+ description: Create narrated explainer videos with the explainroo engine from a BN Panel brief or a user topic. Use when the user opens BiuTalk Studio, mentions explainer/解说视频, or points at a workspace brief.json / PROMPT.md / START_IN_DSH.md.
4
4
  ---
5
5
 
6
6
  # BiuTalk (BN Panel)
7
7
 
8
- ## 面板授权门(强制)
8
+ ## 授权门(强制)
9
9
 
10
- **禁止**在没有有效 `run-permit.json` 时开造。直聊若无 permit:调用面板 `POST /agents/gate/begin`(`agentId: biutalk`),引导用户去 Studio 立项,然后停止。
10
+ 没有有效 `run-permit.json` 不开造。直聊无 permit:调用 `POST /agents/gate/begin`(`agentId: biutalk`),引导用户去 Studio 立项,然后停止。
11
+ 校验:`node studio/assert-panel-permit.mjs --project <cwd> --agent biutalk`。
11
12
 
12
- 校验:`node studio/assert-panel-permit.mjs --project <cwd> --agent biutalk`,或 `POST …/agents/run-permit/verify`。
13
+ ## 执行卡
13
14
 
14
- ---
15
+ **先读同目录 `EXEC.md`(约 3KB),按它的 7 步走。** 不要整份读 explainroo 的 `AGENTS.md`(71KB);需要 Scene API 细节时按关键词检索 20–40 行。
15
16
 
16
- 与「面板 Studio 立项 → kickoff → explainroo」**同一条创作路径**。面板 CreateDesk 单卡立项(需求、Look 模板、尺寸、附件);**不要另造渲染捷径,不要改 explainroo 内核**。
17
+ 固定路径:
18
+ - 预检 `node "$SKILL/scripts/doctor.mjs" --project . --engine "$ENGINE" --json`
19
+ - 骨架 `node "$SKILL/scripts/scaffold.mjs" --project . --engine "$ENGINE" --json`
20
+ - 机检 `node "$SKILL/scripts/qc.mjs" --project . --engine "$ENGINE" [--video ./out/video.mp4] --json`
21
+ - 引擎 CLI 永远用 `node "$ENGINE/bin/explainroo.js" <cmd>`。
17
22
 
18
- 1. 确认 cwd 有有效 permit;优先使用 `PANEL_WORKSPACE/projects/<jobId>/`。
19
- 2. 若已有 `ENGINE_ROOT`(explainroo),严格按该仓库 `AGENTS.md`:`script.md` → `scenes.js` → `voice` → `check` → `render`。
20
- 3. 尊重 brief:`look`、`size`、`pace`、`prompt`、`urls`、上传素材。
21
- 4. 不编造事实。完成后告知用户 MP4 路径(通常在 `out/`)。
23
+ `brief.json` 是合同:不追问 intake,不改 look / size / pace / title。只改 `script.md` 和 `scenes.js`,不上生图,不加 watermark。完成后只回复成片路径、时长、分辨率、`qc.ok`。