@zenaigc/zenmcp 0.0.0-stage → 0.1.0

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 (64) hide show
  1. package/README.md +53 -2
  2. package/dist/src/acquire/download.js +152 -0
  3. package/dist/src/acquire/errors.js +8 -0
  4. package/dist/src/acquire/share.js +67 -0
  5. package/dist/src/acquire/social.js +98 -0
  6. package/dist/src/acquire/trim.js +95 -0
  7. package/dist/src/assets/files.js +29 -0
  8. package/dist/src/assets/generator.js +141 -0
  9. package/dist/src/assets/images.js +90 -0
  10. package/dist/src/assets/index.js +3 -0
  11. package/dist/src/assets/model-library.js +87 -0
  12. package/dist/src/assets/upload-cache.js +36 -0
  13. package/dist/src/contract/cloud-v1.js +334 -0
  14. package/dist/src/core/hash.js +18 -0
  15. package/dist/src/core/index.js +4 -0
  16. package/dist/src/core/job-store.js +251 -0
  17. package/dist/src/core/safety.js +43 -0
  18. package/dist/src/core/schema.js +295 -0
  19. package/dist/src/doctor.js +22 -0
  20. package/dist/src/effects/check.js +19 -0
  21. package/dist/src/effects/font.js +78 -0
  22. package/dist/src/effects/index.js +188 -0
  23. package/dist/src/engine/card.js +50 -0
  24. package/dist/src/engine/direct.js +493 -0
  25. package/dist/src/engine/generate.js +234 -0
  26. package/dist/src/engine/index.js +3 -0
  27. package/dist/src/engine/media.js +24 -0
  28. package/dist/src/engine/steps.js +444 -0
  29. package/dist/src/engine/storage.js +90 -0
  30. package/dist/src/gateway/attempt-store.js +110 -0
  31. package/dist/src/gateway/budget.js +39 -0
  32. package/dist/src/gateway/cloud-gateway.js +141 -0
  33. package/dist/src/gateway/config.js +10 -0
  34. package/dist/src/gateway/device-auth.js +53 -0
  35. package/dist/src/gateway/errors.js +105 -0
  36. package/dist/src/gateway/http.js +124 -0
  37. package/dist/src/gateway/index.js +8 -0
  38. package/dist/src/gateway/paid-runner.js +376 -0
  39. package/dist/src/gateway/types.js +42 -0
  40. package/dist/src/inspect/index.js +276 -0
  41. package/dist/src/inspect/media.js +43 -0
  42. package/dist/src/mcp/server.js +178 -0
  43. package/dist/src/models/wan3/index.js +173 -0
  44. package/dist/src/models/wan3/limits.js +25 -0
  45. package/dist/src/timeline/conform.js +255 -0
  46. package/dist/src/timeline/cuts.js +225 -0
  47. package/dist/src/timeline/diff.js +82 -0
  48. package/dist/src/timeline/errors.js +8 -0
  49. package/dist/src/timeline/ffmpeg.js +164 -0
  50. package/dist/src/timeline/index.js +6 -0
  51. package/dist/src/timeline/params.js +46 -0
  52. package/dist/src/timeline/probe.js +98 -0
  53. package/dist/src/timeline/types.js +1 -0
  54. package/dist/templates/pop-title/README.md +18 -0
  55. package/dist/templates/pop-title/index.html +102 -0
  56. package/dist/templates/pop-title/pop-title.js +97 -0
  57. package/dist/templates/pop-title/render.js +42 -0
  58. package/dist/templates/pop-title/size-1080/index.html +102 -0
  59. package/dist/templates/pop-title/variables.example.json +9 -0
  60. package/dist/templates/pop-title/vendor/FONT.md +10 -0
  61. package/dist/templates/pop-title/vendor/NotoSansCJKsc-Bold.otf +0 -0
  62. package/dist/templates/pop-title/vendor/OFL.txt +92 -0
  63. package/dist/templates/pop-title/vendor/gsap.min.js +11 -0
  64. package/package.json +33 -4
