@ninkch/dsh-infinite-canvas 0.20.1 → 0.20.3

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
@@ -893,7 +893,6 @@ function revealCanvasInRight() {
893
893
  'videoApi': '视频 API(提交 + 轮询)',
894
894
  'baseUrl': '接口地址',
895
895
  'apiKey': 'API Key',
896
- 'model': '模型',
897
896
  'size': '尺寸',
898
897
  'apiHintImage': '留空则使用内置演示模式(本地合成占位图)。配置后请求 POST {baseUrl}/images/generations。',
899
898
  'apiHintVideo': 'POST 接口地址提交任务,轮询 GET {url}/{taskId} 直到返回视频地址;留空则使用演示模式(本地合成动画视频)。',
@@ -1060,11 +1059,7 @@ function revealCanvasInRight() {
1060
1059
  'defaultVideoCfg': '默认视频模型',
1061
1060
  'imageApisLabel': '图片模型(可配多个)',
1062
1061
  'videoApisLabel': '视频模型(可配多个)',
1063
- 'addConfig': '新增配置',
1064
- 'setDefault': '设为默认',
1065
- 'isDefault': '默认',
1066
1062
  'cfgName': '名称',
1067
- 'delConfig': '删除此配置',
1068
1063
  'noCfgHint': '尚未配置;生成节点将使用演示模式',
1069
1064
  'bibleTab': '设定集',
1070
1065
  'bibleStyle': '风格基调(画风、年代、色调…跨集保持一致)',
@@ -1218,6 +1213,23 @@ function revealCanvasInRight() {
1218
1213
  'autoCapsOk': '多智能体:可用',
1219
1214
  'autoCapsNo': '多智能体:宿主未暴露会话服务(暂不可用)',
1220
1215
  'autoOldHost': '宿主插件是旧版本(不支持自动创作开关):完全重启 Harness 后可用',
1216
+ 'autoStartBtn': '启动创作',
1217
+ 'autoBriefPh': '一句话创意…',
1218
+ 'autoQuoteBtn': '刷新预算',
1219
+ 'autoApproveBtn': '批准付费',
1220
+ 'autoApprovePh': '输入「批准」或你的确认原话',
1221
+ 'autoApproveSubmit': '确认批准',
1222
+ 'autoGenerateBtn': '开始生成',
1223
+ 'autoAbortBtn': '中止',
1224
+ 'autoNeedQuote': '先刷新预算',
1225
+ 'autoQuoteSummary': '{s} 场 / {sh} 镜 / {sec} 秒 / 待调用 {calls} 次',
1226
+ 'autoQuoteCost': '估算 ¥{cost}',
1227
+ 'autoQuoteNoPrice': '未配置视频每秒单价(设置→制作 填入后显示估算金额)',
1228
+ 'autoApproveNeedConfirm': '请输入确认原话(批准付费必须留痕)',
1229
+ 'autoApproved': '已批准付费(待调用 {calls} 次)',
1230
+ 'autoAborted': '已中止(保留已产出内容)',
1231
+ 'autoDone': '完成',
1232
+ 'autoFail': '操作失败',
1221
1233
  'stageCurrent': '制作阶段',
1222
1234
  'stageReadyYes': '可交付',
1223
1235
  'stageReadyNo': '未就绪',
@@ -1263,7 +1275,6 @@ function revealCanvasInRight() {
1263
1275
  'renamed': '已重命名',
1264
1276
  'llmMaxTokens': '输出上限 maxTokens',
1265
1277
  'llmTemperature': '温度 temperature',
1266
- 'llmParamAuto': '留空 = 用 Harness/模型默认',
1267
1278
  'llmParamHint': '留空则不下发该参数,直接使用你在 Harness 里为该模型配置的默认值(插件不会写死任何生成参数)',
1268
1279
  'imgSizeOverride': '尺寸覆盖 size',
1269
1280
  'imgSizePlaceholder': '如 1024x1024(留空=按清晰度×比例)',
@@ -1291,6 +1302,20 @@ function revealCanvasInRight() {
1291
1302
  'mentionAssets': '已绑定资产 {n} 项(图片不自动上送,参考图请用连线)',
1292
1303
  'mentionNoAsset': '无绑定资产',
1293
1304
  'mentionNoAssetHint': '该实体没有绑定资产:@名称 只注入设定描述文字(外观/声音);参考图必须用图片节点连线到 ref 口,资产库里的图不会自动追加',
1305
+ 'reqPreview': '请求预览',
1306
+ 'reqPreviewHint': '打开后按需计算:即将发送的模型、时长、分辨率、参考图角色与最终提示词全文(与正式提交同一组装逻辑,只读、零额外点击)',
1307
+ 'reqPreviewFail': '预览失败',
1308
+ 'reqPreviewModel': '模型',
1309
+ 'reqPreviewFrame': '首帧/锚定',
1310
+ 'reqPreviewRefs': '参考图',
1311
+ 'reqPreviewAudio': '声音参考',
1312
+ 'reqPreviewWarnings': '校验提示',
1313
+ 'reqPreviewPrompt': '最终提示词',
1314
+ 'reqPreviewCopy': '复制提示词',
1315
+ 'anchorFirstFrame': '首帧锚定',
1316
+ 'anchorRefImage': '参考图锚定(首帧图为图1)',
1317
+ 'frameOffNone': '不带首帧',
1318
+ 'frameAutoTail': '自动续帧(上一段尾帧)',
1294
1319
  'craftTimeout': 'Craft 任务超时(可在任务面板重试或取消)',
1295
1320
  'errNoImageApi': '未配置图片 API:请到画布设置里添加(未配置时可用演示模式)',
1296
1321
  'photoCmd': 'Craft 命令',
@@ -1873,7 +1898,6 @@ function revealCanvasInRight() {
1873
1898
  'videoApi': 'Video API (submit + poll)',
1874
1899
  'baseUrl': 'Base URL',
1875
1900
  'apiKey': 'API Key',
1876
- 'model': 'Model',
1877
1901
  'size': 'Size',
1878
1902
  'apiHintImage': 'Leave empty to use the built-in demo mode (local placeholder images). When set, requests go to POST {baseUrl}/images/generations.',
1879
1903
  'apiHintVideo': 'POSTs the task to the URL and polls GET {url}/{taskId} until a video URL appears; leave empty for demo mode.',
@@ -2040,11 +2064,7 @@ function revealCanvasInRight() {
2040
2064
  'defaultVideoCfg': 'Default video model',
2041
2065
  'imageApisLabel': 'Image models (multiple)',
2042
2066
  'videoApisLabel': 'Video models (multiple)',
2043
- 'addConfig': 'Add config',
2044
- 'setDefault': 'Make default',
2045
- 'isDefault': 'default',
2046
2067
  'cfgName': 'Name',
2047
- 'delConfig': 'Delete this config',
2048
2068
  'noCfgHint': 'Nothing configured yet; generation nodes will use demo mode',
2049
2069
  'bibleTab': 'Bible',
2050
2070
  'bibleStyle': 'Style baseline (art, era, palette… kept across episodes)',
@@ -2199,6 +2219,23 @@ function revealCanvasInRight() {
2199
2219
  'autoCapsOk': 'Multi-agent: available',
2200
2220
  'autoCapsNo': 'Multi-agent: host does not expose session services (unavailable)',
2201
2221
  'autoOldHost': 'The plugin backend is older and lacks the auto-creation switch — fully restart Harness to enable',
2222
+ 'autoStartBtn': 'Start creation',
2223
+ 'autoBriefPh': 'One-line idea…',
2224
+ 'autoQuoteBtn': 'Refresh budget',
2225
+ 'autoApproveBtn': 'Approve paid run',
2226
+ 'autoApprovePh': 'Type "approve" or your own confirmation words',
2227
+ 'autoApproveSubmit': 'Confirm',
2228
+ 'autoGenerateBtn': 'Start generating',
2229
+ 'autoAbortBtn': 'Abort',
2230
+ 'autoNeedQuote': 'Refresh the budget first',
2231
+ 'autoQuoteSummary': '{s} scenes / {sh} shots / {sec}s / {calls} video calls pending',
2232
+ 'autoQuoteCost': 'Est. ¥{cost}',
2233
+ 'autoQuoteNoPrice': 'No per-second video price configured (set it in Settings → Production to show an estimate)',
2234
+ 'autoApproveNeedConfirm': 'Type your confirmation words first (paid approval must leave a trace)',
2235
+ 'autoApproved': 'Approved ({calls} video calls pending)',
2236
+ 'autoAborted': 'Aborted (produced content kept)',
2237
+ 'autoDone': 'Done',
2238
+ 'autoFail': 'Action failed',
2202
2239
  'stageCurrent': 'Stage',
2203
2240
  'stageReadyYes': 'deliverable',
2204
2241
  'stageReadyNo': 'not ready',
@@ -2244,7 +2281,6 @@ function revealCanvasInRight() {
2244
2281
  'renamed': 'Renamed',
2245
2282
  'llmMaxTokens': 'Output cap (maxTokens)',
2246
2283
  'llmTemperature': 'Temperature',
2247
- 'llmParamAuto': 'empty = Harness/model default',
2248
2284
  'llmParamHint': 'Left empty, the parameter is not sent at all — the model uses the default you configured in Harness. The plugin never hardcodes generation parameters.',
2249
2285
  'imgSizeOverride': 'Size override',
2250
2286
  'imgSizePlaceholder': 'e.g. 1024x1024 (empty = clarity × ratio)',
@@ -2272,6 +2308,20 @@ function revealCanvasInRight() {
2272
2308
  'mentionAssets': '{n} asset(s) bound (images are not auto-sent; wire references explicitly)',
2273
2309
  'mentionNoAsset': 'no bound asset',
2274
2310
  'mentionNoAssetHint': 'No asset bound to this entity: @name only injects bible text (looks/voice); reference images must be wired into the ref port — library images are never auto-added',
2311
+ 'reqPreview': 'Request preview',
2312
+ 'reqPreviewHint': 'Computed on demand: model, duration, resolution, reference roles and the full final prompt exactly as it will be sent (same assembly as the real submission; read-only, zero extra clicks)',
2313
+ 'reqPreviewFail': 'Preview failed',
2314
+ 'reqPreviewModel': 'Model',
2315
+ 'reqPreviewFrame': 'Frame/anchor',
2316
+ 'reqPreviewRefs': 'Refs',
2317
+ 'reqPreviewAudio': 'Voice refs',
2318
+ 'reqPreviewWarnings': 'Checks',
2319
+ 'reqPreviewPrompt': 'Final prompt',
2320
+ 'reqPreviewCopy': 'Copy prompt',
2321
+ 'anchorFirstFrame': 'first_frame anchor',
2322
+ 'anchorRefImage': 'reference_image anchor (frame is image #1)',
2323
+ 'frameOffNone': 'no frame',
2324
+ 'frameAutoTail': 'auto continuation (previous tail frame)',
2275
2325
  'craftTimeout': 'Craft job timed out (retry or cancel it in the job panel)',
2276
2326
  'errNoImageApi': 'No image API configured — add one in canvas settings (demo mode is available without one)',
2277
2327
  'photoCmd': 'Craft command',
@@ -3501,6 +3551,13 @@ body[data-ds-dark-theme] .dshic-storage-details{border-color:var(--dsw-alias-bor
3501
3551
  line-height:var(--dshic-panel-lh);padding:var(--dshic-panel-pad);}
3502
3552
  .dshic-composer .dshic-prompt-input{background:transparent;border-color:transparent;}
3503
3553
  .dshic-composer-extra{display:flex;flex-direction:column;gap:6px;padding:6px 12px 0;}
3554
+ /* 请求预览(0.20.2):折叠区展开后的只读快照(模型/参数/参考图顺序/校验/最终提示词全文) */
3555
+ .dshic-req-preview{display:flex;flex-direction:column;gap:5px;padding:6px 8px;border:1px solid var(--dshic-line, rgba(128,128,128,.25));border-radius:8px;}
3556
+ .dshic-req-grid{display:flex;flex-direction:column;gap:4px;}
3557
+ .dshic-req-warns{display:flex;flex-direction:column;gap:3px;}
3558
+ .dshic-req-prompt{max-height:180px;overflow:auto;font-size:11px;line-height:16px;white-space:pre-wrap;word-break:break-word;
3559
+ padding:6px 8px;border-radius:6px;background:color-mix(in srgb,var(--dshic-ink) 5%,transparent);
3560
+ scrollbar-width:thin;scrollbar-color:var(--dshic-ink3, rgba(128,128,128,.5)) transparent;}
3504
3561
  /* 「更多」折叠开关:面板默认只显示「参考图条 / 提示词 / 一行控件」;
3505
3562
  高级项收进这里,默认收起、不渲染(不占版面),点开才出现。 */
3506
3563
  .dshic-composer-morebar{display:flex;align-items:center;flex:none;padding:2px 12px 0;}
@@ -3576,8 +3633,8 @@ body[data-ds-dark-theme] .dshic-pick-item.is-on{background:color-mix(in srgb,var
3576
3633
  videoProviders: [], // [{id, name, url, apiKey, extra, outputFormat?, generateAudio?, protocol?, watermark?, models: [{id, model}]}]
3577
3634
  imageStar: '', // 'providerId|modelId'
3578
3635
  videoStar: '',
3579
- ttsApis: [], // [{id, name, baseUrl, apiKey, model, voice}]
3580
- ttsApiId: '',
3636
+ ttsProviders: [], // [{id, name, baseUrl, apiKey, timeoutMs?, models: [{id, model, voice}]}] —— voice 每模型一个,timeoutMs 供应商级
3637
+ ttsStar: '', // 'providerId|modelId'
3581
3638
  lang: '', // '' = 跟随 Harness
3582
3639
  };
3583
3640
  function loadSettings() {
@@ -3590,8 +3647,8 @@ body[data-ds-dark-theme] .dshic-pick-item.is-on{background:color-mix(in srgb,var
3590
3647
  videoStar: s.videoStar || '',
3591
3648
  // dsh-image-gen 桥接:启用后画布不自配图片 API,直接走它的 /studio(密钥留在它宿主侧)
3592
3649
  imageGen: { enabled: !!(s.imageGen && s.imageGen.enabled), provider: (s.imageGen && s.imageGen.provider) || '', model: (s.imageGen && s.imageGen.model) || '' },
3593
- ttsApis: Array.isArray(s.ttsApis) ? s.ttsApis : [],
3594
- ttsApiId: s.ttsApiId || '',
3650
+ ttsProviders: Array.isArray(s.ttsProviders) ? s.ttsProviders : [],
3651
+ ttsStar: s.ttsStar || '',
3595
3652
  lang: s.lang || '',
3596
3653
  // 专家:缺字段/非法值/旧字段(skillScript/skillStoryboard)→ 一律回退 general,不报错
3597
3654
  };
@@ -3638,12 +3695,34 @@ body[data-ds-dark-theme] .dshic-pick-item.is-on{background:color-mix(in srgb,var
3638
3695
  legacyVideoApiRefMap = {};
3639
3696
  for (const cfg of s.videoApis) legacyVideoApiRefMap[cfg.id] = 'p_' + cfg.id + '|m_' + cfg.id;
3640
3697
  }
3698
+ // v0.20.2 及以前 TTS 扁平 API(一配置一模型一 voice)→ 供应商 + 模型列表(issue #6 第二阶段):
3699
+ // 与 image/video 同规:派生 id 确定性沿用旧 cfg id(loadSettings 高频调用,绝不用 uid());
3700
+ // 节点数据只存 data.tts[edgeId] = {status, assetId}(无 ttsApiId),零节点迁移负担
3701
+ if (!out.ttsProviders.length && Array.isArray(s.ttsApis) && s.ttsApis.length) {
3702
+ out.ttsProviders = s.ttsApis.map((cfg) => ({
3703
+ id: 'p_' + cfg.id, name: cfg.name || T('defaultTtsCfg'),
3704
+ baseUrl: cfg.baseUrl || '', apiKey: cfg.apiKey || '',
3705
+ timeoutMs: cfg.timeoutMs || '',
3706
+ models: [{ id: 'm_' + cfg.id, model: cfg.model || '', voice: cfg.voice || 'alloy' }],
3707
+ }));
3708
+ out.ttsStar = (s.ttsApiId && 'p_' + s.ttsApiId + '|m_' + s.ttsApiId) || (out.ttsProviders[0] ? out.ttsProviders[0].id + '|' + out.ttsProviders[0].models[0].id : '');
3709
+ }
3641
3710
  return out;
3642
3711
  }
3643
3712
  function saveSettings(s) {
3644
3713
  lsSet(LS_SETTINGS, s);
3645
3714
  notify(); // 设置即改即存(无保存按钮),但必须通知画布重渲染——否则节点上的模型下拉/星标一直是旧快照
3646
3715
  }
3716
+ /** 设置卡写回:以磁盘最新值为基底叠加本卡变更,杜绝跨卡丢失更新(issue #6)。
3717
+ * 旧模式(每张卡持有挂载时快照、把整对象写回)会让卡 B 的任何保存把卡 A 刚写的字段静默回滚。
3718
+ * base = loadSettings() 现取;apply(base) 返回改了本卡字段的副本;写回 + notify。
3719
+ * 返回写回后的新设置——调用方必须 setS(返回值) 同步本地快照,否则同卡二次编辑的渲染基底仍陈旧。 */
3720
+ function updateSettings(apply) {
3721
+ const base = loadSettings();
3722
+ const next = apply(base);
3723
+ saveSettings(next);
3724
+ return next;
3725
+ }
3647
3726
 
3648
3727
  // ---------- 供应商 + 模型(图片/视频):扁平视图与解析 ----------
3649
3728
  let legacyImageApiRefMap = {}; // 旧扁平配置 id → 'providerId|modelId'(节点字段懒迁移用)
@@ -3673,6 +3752,17 @@ body[data-ds-dark-theme] .dshic-pick-item.is-on{background:color-mix(in srgb,var
3673
3752
  }
3674
3753
  return out;
3675
3754
  }
3755
+ /** 供应商列表 → 扁平 TTS 模型视图(ref = 'providerId|modelId');未填模型名的条目不进下拉(与 image/video 同规)。 */
3756
+ function flattenTtsModels(settings) {
3757
+ const out = [];
3758
+ for (const p of settings.ttsProviders || []) {
3759
+ for (const m of (p.models || [])) {
3760
+ if (!m || !m.id || !String(m.model || '').trim()) continue;
3761
+ out.push({ ref: p.id + '|' + m.id, providerId: p.id, providerName: p.name || p.id, modelId: m.id, model: String(m.model).trim(), voice: m.voice || 'alloy', baseUrl: p.baseUrl || '', apiKey: p.apiKey || '', timeoutMs: p.timeoutMs || '' });
3762
+ }
3763
+ }
3764
+ return out;
3765
+ }
3676
3766
  /** 解析节点上的模型引用:空 = 星标默认模型;都没有 = null(运行时报错)。 */
3677
3767
  function resolveImageModelCfg(settings, ref) {
3678
3768
  const list = flattenImageModels(settings);
@@ -7549,11 +7639,6 @@ function queueThumb(assetId) {
7549
7639
  return ['succeeded', 'success', 'completed', 'complete', 'done', 'finished'].includes(taskStatusOf(st));
7550
7640
  }
7551
7641
 
7552
- function resolveApiCfg(list, defId, wantId) {
7553
- if (!Array.isArray(list) || !list.length) return null;
7554
- return list.find((x) => x.id === wantId) || list.find((x) => x.id === defId) || list[0];
7555
- }
7556
-
7557
7642
  /** PCM 采样数组 → WAV Blob(单声道 16-bit,声音参考不需要立体声)。 */
7558
7643
  function pcmToWavBlob(samples, sampleRate) {
7559
7644
  const n = samples.length;
@@ -9463,7 +9548,10 @@ function queueThumb(assetId) {
9463
9548
  }));
9464
9549
  }
9465
9550
  /** 本地一致性检查:分镜里出现的角色/场景/道具(含 visual/motion 文本里的 @提及)是否都在
9466
- * 设定集/资产中登记;两级告警——「未登记」与「已登记但描述为空(待补全)」。 */
9551
+ * 设定集/资产中登记;两级告警——「未登记」与「已登记但描述为空(待补全)」。
9552
+ * 台词碎片豁免:名字以「的」结尾且出现在对白文本里的角色/场景/道具视为描述性片段(如台词
9553
+ * 「来了个带纸的」被抽成道具「带纸的」),未登记不告警——与 Host index.js
9554
+ * storyboardConsistencyWarnings 同规则,两边必须字面同构(防漂移)。 */
9467
9555
  async function checkShotConsistency(shots) {
9468
9556
  const bible = loadBible(S.activeId);
9469
9557
  const entries = [];
@@ -9479,7 +9567,13 @@ function queueThumb(assetId) {
9479
9567
  const warnings = [];
9480
9568
  const seen = new Set();
9481
9569
  const warn = (line) => { if (!seen.has(line) && warnings.length < 12) { seen.add(line); warnings.push(line); } };
9482
- const check = (title, kind, name) => {
9570
+ // 台词碎片收集(与 Host index.js storyboardConsistencyWarnings 同规则——两边必须字面同构,防漂移):
9571
+ // 拼接同 shots 数组内全部对白文本;shots 无 dialogue 字段(旧数据)时按「无对白可查」自然不跳过。
9572
+ let dialogueAll = '';
9573
+ for (const sh of shots || []) {
9574
+ for (const d of ((sh && sh.dialogue) || [])) dialogueAll += ' ' + String((d && d.line) || '');
9575
+ }
9576
+ const check = (title, kind, name, entity) => {
9483
9577
  const q = String(name || '').trim().toLowerCase();
9484
9578
  if (!q) return;
9485
9579
  const exact = entries.find((e) => e.lower === q);
@@ -9487,17 +9581,19 @@ function queueThumb(assetId) {
9487
9581
  if (!exact.desc.trim()) warn(`${title} · ${kind}「${exact.name}」${T('warnEmptyDesc')}`);
9488
9582
  return;
9489
9583
  }
9584
+ // 台词碎片跳过:仅 角色/场景/道具 三类(entity=true);@提及 通道绝不跳过,「已登记但描述为空」路径(上方)不跳过
9585
+ if (entity && String(name || '').trim().endsWith('的') && dialogueAll.includes(String(name || '').trim())) return;
9490
9586
  for (const k of known) { if (k.includes(q) || q.includes(k)) return; }
9491
9587
  warn(`${title} · ${kind}「${String(name).trim()}」${T('warnUnregistered')}`);
9492
9588
  };
9493
9589
  for (const sh of shots) {
9494
9590
  const title = String(sh.title || '').trim() || T('shotPrefix');
9495
- for (const nm of (sh.characters || [])) check(title, T('catCharacter'), nm);
9496
- check(title, T('catScene'), sh.scene);
9497
- for (const nm of (sh.props || [])) check(title, T('catProp'), nm);
9591
+ for (const nm of (sh.characters || [])) check(title, T('catCharacter'), nm, true);
9592
+ check(title, T('catScene'), sh.scene, true);
9593
+ for (const nm of (sh.props || [])) check(title, T('catProp'), nm, true);
9498
9594
  // visual/motion 文本里的 @资产名@ 提及同样纳入检查(未登记的会提示补充资产——这是检查的价值所在)
9499
9595
  const text = String(sh.visual || '') + ' ' + String(sh.motion || '');
9500
- for (const mm of parseMentions(text)) check(title, T('catMention'), mm.name);
9596
+ for (const mm of parseMentions(text)) check(title, T('catMention'), mm.name, false);
9501
9597
  }
9502
9598
  return warnings;
9503
9599
  }
@@ -9602,6 +9698,9 @@ function queueThumb(assetId) {
9602
9698
  menu: null, // {x, y, kind:'add'}
9603
9699
  composerId: null, // 生成面板当前挂靠的节点 id(单例;纯 UI 状态,不持久化)
9604
9700
  assetsTick: 0,
9701
+ // 设定集更新信号:编辑器 persist 后自增,分镜详情据此自动重算一致性告警(旧告警自动消失,免手动 revalidate)。
9702
+ // 不复用 assetsTick——它在资产事件上到处自增,会让无关事件反复触发重算。
9703
+ bibleTick: 0,
9605
9704
  tick: 0,
9606
9705
  craftStatus: null, // {at, data} | {at, error}
9607
9706
  dataRoot: null, // 数据根目录(Host 配置);null = 未设置(资产走 IndexedDB)
@@ -10718,6 +10817,15 @@ function queueThumb(assetId) {
10718
10817
  }
10719
10818
  }
10720
10819
 
10820
+ /** 提交留痕写入(0.20.2 能力③):追加到项目目录 submissions.jsonl
10821
+ * (宿主侧统一 redact + 500 行裁剪;entry 形状见 index.js submissionLogAppend)。
10822
+ * 留痕默认开启、自动、无感(预览面板不放入口);写失败绝不影响生成主链路。 */
10823
+ async function logVideoSubmission(entry) {
10824
+ try {
10825
+ await hostRpc('submissionLogAppend', { projectId: S.activeId, entry });
10826
+ } catch { /* 留痕尽力而为:Host 不在/目录不可写都不能挡住生成 */ }
10827
+ }
10828
+
10721
10829
  async function runGenNode(n) {
10722
10830
  const type = n.type;
10723
10831
  const settings = loadSettings(); // 模型解析(供应商+模型)用
@@ -10800,55 +10908,12 @@ function queueThumb(assetId) {
10800
10908
  if (!cases.length) throw new Error(T('noResult'));
10801
10909
  } else {
10802
10910
  const { refs, entities, audioBlobs } = await collectRefs(n, prompt, bible);
10803
- // 上游是分镜表 → 走厂商「参考生成」结构化提示词(主体/分镜/台词/声音显式绑定,音画同步;
10804
- // 机械拼装会让模型把台词与场景判错);节点上已手写结构化提示词则原样尊重。
10805
- const sbUp = storyboardInputOf(n);
10806
- const shotListAll = sbUp && Array.isArray(sbUp.data.shots) ? sbUp.data.shots : [];
10807
- // 按镜头切段:上游分镜表被"按镜头切段"铺开过时,每个视频节点只负责自己那一段镜头。
10808
- // 只取本段的镜头去组提示词——绝不把整表的镜头都塞进一次请求(那正是"动作被压成平移"的根因)。
10809
- const segMeta = (() => {
10810
- const d = (n.data || {});
10811
- if (!shotListAll.length) return null;
10812
- const from = Number(d.segShotFrom);
10813
- const to = Number(d.segShotTo);
10814
- if (!Number.isFinite(from) || !Number.isFinite(to) || to < from) return null;
10815
- return { from: Math.max(0, Math.floor(from)), to: Math.min(shotListAll.length - 1, Math.floor(to)), index: Number(d.segIndex) || 0, count: Number(d.segCount) || 1, needsTailChain: d.needsTailChain === true, seamRisk: String(d.seamRisk || 'none') };
10816
- })();
10817
- const shotList = segMeta ? shotListAll.slice(segMeta.from, segMeta.to + 1) : shotListAll;
10818
- // 时长策略:未连分镜用节点秒数;已连分镜按本段镜头节拍求和(节点秒数不进请求)
10819
- const durationPlan = videoDurationFor(n, shotList, !!sbUp);
10820
- const autoDuration = durationPlan.value || 5;
10821
- const handWritten = String(n.data.prompt || '').trim();
10822
- // 手写厂商结构化提示词 = 高级直通路径:保留用户的 subject/shot 结构,
10823
- // 只补实体设定文字;风格锁与承接前置块都不再追加,避免污染厂商协议格式。
10824
- const handStructured = handWritten.includes('subject_definitions');
10825
- // 分镜衔接规划:段落类型(续帧/换场/新角色/特写插入)+ 首镜承接口 + 是否接力尾帧
10826
- const zh = effLang() !== 'en';
10827
- const plan = (() => {
10828
- if (!shotList.length) return { first: null, chain: false, join: 'loose', seg: 'opening', fromShot: false };
10829
- const first = shotContinuityPlan(shotList[0], null, 0);
10830
- // 分镜衔接总开关(分镜表 cont):关掉 = 不做跨段承接、不自动取尾帧、不写衔接块
10831
- const contOn = sbUp ? sbUp.data.cont !== false : true;
10832
- // 跨分镜表承接:上游分镜表「衔接上一镜」输入口 ← 上一个分镜表「尾镜」输出口
10833
- const prevSb = (() => {
10834
- const e2 = S.graph.edges.find((x) => x.toNode === (sbUp && sbUp.id) && x.toPort === 'prev');
10835
- const src = e2 && S.graph.nodes[e2.fromNode];
10836
- return src && src.type === 'storyboard' ? src : null;
10837
- })();
10838
- const prevNote = prevSb ? storyboardContinuityNote(prevSb.data.shots || [], String(prevSb.data.label || ''), zh) : null;
10839
- let seg = first.seg;
10840
- // 第 1 镜没有表内上一镜时,可承接上一个分镜表 → 实质是续帧
10841
- if (seg === 'opening' && prevNote) seg = 'continuation';
10842
- const join = (seg === 'scene_change' || seg === 'new_character') ? 'loose' : seg === 'closeup' ? 'cut' : 'strict';
10843
- // 接力判定:切段铺开时以**规划器**为准(它知道本段是否从切点开始);
10844
- // 直接把整表塞一次生成的旧路径才退回"首镜是续帧就接力"。
10845
- const chain = contOn && (segMeta ? (segMeta.needsTailChain && seg === 'continuation') : seg === 'continuation');
10846
- return { first, chain, seg, join, fromShot: contOn && (segMeta ? segMeta.needsTailChain : !!prevNote), contOn, segMeta };
10847
- })();
10911
+ // —— 决策基座(分镜切片/时长策略/衔接规划):与「请求预览」共用同一份(assembleVideoRequest)——
10912
+ const vctx = videoRequestContext(n);
10848
10913
  // 首帧来源:① frame 口连线(用户显式)② 续帧链自动取「上一个视频」的尾帧
10849
10914
  let frameBlob = await resolveAssetBlob(n.id, 'frame');
10850
10915
  let frameAuto = false;
10851
- if (!frameBlob && plan.chain) {
10916
+ if (!frameBlob && vctx.plan.chain) {
10852
10917
  const prevVid = autoPrevVideoNode(n);
10853
10918
  if (prevVid && prevVid.data.assetId) {
10854
10919
  try {
@@ -10870,89 +10935,62 @@ function queueThumb(assetId) {
10870
10935
  } catch { /* 取不到尾帧则降级为纯参考图生成 */ }
10871
10936
  }
10872
10937
  }
10873
- const frameMode = n.data.frameMode || 'auto';
10938
+ // 组装最终请求(与请求预览**同一函数**;p 内容与旧内联实现逐字等价——重构红线)
10939
+ const assembled = await assembleVideoRequest(n, {
10940
+ prompt, bible,
10941
+ refs: refs.map((r) => ({ name: r.name, category: r.category, entity: r.entity || '' })),
10942
+ entities,
10943
+ audioNames: audioBlobs.map((a) => a.name),
10944
+ hasFrame: !!frameBlob,
10945
+ frameAuto,
10946
+ });
10947
+ const p = assembled.p;
10948
+ const params = assembled.params;
10949
+ const autoDuration = params.duration;
10950
+ const frameMode = params.frameMode;
10951
+ const hardFrame = params.hardFrame;
10874
10952
  const useFrame = frameMode !== 'off' && !!frameBlob;
10875
- // 硬首帧只在"不挂实体参考图"时可用(多数厂商 first_frame 与 reference_image 互斥);
10876
- // 续帧段若还要实体参考图 → 尾帧降级为首张参考图 + 软锚定(frameAnchorText 会写明)
10877
- const hardFrame = useFrame && frameMode === 'hard';
10878
- const anchorRole = (useFrame && !hardFrame && refs.length) ? 'reference_image' : 'first_frame';
10879
- let music = '';
10880
- try { const ex2 = parseExtraParams(n.data.vidExtra); if (ex2 && typeof ex2.music === 'string') music = ex2.music; } catch { /* 扩展参数非法时忽略音乐提示 */ }
10881
- // 跨段承接说明:本分镜第 1 镜承接上一个分镜表尾镜(续帧时首帧图已带画面,这里补文字约束)
10882
- const continuity = (() => {
10883
- if (!plan.fromShot) return '';
10884
- const st = shotList[0] || {};
10885
- const tail = String(st.tail || '').trim();
10886
- const bits = [];
10887
- if (plan.seg === 'continuation') {
10888
- bits.push(zh ? '本段是上一段的直接续帧:第 1 帧从上一段结尾接着演,不重演、不重新建立场景、不切换机位' : 'This segment continues the previous one: start from its last frame, no replay, no re-establishing, no camera reset');
10889
- if (tail) bits.push((zh ? '起始状态:' : 'Start state: ') + tail);
10890
- } else if (plan.seg === 'scene_change') {
10891
- bits.push(zh ? '本段换场:不承接上一段画面,但环境声/情绪可延续' : 'Scene change: do not continue the previous frame; ambience and mood may carry over');
10892
- } else if (plan.seg === 'new_character') {
10893
- // 特效入场(灯闪现身/影子凝聚/影化实)合法:首镜 vfx/start 写明特效进入时不逼"走入"
10894
- const fxEntry = /凝聚|凭空|灯闪|黑场|影子|化实|现身|浮现/.test(
10895
- String(st.vfx || '') + String(st.start || '') + String(st.visual || '') + String(st.motion || ''));
10896
- bits.push(zh
10897
- ? (fxEntry
10898
- ? '本段有新角色入场(特效进入):灯闪/黑场后已在场、从影子凝聚立起、浮现成形——不得缓慢走入'
10899
- : '本段有新角色入场:新角色必须从画面内自然进入(走入/被带入),不得凭空出现')
10900
- : (fxEntry
10901
- ? 'A new character enters via an effect: already there after a flash/black frame, rises from a shadow, condenses into form - never walks in slowly'
10902
- : 'A new character enters: they must enter naturally from within the frame, never pop in'));
10903
- }
10904
- return bits.join(zh ? ';' : '; ');
10905
- })();
10906
- let p;
10907
- // 图1=尾帧(降级模式)时实体参考图为图2..N+1:两条提示词组装路径都要同步偏移
10908
- const effOpts = { picOffset: (useFrame && anchorRole === 'reference_image') ? 1 : 0 };
10909
- if (handStructured) {
10910
- p = handWritten; // 高级用法:手写结构化提示词,结构原样保留
10911
- // 只追加 series_bible 文字块:不动用户写好的主体/镜头结构,也不追加任何参考图与风格锁。
10912
- if (!/series_bible/i.test(p)) {
10913
- const bb = entityBibleBlock(entities, bible, zh);
10914
- if (bb) p = p + '\n' + bb;
10915
- }
10916
- } else if (shotList.length) {
10917
- p = buildStructuredVideoPrompt(shotList, refs, bible, {
10918
- zh, prompt: handWritten, music, hasFrame: useFrame, frameRole: anchorRole, continuity,
10919
- // @引用命中实体的设定文字(外观/声音):只注入文本,参考图仍严格只取 ref 连线
10920
- entities,
10921
- });
10922
- if (!p) p = buildEffectivePrompt(prompt, refs, entities, bible, false, effOpts); // 无参考图时回退
10923
- } else {
10924
- p = buildEffectivePrompt(prompt, refs, entities, bible, false, effOpts);
10925
- }
10926
- // 非结构化路径(无参考图/手写提示词)也要有首帧锚定与承接说明
10927
- if ((!shotList.length || !p.includes('subject_definitions')) && !handStructured) {
10928
- const pre = [frameAnchorText({ hasFrame: useFrame, role: anchorRole, zh }), continuity].filter(Boolean).join(zh ? ';' : '; ');
10929
- if (pre) p = pre + '\n' + p;
10930
- }
10931
- // 自动组装路径才追加技能包风格锁;手写厂商结构化提示词保持用户协议结构
10932
- if (!handStructured) {
10933
- try {
10934
- const lock = await buildShotLockText('prompt');
10935
- if (lock) p = p + '\n' + lock;
10936
- } catch { /* 技能包不可用时不影响生成 */ }
10937
- }
10938
10953
  const mcfg = resolveVideoModelCfg(settings, nodeVideoModelRef(n));
10939
10954
  if (!mcfg) throw new Error(T('errNoVideoModel'));
10940
- if (sbUp && !durationPlan.value) addWarn('已连接分镜但暂无镜头时长:视频时长回退 5s(先生成分镜镜头后重跑)');
10941
- const blob = await apiVideo(p, useFrame ? frameBlob : null, mcfg, {
10955
+ // 提交前校验门(能力①):warnings 单一事实源来自 assembleVideoRequest,生成时逐条显式提示
10956
+ // (含旧有的「已连接分镜但暂无镜头时长」原文)——绝不静默修改请求
10957
+ for (const w of params.warnings) addWarn(w);
10958
+ // 脱敏留痕(能力③):失败/未完成也要留底(saveAssetRecord 只在成功后写,追溯不到失败)。
10959
+ // entry 绝不含 taskQueryUrl(带签名地址)/apiKey/素材数据——redact 在宿主侧统一执行。
10960
+ const logBase = () => ({
10961
+ at: Date.now(), projectId: S.activeId, nodeId: n.id, nodeLabel: (n.data && n.data.label) || '',
10962
+ kind: 'video',
10963
+ model: mcfg ? { provider: mcfg.providerName || mcfg.providerId, id: mcfg.model } : { provider: '', id: '' },
10942
10964
  duration: autoDuration, resolution: n.data.resolution, ratio: n.data.ratio,
10943
- frameMode, // auto=尾帧降级为参考图(保留实体参考图)/ hard=硬首帧(放弃参考图)/ off=忽略首帧
10944
- hardFrame,
10945
- refs: refs.map((r) => r.blob),
10946
- refNames: refs.map((r) => r.entity || r.name || ''), // 跨镜衔接标注用(图2..N 的实体名)
10947
- nodeExtra: n.data.vidExtra, // 节点级扩展参数(手动参数框,如 {"use_context_ir":true})
10948
- warn: addWarn, // 参考素材超限等告警回传(节点上可见)
10949
- // 任务提交成功即持久化 task id:轮询中断/页面关闭后仍可凭 id 回查结果(钱花了就必须能找回)
10950
- onTask: (tid, qurl) => {
10951
- update((s) => { const nd = s.graph.nodes[n.id]; if (nd) { nd.data.taskId = String(tid || ''); nd.data.taskQueryUrl = String(qurl || ''); } });
10952
- flushSave();
10953
- },
10954
- audioRefs: audioBlobs.map((a) => a.blob), // 角色声音参考(@引用实体名下的音频资产)
10965
+ frameMode, hardFrame,
10966
+ refNames: params.refNames, audioNames: params.audioNames,
10967
+ promptChars: p.length, effectivePrompt: p, taskId: '', status: 'submitted',
10955
10968
  });
10969
+ let subTid = ''; // onTask 回传的任务 id(失败留痕要能对上已提交的任务)
10970
+ let blob = null;
10971
+ try {
10972
+ blob = await apiVideo(p, useFrame ? frameBlob : null, mcfg, {
10973
+ duration: autoDuration, resolution: n.data.resolution, ratio: n.data.ratio,
10974
+ frameMode, // auto=尾帧降级为参考图(保留实体参考图)/ hard=硬首帧(放弃参考图)/ off=忽略首帧
10975
+ hardFrame,
10976
+ refs: refs.map((r) => r.blob),
10977
+ refNames: refs.map((r) => r.entity || r.name || ''), // 跨镜衔接标注用(图2..N 的实体名)
10978
+ nodeExtra: n.data.vidExtra, // 节点级扩展参数(手动参数框,如 {"use_context_ir":true})
10979
+ warn: addWarn, // 参考素材超限等告警回传(节点上可见)
10980
+ // 任务提交成功即持久化 task id:轮询中断/页面关闭后仍可凭 id 回查结果(钱花了就必须能找回)
10981
+ onTask: (tid, qurl) => {
10982
+ update((s) => { const nd = s.graph.nodes[n.id]; if (nd) { nd.data.taskId = String(tid || ''); nd.data.taskQueryUrl = String(qurl || ''); } });
10983
+ flushSave();
10984
+ subTid = String(tid || '');
10985
+ logVideoSubmission({ ...logBase(), taskId: subTid, status: 'submitted' }); // 提交留痕(自动、无感)
10986
+ },
10987
+ audioRefs: audioBlobs.map((a) => a.blob), // 角色声音参考(@引用实体名下的音频资产)
10988
+ });
10989
+ } catch (eSub) {
10990
+ // 失败留痕(本能力的主要价值):throw 前先落一条 failed,再原样抛出(异常时序与旧实现一致)
10991
+ logVideoSubmission({ ...logBase(), taskId: subTid, status: 'failed', error: String((eSub && eSub.message) || eSub) });
10992
+ throw eSub;
10993
+ }
10956
10994
  const rec = await saveAssetRecord(S.activeId, 'video', blob, {
10957
10995
  name: assetNameFor(n, entities, 'video'),
10958
10996
  prompt: stripMentionMarks(prompt), effectivePrompt: p,
@@ -10962,6 +11000,7 @@ function queueThumb(assetId) {
10962
11000
  nodeLabel: (n.data && n.data.label) || '',
10963
11001
  category: 'finalcut', // 节点生成的视频 = 成片(实体归属由 entities 字段承担,不占用分类)
10964
11002
  });
11003
+ logVideoSubmission({ ...logBase(), taskId: subTid, status: 'done' }); // 终态留痕(fire-and-forget,不改变回写时序)
10965
11004
  // 记录续帧来源(节点上可追溯:本段是从哪一段接过来的)
10966
11005
  if (useFrame) {
10967
11006
  update((s) => {
@@ -11019,14 +11058,14 @@ function queueThumb(assetId) {
11019
11058
  });
11020
11059
  }
11021
11060
  // 接缝校验:本段首帧 vs 上一段尾帧(续帧段才有意义)。不达标 → 节点上可见告警(不静默)
11022
- if (useFrame && plan.chain) {
11061
+ if (useFrame && vctx.plan.chain) {
11023
11062
  try {
11024
11063
  const first = await extractFirstFrame(blob);
11025
11064
  if (first) {
11026
11065
  const ga = await grayThumb(frameBlob, 32);
11027
11066
  const gb = await grayThumb(first, 32);
11028
11067
  const met = frameSeamMetrics(ga, gb);
11029
- const v = seamVerdict(met, plan.join);
11068
+ const v = seamVerdict(met, vctx.plan.join);
11030
11069
  update((s) => {
11031
11070
  const nd = s.graph.nodes[n.id];
11032
11071
  if (nd) nd.data.seam = { ok: v.ok, sim: v.sim == null ? null : Math.round(v.sim * 100) / 100, thr: v.thr, note: v.note, at: Date.now() };
@@ -12303,6 +12342,207 @@ function queueThumb(assetId) {
12303
12342
  return { controlled: false, value: cfg > 0 ? round1(cfg) : 5 };
12304
12343
  }
12305
12344
 
12345
+ // ============================================================
12346
+ // 视频请求组装(0.20.2):run 路径与「请求预览」的单一事实源
12347
+ // ============================================================
12348
+ // 背景(外部用户 issue 三能力):① 提交前自动校验(排除/降级素材时显式提示,不静默);
12349
+ // ② 真预览——与正式提交**同一组装逻辑**(不是另做一个近似预览),且普通生成零新增点击;
12350
+ // ③ 失败可追溯(脱敏留痕见 index.js submissionLogAppend)。
12351
+ // 因此把 runGenNode 视频分支里「从分镜切片到最终提示词」的纯决策+组装抽出来,
12352
+ // run 与预览都调 assembleVideoRequest——p 逐字一致是重构红线(test-submission-log 断言)。
12353
+ /** 本段镜头区间元数据(按镜头切段铺开时节点上写有 segShotFrom/To/Index/Count)。 */
12354
+ function videoSegMetaOf(n, shotListAll) {
12355
+ const d = (n.data || {});
12356
+ if (!shotListAll.length) return null;
12357
+ const from = Number(d.segShotFrom);
12358
+ const to = Number(d.segShotTo);
12359
+ if (!Number.isFinite(from) || !Number.isFinite(to) || to < from) return null;
12360
+ return { from: Math.max(0, Math.floor(from)), to: Math.min(shotListAll.length - 1, Math.floor(to)), index: Number(d.segIndex) || 0, count: Number(d.segCount) || 1, needsTailChain: d.needsTailChain === true, seamRisk: String(d.seamRisk || 'none') };
12361
+ }
12362
+ /** 分镜衔接规划:段落类型(续帧/换场/新角色/特写插入)+ 首镜承接口 + 是否接力尾帧。
12363
+ * 全部是同步图读取——同一节点同一图状态下结果恒定,run 与预览共用。 */
12364
+ function videoContinuityPlan(n, shotList, segMeta, sbUp, zh) {
12365
+ if (!shotList.length) return { first: null, chain: false, join: 'loose', seg: 'opening', fromShot: false };
12366
+ const first = shotContinuityPlan(shotList[0], null, 0);
12367
+ // 分镜衔接总开关(分镜表 cont):关掉 = 不做跨段承接、不自动取尾帧、不写衔接块
12368
+ const contOn = sbUp ? sbUp.data.cont !== false : true;
12369
+ // 跨分镜表承接:上游分镜表「衔接上一镜」输入口 ← 上一个分镜表「尾镜」输出口
12370
+ const prevSb = (() => {
12371
+ const e2 = S.graph.edges.find((x) => x.toNode === (sbUp && sbUp.id) && x.toPort === 'prev');
12372
+ const src = e2 && S.graph.nodes[e2.fromNode];
12373
+ return src && src.type === 'storyboard' ? src : null;
12374
+ })();
12375
+ const prevNote = prevSb ? storyboardContinuityNote(prevSb.data.shots || [], String(prevSb.data.label || ''), zh) : null;
12376
+ let seg = first.seg;
12377
+ // 第 1 镜没有表内上一镜时,可承接上一个分镜表 → 实质是续帧
12378
+ if (seg === 'opening' && prevNote) seg = 'continuation';
12379
+ const join = (seg === 'scene_change' || seg === 'new_character') ? 'loose' : seg === 'closeup' ? 'cut' : 'strict';
12380
+ // 接力判定:切段铺开时以**规划器**为准(它知道本段是否从切点开始);
12381
+ // 直接把整表塞一次生成的旧路径才退回"首镜是续帧就接力"。
12382
+ const chain = contOn && (segMeta ? (segMeta.needsTailChain && seg === 'continuation') : seg === 'continuation');
12383
+ return { first, chain, seg, join, fromShot: contOn && (segMeta ? segMeta.needsTailChain : !!prevNote), contOn, segMeta };
12384
+ }
12385
+ /** 跨段承接说明:本分镜第 1 镜承接上一个分镜表尾镜(续帧时首帧图已带画面,这里补文字约束)。 */
12386
+ function videoContinuityText(plan, shotList, zh) {
12387
+ if (!plan.fromShot) return '';
12388
+ const st = shotList[0] || {};
12389
+ const tail = String(st.tail || '').trim();
12390
+ const bits = [];
12391
+ if (plan.seg === 'continuation') {
12392
+ bits.push(zh ? '本段是上一段的直接续帧:第 1 帧从上一段结尾接着演,不重演、不重新建立场景、不切换机位' : 'This segment continues the previous one: start from its last frame, no replay, no re-establishing, no camera reset');
12393
+ if (tail) bits.push((zh ? '起始状态:' : 'Start state: ') + tail);
12394
+ } else if (plan.seg === 'scene_change') {
12395
+ bits.push(zh ? '本段换场:不承接上一段画面,但环境声/情绪可延续' : 'Scene change: do not continue the previous frame; ambience and mood may carry over');
12396
+ } else if (plan.seg === 'new_character') {
12397
+ // 特效入场(灯闪现身/影子凝聚/影化实)合法:首镜 vfx/start 写明特效进入时不逼"走入"
12398
+ const fxEntry = /凝聚|凭空|灯闪|黑场|影子|化实|现身|浮现/.test(
12399
+ String(st.vfx || '') + String(st.start || '') + String(st.visual || '') + String(st.motion || ''));
12400
+ bits.push(zh
12401
+ ? (fxEntry
12402
+ ? '本段有新角色入场(特效进入):灯闪/黑场后已在场、从影子凝聚立起、浮现成形——不得缓慢走入'
12403
+ : '本段有新角色入场:新角色必须从画面内自然进入(走入/被带入),不得凭空出现')
12404
+ : (fxEntry
12405
+ ? 'A new character enters via an effect: already there after a flash/black frame, rises from a shadow, condenses into form - never walks in slowly'
12406
+ : 'A new character enters: they must enter naturally from within the frame, never pop in'));
12407
+ }
12408
+ return bits.join(zh ? ';' : '; ');
12409
+ }
12410
+ /** 视频请求的公共决策基座:分镜输入/段元数据/切片/时长策略/手写判定/衔接规划。
12411
+ * run 路径(自动续帧要读 plan.chain)与 assembleVideoRequest 都从这里取,保证两边一致。 */
12412
+ function videoRequestContext(n) {
12413
+ const sbUp = storyboardInputOf(n);
12414
+ const shotListAll = sbUp && Array.isArray(sbUp.data.shots) ? sbUp.data.shots : [];
12415
+ const segMeta = videoSegMetaOf(n, shotListAll);
12416
+ const shotList = segMeta ? shotListAll.slice(segMeta.from, segMeta.to + 1) : shotListAll;
12417
+ // 时长策略:未连分镜用节点秒数;已连分镜按本段镜头节拍求和(节点秒数不进请求)
12418
+ const durationPlan = videoDurationFor(n, shotList, !!sbUp);
12419
+ const autoDuration = durationPlan.value || 5;
12420
+ const handWritten = String(n.data.prompt || '').trim();
12421
+ // 手写厂商结构化提示词 = 高级直通路径:保留用户的 subject/shot 结构,
12422
+ // 只补实体设定文字;风格锁与承接前置块都不再追加,避免污染厂商协议格式。
12423
+ const handStructured = handWritten.includes('subject_definitions');
12424
+ const zh = effLang() !== 'en';
12425
+ const plan = videoContinuityPlan(n, shotList, segMeta, sbUp, zh);
12426
+ return { sbUp, shotListAll, segMeta, shotList, durationPlan, autoDuration, handWritten, handStructured, zh, plan };
12427
+ }
12428
+ /** 组装一次视频请求(blob 无关):
12429
+ * - inputs = { prompt, bible, refs, entities, audioNames, hasFrame, frameAuto }
12430
+ * refs 传描述符 {name, category, entity}(组装只消费这三个字段,blob 由 run 路径在
12431
+ * 真正调用 apiVideo 时映射);hasFrame/frameAuto 由调用方按各自口径给
12432
+ * (run=blob 实际存在,预览=连线存在性),组装决策对两边一致。
12433
+ * - 返回 { p, params: { duration, resolution, ratio, frameMode, hardFrame, anchorRole,
12434
+ * useFrame, frameAuto, refNames, refRoles, audioNames, modelLabel, segMeta, warnings } }
12435
+ * - warnings = 提交前校验门(单一事实源):每条都是显式提示,绝不静默修改请求;
12436
+ * run 路径逐条 addWarn(生成时节点可见),预览面板原样展示。 */
12437
+ async function assembleVideoRequest(n, inputs) {
12438
+ const i = inputs || {};
12439
+ const refs = Array.isArray(i.refs) ? i.refs : [];
12440
+ const entities = Array.isArray(i.entities) ? i.entities : [];
12441
+ const audioNames = Array.isArray(i.audioNames) ? i.audioNames : [];
12442
+ const hasFrame = !!i.hasFrame;
12443
+ const frameAuto = !!i.frameAuto;
12444
+ // 与旧内联实现同名(重构红线:p 逐字等价的最强自证——本函数体即原 runGenNode 视频分支原文)
12445
+ const { shotList, autoDuration, handWritten, handStructured, zh, plan, durationPlan, sbUp, segMeta: segMetaRef } = videoRequestContext(n);
12446
+ const prompt = String(i.prompt ?? '');
12447
+ const bible = i.bible || null;
12448
+ const frameMode = n.data.frameMode || 'auto';
12449
+ const useFrame = frameMode !== 'off' && hasFrame;
12450
+ // 硬首帧只在"不挂实体参考图"时可用(多数厂商 first_frame 与 reference_image 互斥);
12451
+ // 续帧段若还要实体参考图 → 尾帧降级为首张参考图 + 软锚定(frameAnchorText 会写明)
12452
+ const hardFrame = useFrame && frameMode === 'hard';
12453
+ const anchorRole = (useFrame && !hardFrame && refs.length) ? 'reference_image' : 'first_frame';
12454
+ let music = '';
12455
+ try { const ex2 = parseExtraParams(n.data.vidExtra); if (ex2 && typeof ex2.music === 'string') music = ex2.music; } catch { /* 扩展参数非法时忽略音乐提示 */ }
12456
+ // 跨段承接说明:本分镜第 1 镜承接上一个分镜表尾镜(续帧时首帧图已带画面,这里补文字约束)
12457
+ const continuity = videoContinuityText(plan, shotList, zh);
12458
+ let p;
12459
+ // 图1=尾帧(降级模式)时实体参考图为图2..N+1:两条提示词组装路径都要同步偏移
12460
+ const effOpts = { picOffset: (useFrame && anchorRole === 'reference_image') ? 1 : 0 };
12461
+ if (handStructured) {
12462
+ p = handWritten; // 高级用法:手写结构化提示词,结构原样保留
12463
+ // 只追加 series_bible 文字块:不动用户写好的主体/镜头结构,也不追加任何参考图与风格锁。
12464
+ if (!/series_bible/i.test(p)) {
12465
+ const bb = entityBibleBlock(entities, bible, zh);
12466
+ if (bb) p = p + '\n' + bb;
12467
+ }
12468
+ } else if (shotList.length) {
12469
+ p = buildStructuredVideoPrompt(shotList, refs, bible, {
12470
+ zh, prompt: handWritten, music, hasFrame: useFrame, frameRole: anchorRole, continuity,
12471
+ // @引用命中实体的设定文字(外观/声音):只注入文本,参考图仍严格只取 ref 连线
12472
+ entities,
12473
+ });
12474
+ if (!p) p = buildEffectivePrompt(prompt, refs, entities, bible, false, effOpts); // 无参考图时回退
12475
+ } else {
12476
+ p = buildEffectivePrompt(prompt, refs, entities, bible, false, effOpts);
12477
+ }
12478
+ // 非结构化路径(无参考图/手写提示词)也要有首帧锚定与承接说明
12479
+ if ((!shotList.length || !p.includes('subject_definitions')) && !handStructured) {
12480
+ const pre = [frameAnchorText({ hasFrame: useFrame, role: anchorRole, zh }), continuity].filter(Boolean).join(zh ? ';' : '; ');
12481
+ if (pre) p = pre + '\n' + p;
12482
+ }
12483
+ // 自动组装路径才追加技能包风格锁;手写厂商结构化提示词保持用户协议结构
12484
+ if (!handStructured) {
12485
+ try {
12486
+ const lock = await buildShotLockText('prompt');
12487
+ if (lock) p = p + '\n' + lock;
12488
+ } catch { /* 技能包不可用时不影响生成 */ }
12489
+ }
12490
+ const mcfg = resolveVideoModelCfg(loadSettings(), nodeVideoModelRef(n));
12491
+ const frameWired = S.graph.edges.some((x) => x.toNode === n.id && x.toPort === 'frame');
12492
+ // —— 提交前校验门(显式提示,绝不静默)——
12493
+ const warnings = [];
12494
+ if (!mcfg) warnings.push('未配置视频模型:请到画布设置里选择视频模型后再生成');
12495
+ if (sbUp && !durationPlan.value) warnings.push('已连接分镜但暂无镜头时长:视频时长回退 5s(先生成分镜镜头后重跑)');
12496
+ if (autoDuration > 15) warnings.push('时长 ' + autoDuration + 's 超过单次生成上限 15s:厂商可能直接拒绝(如中转站 400)——建议按镜头切段或压缩镜头');
12497
+ if (refs.length > 4) warnings.push('参考图 ' + refs.length + ' 张可能超过厂商常见上限(4 张):超出部分可能被忽略——请核对厂商文档');
12498
+ if (useFrame && !hardFrame && refs.length) warnings.push('硬首帧与实体参考图互斥:已降级为参考图锚定');
12499
+ if (frameMode === 'off' && frameWired) warnings.push('首帧已接线但 frameMode=off:本请求不带首帧');
12500
+ return {
12501
+ p,
12502
+ params: {
12503
+ duration: autoDuration, resolution: n.data.resolution, ratio: n.data.ratio,
12504
+ frameMode, hardFrame, anchorRole, useFrame, frameAuto,
12505
+ refNames: refs.map((r) => r.entity || r.name || ''),
12506
+ refRoles: refs.map((r) => r.category || ''),
12507
+ audioNames,
12508
+ modelLabel: mcfg ? ((mcfg.providerName || mcfg.providerId) + ' / ' + mcfg.model) : '',
12509
+ segMeta: segMetaRef,
12510
+ warnings,
12511
+ },
12512
+ };
12513
+ }
12514
+ /** 请求预览的轻量 inputs(零 blob 解码):连线存在性代替 blob 存在性
12515
+ * (frame 口有连线+上游 assetId → hasFrame=true;续帧链上有已生成的上一段 → frameAuto)。
12516
+ * refs 名称/分类取资产元数据缓存(assetMem),取不到退回节点标签——
12517
+ * 组装只消费 name/category/entity 三个字段,与 run 路径的 collectRefs 产物同构。 */
12518
+ async function previewVideoInputs(n) {
12519
+ const bible = loadBible(S.activeId);
12520
+ // 与 run 路径同口径:先做未闭合引用自愈(预览只读,不回写节点)
12521
+ const prompt = repairUnclosedMentions(resolvePrompt(n), bibleNames(bible));
12522
+ // @引用解析先行:idbByProject 会顺带预热 assetMem(资产元数据缓存),ref 名称从它取
12523
+ // (先建 ref 再解析会把首帧预览锁在冷缓存上,名称退回节点标签)
12524
+ const bundle = await resolveMentionBundle(prompt, bible, S.activeId);
12525
+ const audioNames = (bundle.audioRefs || []).map((r) => r.name);
12526
+ const refEdges = S.graph.edges.filter((e) => e.toNode === n.id && e.toPort === 'ref');
12527
+ const refs = orderedRefEdgeIds(n, refEdges).map((id) => {
12528
+ const e = refEdges.find((x) => x.id === id);
12529
+ const src = e && S.graph.nodes[e.fromNode];
12530
+ const aid = src ? servedAssetId(src, e.fromPort) : null;
12531
+ const rec = aid ? assetMem.get(aid) : null;
12532
+ return { name: String((rec && rec.name) || (src && (src.data.label || src.data.placeholderName)) || '…'), category: (rec && rec.category) || 'general', entity: '' };
12533
+ });
12534
+ let hasFrame = false;
12535
+ let frameAuto = false;
12536
+ const fe = S.graph.edges.find((x) => x.toNode === n.id && x.toPort === 'frame');
12537
+ const faid = fe ? servedAssetId(S.graph.nodes[fe.fromNode], fe.fromPort) : null;
12538
+ if (faid) hasFrame = true;
12539
+ if (!hasFrame && videoRequestContext(n).plan.chain) {
12540
+ const pv = autoPrevVideoNode(n);
12541
+ if (pv && pv.data.assetId) { hasFrame = true; frameAuto = true; }
12542
+ }
12543
+ return { prompt, bible, refs, entities: bundle.entities, audioNames, hasFrame, frameAuto };
12544
+ }
12545
+
12306
12546
  /** 自定义数值的统一夹取:低于下限视为无效(0 是“自动”等保留值,不能悄悄变成 1);
12307
12547
  * 超上限夹回上限;整数/一位小数口径固定;非法输入回退当前值。 */
12308
12548
  function clampCustomNumber(raw, opts) {
@@ -12989,6 +13229,7 @@ function queueThumb(assetId) {
12989
13229
  })
12990
13230
  : null,
12991
13231
  (isImage || isVideo) ? h(MentionInfo, { n }) : null,
13232
+ isVideo ? h(RequestPreview, { n }) : null, // 请求预览(0.20.2):只读折叠区,打开才计算,零新增点击
12992
13233
  (n.data.history || []).length > 1
12993
13234
  ? h('div', { className: 'dshic-hist' },
12994
13235
  (n.data.history || []).map((hh) => h(HistThumb, {
@@ -13492,6 +13733,104 @@ function queueThumb(assetId) {
13492
13733
  );
13493
13734
  }
13494
13735
 
13736
+ /** 请求预览(0.20.2 能力①②):只读、按需计算、普通生成零新增点击。
13737
+ * 折叠区打开时才调 assembleVideoRequest——与正式提交**同一组装函数**(轻量 inputs:
13738
+ * 连线存在性代替 blob 存在性),展示模型/时长/分辨率/锚定角色/参考图顺序/声音参考/
13739
+ * 校验 warnings/最终提示词全文。不是另做的近似预览,p 与正式提交逐字一致。 */
13740
+ function RequestPreview({ n }) {
13741
+ const [open, setOpen] = useState(false);
13742
+ const [snap, setSnap] = useState(null); // { p, params, error }
13743
+ useEffect(() => {
13744
+ if (!open) return undefined;
13745
+ let alive = true;
13746
+ (async () => {
13747
+ try {
13748
+ const inputs = await previewVideoInputs(n);
13749
+ const out = await assembleVideoRequest(n, inputs);
13750
+ if (alive) setSnap({ error: null, p: out.p, params: out.params });
13751
+ } catch (e) {
13752
+ if (alive) setSnap({ error: String((e && e.message) || e), p: null, params: null });
13753
+ }
13754
+ })();
13755
+ return () => { alive = false; };
13756
+ }, [open, n && n.data.prompt, n && n.data.frameMode, n && n.data.duration, n && n.data.resolution,
13757
+ n && n.data.ratio, n && n.data.vidExtra, ((n && n.data.refOrder) || []).length, S.assetsTick, S.activeId]);
13758
+ const toggle = (v) => (e) => { e.stopPropagation(); setOpen(v); };
13759
+ if (!open) {
13760
+ return h('button', {
13761
+ type: 'button', className: 'dshic-mini is-ghost', 'data-req-preview': 'closed', title: T('reqPreviewHint'),
13762
+ onPointerDown: (e) => e.stopPropagation(),
13763
+ onClick: toggle(true),
13764
+ }, '👁 ' + T('reqPreview'));
13765
+ }
13766
+ const ps = snap && snap.params;
13767
+ const modeLabel = (m) => (m === 'hard' ? T('frameModeHard') : m === 'off' ? T('frameModeOff') : T('frameModeAuto'));
13768
+ // 图1=尾帧(降级锚定)时实体参考图实际是图2..N+1——与请求侧 picOffset 同一口径
13769
+ const off = ps && ps.useFrame && ps.anchorRole === 'reference_image' ? 1 : 0;
13770
+ return h('div', { className: 'dshic-req-preview', 'data-req-preview': 'open', onPointerDown: (e) => e.stopPropagation() },
13771
+ h('div', { className: 'dshic-row', style: { gap: 6, alignItems: 'center' } },
13772
+ h('span', { className: 'dshic-shot-label' }, T('reqPreview')),
13773
+ h('span', { style: { flex: 1 } }),
13774
+ h('button', {
13775
+ type: 'button', className: 'dshic-mini is-ghost', title: T('lbHint'),
13776
+ onPointerDown: (e) => e.stopPropagation(),
13777
+ onClick: toggle(false),
13778
+ }, '▾')),
13779
+ snap && snap.error ? h('div', { className: 'dshic-err' }, T('reqPreviewFail') + ':' + snap.error) : null,
13780
+ !snap ? h('div', { className: 'dshic-hint' }, '…') : null,
13781
+ ps ? h('div', { className: 'dshic-req-grid' },
13782
+ h('div', { className: 'dshic-row' },
13783
+ h('span', { className: 'dshic-shot-label', style: { flex: 'none' } }, T('reqPreviewModel')),
13784
+ h('span', { className: 'dshic-hint', style: { flex: 1, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, ps.modelLabel || '—')),
13785
+ h('div', { className: 'dshic-row' },
13786
+ h('span', { className: 'dshic-shot-label', style: { flex: 'none' } }, T('durationLabel')),
13787
+ h('span', { className: 'dshic-hint' }, ps.duration + 's')),
13788
+ h('div', { className: 'dshic-row' },
13789
+ h('span', { className: 'dshic-shot-label', style: { flex: 'none' } }, T('resolutionLabel')),
13790
+ h('span', { className: 'dshic-hint' }, String(ps.resolution || '—') + ' · ' + String(ps.ratio || '—'))),
13791
+ h('div', { className: 'dshic-row' },
13792
+ h('span', { className: 'dshic-shot-label', style: { flex: 'none' } }, T('reqPreviewFrame')),
13793
+ h('span', { className: 'dshic-hint', style: { flex: 1, minWidth: 0 } },
13794
+ modeLabel(ps.frameMode) + ' · ' + (ps.frameMode === 'off'
13795
+ ? T('frameOffNone')
13796
+ : (ps.anchorRole === 'reference_image' ? T('anchorRefImage') : T('anchorFirstFrame')))
13797
+ + (ps.frameAuto ? ' · ' + T('frameAutoTail') : ''))),
13798
+ h('div', { className: 'dshic-shot-label' }, T('reqPreviewRefs') + '(' + ps.refNames.length + ')'),
13799
+ ps.refNames.length
13800
+ ? ps.refNames.map((nm, i2) => h('div', { key: i2, className: 'dshic-row', style: { gap: 5 } },
13801
+ h('span', { className: 'dshic-mention' }, '[图' + (i2 + 1 + off) + ']'),
13802
+ h('span', { className: 'dshic-hint', style: { flex: 1, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } },
13803
+ String(nm || '—') + (ps.refRoles[i2] ? '(' + catLabel(ps.refRoles[i2]) + ')' : ''))))
13804
+ : h('div', { className: 'dshic-hint' }, '—'),
13805
+ ps.useFrame && off
13806
+ ? h('div', { className: 'dshic-row', style: { gap: 5 } },
13807
+ h('span', { className: 'dshic-mention' }, '[图1]'),
13808
+ h('span', { className: 'dshic-hint' }, T('frameModeAuto') + (ps.frameAuto ? '(' + T('frameAutoTail') + ')' : '')))
13809
+ : null,
13810
+ h('div', { className: 'dshic-row' },
13811
+ h('span', { className: 'dshic-shot-label', style: { flex: 'none' } }, T('reqPreviewAudio')),
13812
+ h('span', { className: 'dshic-hint', style: { flex: 1, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } },
13813
+ ps.audioNames.length ? ps.audioNames.join('、') : '—')),
13814
+ ps.warnings.length
13815
+ ? h('div', { className: 'dshic-req-warns', 'data-req-warnings': String(ps.warnings.length) },
13816
+ ps.warnings.map((w, i2) => h('div', { key: i2, className: 'dshic-hint', style: { color: 'var(--dsw-alias-state-warning-primary, #d08700)' } }, '⚠ ' + w)))
13817
+ : null,
13818
+ h('div', { className: 'dshic-row', style: { gap: 6, alignItems: 'center' } },
13819
+ h('span', { className: 'dshic-shot-label' }, T('reqPreviewPrompt')),
13820
+ h('span', { style: { flex: 1 } }),
13821
+ h('button', {
13822
+ type: 'button', className: 'dshic-mini is-ghost',
13823
+ onPointerDown: (e) => e.stopPropagation(),
13824
+ onClick: (e) => {
13825
+ e.stopPropagation();
13826
+ try { navigator.clipboard.writeText(snap.p).then(() => toast(T('copiedOk'))).catch(() => {}); } catch { /* 剪贴板不可用时忽略 */ }
13827
+ },
13828
+ }, '⧉ ' + T('reqPreviewCopy'))),
13829
+ h('div', { className: 'dshic-req-prompt', 'data-req-prompt': '1' }, snap.p),
13830
+ ) : null,
13831
+ );
13832
+ }
13833
+
13495
13834
  /** 文本节点:只显示正文结果(内容在生成面板里编辑;@资产名@ 仍高亮) */
13496
13835
  function TextNodeBody({ n }) {
13497
13836
  const text = String(n.data.text || '');
@@ -13751,8 +14090,8 @@ function queueThumb(assetId) {
13751
14090
  // 切段预览:把"这张分镜表会被切成几次生成、每次几镜几秒、哪些段要接尾帧"直接显示在节点上,
13752
14091
  // 用户铺开前就知道会切成什么样——不用等到生成完才发现接不上。
13753
14092
  const segPlan = shots.length ? planShotSegments(shots, { maxSeconds: Number(n.data.segMaxSeconds) || 15 }) : null;
13754
- // 一致性告警的手动重校验:告警是**生成时刻**算的,之后补全设定集不会让它们自动消失——
13755
- // 点刷新按当前设定集重算(checkShotConsistency 读的是实时 bible/资产名索引)
14093
+ // 一致性告警的重校验:告警是**生成时刻**算的;设定集更新后有 bibleTick 自动重算(见下),
14094
+ // 这里保留手动入口兜底——点刷新按当前设定集重算(checkShotConsistency 读的是实时 bible/资产名索引)
13756
14095
  const [wvChecking, setWvChecking] = useState(false);
13757
14096
  const revalidate = async () => {
13758
14097
  if (wvChecking || !shots.length) return;
@@ -13763,6 +14102,15 @@ function queueThumb(assetId) {
13763
14102
  } catch { /* 校验失败保留旧告警 */ }
13764
14103
  setWvChecking(false);
13765
14104
  };
14105
+ // 设定集更新自动刷新:bibleTick 在设定集编辑器 persist 后自增——变化时按当前设定集重算告警,
14106
+ // 补全描述后节点上的旧告警自动消失,不再依赖用户点 revalidate(宿主侧重算只写 Host 文档,够不着本地状态)。
14107
+ // ref 记上次已响应的 tick:首渲染(打开面板/重挂载)不触发;wvChecking 防重入。
14108
+ const lastBibleTickRef = useRef(S.bibleTick);
14109
+ useEffect(() => {
14110
+ if (S.bibleTick === lastBibleTickRef.current) return;
14111
+ lastBibleTickRef.current = S.bibleTick;
14112
+ revalidate();
14113
+ }, [S.bibleTick]);
13766
14114
  return [
13767
14115
  h('div', { key: 'sum', className: 'dshic-shot-summary' },
13768
14116
  h('b', {}, shots.length ? (shots.length + ' ' + T('shotsUnit')) : T('noShotsYet')),
@@ -14061,7 +14409,8 @@ function queueThumb(assetId) {
14061
14409
  };
14062
14410
  const genTts = async (x) => {
14063
14411
  const settings = loadSettings();
14064
- const cfg = resolveApiCfg(settings.ttsApis, settings.ttsApiId, null);
14412
+ const list = flattenTtsModels(settings);
14413
+ const cfg = list.find((y) => y.ref === settings.ttsStar) || list[0];
14065
14414
  if (!cfg) { toast(T('errNoTts')); return; }
14066
14415
  const text = String(getSub(x) || '').trim();
14067
14416
  if (!text) { toast(T('subPlaceholder')); return; }
@@ -19094,12 +19443,9 @@ const DIRECTOR_KEY_HELP = [
19094
19443
  for (const m of (p.models || [])) options.push({ value: p.id + '|' + m.id, label: `${p.name} · ${m.name}` });
19095
19444
  }
19096
19445
  const applyTextLlm = (provider, model) => {
19097
- setS((prev) => {
19098
- const next = JSON.parse(JSON.stringify(prev));
19099
- next.textLlm = { provider: provider || '', model: model || '' };
19100
- saveSettings(next);
19101
- return next;
19102
- });
19446
+ // issue #6:基底现取磁盘最新(不再用挂载时快照整对象写回),写回后 setS 同步刷新本地快照
19447
+ const next = updateSettings((b) => ({ ...b, textLlm: { provider: provider || '', model: model || '' } }));
19448
+ setS(next);
19103
19449
  };
19104
19450
  return h('div', { className: 'dshic-field' },
19105
19451
  h('span', { className: 'dshic-field-label' }, T('llmLabel')),
@@ -19168,25 +19514,29 @@ const DIRECTOR_KEY_HELP = [
19168
19514
  style: { flex: 'none', width: 14, height: 14, lineHeight: '13px', textAlign: 'center', fontSize: 10, borderRadius: '50%', border: '1px solid var(--dsw-alias-border-secondary, #777)', color: 'var(--dsw-alias-label-secondary, #999)', cursor: 'help', userSelect: 'none', opacity: 0.85 },
19169
19515
  }, 'i');
19170
19516
  }
19171
- /** 图片/视频模型配置(供应商 + 模型两级):一个供应商配一次 URL/Key,下面挂多个模型;
19172
- * ★星标模型 = 节点未指定时的默认路由。 */
19517
+ /** 图片/视频/TTS 模型配置(供应商 + 模型两级):一个供应商配一次 URL/Key,下面挂多个模型;
19518
+ * ★星标模型 = 节点未指定时的默认路由。TTS(issue #6 第二阶段):
19519
+ * voice 是每模型字段(不同模型支持的音色清单不同),timeoutMs 是供应商级(一供应商=一连接)。 */
19173
19520
  function ModelProviderEditor({ kind }) {
19174
19521
  const [s, setS] = useState(loadSettings);
19175
19522
  const [openId, setOpenId] = useState(null);
19176
- const listKey = kind === 'image' ? 'imageProviders' : 'videoProviders';
19177
- const starKey = kind === 'image' ? 'imageStar' : 'videoStar';
19178
- const icon = kind === 'image' ? 'image' : 'video';
19179
- const labelKey = kind === 'image' ? 'imageApisLabel' : 'videoApisLabel';
19180
- const nameKey = kind === 'image' ? 'defaultImageCfg' : 'defaultVideoCfg';
19181
- const urlKey = kind === 'image' ? 'baseUrl' : 'url';
19523
+ const listKey = kind === 'image' ? 'imageProviders' : kind === 'video' ? 'videoProviders' : 'ttsProviders';
19524
+ const starKey = kind === 'image' ? 'imageStar' : kind === 'video' ? 'videoStar' : 'ttsStar';
19525
+ const icon = kind === 'image' ? 'image' : kind === 'video' ? 'video' : 'audio';
19526
+ const labelKey = kind === 'image' ? 'imageApisLabel' : kind === 'video' ? 'videoApisLabel' : 'ttsApisLabel';
19527
+ const nameKey = kind === 'image' ? 'defaultImageCfg' : kind === 'video' ? 'defaultVideoCfg' : 'defaultTtsCfg';
19528
+ const urlKey = kind === 'video' ? 'url' : 'baseUrl';
19182
19529
  const urlPh = kind === 'image'
19183
19530
  ? 'https://api.example.com/v1(或完整 /images/generations 端点)'
19184
- : 'https://api.example.com/v1/video/generations(或裸域 / /v1)';
19185
- const persist = (next) => { setS(next); saveSettings(next); };
19186
- const mutate = (fn) => { const next = JSON.parse(JSON.stringify(s)); fn(next); persist(next); };
19531
+ : kind === 'video'
19532
+ ? 'https://api.example.com/v1/video/generations(或裸域 / /v1)'
19533
+ : 'https://api.example.com/v1';
19534
+ // issue #6:写回基底 = updateSettings 现取磁盘最新(不再是挂载时快照);persist 只负责把返回的新值同步进本地快照
19535
+ const persist = (next) => setS(next);
19536
+ const mutate = (fn) => { persist(updateSettings((b) => { const d = JSON.parse(JSON.stringify(b)); fn(d); return d; })); };
19187
19537
  const addProvider = () => {
19188
19538
  const id = uid('prov');
19189
- mutate((d) => { d[listKey] = (d[listKey] || []).concat([{ id, name: T(nameKey) + ' ' + ((d[listKey] || []).length + 1), [urlKey]: '', apiKey: '', extra: '', models: [], ...(kind === 'image' ? { mode: 'generations' } : {}) }]); });
19539
+ mutate((d) => { d[listKey] = (d[listKey] || []).concat([{ id, name: T(nameKey) + ' ' + ((d[listKey] || []).length + 1), [urlKey]: '', apiKey: '', ...(kind === 'tts' ? { timeoutMs: '' } : { extra: '' }), models: [], ...(kind === 'image' ? { mode: 'generations' } : {}) }]); });
19190
19540
  setOpenId(id);
19191
19541
  };
19192
19542
  const removeProvider = (id) => {
@@ -19194,7 +19544,7 @@ const DIRECTOR_KEY_HELP = [
19194
19544
  if (openId === id) setOpenId(null);
19195
19545
  };
19196
19546
  const patchProvider = (id, k, v) => mutate((d) => { d[listKey] = (d[listKey] || []).map((x) => (x.id === id ? { ...x, [k]: v } : x)); });
19197
- const addModel = (pid) => mutate((d) => { const p = (d[listKey] || []).find((x) => x.id === pid); if (p) p.models = (p.models || []).concat([{ id: uid('m'), model: '' }]); });
19547
+ const addModel = (pid) => mutate((d) => { const p = (d[listKey] || []).find((x) => x.id === pid); if (p) p.models = (p.models || []).concat([Object.assign({ id: uid('m'), model: '' }, kind === 'tts' ? { voice: 'alloy' } : {})]); });
19198
19548
  const patchModel = (pid, mid, k, v) => mutate((d) => { const p = (d[listKey] || []).find((x) => x.id === pid); if (!p) return; p.models = (p.models || []).map((x) => (x.id === mid ? { ...x, [k]: v } : x)); });
19199
19549
  const removeModel = (pid, mid) => mutate((d) => {
19200
19550
  const p = (d[listKey] || []).find((x) => x.id === pid); if (!p) return;
@@ -19239,6 +19589,11 @@ const DIRECTOR_KEY_HELP = [
19239
19589
  ) : null,
19240
19590
  h(Field, { key: 'u', label: T('baseUrl'), value: p[urlKey] || '', onChange: (v) => patchProvider(p.id, urlKey, v), placeholder: kind === 'video' ? ((VIDEO_VENDORS[detectVideoVendor(p)] || {}).base || urlPh) : urlPh }),
19241
19591
  h(Field, { key: 'k', label: T('apiKey'), value: p.apiKey || '', onChange: (v) => patchProvider(p.id, 'apiKey', v), placeholder: kind === 'video' ? ((VIDEO_VENDORS[detectVideoVendor(p)] || {}).keyPh || 'sk-…') : 'sk-…', password: true }),
19592
+ kind === 'tts' ? h(Field, {
19593
+ key: 'to', label: T('apiTimeout'), value: p.timeoutMs || '',
19594
+ placeholder: '留空 = 120000',
19595
+ onChange: (v) => patchProvider(p.id, 'timeoutMs', v),
19596
+ }) : null,
19242
19597
  kind === 'image' ? [
19243
19598
  h(Field, { key: 'size', label: T('imgSizeOverride'), value: p.size || '', onChange: (v) => patchProvider(p.id, 'size', v), placeholder: T('imgSizePlaceholder') }),
19244
19599
  h(Field, { key: 'rf', label: T('imgResponseFormat'), value: p.responseFormat || '', onChange: (v) => patchProvider(p.id, 'responseFormat', v), placeholder: 'b64_json / url(留空=API 默认)' }),
@@ -19249,12 +19604,12 @@ const DIRECTOR_KEY_HELP = [
19249
19604
  h('option', { value: 'edits' }, T('modeEdits')),
19250
19605
  h('option', { value: 'compshare' }, T('modeCompshare')),
19251
19606
  h('option', { value: 'sanbao' }, T('modeSanbao')))),
19252
- ] : [
19607
+ ] : kind === 'video' ? [
19253
19608
  (detectVideoVendor(p) === 'openai' || detectVideoVendor(p) === 'seedance') ? h(Field, { key: 'of', label: T('vidOutFormat'), value: p.outputFormat || '', onChange: (v) => patchProvider(p.id, 'outputFormat', v), placeholder: 'mp4(留空不发送)' }) : null,
19254
19609
  (detectVideoVendor(p) === 'openai' || detectVideoVendor(p) === 'seedance') ? h('label', { key: 'ga', className: 'dshic-row', style: { gap: 6, fontSize: 11 } },
19255
19610
  h('input', { type: 'checkbox', checked: p.generateAudio === true, onChange: (e) => patchProvider(p.id, 'generateAudio', e.target.checked), onPointerDown: (e) => e.stopPropagation() }),
19256
19611
  h('span', {}, T('vidAudioOpt'))) : null,
19257
- ],
19612
+ ] : null,
19258
19613
  (kind === 'image' || kind === 'video') ? [
19259
19614
  h(Field, { key: 'extra', label: T('cfgExtra'), value: p.extra || '', onChange: (v) => patchProvider(p.id, 'extra', v), placeholder: '{"watermark":false,"prompt_extend":false}', tip: T('cfgExtraHint') }),
19260
19615
  ] : null,
@@ -19269,6 +19624,8 @@ const DIRECTOR_KEY_HELP = [
19269
19624
  onPointerDown: (e) => e.stopPropagation(), onClick: () => toggleStar(p.id, m.id),
19270
19625
  }, s[starKey] === p.id + '|' + m.id ? '★' : '☆'),
19271
19626
  h('input', { className: 'dshic-input', style: { flex: 1, minWidth: 0 }, value: m.model || '', placeholder: T('modelNamePh'), onChange: (e) => patchModel(p.id, m.id, 'model', e.target.value), onPointerDown: (e) => e.stopPropagation() }),
19627
+ // TTS:voice 每模型一个(修复旧 ApiListEditor「voice 无编辑入口」的原始缺口)
19628
+ kind === 'tts' ? h('input', { className: 'dshic-input', style: { flex: 1, minWidth: 0 }, value: m.voice || '', placeholder: 'alloy', 'aria-label': T('voice'), onChange: (e) => patchModel(p.id, m.id, 'voice', e.target.value), onPointerDown: (e) => e.stopPropagation() }) : null,
19272
19629
  h('button', { type: 'button', className: 'dshic-iconbtn', title: T('doDelete'), onPointerDown: (e) => e.stopPropagation(), onClick: () => removeModel(p.id, m.id) }, '×'),
19273
19630
  )),
19274
19631
  !(p.models || []).length ? h('div', { className: 'dshic-hint' }, T('noModelsCfg')) : null,
@@ -19277,158 +19634,6 @@ const DIRECTOR_KEY_HELP = [
19277
19634
  }),
19278
19635
  );
19279
19636
  }
19280
- function ApiListEditor({ kind }) {
19281
- const [s, setS] = useState(loadSettings);
19282
- const [openId, setOpenId] = useState(null);
19283
- const listKey = kind === 'image' ? 'imageApis' : kind === 'video' ? 'videoApis' : 'ttsApis';
19284
- const defKey = kind === 'image' ? 'imageApiId' : kind === 'video' ? 'videoApiId' : 'ttsApiId';
19285
- const labelKey = kind === 'image' ? 'imageApisLabel' : kind === 'video' ? 'videoApisLabel' : 'ttsApisLabel';
19286
- const icon = kind === 'image' ? 'image' : kind === 'video' ? 'video' : 'audio';
19287
- const nameKey = kind === 'image' ? 'defaultImageCfg' : kind === 'video' ? 'defaultVideoCfg' : 'defaultTtsCfg';
19288
- const persist = (next) => { setS(next); saveSettings(next); };
19289
- const mutate = (fn) => {
19290
- const next = JSON.parse(JSON.stringify(s));
19291
- next[listKey] = fn(next[listKey] || []);
19292
- persist(next);
19293
- };
19294
- const add = () => {
19295
- const id = uid('cfg');
19296
- mutate((list) => list.concat([{
19297
- id,
19298
- name: T(nameKey) + ' ' + ((s[listKey] || []).length + 1),
19299
- [kcUrlKey(kind)]: '',
19300
- apiKey: '',
19301
- model: '',
19302
- ...(kind === 'image' ? { mode: 'generations' } : {}),
19303
- ...(kind === 'tts' ? { voice: 'alloy' } : {}),
19304
- }]));
19305
- setOpenId(id);
19306
- };
19307
- const patch = (id, k, v) => mutate((list) => list.map((x) => (x.id === id ? { ...x, [k]: v } : x)));
19308
- const remove = (id) => {
19309
- mutate((list) => list.filter((x) => x.id !== id));
19310
- if (openId === id) setOpenId(null);
19311
- };
19312
- const list = s[listKey] || [];
19313
- const urlPh = kind === 'image' ? 'https://api.example.com/v1' : kind === 'video' ? 'https://api.example.com/v1/video/generations' : 'https://api.example.com/v1';
19314
- const urlKey = kind === 'image' ? 'baseUrl' : 'url';
19315
- return h('div', { className: 'dshic-card' },
19316
- h('div', { className: 'dshic-row' },
19317
- Ic(icon, 12),
19318
- h('strong', { style: { fontSize: 12, flex: 1, minWidth: 0, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' } }, T(labelKey)),
19319
- h('span', { className: 'dshic-tag st' }, String(list.length)),
19320
- h('button', { type: 'button', className: 'dshic-mini', onClick: add, onPointerDown: (e) => e.stopPropagation() }, Ic('plus', 11), T('addConfig')),
19321
- ),
19322
- list.length === 0 ? h('div', { className: 'dshic-hint' }, T('noCfgHint')) : null,
19323
- list.map((cfg) => {
19324
- const open = openId === cfg.id;
19325
- const isDef = s[defKey] === cfg.id;
19326
- return h('div', { key: cfg.id, className: 'dshic-card', style: { padding: open ? 8 : 5, gap: 6, background: 'var(--dsw-alias-bg-layer-1)' } },
19327
- // 折叠头:箭头 + 名称 + 默认标记 + 删除
19328
- h('div', { className: 'dshic-row' },
19329
- h('button', {
19330
- type: 'button', className: 'dshic-iconbtn', title: open ? T('collapse') : T('unfold'),
19331
- onPointerDown: (e) => e.stopPropagation(),
19332
- onClick: () => setOpenId(open ? null : cfg.id),
19333
- }, open ? '▾' : '▸'),
19334
- open
19335
- ? h('input', {
19336
- className: 'dshic-input', style: { flex: 1, minWidth: 0, fontWeight: 600 }, value: cfg.name || '',
19337
- placeholder: T('cfgName'), autoFocus: true,
19338
- onChange: (e) => patch(cfg.id, 'name', e.target.value),
19339
- onPointerDown: (e) => e.stopPropagation(),
19340
- })
19341
- : h('span', {
19342
- style: { flex: 1, minWidth: 0, fontSize: 12, fontWeight: 600, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis', cursor: 'pointer', color: 'var(--dsw-alias-label-primary)' },
19343
- onClick: () => setOpenId(cfg.id),
19344
- onPointerDown: (e) => e.stopPropagation(),
19345
- title: T('baseUrl') + ': ' + (cfg[kcUrlKey(kind)] || '—'),
19346
- }, cfg.name || T('cfgName')),
19347
- isDef
19348
- ? h('span', { className: 'dshic-tag api' }, T('isDefault'))
19349
- : h('button', {
19350
- type: 'button', className: 'dshic-mini is-ghost', title: T('setDefault'),
19351
- onPointerDown: (e) => e.stopPropagation(),
19352
- onClick: () => { const next = { ...s, [defKey]: cfg.id }; persist(next); },
19353
- }, '★'),
19354
- cfg.model ? h('span', { className: 'dshic-tag st' }, String(cfg.model).slice(0, 18)) : null,
19355
- h('button', {
19356
- type: 'button', className: 'dshic-iconbtn is-danger', title: T('delConfig'),
19357
- onPointerDown: (e) => e.stopPropagation(),
19358
- onClick: () => remove(cfg.id),
19359
- }, Ic('trash', 11)),
19360
- ),
19361
- open ? [
19362
- h(Field, { key: 'u', label: T('baseUrl'), value: cfg[kcUrlKey(kind)] || '', onChange: (v) => patch(cfg.id, urlKey, v), placeholder: urlPh }),
19363
- h(Field, { key: 'k', label: T('apiKey'), value: cfg.apiKey || '', onChange: (v) => patch(cfg.id, 'apiKey', v), placeholder: 'sk-…', password: true }),
19364
- h(Field, { key: 'm', label: T('model'), value: cfg.model || '', onChange: (v) => patch(cfg.id, 'model', v) }),
19365
- h(Field, {
19366
- key: 'to', label: T('apiTimeout'), value: cfg.timeoutMs || '',
19367
- placeholder: T('llmParamAuto'),
19368
- onChange: (v) => patch(cfg.id, 'timeoutMs', v),
19369
- }),
19370
- kind === 'image'
19371
- ? h(Field, { key: 'size', label: T('imgSizeOverride'), value: cfg.size || '', onChange: (v) => patch(cfg.id, 'size', v), placeholder: T('imgSizePlaceholder') })
19372
- : null,
19373
- kind === 'image'
19374
- ? h(Field, { key: 'rf', label: T('imgResponseFormat'), value: cfg.responseFormat || '', onChange: (v) => patch(cfg.id, 'responseFormat', v), placeholder: 'b64_json / url(留空=API 默认)' })
19375
- : null,
19376
- kind === 'image'
19377
- ? h('div', { key: 'mode', className: 'dshic-field' },
19378
- h('span', { className: 'dshic-field-label' }, T('imgMode')),
19379
- h('select', {
19380
- className: 'dshic-select', value: cfg.mode || 'generations',
19381
- onChange: (e) => patch(cfg.id, 'mode', e.target.value),
19382
- onPointerDown: (e) => e.stopPropagation(),
19383
- },
19384
- h('option', { value: 'generations' }, T('modeGenerations')),
19385
- h('option', { value: 'edits' }, T('modeEdits')),
19386
- h('option', { value: 'sanbao' }, T('modeSanbao'))))
19387
- : null,
19388
- kind === 'video'
19389
- ? h('div', { key: 'proto', className: 'dshic-field' },
19390
- h('span', { className: 'dshic-field-label' }, T('vidProtocol'), InfoTip(T('vidProtocolHint'))),
19391
- h('select', {
19392
- className: 'dshic-select', value: cfg.protocol || 'generic',
19393
- onChange: (e) => patch(cfg.id, 'protocol', e.target.value),
19394
- onPointerDown: (e) => e.stopPropagation(),
19395
- },
19396
- h('option', { value: 'generic' }, T('protoGeneric')),
19397
- h('option', { value: 'seedance' }, T('protoSeedance'))))
19398
- : null,
19399
- kind === 'video'
19400
- ? h('label', { key: 'ga', className: 'dshic-row', style: { gap: 6, fontSize: 11 } },
19401
- h('input', {
19402
- type: 'checkbox', checked: cfg.generateAudio === true,
19403
- onChange: (e) => patch(cfg.id, 'generateAudio', e.target.checked),
19404
- onPointerDown: (e) => e.stopPropagation(),
19405
- }),
19406
- h('span', {}, T('vidAudioOpt')))
19407
- : null,
19408
- kind === 'video'
19409
- ? h(Field, { key: 'of', label: T('vidOutFormat'), value: cfg.outputFormat || '', onChange: (v) => patch(cfg.id, 'outputFormat', v), placeholder: 'mp4(留空不发送)' })
19410
- : null,
19411
- kind === 'video' && cfg.protocol === 'seedance'
19412
- ? h('label', { key: 'wm', className: 'dshic-row', style: { gap: 6, fontSize: 11 } },
19413
- h('input', {
19414
- type: 'checkbox', checked: cfg.watermark === true,
19415
- onChange: (e) => patch(cfg.id, 'watermark', e.target.checked),
19416
- onPointerDown: (e) => e.stopPropagation(),
19417
- }),
19418
- h('span', {}, T('seedanceWatermark')))
19419
- : null,
19420
- (kind === 'image' || kind === 'video')
19421
- ? h(Field, { key: 'extra', label: T('cfgExtra'), value: cfg.extra || '', onChange: (v) => patch(cfg.id, 'extra', v), placeholder: '{"watermark":false,"prompt_extend":false}', tip: T('cfgExtraHint') })
19422
- : null,
19423
- kind === 'tts'
19424
- ? h(Field, { key: 'voice', label: T('voice'), value: cfg.voice || '', onChange: (v) => patch(cfg.id, 'voice', v), placeholder: 'alloy' })
19425
- : null,
19426
- ] : null,
19427
- );
19428
- }),
19429
- );
19430
- }
19431
- function kcUrlKey(kind) { return kind === 'image' ? 'baseUrl' : 'url'; }
19432
19637
 
19433
19638
  /** T2:设置面板 Craft 后期卡片(连接状态 / 工具灯 / 数据目录)。 */
19434
19639
  function CraftCard() {
@@ -19772,9 +19977,16 @@ const DIRECTOR_KEY_HELP = [
19772
19977
  );
19773
19978
  }
19774
19979
  /** 图片模型桥接卡(0.20.0):检测 dsh-image-gen 并直接选用它的服务商/模型(密钥留在它宿主侧)。 */
19775
- /** 自动创作开关(实验):只留开关与状态;入口在 Harness 原生对话框(canvas_auto_* 工具)。 */
19980
+ /** 自动创作卡(实验):开关 + 状态 + 快捷动作区。对话仍是主入口(canvas_auto_* 工具带完整上下文),
19981
+ * 此卡提供与对话同 RPC 的快捷操作,不切对话也能:启动创作(brief)→ 刷新预算(autoQuote)→
19982
+ * 批准付费(行内确认,quoteId+confirm)→ 开始生成(全量;部分选场是 T9 对话侧能力,卡片不放)→ 中止。
19983
+ * 批准令牌语义:quoteId 用卡片最近一次 autoQuote 返回值(不自动重刷——预算指纹绑定,卡片刷新的即当前指纹)。
19984
+ * 纪律:不新增轮询、不新增 RPC;单一 busy 防重入(动作互斥,避免并发计费操作);错误 catch 接住显示卡内。 */
19776
19985
  function AutoModeCard() {
19777
19986
  const [st, setSt] = useState(null);
19987
+ // 动作区状态(一个对象收口):brief 输入 / 最近预算单 quote(quoteId+摘要)/ 行内确认开合与文本 /
19988
+ // busy(在跑的动作名,防重入)/ msg 成功小字 / err 错误小字
19989
+ const [act, setAct] = useState(() => ({ brief: '', confirm: '', quote: null, confirmOpen: false, busy: null, msg: '', err: '' }));
19778
19990
  const refresh = async () => {
19779
19991
  try {
19780
19992
  const r = await hostRpc('autoModeGet');
@@ -19794,6 +20006,54 @@ const DIRECTOR_KEY_HELP = [
19794
20006
  setSt({ ...st, busy: false });
19795
20007
  }
19796
20008
  };
20009
+ const pid = S.activeId || '';
20010
+ const multiAgent = !!(st && st.caps && st.caps.multiAgent);
20011
+ const actionsOn = !!(st && !st.oldHost && st.enabled && multiAgent);
20012
+ // 动作通用壳:结果 {ok:false,error} 视为业务失败,与网络异常同样接住显示在卡内
20013
+ const runAction = async (key, fn, okMsgOf) => {
20014
+ if (!pid || act.busy) return;
20015
+ setAct((a) => ({ ...a, busy: key, err: '', msg: '' }));
20016
+ try {
20017
+ const r = await fn();
20018
+ if (r && r.ok === false) throw new Error(r.error || T('autoFail'));
20019
+ setAct((a) => ({ ...a, busy: null, msg: okMsgOf ? okMsgOf(r) : T('autoDone'), err: '' }));
20020
+ refresh();
20021
+ } catch (e) {
20022
+ setAct((a) => ({ ...a, busy: null, err: String((e && e.message) || e) || T('autoFail') }));
20023
+ }
20024
+ };
20025
+ // 预算小字:场/镜/秒/待调用次数 + 估算金额或单价引导(T9 锚点「视频每秒单价」)
20026
+ const quoteLine = (r) => T('autoQuoteSummary').replace('{s}', String(r.sceneCount || 0)).replace('{sh}', String(r.shotCount || 0))
20027
+ .replace('{sec}', String(r.totalSeconds || 0)).replace('{calls}', String(r.videoCalls || 0))
20028
+ + ' · ' + (r.estimatedCost != null
20029
+ ? T('autoQuoteCost').replace('{cost}', String(r.estimatedCost))
20030
+ : T('autoQuoteNoPrice'));
20031
+ const doQuote = () => runAction('quote', async () => {
20032
+ const r = await hostRpc('autoQuote', { projectId: pid });
20033
+ if (r && r.ok !== false && r.quoteId) {
20034
+ // 批准令牌只信这次刷新返回的 quoteId(指纹绑定);旧的行内确认随之作废收起
20035
+ setAct((a) => ({ ...a, quote: { quoteId: r.quoteId, summary: quoteLine(r) }, confirmOpen: false, confirm: '' }));
20036
+ }
20037
+ return r;
20038
+ });
20039
+ const doStart = () => {
20040
+ const brief = act.brief.trim();
20041
+ if (!brief) return;
20042
+ runAction('start', () => hostRpc('autoStart', { projectId: pid, brief }), (r) => (r && r.note) || T('autoDone'));
20043
+ };
20044
+ const doApprove = () => {
20045
+ if (!act.quote) return;
20046
+ const words = act.confirm.trim();
20047
+ if (!words) { setAct((a) => ({ ...a, err: T('autoApproveNeedConfirm') })); return; }
20048
+ runAction('approve', () => hostRpc('autoApprove', { projectId: pid, quoteId: act.quote.quoteId, confirm: words }),
20049
+ (r) => T('autoApproved').replace('{calls}', String((r && r.videoCalls) || '')));
20050
+ };
20051
+ const doGenerate = () => runAction('generate', () => hostRpc('autoGenerate', { projectId: pid }), (r) => (r && r.note) || T('autoDone'));
20052
+ const doAbort = () => runAction('abort', () => hostRpc('autoAbort', { projectId: pid }), () => T('autoAborted'));
20053
+ const miniBtn = (role, label, onClick, disabled, extra) => h('button', Object.assign({
20054
+ type: 'button', className: 'dshic-mini', 'data-role': role, disabled: !!disabled || !!act.busy,
20055
+ onPointerDown: (e) => e.stopPropagation(), onClick,
20056
+ }, extra || {}), label);
19797
20057
  const lines = [];
19798
20058
  if (!st) lines.push(T('storageLoading'));
19799
20059
  else if (st.oldHost) lines.push(T('autoOldHost'));
@@ -19801,7 +20061,7 @@ const DIRECTOR_KEY_HELP = [
19801
20061
  lines.push(st.enabled ? T('autoOn') : T('autoOff'));
19802
20062
  lines.push(st.caps && st.caps.multiAgent ? T('autoCapsOk') : T('autoCapsNo'));
19803
20063
  }
19804
- return h('div', { className: 'dshic-card' },
20064
+ return h('div', { className: 'dshic-card', 'data-role': 'auto-mode-card' },
19805
20065
  h('div', { className: 'dshic-row' },
19806
20066
  Ic('spark', 12),
19807
20067
  h('strong', { style: { fontSize: 12, flex: 1, minWidth: 0 } }, T('autoTitle')),
@@ -19813,6 +20073,37 @@ const DIRECTOR_KEY_HELP = [
19813
20073
  : null,
19814
20074
  ),
19815
20075
  h('div', { className: 'dshic-hint', style: { marginTop: 4 }, 'data-role': 'auto-mode-status' }, lines.join(' · ')),
20076
+ actionsOn ? h('div', { 'data-role': 'auto-actions', style: { marginTop: 6 } },
20077
+ // 启动创作:brief 输入(为空禁用)+ 按钮
20078
+ h('textarea', {
20079
+ className: 'dshic-input', 'data-role': 'auto-brief-input', rows: 1, value: act.brief,
20080
+ placeholder: T('autoBriefPh'), style: { width: '100%', fontSize: 11, resize: 'vertical', marginBottom: 4 },
20081
+ onPointerDown: (e) => e.stopPropagation(), onChange: (e) => setAct((a) => ({ ...a, brief: e.target.value })),
20082
+ }),
20083
+ h('div', { className: 'dshic-row', style: { gap: 6, flexWrap: 'wrap' } },
20084
+ miniBtn('auto-start-btn', T('autoStartBtn'), doStart, !act.brief.trim() || !pid),
20085
+ miniBtn('auto-quote-btn', T('autoQuoteBtn'), doQuote, !pid),
20086
+ miniBtn('auto-approve-btn', T('autoApproveBtn'),
20087
+ () => setAct((a) => ({ ...a, confirmOpen: !a.confirmOpen, err: '', msg: '' })),
20088
+ !act.quote || !pid, { title: act.quote ? '' : T('autoNeedQuote') }),
20089
+ miniBtn('auto-generate-btn', T('autoGenerateBtn'), doGenerate, !pid),
20090
+ miniBtn('auto-abort-btn', T('autoAbortBtn'), doAbort, !pid),
20091
+ ),
20092
+ // 最近一次刷新的预算单(批准令牌来源)+ 行内确认输入(confirm 用户原话)
20093
+ act.quote ? h('div', { className: 'dshic-hint', 'data-role': 'auto-quote-line', style: { marginTop: 4 } }, act.quote.summary) : null,
20094
+ act.quote && act.confirmOpen ? h('div', { className: 'dshic-row', style: { gap: 6, marginTop: 4 } },
20095
+ h('input', {
20096
+ className: 'dshic-input', 'data-role': 'auto-confirm-input', value: act.confirm,
20097
+ placeholder: T('autoApprovePh'), style: { flex: 1, minWidth: 0, fontSize: 11 },
20098
+ onPointerDown: (e) => e.stopPropagation(),
20099
+ onChange: (e) => setAct((a) => ({ ...a, confirm: e.target.value })),
20100
+ onKeyDown: (e) => { if (e.key === 'Enter') { e.preventDefault(); doApprove(); } },
20101
+ }),
20102
+ miniBtn('auto-confirm-submit', T('autoApproveSubmit'), doApprove, !act.confirm.trim()),
20103
+ ) : null,
20104
+ act.msg ? h('div', { className: 'dshic-hint', 'data-role': 'auto-act-msg', style: { marginTop: 4 } }, act.msg) : null,
20105
+ act.err ? h('div', { className: 'dshic-err', 'data-role': 'auto-act-err', style: { marginTop: 4 } }, act.err) : null,
20106
+ ) : null,
19816
20107
  );
19817
20108
  }
19818
20109
 
@@ -19898,7 +20189,8 @@ const DIRECTOR_KEY_HELP = [
19898
20189
  list.unshift({ id: 'image-gen-bridge', name: '桥接dsh-image-gen', baseUrl: '', apiKey: '', viaImageGen: true, models });
19899
20190
  }
19900
20191
  const noChange = JSON.stringify(s0.imageProviders || []) === JSON.stringify(list);
19901
- if (!noChange) { s0.imageProviders = list; saveSettings(s0); }
20192
+ // issue #6:写回统一走 updateSettings(现取磁盘最新做基底,杜绝把别的卡刚写的字段回滚)
20193
+ if (!noChange) updateSettings((b) => ({ ...b, imageProviders: list }));
19902
20194
  return { models: models.length, changed: !noChange };
19903
20195
  };
19904
20196
  useEffect(() => {
@@ -19923,9 +20215,8 @@ const DIRECTOR_KEY_HELP = [
19923
20215
  const toggle = () => {
19924
20216
  const v = !enabled;
19925
20217
  setEnabled(v);
19926
- const s0 = loadSettings();
19927
- s0.imageGen = { ...(s0.imageGen || {}), enabled: v };
19928
- saveSettings(s0);
20218
+ // issue #6:写回统一走 updateSettings(现取磁盘最新做基底)
20219
+ updateSettings((b) => ({ ...b, imageGen: { ...(b.imageGen || {}), enabled: v } }));
19929
20220
  // 开/关即时生效:重跑一次探测同步(加回或移除桥接模型条目)
19930
20221
  (async () => {
19931
20222
  try {
@@ -19956,12 +20247,8 @@ const DIRECTOR_KEY_HELP = [
19956
20247
  function SettingsTab() {
19957
20248
  const [s, setS] = useState(loadSettings);
19958
20249
  const apply = (fn) => {
19959
- setS((prev) => {
19960
- const next = JSON.parse(JSON.stringify(prev));
19961
- fn(next);
19962
- saveSettings(next);
19963
- return next;
19964
- });
20250
+ // issue #6:与四张卡同根——基底现取磁盘最新,不再用挂载快照整对象写回
20251
+ setS(updateSettings((b) => { const d = JSON.parse(JSON.stringify(b)); fn(d); return d; }));
19965
20252
  };
19966
20253
  const field = (label, value, onChange, placeholder, password) => h(Field, { label, value, onChange, placeholder, password });
19967
20254
  return [
@@ -19996,7 +20283,7 @@ const DIRECTOR_KEY_HELP = [
19996
20283
  ),
19997
20284
  h(ModelProviderEditor, { key: 'imglist', kind: 'image' }),
19998
20285
  h(ModelProviderEditor, { key: 'vidlist', kind: 'video' }),
19999
- h(ApiListEditor, { key: 'ttslist', kind: 'tts' }),
20286
+ h(ModelProviderEditor, { key: 'ttslist', kind: 'tts' }),
20000
20287
  // 帮助与反馈:一行入口(点开弹窗看二维码与提 Issue)
20001
20288
  h('div', {
20002
20289
  key: 'support', className: 'dshic-card', style: { cursor: 'pointer' },
@@ -20132,7 +20419,9 @@ const DIRECTOR_KEY_HELP = [
20132
20419
  const [bible, setBible] = useState(() => loadBible(S.activeId));
20133
20420
  const [busy, setBusy] = useState(false);
20134
20421
  useEffect(() => { setBible(loadBible(S.activeId)); }, [S.activeId, S.assetsTick]);
20135
- const persist = (next) => { setBible(next); saveBible(S.activeId, next); };
20422
+ // persist:本地保存 + 推送防抖 + bibleTick 自增(分镜详情监听它自动重算一致性告警——
20423
+ // 宿主侧重算只写 Host 文档,客户端本地节点的旧告警必须靠这条信号自己刷新)
20424
+ const persist = (next) => { setBible(next); saveBible(S.activeId, next); update((s) => { s.bibleTick++; }); };
20136
20425
  /** 从项目里的创作意图/剧本一键起草设定集(设定集先行)。 */
20137
20426
  const draft = async () => {
20138
20427
  if (busy) return;
@@ -21757,6 +22046,8 @@ const DIRECTOR_KEY_HELP = [
21757
22046
  if (typeof window !== 'undefined' && window.__DSH_IC_SMOKE__) {
21758
22047
  window.__DSH_IC_TABS__ = {
21759
22048
  ProjectsTab, AssetsTab, BibleTab, SettingsTab, DataRootCard, CanvasPage, ShortcutsPanel, CanvasHostedApp, SkillPalette,
22049
+ // 自动创作卡(0.20.2 T12):快捷动作区(启动/预算/批准/生成/中止)——供 test-panel-layout 直渲染与断言
22050
+ AutoModeCard,
21760
22051
  // 面板结构重构(左侧图标列 / 顶部工具栏 / 右侧面板 / 统一弹窗)
21761
22052
  Toolbar, Rightbar, IconRail, StudioModal, ProjectNameDialog,
21762
22053
  // 技能页(四层图标瓦片):组件 + 图标表 + 配置读写 + 切片入口
@@ -21878,6 +22169,10 @@ const DIRECTOR_KEY_HELP = [
21878
22169
  // 供 scripts/test-segment-plan.mjs 直接断言
21879
22170
  window.__DSH_IC_SEGMENT__ = { planShotSegments, isCutPoint, segmentNeedsHardFrame, videoSegmentOf, shotContinuityPlan };
21880
22171
  window.__DSH_IC_STORYBOARD_PROMPT__ = { buildStoryboardVideoPrompt };
22172
+ // 视频请求组装(0.20.2):run 与「请求预览」的单一事实源——
22173
+ // assembleVideoRequest(组装+校验门)/ previewVideoInputs(预览轻量 inputs)/ videoRequestContext(决策基座)
22174
+ // 供 scripts/test-submission-log.mjs 断言 p 逐字一致与 warnings 三条逐一触发
22175
+ window.__DSH_IC_VIDEO_REQUEST__ = { assembleVideoRequest, previewVideoInputs, videoRequestContext };
21881
22176
  // 3D 导演台:引擎在 assets/director/engine.js(代码分割),这里只导出面板与
21882
22177
  // 引擎加载器;引擎内部的纯函数由测试直接 ESM import engine.js 断言——
21883
22178
  // 两端同一份代码,不存在"测试测的是拷贝"的问题。
@@ -21946,9 +22241,11 @@ const DIRECTOR_KEY_HELP = [
21946
22241
  window.__DSH_IC_CRAFT__ = { craftBaseDir, craftBaseDirRequired, joinLocal, craftFolderOf, craft };
21947
22242
  // 设置迁移的测试缝隙
21948
22243
  window.__DSH_IC_SETTINGS__ = {
21949
- DEFAULT_SETTINGS, loadSettings, saveSettings,
21950
- flattenImageModels, resolveImageModelCfg,
22244
+ DEFAULT_SETTINGS, loadSettings, saveSettings, updateSettings,
22245
+ flattenImageModels, flattenTtsModels, resolveImageModelCfg,
21951
22246
  buildExpertContext,
22247
+ // 设置卡组件缝合口(跨卡丢失更新回归用,scripts/test-panel-layout.mjs;不进 __DSH_IC_TABS__,smoke 会遍历渲染)
22248
+ LlmModelSelect, ModelProviderEditor,
21952
22249
  };
21953
22250
  // 创作上下文注入的测试缝隙(供 scripts/test-skill-inject.mjs 断言)
21954
22251
  window.__DSH_IC_SKILL__ = {