@ninkch/dsh-infinite-canvas 0.20.3 → 0.20.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/client.js CHANGED
@@ -456,6 +456,8 @@ function revealCanvasInRight() {
456
456
  'segPlanHint': '按真实镜头边界把分镜切成若干次生成:切点只在换场/特写插入/新角色入场处;同一段连续动作不拆开。',
457
457
  'segMaxLabel': '单段上限',
458
458
  'segMaxHint': '单次生成的最大秒数(按厂商上限填,MiniMax 这类弱衔接模型建议 6–10 秒)',
459
+ 'targetDurationLabel': '分镜总时长',
460
+ 'targetDurationAuto': '按镜头节奏自动',
459
461
  'customValuePh': '自定义后回车',
460
462
  'customCountPh': '自定义 1–100 镜',
461
463
  'customSegMaxPh': '自定义 1–300 秒',
@@ -1461,6 +1463,8 @@ function revealCanvasInRight() {
1461
1463
  'segPlanHint': 'Split the storyboard into several generations at real shot boundaries: cuts only land on scene change / insert / new character; one continuous action is never split.',
1462
1464
  'segMaxLabel': 'Per-segment max',
1463
1465
  'segMaxHint': 'Max seconds per generation (match the vendor limit; for weak-continuity models like MiniMax use 6-10s)',
1466
+ 'targetDurationLabel': 'Storyboard total duration',
1467
+ 'targetDurationAuto': 'Auto by shot pacing',
1464
1468
  'customValuePh': 'Custom, press Enter',
1465
1469
  'customCountPh': 'Custom 1-100 shots',
1466
1470
  'customSegMaxPh': 'Custom 1-300 seconds',
@@ -3585,6 +3589,7 @@ body[data-ds-dark-theme] .dshic-storage-details{border-color:var(--dsw-alias-bor
3585
3589
  .dshic-pick-menu{position:fixed;z-index:240;background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dshic-line2);border-radius:14px;box-shadow:var(--dshic-shadow-lg);display:flex;flex-direction:column;max-height:280px;overflow:hidden;box-sizing:border-box;}
3586
3590
  body[data-ds-dark-theme] .dshic-pick-menu{border-color:var(--dsw-alias-border-l2);}
3587
3591
  .dshic-pick-search{padding:7px;border-bottom:1px solid var(--dshic-line);flex:none;}
3592
+ .dshic-pick-search.is-flipped{border-bottom:none;border-top:1px solid var(--dshic-line);}
3588
3593
  .dshic-pick-search .dshic-input{height:26px;font-size:12px;}
3589
3594
  .dshic-pick-list{overflow-y:auto;padding:5px;flex:1;}
3590
3595
  /* 下拉 / 文本正文 / 分镜清单:滚动条必须可见且可命中;不能用系统默认的淡细条。
@@ -6633,6 +6638,7 @@ function queueThumb(assetId) {
6633
6638
  kling: { label: '快手可灵 Kling', base: 'https://api.klingai.com', keyPh: 'AK:SK(冒号分隔)', note: 'Key 填 AK:SK,代码自动签 JWT;国际站把 Base URL 改为 api-singapore.klingai.com;时长按官方 5/10s 取整' },
6634
6639
  wan: { label: '阿里通义万相 Wan(DashScope)', base: 'https://dashscope.aliyuncs.com', note: '异步任务制;国际站把 Base URL 改为 dashscope-intl.aliyuncs.com;图生视频走 img_url' },
6635
6640
  sanbao: { label: '三宝影像工坊(Sanbao 多参考)', base: 'https://sanbaobeauty.com', keyPh: 'sk-sanbao-…', note: '任务制 /openapi/v1/videos;本地素材 dataURL 直传(全模型 media_inputs 含 data_url,已实测);报图片格式错误自动用扩展参数 {"uploadKey":"sk-sanbao-…"} 指定的专用 key 上传 /openapi/v1/uploads/raw 转公网 URL 后重试一次;resolution 小写(480p/720p/1080p/2k);reference 固定 all(可扩展参数覆盖);参考图上限按模型:wan/kling 系 10、hailuo/SD2.0 系 9、SD2.5 系 30,音频 3–10' },
6641
+ api6789: { label: '6789API(任务制 /v1/videos)', base: '', keyPh: 'sk-…', note: '任务制三段式:POST /v1/videos(Idempotency-Key 幂等)→ GET /v1/videos/{id} 每 5s 轮询 → file/download_url 或 /content 下载(任务成功后 CDN 就绪需等待:10 分钟重试窗口每 30s 一次)。请求体按模型分两族:seedance* 用 duration/ratio/resolution/image_urls(resolution 小写;seedance2.5 参考图 30 张、其余 9 张);minimax* 用 seconds/size/workflow_id/images(比例×清晰度映射精确像素尺寸,2K/4K 大写且必须至少 1 张参考图,seconds 5–15)。Base URL 填站点根(…/v1、…/v1/videos 自动归一);任何同格式站点都能用。本地参考图 dataURL 直发,站方要求公网直链时用扩展参数 {"image_urls":["https://…"]}(minimax 系字段名 images)直给' },
6636
6642
  minimax: { label: 'MiniMax 海螺视频(V1 协议)', base: 'https://api.minimaxi.com', note: '异步任务制;时长按官方 6/10s 取整;首帧图支持 base64' },
6637
6643
  minimaxv2: { label: 'MiniMax H3 · V2 协议(优云智算 / 官方)', base: 'https://cp.compshare.cn', keyPh: 'sk-ml-…', note: 'V2 协议自动适配:优云智算走 /minimax/v2,官方(api.minimax.io/.cn)走 /v2;content[] 多模态(首帧/尾帧/参考图≤9/视频≤3/音频≤3),原生音频,分辨率 480P/768P/1080P/2K/4K(大小写敏感),时长 4-30s;use_context_ir / mute_audio 等走扩展参数' },
6638
6644
  vidu: { label: '生数科技 Vidu', base: 'https://api.vidu.com', note: '图片支持 base64;时长按官方 4/8s 取整' },
@@ -6882,6 +6888,120 @@ function queueThumb(assetId) {
6882
6888
  if (!/^https?:/.test(String(url || ''))) throw new Error('Sanbao 素材上传未返回 file.url');
6883
6889
  return url;
6884
6890
  }
6891
+ // —— 6789API:任务制 /v1/videos(同一路径按模型分两族请求体:seedance* / minimax*)——
6892
+ /** 6789 图片数组上限(纯函数供回归断言):seedance2.5 系 30 张、其余 9 张。 */
6893
+ function api6789ImageCap(model) {
6894
+ return /2\.5/.test(String(model || '')) ? 30 : 9;
6895
+ }
6896
+ /** 6789 请求体(纯函数供回归断言):按模型名分两族——
6897
+ * · seedance*:{model, prompt, duration, ratio, resolution(小写), image_urls?}
6898
+ * 时长/比例/分辨率一律透传(站方校验、报错可见,绝不静默裁剪);
6899
+ * · minimax*:{model, prompt, seconds, size, workflow_id, images?}
6900
+ * 比例×清晰度必须映射为精确像素 size(2K/4K 大写);workflow_id 自动选:
6901
+ * 无图 text-to-video / 有图普通 multi-reference / 有图 2K/4K cf-multi-reference。
6902
+ * images:首帧在前、参考图在后(dataURL 直发;站方要公网直链时扩展参数覆盖)。 */
6903
+ function build6789VideoBody(spec, media) {
6904
+ const sp = spec || {};
6905
+ const m = media || {};
6906
+ const model = String(sp.model || '').toLowerCase();
6907
+ const frame = String(m.frameDataUrl || '');
6908
+ const refs = (Array.isArray(m.refDataUrls) ? m.refDataUrls : []).map(String).filter(Boolean);
6909
+ const isMini = model.includes('minimax');
6910
+ if (isMini) {
6911
+ const out = {
6912
+ model,
6913
+ prompt: String(sp.prompt || ''),
6914
+ seconds: Math.round(Number(sp.duration)) || 5,
6915
+ size: api6789SizeOf(sp.ratio, sp.resolution),
6916
+ workflow_id: 'text-to-video',
6917
+ };
6918
+ const images = (frame ? [frame] : []).concat(refs);
6919
+ if (images.length) {
6920
+ out.images = images;
6921
+ out.workflow_id = /^2K$|^4K$/i.test(String(out.size)) ? 'cf-multi-reference' : 'multi-reference';
6922
+ }
6923
+ return out;
6924
+ }
6925
+ const out = {
6926
+ model,
6927
+ prompt: String(sp.prompt || ''),
6928
+ duration: Math.round(Number(sp.duration)) || 5,
6929
+ ratio: String(sp.ratio || '16:9'),
6930
+ resolution: String(sp.resolution || '720p').toLowerCase(),
6931
+ };
6932
+ const images = (frame ? [frame] : []).concat(refs);
6933
+ if (images.length) out.image_urls = images;
6934
+ return out;
6935
+ }
6936
+ /** 6789 minimax 系尺寸映射(纯函数供回归断言):普通清晰度 = 比例×清晰度档的精确像素;
6937
+ * 2K/4K 直接大写(站方要求)。480p 不在枚举 → 按最接近的 768P 档处理并告警可见。 */
6938
+ function api6789SizeOf(ratio, resolution) {
6939
+ const res = String(resolution || '720p').toLowerCase();
6940
+ if (res.includes('2k')) return '2K';
6941
+ if (res.includes('4k')) return '4K';
6942
+ const hd = res.includes('1080');
6943
+ const r = String(ratio || '16:9');
6944
+ const MAP = {
6945
+ // 720P 档 1080P 档
6946
+ '16:9': ['1376x768', '1920x1088'],
6947
+ '9:16': ['768x1376', '1088x1920'],
6948
+ '1:1': ['1024x1024', '1440x1440'],
6949
+ '4:3': ['1184x896', '1664x1248'],
6950
+ '3:4': ['896x1184', '1248x1664'],
6951
+ '21:9': ['1568x672', '2208x960'],
6952
+ };
6953
+ const pair = MAP[r] || MAP['16:9'];
6954
+ return hd ? pair[1] : pair[0];
6955
+ }
6956
+ /** 6789 任务 id(纯函数):顶层 id / task_id,兼容 data 包装(data.task_id / data.id)。 */
6957
+ function api6789TaskIdOf(j) {
6958
+ if (!j || typeof j !== 'object') return null;
6959
+ return j.id ?? j.task_id ?? (j.data && (j.data.task_id ?? j.data.id)) ?? null;
6960
+ }
6961
+ /** 6789 状态(纯函数):顶层 status,兼容 data 包装(data.status)。 */
6962
+ function api6789StatusOf(j) {
6963
+ if (!j || typeof j !== 'object') return '';
6964
+ return String(j.status ?? (j.data && j.data.status) ?? '').trim().toLowerCase();
6965
+ }
6966
+ /** 6789 结果地址(纯函数):优先绝对地址(download_url → video_url → content/output.video_url →
6967
+ * data.video_url),file 为相对路径(/v1/videos/{id}/content)时原样返回(调用方拼 origin)。
6968
+ * 空串视为「未提供」(站方成功响应里 file/download_url 可为 '')。 */
6969
+ function api6789VideoUrlOf(j) {
6970
+ if (!j || typeof j !== 'object') return '';
6971
+ const d = (j.data && typeof j.data === 'object') ? j.data : {};
6972
+ const cands = [j.download_url, j.video_url, d.download_url, d.video_url,
6973
+ j.content && j.content.video_url, j.output && j.output.video_url];
6974
+ const abs = cands.find((u) => typeof u === 'string' && /^https?:/i.test(u));
6975
+ if (abs) return abs;
6976
+ const file = [j.file, d.file].find((u) => typeof u === 'string' && u.startsWith('/'));
6977
+ return file || '';
6978
+ }
6979
+ /** 6789 失败原因(纯函数):error → fail_reason → message → data.error。 */
6980
+ function api6789ErrorOf(j) {
6981
+ if (!j || typeof j !== 'object') return '';
6982
+ const d = (j.data && typeof j.data === 'object') ? j.data : {};
6983
+ const v = j.error || j.fail_reason || j.message || d.error || '';
6984
+ if (!v) return '';
6985
+ return (typeof v === 'string' ? v : JSON.stringify(v)).slice(0, 300);
6986
+ }
6987
+ /** 6789 轮询判定(纯函数):queued/running 及未知状态 = 继续;成功集合取地址;
6988
+ * 失败集合报错。与站方文档枚举一致(含 cancelled/canceled/expired)。 */
6989
+ function api6789PollState(j) {
6990
+ const st = api6789StatusOf(j);
6991
+ if (['succeeded', 'completed', 'success'].includes(st)) {
6992
+ const url = api6789VideoUrlOf(j);
6993
+ return url ? { state: 'done', url } : { state: 'fail', error: '任务成功但响应中没有视频地址' };
6994
+ }
6995
+ if (['failed', 'error', 'cancelled', 'canceled', 'expired'].includes(st)) {
6996
+ return { state: 'fail', error: api6789ErrorOf(j) || st };
6997
+ }
6998
+ return { state: 'wait' };
6999
+ }
7000
+ /** 6789 本地素材是否需要「公网直链」类重试提示(纯函数):只认图片/URL/格式类错误。 */
7001
+ function needs6789MediaHint(errText) {
7002
+ const t = String(errText || '');
7003
+ return /https?:|url|图片|image|格式|format/i.test(t);
7004
+ }
6885
7005
  /** 读取生成视频的真实尺寸与时长(用于「厂商是否忽略了参数」的可见校验)。 */
6886
7006
  function probeVideoMeta(blob) {
6887
7007
  return new Promise((resolve) => {
@@ -7138,6 +7258,91 @@ function queueThumb(assetId) {
7138
7258
  throw err;
7139
7259
  }
7140
7260
  },
7261
+ // —— 6789API:任务制 /v1/videos,同一路径按模型分两族请求体(seedance* / minimax*)——
7262
+ async api6789(prompt, frameBlob, s, o) {
7263
+ if (!s.url) throw new Error('未配置视频 API(6789API 格式:Base URL 填站点根,…/v1 自动归一)');
7264
+ if (!s.model) throw new Error('请在设置里为该视频 API 填写模型名(如 seedance2.0fast / minimax-h3)');
7265
+ const base = vendorBase(s.url, '');
7266
+ if (!base) throw new Error('6789API 需要填写 Base URL');
7267
+ const headers = { 'Content-Type': 'application/json', Authorization: 'Bearer ' + (s.apiKey || '') };
7268
+ const model = String(s.model || '').toLowerCase();
7269
+ const isMini = model.includes('minimax');
7270
+ // 参考图装填:首帧在前、参考图在后;上限按模型(2.5 系 30、其余 9)——超限告警可见
7271
+ const cap = api6789ImageCap(model);
7272
+ const rawRefs = o.hardFrame ? [] : (o.refs || []).slice(0, cap);
7273
+ if (o.warn && (o.refs || []).length > rawRefs.length) {
7274
+ o.warn('参考图 ' + (o.refs || []).length + ' 张超过「' + model + '」上限 ' + cap + ' 张,本次只使用前 ' + cap + ' 张');
7275
+ }
7276
+ let text = prompt;
7277
+ if (frameBlob && rawRefs.length) text = videoRefNote(o.refNames) + '\n' + prompt;
7278
+ // 本地素材 dataURL 直发(宽松尝试,与通用链同口径);站方要求公网直链时报错原文透传
7279
+ const media = {
7280
+ frameDataUrl: frameBlob ? await blobToDataUrlScaled(frameBlob) : '',
7281
+ refDataUrls: await Promise.all(rawRefs.map((b) => blobToDataUrlScaled(b))),
7282
+ };
7283
+ const spec = { model, prompt: text, duration: o.duration, ratio: o.ratio, resolution: o.resolution || '720p' };
7284
+ const body = build6789VideoBody(spec, media);
7285
+ // minimax 系 2K/4K 必须至少 1 张参考图(站方文档硬约束)——提交前明确报错
7286
+ if (isMini && /^2K$|^4K$/i.test(String(body.size)) && !(body.images || []).length) {
7287
+ throw new Error('「' + model + '」的 ' + body.size + ' 清晰度必须至少提供 1 张参考图(站方硬约束):请连线参考图,或把清晰度改成 720P/1080P');
7288
+ }
7289
+ // 480p 不在 minimax 尺寸枚举 → 降档可见告警(build 内已按 768P 档映射)
7290
+ if (isMini && o.warn && String(o.resolution || '').toLowerCase().includes('480')) {
7291
+ o.warn('「' + model + '」没有 480p 尺寸档,本次按 768P 档发送(可选 720P/1080P/2K/4K)');
7292
+ }
7293
+ // 扩展参数:逃生舱(可覆盖任意字段,如 {"image_urls":["https://…"]} 公网直链直给)
7294
+ mergeExtra(body, s);
7295
+ // 幂等键:本次生成固定一个 UUID,网络重试复用(站方文档要求)
7296
+ const idem = (globalThis.crypto && crypto.randomUUID) ? crypto.randomUUID() : ('idem-' + Date.now().toString(36) + Math.random().toString(36).slice(2));
7297
+ const submitUrl = base + '/v1/videos';
7298
+ const r1 = await fetchViaProxy(submitUrl, { headers: { ...headers, 'Idempotency-Key': idem }, body, timeoutMs: Number(s.timeoutMs) > 0 ? Number(s.timeoutMs) : 120000, label: '6789 提交' });
7299
+ if (!r1.ok) {
7300
+ const hint = needs6789MediaHint(r1.text) && (frameBlob || rawRefs.length)
7301
+ ? '——该站参考图要求公网 https 直链:可在扩展参数填 {"image_urls":["https://…"]}(minimax 系字段名 images)直给,或改用文生视频'
7302
+ : '';
7303
+ throw new Error('6789 提交 HTTP ' + r1.status + ' @ ' + submitUrl + ':' + r1.text.slice(0, 300) + hint);
7304
+ }
7305
+ let j1 = null; try { j1 = JSON.parse(r1.text); } catch { throw new Error('6789 响应非 JSON:' + r1.text.slice(0, 200)); }
7306
+ const tid = api6789TaskIdOf(j1);
7307
+ if (!tid) throw new Error('6789 响应中没有任务 id:' + r1.text.slice(0, 200));
7308
+ const taskUrl = base + '/v1/videos/' + encodeURIComponent(tid);
7309
+ if (o.onTask) { try { o.onTask(tid, taskUrl); } catch { /* 持久化失败不影响生成 */ } }
7310
+ const queryTask = async (label) => {
7311
+ const r = await fetchViaProxy(taskUrl, { method: 'GET', headers, timeoutMs: 60000, label });
7312
+ if (!r || !r.ok) return null;
7313
+ try { return JSON.parse(r.text); } catch { return null; }
7314
+ };
7315
+ // 站方建议每 5s 查询一次;画布最长轮询 30 分钟(任务 id 已挂节点,超时可凭 id 回查)
7316
+ const url = await vendorPoll('6789', 5000, async () => {
7317
+ const j = await queryTask('6789 查询');
7318
+ return j ? api6789PollState(j) : { state: 'wait' };
7319
+ });
7320
+ // 任务成功 ≠ 文件可下载:CDN 就绪窗口内重试(10 分钟、每 30s 一次,与三宝同款口径)。
7321
+ // file 相对路径 → 拼 origin 且带 Bearer 下载;绝对地址裸 GET、401/403 自动带鉴权重试;
7322
+ // 每次重试前重查任务刷新地址(download_url 可能是带 exp 的签名地址,会过期)。
7323
+ const origin = (() => { try { return new URL(base).origin; } catch { return ''; } })();
7324
+ const dlHeaders = (u) => String(u || '').startsWith('/') ? headers
7325
+ : (() => { try { return new URL(u).origin === origin ? headers : {}; } catch { return {}; } })();
7326
+ try {
7327
+ return await downloadVideoWithRetry(url, dlHeaders(url), {
7328
+ windowMs: SANBAO_DOWNLOAD_RETRY_MS,
7329
+ stepMs: SANBAO_DOWNLOAD_RETRY_STEP_MS,
7330
+ refreshUrl: async () => {
7331
+ const j = await queryTask('6789 缓存查询');
7332
+ if (!j) return '';
7333
+ const st = api6789PollState(j);
7334
+ return st.state === 'done' ? st.url : '';
7335
+ },
7336
+ onRetry: (e, n) => {
7337
+ try { console.info('[IC] 6789 download not ready (' + ((e && e.message) || e) + ') — retry ' + n); } catch { /* 忽略 */ }
7338
+ },
7339
+ });
7340
+ } catch (e) {
7341
+ const err = new Error('6789 视频下载失败(任务 ' + tid + '):' + ((e && e.message) || e));
7342
+ err.status = e && e.status;
7343
+ throw err;
7344
+ }
7345
+ },
7141
7346
  // —— MiniMax 海螺:异步 task_id + query 接口 ——
7142
7347
  async minimax(prompt, frameBlob, s, o) {
7143
7348
  const base = vendorBase(s.url, VIDEO_VENDORS.minimax.base);
@@ -7431,6 +7636,8 @@ function queueThumb(assetId) {
7431
7636
  // 三宝:按最保守通用模型(hailuo/SD2.0 系 9 图 3 音频;wan/kling 系 10 图、SD2.5 系 30 图,见厂商 note)
7432
7637
  sanbao: { img: 9, audio: 3 },
7433
7638
  minimaxv2: { img: 9, audio: 3 },
7639
+ // 6789:seedance2.5 系 30 图、其余 9 图(api6789ImageCap 按模型取精确值,此处按保守 9 告警)
7640
+ api6789: { img: 9 },
7434
7641
  openai: { img: 8 },
7435
7642
  seedance: { img: 8 },
7436
7643
  // img:0 = 该厂商的协议**没有任何实体参考图入口**(已核对各自 runner:只收首帧/提示词)——
@@ -9319,6 +9526,11 @@ function queueThumb(assetId) {
9319
9526
  const bible = bibleBlock(loadBible(S.activeId));
9320
9527
  const zh = effLang() !== 'en';
9321
9528
  const contOn = !(opts && opts.cont === false); // 分镜衔接开关(默认开)
9529
+ // 分镜总时长(issue:下拉硬约束):targetDuration > 0 = 用户手动设定的**本分镜节点总时长**,
9530
+ // 严格 =X 秒——不论切 5 镜还是 50 镜,所有镜头 duration 之和必须等于 X;技能只管按节奏谱系
9531
+ // 把 X 分配到各镜(快冲突 0.3-0.8s / 对白 2-4s / 情绪长镜 ≥5s),装不下压每镜时长而非删戏。
9532
+ // 0/缺省 = 自动档:与旧版逐字一致(节奏自然决定,无硬上限)。
9533
+ const targetDuration = Math.max(0, Math.round(Number(opts && opts.targetDuration) * 10) / 10) || 0;
9322
9534
  // 特效演绎开关:任一所选题材/影调卡 fx_motion:true → 追加特效演绎扩展块(见 FX_RULES)
9323
9535
  const fxOn = await fxMotionEnabledFor(S.activeId);
9324
9536
  const contFields = (() => {
@@ -9407,7 +9619,11 @@ function queueThumb(assetId) {
9407
9619
  '- **Never use straight double quotes " inside JSON string values** — quoted text (signs/subtitles/lines) uses 「」 instead;',
9408
9620
  '- **Split shots by actual content**: one continuous action beat = one shot; the count is decided by the content (3-10 shots are all normal) — never pad, never use a fixed number;',
9409
9621
  '- **[SEGMENTATION-FRIENDLY - HARD] shot boundaries must land where a cut can actually happen**: the system splits this storyboard into several generations, and a split is only allowed on a "cut" boundary - scene change / insert close-up / new character enters. Therefore: never break ONE character\'s ONE continuous action into several `continuation` shots (give that single shot a longer duration instead) - if it gets split across two generations, the two clips cannot be matched. When you genuinely change the camera, make the next shot one of scene change / insert close-up / new character (even a single insert close-up is enough) so the boundary is a clean cut rather than a forced match. **Do not fake it**: never label shots `scene_change` just to create cut points inside the same space - that reads as a jump;',
9410
- '- duration is the shot length in seconds, **one decimal allowed**; **assign by pacing spectrum, never uniform**: normal narrative/dialogue 2-4s, fast conflict/fight/chase 0.3-0.8s (rapid cuts), key reversal/impact 1-2s, long emotional take >=5s — every scene must contain at least one obvious rhythm change (e.g. 3s narrative -> 0.6s cuts x2 -> 1.5s reversal -> 5s emotional take); identical durations kill the rhythm; total duration follows what the scene needs - no hard cap (vendor limits differ and change; if exceeded the video call reports it explicitly, then you split or adjust); shot order = narrative order; last shot lands the emotion; **if a CONTINUITY CONSTRAINT is given below, shot 1 must continue the previous scene\'s last frame and character state (no re-establishing, no wide reset); only without a constraint does shot 1 establish the scene**;',
9622
+ '- duration is the shot length in seconds, **one decimal allowed**; **assign by pacing spectrum, never uniform**: normal narrative/dialogue 2-4s, fast conflict/fight/chase 0.3-0.8s (rapid cuts), key reversal/impact 1-2s, long emotional take >=5s — every scene must contain at least one obvious rhythm change (e.g. 3s narrative -> 0.6s cuts x2 -> 1.5s reversal -> 5s emotional take); identical durations kill the rhythm; '
9623
+ + (targetDuration
9624
+ ? '**[TOTAL DURATION - HARD USER OVERRIDE] the user has fixed this storyboard\'s TOTAL duration at exactly ' + targetDuration + 's**: the sum of ALL shot durations must equal ' + targetDuration + 's (±0.3s rounding tolerance on the last shot, then settle). Distribute ' + targetDuration + 's across shots by the pacing spectrum above; more shots = each shot gets proportionally less, fewer shots = more each; when content cannot fit, compress per-shot durations — never drop dialogue or key actions; a shot may go below its usual spectrum floor if needed (a 0.5s beat is legal), but the TOTAL is inviolable'
9625
+ : 'total duration follows what the scene needs - no hard cap (vendor limits differ and change; if exceeded the video call reports it explicitly, then you split or adjust)')
9626
+ + '; shot order = narrative order; last shot lands the emotion; **if a CONTINUITY CONSTRAINT is given below, shot 1 must continue the previous scene\'s last frame and character state (no re-establishing, no wide reset); only without a constraint does shot 1 establish the scene**;',
9411
9627
  '- **Pick the shot size by emotion**: loneliness/despair/grand crisis = wide; confrontation/action/relationship = full; dialogue/probing/info exchange = medium; shock/suspicion/inner shake = close-up; breakdown/screaming/emotional burst = extreme close-up; key detail/prop reveal = big close-up — conflicts play wide, reveals move close, bursts go extreme, reversals can pull wide; the changing distance itself tells the emotion;',
9412
9628
  '- **Rapid cuts (<1.5s) get minimal visual/motion** (one action, one piece of in-frame information); long durations are earned by information density — duration must match content;',
9413
9629
  '- Output JSON only.',
@@ -9448,6 +9664,14 @@ function queueThumb(assetId) {
9448
9664
  ? `镜头数量:必须输出恰好 ${countNum} 镜(用户手动设置;硬性参数,不是参考值)。`
9449
9665
  : `Shot count: output EXACTLY ${countNum} shots (set by the user; hard parameter, not a reference).`)
9450
9666
  : `${zh ? '镜头数量' : 'Shot count'}:**不固定**——按实际动作节拍切分,由内容自然决定`;
9667
+ // 分镜总时长行:手动档 = 硬性参数(与 countLine 同款口径);自动档 = 如实说「不固定」。
9668
+ const durationLine = targetDuration
9669
+ ? (zh
9670
+ ? `分镜总时长:所有镜头时长之和必须**恰好等于 ${targetDuration} 秒**(用户手动设定;硬性参数,不是参考值)。切 5 镜还是 50 镜都可以,镜头数由内容按节奏决定,但每个镜头 duration 相加必须等于 ${targetDuration} 秒。`
9671
+ : `Storyboard total duration: the sum of ALL shot durations must be EXACTLY ${targetDuration} seconds (set by the user; hard parameter, not a reference). 5 shots or 50 are both fine — shot count follows the content's pacing, but the durations must add up to ${targetDuration}s.`)
9672
+ : (zh
9673
+ ? `分镜总时长:**不固定**——由技能按节奏自然分配`
9674
+ : `Storyboard total duration: **not fixed** — distributed by pacing naturally`);
9451
9675
  // 承接约束:由连线指定(分镜表「衔接上一镜」输入口 ← 上游分镜表「尾镜」输出口)。
9452
9676
  // 只承接尾镜的**结尾瞬间**(≤0.2s 重叠),不重演上一镜——视频模型按秒计费,重演等于白花钱。
9453
9677
  const cont = (() => {
@@ -9498,6 +9722,7 @@ function queueThumb(assetId) {
9498
9722
  `${zh ? '剧本' : 'Script'}:\n${String(scriptText ?? '').trim()}`,
9499
9723
  `${zh ? '额外要求' : 'Extra requirements'}:${String(requirement ?? '').trim() || (zh ? '无' : 'none')}`,
9500
9724
  countLine,
9725
+ durationLine,
9501
9726
  prevLine,
9502
9727
  ].filter(Boolean).join('\n\n');
9503
9728
  const text = await aiCompleteStream({
@@ -10701,7 +10926,24 @@ function queueThumb(assetId) {
10701
10926
  flushSave();
10702
10927
  try {
10703
10928
  const prev = prevSceneTail(n); // 场 N-1 的尾镜 → 作为本场第 1 镜的硬性承接约束
10704
- const shots = await aiStoryboardShots(st, n.data.requirement, Number(n.data.count) || 0, n.data.model, (kind, d) => aiStreamAppend(n.id, kind, d), prev, { cont: n.data.cont !== false });
10929
+ const targetDur = Math.max(0, Math.round(Number(n.data.targetDuration) * 10) / 10) || 0;
10930
+ const shots = await aiStoryboardShots(st, n.data.requirement, Number(n.data.count) || 0, n.data.model, (kind, d) => aiStreamAppend(n.id, kind, d), prev, { cont: n.data.cont !== false, targetDuration: targetDur });
10931
+ // 总时长机械归位(issue:下拉硬约束的执行侧保底):模型 Σ≠X 时按比例缩放各镜 duration,
10932
+ // 末镜吸收舍入残差 → Σ 恰等于 X。只缩放时长,绝不动内容字段;自动档(targetDur=0)零操作。
10933
+ if (targetDur && shots.length) {
10934
+ const sum = shots.reduce((a, s) => a + (Number(s.duration) || 0), 0);
10935
+ if (sum > 0 && Math.abs(sum - targetDur) > 0.05) {
10936
+ const k = targetDur / sum;
10937
+ let acc = 0;
10938
+ for (let i = 0; i < shots.length; i++) {
10939
+ const scaled = i === shots.length - 1
10940
+ ? Math.round((targetDur - acc) * 10) / 10 // 末镜吸收残差
10941
+ : Math.max(0.3, Math.round(Number(shots[i].duration) * k * 10) / 10);
10942
+ shots[i].duration = scaled;
10943
+ acc += scaled;
10944
+ }
10945
+ }
10946
+ }
10705
10947
  // 未闭合引用自愈:句尾丢闭合 @ 的引用按设定集名补全(否则参考图静默丢失)
10706
10948
  const _known = bibleNames(loadBible(S.activeId));
10707
10949
  for (const sh of shots) {
@@ -12572,22 +12814,41 @@ function queueThumb(assetId) {
12572
12814
  const [open, setOpen] = useState(false);
12573
12815
  const [q, setQ] = useState('');
12574
12816
  const [custom, setCustom] = useState('');
12575
- const [pos, setPos] = useState({ left: 0, top: 0, width: width || 160 });
12817
+ const [pos, setPos] = useState({ left: 0, top: 0, width: width || 160, flipped: false });
12576
12818
  const btnRef = useRef(null);
12577
12819
  const menuRef = useRef(null);
12578
- const openMenu = () => {
12579
- if (disabled) return;
12820
+ /** 统一定位器(三处同源:openMenu 初定位 / composerReposition 跟随 / layout effect 实高校正)。
12821
+ * 镜像贴附语义:下翻菜单顶=按钮底+6(搜索框贴按钮);上翻菜单底=按钮顶-6(搜索框在菜单
12822
+ * 最下仍贴按钮)。menuH 传实际高度(layout effect 量得);初定位/跟随阶段传 0 用估算 280。 */
12823
+ const placeMenu = (menuH) => {
12580
12824
  const btn = btnRef.current;
12581
- if (btn && btn.getBoundingClientRect) {
12582
- const r = btn.getBoundingClientRect();
12583
- const mw = Math.max(Number(width) || 160, 200);
12584
- const vw = window.innerWidth || 1200;
12585
- const vh = window.innerHeight || 800;
12586
- const left = Math.max(8, Math.min(r.left, vw - mw - 8));
12587
- const below = r.bottom + 6;
12588
- const top = (below + 280 > vh - 8) ? Math.max(8, r.top - 286) : below;
12589
- setPos({ left, top, width: mw });
12825
+ if (!btn || !btn.getBoundingClientRect) return null;
12826
+ const r = btn.getBoundingClientRect();
12827
+ const mw = Math.max(Number(width) || 160, 200);
12828
+ const vw = window.innerWidth || 1200;
12829
+ const vh = window.innerHeight || 800;
12830
+ const pad = 8;
12831
+ const gap = 6;
12832
+ const left = Math.max(8, Math.min(r.left, vw - mw - 8));
12833
+ const h = Math.max(60, Number(menuH) || 280);
12834
+ // 空间裁决:向下放不下且上方更宽裕 → 上翻;否则下翻(下翻越界时夹视口底)。
12835
+ const downOver = r.bottom + gap + h - (vh - pad); // 下翻超出视口底的量
12836
+ const upSpace = r.top - gap - h - pad; // 上翻后距视口顶的余量
12837
+ const flipped = downOver > 0 && upSpace > -downOver; // 哪边溢出少选哪边
12838
+ let top;
12839
+ if (flipped) {
12840
+ top = r.top - gap - h; // 上翻:菜单底贴按钮顶
12841
+ if (top < pad) { top = Math.max(pad, Math.min(r.bottom + gap, vh - h - pad)); flipped = false; }
12842
+ } else {
12843
+ top = r.bottom + gap; // 下翻:菜单顶贴按钮底
12844
+ if (top + h > vh - pad) top = Math.max(pad, vh - h - pad);
12590
12845
  }
12846
+ return { left, top, width: mw, flipped };
12847
+ };
12848
+ const openMenu = () => {
12849
+ if (disabled) return;
12850
+ const p = placeMenu(0); // 初定位用估算高度(菜单未渲染);layout effect 随后按实际高度校正
12851
+ if (p) setPos(p);
12591
12852
  setQ('');
12592
12853
  setCustom('');
12593
12854
  setOpen(true);
@@ -12614,7 +12875,24 @@ function queueThumb(assetId) {
12614
12875
  setOpen(false);
12615
12876
  };
12616
12877
  document.addEventListener('pointerdown', onDown, true);
12878
+ // 菜单跟随:composer 是活的(跟随节点拖动/画布缩放重定位),菜单坐标若只是打开瞬间的
12879
+ // 快照就会「飞离选择位置」。把自己挂进 composerReposition 链——composer 每次重定位时
12880
+ // 菜单同步重算(与 layout effect 同一 placeMenu:镜像方向 + flipped 一并保持)。
12881
+ const reposition = () => {
12882
+ const menu = menuRef.current;
12883
+ const p = placeMenu(menu && menu.getBoundingClientRect ? menu.getBoundingClientRect().height : 0);
12884
+ if (p) setPos(p);
12885
+ };
12886
+ const prevReposition = composerReposition;
12887
+ composerReposition = () => { try { reposition(); } catch { /* 定位失败不影响画布 */ } if (prevReposition) prevReposition(); };
12888
+ window.addEventListener('resize', reposition);
12889
+ // 打开瞬间校正一次:composer 自身刚完成定位(点击内容区 → composer 挂载 → 立刻点下拉),
12890
+ // openMenu 算到的 btn rect 可能来自 composer 定位前的那一帧——下一帧按已就位的 rect 校正。
12891
+ const raf = requestAnimationFrame(reposition);
12617
12892
  return () => {
12893
+ cancelAnimationFrame(raf);
12894
+ composerReposition = prevReposition;
12895
+ window.removeEventListener('resize', reposition);
12618
12896
  delete document.body.dataset.dshicPickOpen;
12619
12897
  document.removeEventListener('pointerdown', onDown, true);
12620
12898
  };
@@ -12628,6 +12906,19 @@ function queueThumb(assetId) {
12628
12906
  const shown = (searchable && query)
12629
12907
  ? options.filter((o) => (String(o.label) + ' ' + String(o.sub || '') + ' ' + String(o.value)).toLowerCase().includes(query))
12630
12908
  : options;
12909
+ // 菜单实际高度就位后的精确定位(useLayoutEffect 绘制前,无闪烁):与 placeMenu 同源——
12910
+ // 量真实高度重算镜像方向与贴附(初定位用估算 280,渲染后按实际高度修正)。
12911
+ useLayoutEffect(() => {
12912
+ if (!open) return;
12913
+ const menu = menuRef.current;
12914
+ if (!menu || !menu.getBoundingClientRect) return;
12915
+ const mr = menu.getBoundingClientRect();
12916
+ if (!mr.height) return;
12917
+ const p = placeMenu(mr.height);
12918
+ if (!p) return;
12919
+ const changed = Math.abs(p.top - pos.top) > 0.5 || Math.abs((p.left ?? 0) - (pos.left ?? 0)) > 0.5 || !!p.flipped !== !!pos.flipped;
12920
+ if (changed) setPos(p);
12921
+ }, [open, shown.length, editable]);
12631
12922
  return h('span', {
12632
12923
  className: cls('dshic-pick-wrap', className),
12633
12924
  // 可收缩的下拉(模型):flex-basis = 期望宽度,min-width:0 允许被压到省略号
@@ -12647,11 +12938,11 @@ function queueThumb(assetId) {
12647
12938
  h('span', { className: 'dshic-pick-car' }, '▾')),
12648
12939
  open
12649
12940
  ? h('div', {
12650
- ref: menuRef, className: 'dshic-pick-menu',
12941
+ ref: menuRef, className: cls('dshic-pick-menu', pos.flipped && 'is-flipped'),
12651
12942
  style: { left: pos.left, top: pos.top, width: pos.width },
12652
12943
  onPointerDown: (e) => e.stopPropagation(),
12653
12944
  },
12654
- searchable
12945
+ searchable && !pos.flipped
12655
12946
  ? h('div', { className: 'dshic-pick-search' },
12656
12947
  h('input', {
12657
12948
  className: 'dshic-input', autoFocus: true, placeholder: T('searchModelPh'), value: q,
@@ -12671,7 +12962,29 @@ function queueThumb(assetId) {
12671
12962
  h('span', { className: 'dshic-pick-name' }, o.label),
12672
12963
  o.sub ? h('span', { className: 'dshic-pick-sub' }, o.sub) : null))
12673
12964
  : h('div', { className: 'dshic-pick-empty' }, T('noModelMatch'))),
12674
- editable
12965
+ // 上翻(镜像):搜索框/自定义输入框贴按钮的一侧(菜单最下)→ 渲染顺序整体倒置
12966
+ searchable && pos.flipped
12967
+ ? h('div', { className: 'dshic-pick-search is-flipped' },
12968
+ h('input', {
12969
+ className: 'dshic-input', autoFocus: true, placeholder: T('searchModelPh'), value: q,
12970
+ onChange: (e) => setQ(e.target.value), onPointerDown: (e) => e.stopPropagation(),
12971
+ }))
12972
+ : null,
12973
+ editable && pos.flipped
12974
+ ? h('div', { className: 'dshic-pick-custom is-flipped' },
12975
+ h('input', {
12976
+ className: 'dshic-input', type: 'text',
12977
+ inputMode: integer ? 'numeric' : 'decimal',
12978
+ placeholder: customPlaceholder || T('customValuePh'),
12979
+ title: customPlaceholder || T('customValuePh'),
12980
+ value: custom,
12981
+ onChange: (e) => setCustom(e.target.value),
12982
+ onKeyDown: (e) => { if (e && e.key === 'Enter') { e.preventDefault(); submitCustom(); } },
12983
+ onBlur: submitCustom,
12984
+ onPointerDown: (e) => e.stopPropagation(),
12985
+ }))
12986
+ : null,
12987
+ editable && !pos.flipped
12675
12988
  ? h('div', { className: 'dshic-pick-custom' },
12676
12989
  h('input', {
12677
12990
  className: 'dshic-input', type: 'text',
@@ -12773,12 +13086,15 @@ function queueThumb(assetId) {
12773
13086
 
12774
13087
  // —— 模型选项:只列已配置的模型(文本取 Harness 会话可用模型;图片/视频取插件设置里的供应商+模型)——
12775
13088
  const modelOptions = (() => {
12776
- const opts = [{ value: '', label: T('followSettings'), sub: '' }];
13089
+ const opts = [];
12777
13090
  if (isTextLike) {
13091
+ // 文本模型才有「跟随设置」:语言模型由 Harness 会话提供,节点不选 = 用当前会话模型。
13092
+ opts.push({ value: '', label: T('followSettings'), sub: '' });
12778
13093
  for (const p of ((llm && llm.providers) || [])) {
12779
13094
  for (const m of (p.models || [])) opts.push({ value: p.id + '|' + m.id, label: m.name, sub: p.name, title: p.name + ' · ' + m.name });
12780
13095
  }
12781
13096
  } else if (isImage) {
13097
+ // 图片/视频无「跟随设置」:设置页有真实默认(★ 星标),节点不选 = 直接用 ★(resolveImageModelCfg 同语义)。
12782
13098
  for (const m of flattenImageModels(settings)) opts.push({ value: m.ref, label: m.model, sub: m.providerName, title: m.providerName + ' · ' + m.model + (m.ref === settings.imageStar ? ' ★' : '') });
12783
13099
  } else if (isVideo) {
12784
13100
  for (const m of flattenVideoModels(settings)) opts.push({ value: m.ref, label: m.model, sub: m.providerName, title: m.providerName + ' · ' + m.model + (m.ref === settings.videoStar ? ' ★' : '') });
@@ -12786,6 +13102,11 @@ function queueThumb(assetId) {
12786
13102
  return opts;
12787
13103
  })();
12788
13104
  const modelRef = isImage ? nodeImageModelRef(n) : isVideo ? nodeVideoModelRef(n) : (n.data.model || '');
13105
+ // 图片/视频:节点未选模型时显示 ★ 默认模型(而非「跟随设置」)——下拉里它就是普通一项,
13106
+ // 点它 = 显式把节点钉到该模型(写 ref),与「未选时请求侧走 ★」同一结论。
13107
+ const modelValue = modelRef || (!isTextLike
13108
+ ? (isImage ? settings.imageStar : settings.videoStar) || ''
13109
+ : '');
12789
13110
  const setModel = (v) => update((s) => {
12790
13111
  const nd = s.graph.nodes[n.id];
12791
13112
  if (!nd) return;
@@ -13041,7 +13362,7 @@ function queueThumb(assetId) {
13041
13362
  // finalcut 无模型(只有比例/分辨率);其余类型模型永远排在最前
13042
13363
  !isFinalCut
13043
13364
  ? h(PopupSelect, {
13044
- value: modelRef, options: modelOptions, onChange: setModel, width: 172,
13365
+ value: modelValue, options: modelOptions, onChange: setModel, width: 172,
13045
13366
  title: T('modelLabel'), searchable: true, className: 'is-model', shrink: true,
13046
13367
  })
13047
13368
  : null,
@@ -13061,13 +13382,16 @@ function queueThumb(assetId) {
13061
13382
  onChange: (v) => setStoryboardPrev(n.id, v || null),
13062
13383
  })
13063
13384
  : null,
13064
- // 单段生成上限:切段规划器按它决定"一张分镜表切成几次生成"。
13065
- // MiniMax 这类弱衔接模型建议填 6–10;Seedance 2.5 可以填到 15。
13385
+ // 分镜总时长(issue:下拉硬约束):首选项「按镜头节奏自动」(默认,data.targetDuration 缺省)
13386
+ // = 技能按节奏谱系自然分配各镜时长;选任何秒数(预设或自定义 1–300)= 本分镜节点总时长
13387
+ // 硬约束——不论切几镜,所有镜头 duration 之和严格等于该值(生成侧提示词注入 + 机械归位)。
13388
+ // 与切段规划器(planShotSegments 的 maxSeconds,恒用默认 15)解耦:本下拉只管总时长。
13066
13389
  isStoryboard
13067
13390
  ? h(PopupSelect, {
13068
- value: String(Number(n.data.segMaxSeconds) || 15), width: 84, title: T('segMaxLabel'), className: 'is-segmax',
13069
- options: [6, 8, 10, 12, 15, 20, 30].map((x) => ({ value: String(x), label: x + 's' })),
13070
- onChange: (v) => setData('segMaxSeconds', Number(v)),
13391
+ value: n.data.targetDuration != null && Number(n.data.targetDuration) > 0 ? String(Number(n.data.targetDuration)) : '',
13392
+ width: 84, title: T('targetDurationLabel'), className: 'is-segmax',
13393
+ options: [{ value: '', label: T('targetDurationAuto') }].concat([6, 8, 10, 12, 15, 20, 30].map((x) => ({ value: String(x), label: x + 's' }))),
13394
+ onChange: (v) => setData('targetDuration', v === '' ? null : Number(v)),
13071
13395
  editable: true, min: 1, max: 300, integer: false, decimals: 1,
13072
13396
  customLabel: (v) => String(v) + 's', customPlaceholder: T('customSegMaxPh'),
13073
13397
  })
@@ -14089,7 +14413,7 @@ function queueThumb(assetId) {
14089
14413
  const totalDur = shots.reduce((a, sh) => a + Math.max(0, Number(sh.duration) || 0), 0);
14090
14414
  // 切段预览:把"这张分镜表会被切成几次生成、每次几镜几秒、哪些段要接尾帧"直接显示在节点上,
14091
14415
  // 用户铺开前就知道会切成什么样——不用等到生成完才发现接不上。
14092
- const segPlan = shots.length ? planShotSegments(shots, { maxSeconds: Number(n.data.segMaxSeconds) || 15 }) : null;
14416
+ const segPlan = shots.length ? planShotSegments(shots, { maxSeconds: Number(n.data.targetDuration) || 15 }) : null;
14093
14417
  // 一致性告警的重校验:告警是**生成时刻**算的;设定集更新后有 bibleTick 自动重算(见下),
14094
14418
  // 这里保留手动入口兜底——点刷新按当前设定集重算(checkShotConsistency 读的是实时 bible/资产名索引)
14095
14419
  const [wvChecking, setWvChecking] = useState(false);
@@ -14228,7 +14552,7 @@ function queueThumb(assetId) {
14228
14552
  if (!shots.length) { toast(T('expandNoShots')); return; }
14229
14553
  const zh = effLang() !== 'en';
14230
14554
  // 切段规划:纯函数,可在面板上预览,也由 scripts/test-segment-plan.mjs 直接断言
14231
- const plan = planShotSegments(shots, { maxSeconds: Number(n.data.segMaxSeconds) || 15 });
14555
+ const plan = planShotSegments(shots, { maxSeconds: Number(n.data.targetDuration) || 15 });
14232
14556
  const segs = plan.segments.length ? plan.segments : [{ index: 0, shots, startIndex: 0, endIndex: shots.length - 1, duration: plan.total, firstSeg: 'opening', lastSeg: 'continuation', opensOnCut: true, closesOnCut: true, seamRisk: 'none', needsTailChain: false, reason: '' }];
14233
14557
  // 项目资产名称索引(用于把角色/场景/道具连接到已有资产节点)
14234
14558
  const recs = await idbByProject(S.activeId).catch(() => []);
@@ -22164,7 +22488,7 @@ const DIRECTOR_KEY_HELP = [
22164
22488
  // IC-04:参考图上传三件套的纯函数出口(供 scripts/test-image-upload.mjs 直接断言)
22165
22489
  window.__DSH_IC_IMGREF__ = { rawImageDims, sniffImageEncoding, registerReferenceAsset };
22166
22490
  // IC-03:视频厂商识别/前缀归一化的纯函数出口(供 scripts/test-vendor-detect.mjs 直接断言)
22167
- window.__DSH_IC_VENDOR__ = { detectVideoVendor, gatewayPrefixFor, wanEndpoints, vendorBase, VIDEO_REF_CAPS, needsSimpleMediaRetry, buildSimpleMediaRetryBody, wanTaskIdOf, wanStatusOf, wanPollState, buildSanbaoVideoBody, sanbaoTaskIdOf, sanbaoPollState, needsSanbaoMediaRetry, retryableDownloadError, downloadVideoWithRetry, SANBAO_DOWNLOAD_RETRY_MS, SANBAO_DOWNLOAD_RETRY_STEP_MS, buildSanbaoImageBody, sanbaoImageResultOf, sanbaoImagePollState, bibleStyleAnchor };
22491
+ window.__DSH_IC_VENDOR__ = { detectVideoVendor, gatewayPrefixFor, wanEndpoints, vendorBase, VIDEO_REF_CAPS, needsSimpleMediaRetry, buildSimpleMediaRetryBody, wanTaskIdOf, wanStatusOf, wanPollState, buildSanbaoVideoBody, sanbaoTaskIdOf, sanbaoPollState, needsSanbaoMediaRetry, retryableDownloadError, downloadVideoWithRetry, SANBAO_DOWNLOAD_RETRY_MS, SANBAO_DOWNLOAD_RETRY_STEP_MS, buildSanbaoImageBody, sanbaoImageResultOf, sanbaoImagePollState, bibleStyleAnchor, build6789VideoBody, api6789SizeOf, api6789ImageCap, api6789TaskIdOf, api6789StatusOf, api6789VideoUrlOf, api6789ErrorOf, api6789PollState, needs6789MediaHint };
22168
22492
  // 按镜头切段(分段生成本身就是最容易出错的地方):规划器 + 强弱模型分流 + 节点段区间解析
22169
22493
  // 供 scripts/test-segment-plan.mjs 直接断言
22170
22494
  window.__DSH_IC_SEGMENT__ = { planShotSegments, isCutPoint, segmentNeedsHardFrame, videoSegmentOf, shotContinuityPlan };
package/index.js CHANGED
@@ -4064,7 +4064,7 @@ export function apply(ctx) {
4064
4064
  const boards = [];
4065
4065
  let prevBoard = null;
4066
4066
  // 0.20.2 T5 防线②:分镜产出后的场时长校验。切段算法与 client.js 同源(shot-segments.js),
4067
- // 上限同式取分镜表节点 data.segMaxSeconds(缺省 15,不另立常量)。判据:切段段数 >1
4067
+ // 上限同式取分镜表节点 data.targetDuration(0.20.3 起下拉即总时长语义;缺省 15,不另立常量)。判据:切段段数 >1
4068
4068
  //(该场要拆多次生成才装得下)或任一单镜 duration 超上限 → 场超时长。
4069
4069
  const shotDurOf = (s) => Math.max(0.3, Math.round((Number(s && s.duration) || 3) * 10) / 10);
4070
4070
  const durCheck = (shots, cap) => {
@@ -4103,7 +4103,7 @@ export function apply(ctx) {
4103
4103
  const sbDoc = readToolDoc({ projectId: pid, canvasId: cid });
4104
4104
  const sbNode0 = sbDoc.nodes[sb.nodeId];
4105
4105
  origReq = String((sbNode0 && sbNode0.data && sbNode0.data.requirement) || '');
4106
- segMax = Number(sbNode0 && sbNode0.data && sbNode0.data.segMaxSeconds) || 15;
4106
+ segMax = Number(sbNode0 && sbNode0.data && sbNode0.data.targetDuration) || 15;
4107
4107
  } catch { /* 读不到按空处理 */ }
4108
4108
  let sbSt = await canvasExec(pid, cid, sb.nodeId, { timeoutMs: 10 * 60 * 1000 });
4109
4109
  let gate = PROD.gateStoryboard(sbSt.shots);
@@ -4229,7 +4229,7 @@ export function apply(ctx) {
4229
4229
  const sb = boards[i];
4230
4230
  run.paidPhase = 'video ' + (i + 1) + '/' + boards.length;
4231
4231
  const shots = Array.isArray(sb.data && sb.data.shots) ? sb.data.shots : [];
4232
- const segMax = Number(sb.data && sb.data.segMaxSeconds) || 15;
4232
+ const segMax = Number(sb.data && sb.data.targetDuration) || 15;
4233
4233
  const plan = planShotSegments(shots, { maxSeconds: segMax });
4234
4234
  // 客户端兜底同款(production.quote 同式):切段为空但表里有镜头 → 整表按一段
4235
4235
  const segs = plan.segments.length ? plan.segments
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ninkch/dsh-infinite-canvas",
3
- "version": "0.20.3",
3
+ "version": "0.20.4",
4
4
  "description": "无限画布(Infinite Canvas)for DeepSeek Harness:节点式创作工作室(剧本/分镜/生成/成片),内置「媒体创作」预设模式(导演第一视角 + 引导工作坊)。Version-agnostic: reads the live catalog from the installed package at load time.",
5
5
  "keywords": [
6
6
  "dsh",
package/production.js CHANGED
@@ -238,7 +238,7 @@ export function createProduction(deps) {
238
238
  * 角色/场景/道具 实体数),顶层 refImagesTotal;跨场共享实体只计一次(与执行侧
239
239
  * run 级 Map 同序先到先得,归属第一场)。已有参考资产(readAssetIndexNames 边界匹配)的不计。
240
240
  * 切段口径与客户端执行完全同源:同一个 planShotSegments(shot-segments.js,client.js 的逐字移植),
241
- * maxSeconds 同样取分镜表节点 data.segMaxSeconds(缺省 15,client.js L13883 同式)。
241
+ * maxSeconds 同样取分镜表节点 data.targetDuration(0.20.3 起下拉即总时长语义;缺省 15,client.js StoryboardNodeBody 同式)。
242
242
  * 单价由调用方传入(画布设置里的单价,未配置则不给金额,只给调用次数与秒数)。
243
243
  */
244
244
  function quote(pid, cid, unitPricePerSecond) {
@@ -258,7 +258,7 @@ export function createProduction(deps) {
258
258
  const secs = shots.reduce((a, s) => a + (Number(s && s.duration) || 0), 0);
259
259
  totalSeconds += secs;
260
260
  const hasVideo = videoNodes.some((v) => (doc.edges || []).some((e) => e.fromNode === n.id && e.toNode === v.id));
261
- const maxSeconds = Number(n.data.segMaxSeconds) || 15;
261
+ const maxSeconds = Number(n.data.targetDuration) || 15;
262
262
  // 已有视频的表不产生新调用;待生成的表按切段算法数段(与客户端 expandStoryboard 同式同默认)
263
263
  let calls = 0;
264
264
  let refImages = 0;
package/shot-segments.js CHANGED
@@ -8,7 +8,7 @@
8
8
  * - planShotSegments ← client.js L4389-4514
9
9
  *
10
10
  * 为什么必须逐字:真实视频调用次数由客户端切段决定(client.js expandStoryboard /
11
- * StoryboardNodeBody 都以 `planShotSegments(shots, { maxSeconds: Number(n.data.segMaxSeconds) || 15 })`
11
+ * StoryboardNodeBody 都以 `planShotSegments(shots, { maxSeconds: Number(n.data.targetDuration) || 15 })`
12
12
  * 的结果为准——一个分镜表 ≠ 一次生成)。宿主预算单(production.js quote)按这里的输出
13
13
  * 估算 videoCalls;任何语义简化都会让预算再次失真(#8:显示 4 次、实际 14 次)。
14
14
  *