@@ -0,0 +1,78 @@
1
+ /** Table offsets in the bundled OpenType font, never a system font. */
2
+ function tableOffset(font, tag) {
3
+ for (let i = 0; i < font.readUInt16BE(4); i++) {
4
+ const record = 12 + i * 16;
5
+ if (font.toString('ascii', record, record + 4) === tag)
6
+ return font.readUInt32BE(record + 8);
7
+ }
8
+ throw new Error(`font_${tag}_missing`);
9
+ }
10
+ function glyphLookup(font) {
11
+ const cmap = tableOffset(font, 'cmap');
12
+ const tables = [];
13
+ for (let i = 0; i < font.readUInt16BE(cmap + 2); i++) {
14
+ const record = cmap + 4 + i * 8;
15
+ const platform = font.readUInt16BE(record);
16
+ const encoding = font.readUInt16BE(record + 2);
17
+ if (platform === 0 || (platform === 3 && (encoding === 1 || encoding === 10))) {
18
+ tables.push(cmap + font.readUInt32BE(record + 4));
19
+ }
20
+ }
21
+ return (code) => {
22
+ for (const offset of tables) {
23
+ const format = font.readUInt16BE(offset);
24
+ if (format === 12) {
25
+ for (let i = 0; i < font.readUInt32BE(offset + 12); i++) {
26
+ const p = offset + 16 + i * 12;
27
+ const start = font.readUInt32BE(p);
28
+ if (code >= start && code <= font.readUInt32BE(p + 4)) {
29
+ const glyph = font.readUInt32BE(p + 8) + code - start;
30
+ if (glyph)
31
+ return glyph;
32
+ }
33
+ }
34
+ }
35
+ if (format === 4 && code <= 0xffff) {
36
+ const count = font.readUInt16BE(offset + 6) / 2;
37
+ for (let i = 0; i < count; i++) {
38
+ const end = font.readUInt16BE(offset + 14 + i * 2);
39
+ const start = font.readUInt16BE(offset + 16 + count * 2 + i * 2);
40
+ if (code < start || code > end)
41
+ continue;
42
+ const delta = font.readInt16BE(offset + 16 + count * 4 + i * 2);
43
+ const rangePos = offset + 16 + count * 6 + i * 2;
44
+ const range = font.readUInt16BE(rangePos);
45
+ if (range === 0) {
46
+ const glyph = (code + delta) & 0xffff;
47
+ if (glyph)
48
+ return glyph;
49
+ continue;
50
+ }
51
+ const glyph = font.readUInt16BE(rangePos + range + (code - start) * 2);
52
+ const mapped = (glyph + delta) & 0xffff;
53
+ if (glyph !== 0 && mapped !== 0)
54
+ return mapped;
55
+ }
56
+ }
57
+ }
58
+ return 0;
59
+ };
60
+ }
61
+ /** Read Unicode cmap entries from the bundled font. */
62
+ export function assertFontCoverage(font, text) {
63
+ const glyphId = glyphLookup(font);
64
+ const missing = [...new Set(Array.from(text))].filter(ch => !glyphId(ch.codePointAt(0)));
65
+ if (missing.length)
66
+ throw new Error(`missing_glyph: ${missing.map(ch => `${ch} (U+${ch.codePointAt(0).toString(16).toUpperCase()})`).join(', ')}`);
67
+ }
68
+ /** Sum advances for individually rendered glyph spans (no cross-span shaping). */
69
+ export function advanceWidthEm(font, text) {
70
+ const glyphId = glyphLookup(font);
71
+ const unitsPerEm = font.readUInt16BE(tableOffset(font, 'head') + 18);
72
+ const numberOfHMetrics = font.readUInt16BE(tableOffset(font, 'hhea') + 34);
73
+ const hmtx = tableOffset(font, 'hmtx');
74
+ return Array.from(text).reduce((sum, ch) => {
75
+ const metric = Math.min(glyphId(ch.codePointAt(0)), numberOfHMetrics - 1);
76
+ return sum + font.readUInt16BE(hmtx + metric * 4) / unitsPerEm;
77
+ }, 0);
78
+ }
@@ -0,0 +1,188 @@
1
+ import { execFile } from 'node:child_process';
2
+ import { promisify } from 'node:util';
3
+ import { createRequire } from 'node:module';
4
+ import { dirname, join, resolve } from 'node:path';
5
+ import { fileURLToPath } from 'node:url';
6
+ import { access, copyFile, cp, mkdir, mkdtemp, readFile, rm, writeFile, rename } from 'node:fs/promises';
7
+ import { parseJob, cutsOf, effectSchema, sha256String } from '../core/index.js';
8
+ import { probe } from '../timeline/index.js';
9
+ import { assertFontCoverage, advanceWidthEm } from './font.js';
10
+ import { validateCheck } from './check.js';
11
+ const exec = promisify(execFile);
12
+ const FONT_SIZE_RATIO = 0.092;
13
+ const template = fileURLToPath(new URL('../../templates/pop-title/', import.meta.url));
14
+ const cli = join(dirname(createRequire(import.meta.url).resolve('hyperframes/package.json')), 'bin/hyperframes.mjs');
15
+ const SAFE_ENV_KEYS = [
16
+ 'PATH', 'HOME', 'TMPDIR', 'TEMP', 'TMP', 'USER', 'LOGNAME', 'LANG', 'LC_ALL', 'LC_CTYPE',
17
+ 'DISPLAY', 'XDG_CONFIG_HOME', 'XDG_CACHE_HOME', 'XDG_RUNTIME_DIR',
18
+ 'SYSTEMROOT', 'SYSTEMDRIVE', 'WINDIR', 'LOCALAPPDATA', 'APPDATA', 'PROGRAMFILES', 'PROGRAMFILES(X86)', 'COMMONPROGRAMFILES',
19
+ 'CHROME_PATH', 'PUPPETEER_EXECUTABLE_PATH', 'FONTCONFIG_FILE', 'FONTCONFIG_PATH',
20
+ ];
21
+ /** Pass only OS/runtime locator variables to child processes; never forward ZENMCP_TOKEN or arbitrary env secrets. */
22
+ export function childEnv(source = process.env) {
23
+ const picked = {
24
+ HYPERFRAMES_NO_TELEMETRY: '1',
25
+ HYPERFRAMES_NO_UPDATE_CHECK: '1',
26
+ HYPERFRAMES_SKIP_SKILLS: '1',
27
+ HYPERFRAMES_AGENT: '1',
28
+ };
29
+ for (const key of SAFE_ENV_KEYS) {
30
+ if (source[key] !== undefined)
31
+ picked[key] = source[key];
32
+ }
33
+ return picked;
34
+ }
35
+ async function hyperframes(args, allowFailure = false) {
36
+ try {
37
+ return (await exec(process.execPath, [cli, ...args], { env: childEnv(), maxBuffer: 16 * 1024 * 1024, timeout: 180_000 })).stdout;
38
+ }
39
+ catch (error) {
40
+ const e = error;
41
+ if (allowFailure && typeof e.code === 'number' && e.stdout?.trim())
42
+ return e.stdout;
43
+ throw new Error(`hyperframes_failed: ${e.message}\n${e.stdout ?? ''}\n${e.stderr ?? ''}`);
44
+ }
45
+ }
46
+ /** Doctor keeps its numeric exit verdict alongside diagnostics; crashes fail closed. */
47
+ async function doctorRuntime() {
48
+ try {
49
+ const { stdout } = await exec(process.execPath, [cli, 'doctor', '--json'], { env: childEnv(), maxBuffer: 16 * 1024 * 1024, timeout: 180_000 });
50
+ return { stdout, code: 0 };
51
+ }
52
+ catch (error) {
53
+ const e = error;
54
+ if (typeof e.code === 'number' && Number.isInteger(e.code) && !e.signal && !e.killed && typeof e.stdout === 'string') {
55
+ return { stdout: e.stdout, code: e.code };
56
+ }
57
+ return { stdout: '', code: null };
58
+ }
59
+ }
60
+ const runtimeNames = ['Chrome', 'FFmpeg', 'FFprobe'];
61
+ /** Read only required check names; never expose doctor details or paths. */
62
+ export function runtimeIssues(doctorJson, exitCode = 0) {
63
+ try {
64
+ const doctor = JSON.parse(doctorJson);
65
+ const checks = doctor && typeof doctor === 'object' && 'checks' in doctor ? doctor.checks : undefined;
66
+ if (!Array.isArray(checks))
67
+ return [...runtimeNames];
68
+ const failed = runtimeNames.filter(name => {
69
+ const matches = checks.filter(check => check && typeof check === 'object' && check.name === name);
70
+ return matches.length !== 1 || matches[0].ok !== true;
71
+ });
72
+ return exitCode !== 0 && !failed.length ? [...runtimeNames] : failed;
73
+ }
74
+ catch {
75
+ return [...runtimeNames];
76
+ }
77
+ }
78
+ export async function checkEffectsRuntime() {
79
+ const doctor = await doctorRuntime();
80
+ const issues = doctor.code === null ? [...runtimeNames] : runtimeIssues(doctor.stdout, doctor.code);
81
+ const checks = runtimeNames.map(name => ({ name, ok: !issues.includes(name) }));
82
+ for (const name of ['render.js', 'vendor/NotoSansCJKsc-Bold.otf']) {
83
+ const ok = await access(join(template, name)).then(() => true, () => false);
84
+ checks.push({ name, ok });
85
+ }
86
+ return checks;
87
+ }
88
+ /** Bind one immutable Job to the frozen engine renderer interface. */
89
+ export class PopTitleRenderer {
90
+ version;
91
+ job;
92
+ constructor(job) {
93
+ this.job = parseJob(structuredClone(job));
94
+ // Engine hashes the version: include the bound timeline/canvas as well.
95
+ this.version = `pop-title-v2/hyperframes-0.9.16/${sha256String(JSON.stringify(this.job.storyboard))}`;
96
+ }
97
+ async checkRuntime() {
98
+ const failed = (await checkEffectsRuntime()).filter(check => !check.ok).map(check => check.name);
99
+ if (failed.length)
100
+ throw new Error(`effect_runtime_unavailable: ${failed.join(', ')}`);
101
+ }
102
+ async author(layers) {
103
+ const source = this.job.storyboard.source;
104
+ const cuts = [0, ...cutsOf(this.job.storyboard), source.frames];
105
+ const font = await readFile(join(template, 'vendor/NotoSansCJKsc-Bold.otf')).catch(() => { throw new Error('effect_font_unavailable'); });
106
+ return layers.map((input, effect) => {
107
+ const layer = effectSchema.parse(input);
108
+ if (layer.template !== 'pop-title')
109
+ throw new Error(`unsupported_effect_template: ${layer.template}`);
110
+ const start_frame = cuts[layer.start_cut];
111
+ const end_frame = cuts[layer.end_cut];
112
+ if (start_frame === undefined || end_frame === undefined)
113
+ throw new Error('effect_cut_out_of_range');
114
+ const lines = layer.slots.lines;
115
+ if (!Array.isArray(lines) || lines.length < 1 || lines.length > 2 || !lines.every(l => typeof l === 'string' && l.length > 0))
116
+ throw new Error('pop_title_lines: expected one or two nonempty strings');
117
+ if (Object.keys(layer.slots).some(k => k !== 'lines') || Object.keys(layer.assets).length || Object.keys(layer.style).some(k => !['position', 'color'].includes(k)))
118
+ throw new Error('unsupported_pop_title_parameter');
119
+ assertFontCoverage(font, lines.join(''));
120
+ const position = layer.style.position;
121
+ if (position !== undefined && (!position || typeof position !== 'object' || Array.isArray(position) || Object.keys(position).some(k => !['x', 'y'].includes(k))))
122
+ throw new Error('pop_title_position: expected {x, y}');
123
+ const x = position?.x ?? 0.5;
124
+ const y = position?.y ?? 0.52;
125
+ if (typeof x !== 'number' || typeof y !== 'number' || !Number.isFinite(x) || !Number.isFinite(y) || x < 0 || x > 1 || y < 0 || y > 1)
126
+ throw new Error('pop_title_position: expected fractions in 0..1');
127
+ const color = layer.style.color ?? '#ffffff';
128
+ if (typeof color !== 'string' || !/^#[\da-f]{6}$/i.test(color))
129
+ throw new Error('pop_title_color: expected #RRGGBB');
130
+ const size = Math.round(source.width * FONT_SIZE_RATIO);
131
+ // Chrome rounds each inline-block advance to 1/64px. Do not spend check's 2px tolerance.
132
+ const width = Math.max(...lines.map(line => advanceWidthEm(font, line) * size + Array.from(line).length / 64));
133
+ const height = lines.length * Math.ceil(size * 1.08 * 64) / 64;
134
+ // Bundled font Range boxes extend beyond 1.08 line boxes; calibrated at 29/99px.
135
+ // .224em bounds that extension, .04em is half the stroke, shadow adds .08/.1em.
136
+ const left = size * 0.04 + 1;
137
+ const right = size * 0.12 + 1;
138
+ const top = size * (0.224 + 0.04) + 1;
139
+ const bottom = size * (0.224 + 0.14) + 1;
140
+ if (x * source.width - width / 2 < left || (1 - x) * source.width - width / 2 < right ||
141
+ y * source.height - height / 2 < top || (1 - y) * source.height - height / 2 < bottom) {
142
+ throw new Error('pop_title_overflow');
143
+ }
144
+ return { effect, start_frame, end_frame, lines, x, y, color };
145
+ });
146
+ }
147
+ async validate(layers) {
148
+ await this.author(layers);
149
+ }
150
+ async render(base, layers, output) {
151
+ const authored = await this.author(layers);
152
+ const source = this.job.storyboard.source;
153
+ const facts = await probe(base);
154
+ if (facts.frames !== source.frames || facts.fps.num * source.fps.den !== source.fps.num * facts.fps.den)
155
+ throw new Error('effect_base_timeline_mismatch');
156
+ output = resolve(output);
157
+ await mkdir(dirname(output), { recursive: true });
158
+ const work = await mkdtemp(join(dirname(output), '.pop-title-'));
159
+ try {
160
+ await cp(join(template, 'vendor'), join(work, 'vendor'), { recursive: true });
161
+ await copyFile(join(template, 'render.js'), join(work, 'render.js'));
162
+ // Remove audio before HyperFrames sees the asset. The engine owns mixing.
163
+ await exec('ffmpeg', ['-v', 'error', '-y', '-i', resolve(base), '-map', '0:v:0', '-c:v', 'copy', '-an', join(work, 'base.mp4')], { env: childEnv() });
164
+ const fps = source.fps.num / source.fps.den;
165
+ const duration = source.frames / fps;
166
+ const config = JSON.stringify({ fps, duration, layers: authored }).replace(/</g, '\\u003c');
167
+ await writeFile(join(work, 'index.html'), `<!doctype html><html><head><meta charset="utf-8"><script src="vendor/gsap.min.js"></script><style>
168
+ @font-face{font-family:PopTitle;src:url('vendor/NotoSansCJKsc-Bold.otf');font-weight:700}
169
+ html,body{margin:0;background:#000}#root{position:relative;width:${source.width}px;height:${source.height}px;overflow:hidden;background:#000}
170
+ #base{position:absolute;inset:0;width:100%;height:100%;object-fit:contain}
171
+ .title{position:absolute;transform:translate(-50%,-50%);text-align:center;white-space:nowrap;font:700 ${Math.round(source.width * FONT_SIZE_RATIO)}px/1.08 PopTitle}
172
+ .glyph{display:inline-block;opacity:0;transform:scale(.35);-webkit-text-stroke:.08em #1a1a1a;paint-order:stroke fill;text-shadow:.08em .1em 0 rgba(0,0,0,.72)}
173
+ </style></head><body><div id="root" data-composition-id="pop-title" data-start="0" data-duration="${duration}" data-fps="${fps}" data-width="${source.width}" data-height="${source.height}"><video id="base" src="base.mp4" data-start="0" data-duration="${duration}" data-track-index="0" data-has-audio="false" muted playsinline></video></div><script type="application/json" id="task">${config}</script><script src="render.js"></script></body></html>`);
174
+ const times = [...new Set(authored.flatMap(l => [l.start_frame + (l.end_frame - l.start_frame) * 0.25, l.start_frame + (l.end_frame - l.start_frame) * 0.6]).map(f => f / fps))];
175
+ validateCheck(await hyperframes(['check', work, '--json', ...(times.length ? ['--at', times.join(',')] : []), '--timeout', '90000'], true));
176
+ const rendered = join(work, 'rendered.mp4');
177
+ await hyperframes(['render', work, '--fps', `${source.fps.num}/${source.fps.den}`, '--quality', 'looks', '--output', rendered]);
178
+ const result = await probe(rendered);
179
+ if (result.frames !== source.frames || result.width !== source.width || result.height !== source.height || result.has_audio || result.fps.num * source.fps.den !== source.fps.num * result.fps.den)
180
+ throw new Error(`effect_output_mismatch: ${JSON.stringify(result)}`);
181
+ await rename(rendered, output);
182
+ return { path: output, ranges: authored.map(({ effect, start_frame, end_frame }) => ({ effect, start_frame, end_frame })) };
183
+ }
184
+ finally {
185
+ await rm(work, { recursive: true, force: true });
186
+ }
187
+ }
188
+ }
@@ -0,0 +1,50 @@
1
+ import { redact } from '../gateway/index.js';
2
+ // Presentation only: never contributes to a step's output or hash.
3
+ // Shared terminators; dots, colons and query markers inside filenames/URLs stay in the token.
4
+ const TEXT_TOKEN = /[^\s\p{Pi}\p{Pf}\p{Pe}"'``"'<><>〈《,。;!?、,;!||]+/u.source;
5
+ const LINKS = new RegExp(String.raw `\b(?:[A-Za-z][A-Za-z0-9+.-]*:\/\/|file:)${TEXT_TOKEN}`, 'giu');
6
+ const PATHS = new RegExp(String.raw `(?<![\p{L}\p{N}._~-])(?:\/|~\/|[A-Za-z]:[\\/]|\\\\)${TEXT_TOKEN}|(?<![A-Za-z0-9._~-])(?:\/[A-Za-z0-9._~-]+){3,}`, 'gu');
7
+ // A slash followed by non-whitespace is sensitive unless A: its prefix is ASCII letter/digit/._~-, or B: its prefix is a non-ASCII letter/digit and every character until whitespace/end is non-ASCII. Unattached ~/home remains sensitive.
8
+ // Do not combine i and u: Unicode folding makes U+212A/U+017F match ASCII classes.
9
+ const SENSITIVE_TOKENS = /[a-z][a-z0-9+.-]*:\/\/|\bfile:\S|[a-z]:[\\/]|\\\\|zk_(?:live|test)_|Bearer\s/i;
10
+ const SENSITIVE_SLASHES = new RegExp(String.raw `(?<![\p{L}\p{N}._~-])~\/\S|(?<![A-Za-z0-9._~-])\/(?!(?<=[\p{L}\p{N}]\/)[^\s\x00-\x7F]+(?:\s|$))\S`, 'u');
11
+ export function containsSensitiveText(text) {
12
+ return SENSITIVE_TOKENS.test(text) || SENSITIVE_SLASHES.test(text);
13
+ }
14
+ const cell = (value) => redact(String(value ?? '')
15
+ .replace(LINKS, '[链接已隐藏]')
16
+ .replace(PATHS, '[路径已隐藏]'))
17
+ .replace(/\|/g, '&#124;').replace(/[\r\n]+/g, ' ');
18
+ const filename = (path) => path.split(/[\\/]/).pop() ?? '';
19
+ export function planCard(input, planData, issues, planDigest) {
20
+ const { job, output } = input;
21
+ const source = job.storyboard.source;
22
+ const seconds = (frame) => Number((frame * source.fps.den / source.fps.num).toFixed(6));
23
+ const rows = job.storyboard.segments.map(segment => {
24
+ const products = job.bindings.filter(b => b.segment === segment.id).flatMap(b => job.assets.filter(a => a.id === b.asset && a.role === 'product'));
25
+ return `| ${cell(segment.id)} | ${seconds(segment.start_frame)} | ${seconds(segment.end_frame)} | ${cell(products.map(a => a.id).join('、'))} | ${cell(products.map(a => a.attributes ?? '待确认').join(';'))} |`;
26
+ });
27
+ const roles = { identity: '身份', motion_ref: '动作参考', product: '服装', scene: '场景', detail: '细节' };
28
+ const assets = job.assets.map(a => `| ${cell(a.id)} | ${roles[a.role]} | ${cell(a.path)} | ${a.approved ? '已批准' : '待批准'} |`);
29
+ const lines = [
30
+ '# 执行计划', '', `**目录标识:${cell(planData.catalog)}**`, '',
31
+ '## 结构', '', '| 段落 | 开始(秒) | 结束(秒) | 产品素材 | 已确认属性 |', '| --- | --- | --- | --- | --- |', ...rows, '',
32
+ '## 素材', '', '| 素材 | 角色 | 任务相对路径 | 批准状态 |', '| --- | --- | --- | --- |', ...assets, '',
33
+ ];
34
+ if (job.storyboard.effects.length) {
35
+ lines.push('## 标题特效', '', '| 文案 | 段落范围 |', '| --- | --- |');
36
+ for (const layer of job.storyboard.effects)
37
+ lines.push(`| ${cell(Array.isArray(layer.slots.lines) ? layer.slots.lines.join(';') : layer.slots.lines)} | ${cell(job.storyboard.segments[layer.start_cut]?.id)} 至 ${cell(job.storyboard.segments[layer.end_cut - 1]?.id)} |`);
38
+ lines.push('');
39
+ }
40
+ lines.push('## 输出', '', `时长:${output.duration_seconds} 秒;分辨率:${output.resolution};比例:${cell(output.ratio)}。`, `参考:${cell(filename(input.reference))}。音源:${input.audio ? `用户音频(${cell(filename(input.audio))})` : source.has_audio ? `参考音频(${cell(filename(input.reference))})` : '静音'}。`, '', '## 预算', '', '| 项目 | 积分 |', '| --- | --- |');
41
+ for (const item of planData.lineItems)
42
+ lines.push(`| ${cell(item.operation)} | ${item.credits} |`);
43
+ lines.push('', `重试预留上限:${planData.retryReserveCredits} 积分,仅在实际重试时使用,不是已收取费用。`, `**总预算上限:${planData.totalCredits} 积分(${cell(planData.currency)})**`, '');
44
+ if (planDigest)
45
+ lines.push(`计划摘要:\`${cell(planDigest)}\``, '');
46
+ if (issues.length)
47
+ lines.push('## 编译器警告', '', ...issues.map(i => `- ${cell(i.code)}:${cell(i.message)}${i.segment ? `(${cell(i.segment)})` : ''}`), '');
48
+ lines.push('确认总预算才授权执行;服装和身份仍需人工验收。', '付款前如需纠正,请使用 plan_job 携带新 input,在同一目录重新规划。');
49
+ return lines.join('\n');
50
+ }