@ninkch/dsh-infinite-canvas 0.20.1 → 0.20.2
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 +563 -137
- package/index.js +548 -93
- package/package.json +1 -1
- package/production.js +83 -6
package/client.js
CHANGED
|
@@ -1218,6 +1218,23 @@ function revealCanvasInRight() {
|
|
|
1218
1218
|
'autoCapsOk': '多智能体:可用',
|
|
1219
1219
|
'autoCapsNo': '多智能体:宿主未暴露会话服务(暂不可用)',
|
|
1220
1220
|
'autoOldHost': '宿主插件是旧版本(不支持自动创作开关):完全重启 Harness 后可用',
|
|
1221
|
+
'autoStartBtn': '启动创作',
|
|
1222
|
+
'autoBriefPh': '一句话创意…',
|
|
1223
|
+
'autoQuoteBtn': '刷新预算',
|
|
1224
|
+
'autoApproveBtn': '批准付费',
|
|
1225
|
+
'autoApprovePh': '输入「批准」或你的确认原话',
|
|
1226
|
+
'autoApproveSubmit': '确认批准',
|
|
1227
|
+
'autoGenerateBtn': '开始生成',
|
|
1228
|
+
'autoAbortBtn': '中止',
|
|
1229
|
+
'autoNeedQuote': '先刷新预算',
|
|
1230
|
+
'autoQuoteSummary': '{s} 场 / {sh} 镜 / {sec} 秒 / 待调用 {calls} 次',
|
|
1231
|
+
'autoQuoteCost': '估算 ¥{cost}',
|
|
1232
|
+
'autoQuoteNoPrice': '未配置视频每秒单价(设置→制作 填入后显示估算金额)',
|
|
1233
|
+
'autoApproveNeedConfirm': '请输入确认原话(批准付费必须留痕)',
|
|
1234
|
+
'autoApproved': '已批准付费(待调用 {calls} 次)',
|
|
1235
|
+
'autoAborted': '已中止(保留已产出内容)',
|
|
1236
|
+
'autoDone': '完成',
|
|
1237
|
+
'autoFail': '操作失败',
|
|
1221
1238
|
'stageCurrent': '制作阶段',
|
|
1222
1239
|
'stageReadyYes': '可交付',
|
|
1223
1240
|
'stageReadyNo': '未就绪',
|
|
@@ -1291,6 +1308,20 @@ function revealCanvasInRight() {
|
|
|
1291
1308
|
'mentionAssets': '已绑定资产 {n} 项(图片不自动上送,参考图请用连线)',
|
|
1292
1309
|
'mentionNoAsset': '无绑定资产',
|
|
1293
1310
|
'mentionNoAssetHint': '该实体没有绑定资产:@名称 只注入设定描述文字(外观/声音);参考图必须用图片节点连线到 ref 口,资产库里的图不会自动追加',
|
|
1311
|
+
'reqPreview': '请求预览',
|
|
1312
|
+
'reqPreviewHint': '打开后按需计算:即将发送的模型、时长、分辨率、参考图角色与最终提示词全文(与正式提交同一组装逻辑,只读、零额外点击)',
|
|
1313
|
+
'reqPreviewFail': '预览失败',
|
|
1314
|
+
'reqPreviewModel': '模型',
|
|
1315
|
+
'reqPreviewFrame': '首帧/锚定',
|
|
1316
|
+
'reqPreviewRefs': '参考图',
|
|
1317
|
+
'reqPreviewAudio': '声音参考',
|
|
1318
|
+
'reqPreviewWarnings': '校验提示',
|
|
1319
|
+
'reqPreviewPrompt': '最终提示词',
|
|
1320
|
+
'reqPreviewCopy': '复制提示词',
|
|
1321
|
+
'anchorFirstFrame': '首帧锚定',
|
|
1322
|
+
'anchorRefImage': '参考图锚定(首帧图为图1)',
|
|
1323
|
+
'frameOffNone': '不带首帧',
|
|
1324
|
+
'frameAutoTail': '自动续帧(上一段尾帧)',
|
|
1294
1325
|
'craftTimeout': 'Craft 任务超时(可在任务面板重试或取消)',
|
|
1295
1326
|
'errNoImageApi': '未配置图片 API:请到画布设置里添加(未配置时可用演示模式)',
|
|
1296
1327
|
'photoCmd': 'Craft 命令',
|
|
@@ -2199,6 +2230,23 @@ function revealCanvasInRight() {
|
|
|
2199
2230
|
'autoCapsOk': 'Multi-agent: available',
|
|
2200
2231
|
'autoCapsNo': 'Multi-agent: host does not expose session services (unavailable)',
|
|
2201
2232
|
'autoOldHost': 'The plugin backend is older and lacks the auto-creation switch — fully restart Harness to enable',
|
|
2233
|
+
'autoStartBtn': 'Start creation',
|
|
2234
|
+
'autoBriefPh': 'One-line idea…',
|
|
2235
|
+
'autoQuoteBtn': 'Refresh budget',
|
|
2236
|
+
'autoApproveBtn': 'Approve paid run',
|
|
2237
|
+
'autoApprovePh': 'Type "approve" or your own confirmation words',
|
|
2238
|
+
'autoApproveSubmit': 'Confirm',
|
|
2239
|
+
'autoGenerateBtn': 'Start generating',
|
|
2240
|
+
'autoAbortBtn': 'Abort',
|
|
2241
|
+
'autoNeedQuote': 'Refresh the budget first',
|
|
2242
|
+
'autoQuoteSummary': '{s} scenes / {sh} shots / {sec}s / {calls} video calls pending',
|
|
2243
|
+
'autoQuoteCost': 'Est. ¥{cost}',
|
|
2244
|
+
'autoQuoteNoPrice': 'No per-second video price configured (set it in Settings → Production to show an estimate)',
|
|
2245
|
+
'autoApproveNeedConfirm': 'Type your confirmation words first (paid approval must leave a trace)',
|
|
2246
|
+
'autoApproved': 'Approved ({calls} video calls pending)',
|
|
2247
|
+
'autoAborted': 'Aborted (produced content kept)',
|
|
2248
|
+
'autoDone': 'Done',
|
|
2249
|
+
'autoFail': 'Action failed',
|
|
2202
2250
|
'stageCurrent': 'Stage',
|
|
2203
2251
|
'stageReadyYes': 'deliverable',
|
|
2204
2252
|
'stageReadyNo': 'not ready',
|
|
@@ -2272,6 +2320,20 @@ function revealCanvasInRight() {
|
|
|
2272
2320
|
'mentionAssets': '{n} asset(s) bound (images are not auto-sent; wire references explicitly)',
|
|
2273
2321
|
'mentionNoAsset': 'no bound asset',
|
|
2274
2322
|
'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',
|
|
2323
|
+
'reqPreview': 'Request preview',
|
|
2324
|
+
'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)',
|
|
2325
|
+
'reqPreviewFail': 'Preview failed',
|
|
2326
|
+
'reqPreviewModel': 'Model',
|
|
2327
|
+
'reqPreviewFrame': 'Frame/anchor',
|
|
2328
|
+
'reqPreviewRefs': 'Refs',
|
|
2329
|
+
'reqPreviewAudio': 'Voice refs',
|
|
2330
|
+
'reqPreviewWarnings': 'Checks',
|
|
2331
|
+
'reqPreviewPrompt': 'Final prompt',
|
|
2332
|
+
'reqPreviewCopy': 'Copy prompt',
|
|
2333
|
+
'anchorFirstFrame': 'first_frame anchor',
|
|
2334
|
+
'anchorRefImage': 'reference_image anchor (frame is image #1)',
|
|
2335
|
+
'frameOffNone': 'no frame',
|
|
2336
|
+
'frameAutoTail': 'auto continuation (previous tail frame)',
|
|
2275
2337
|
'craftTimeout': 'Craft job timed out (retry or cancel it in the job panel)',
|
|
2276
2338
|
'errNoImageApi': 'No image API configured — add one in canvas settings (demo mode is available without one)',
|
|
2277
2339
|
'photoCmd': 'Craft command',
|
|
@@ -3501,6 +3563,13 @@ body[data-ds-dark-theme] .dshic-storage-details{border-color:var(--dsw-alias-bor
|
|
|
3501
3563
|
line-height:var(--dshic-panel-lh);padding:var(--dshic-panel-pad);}
|
|
3502
3564
|
.dshic-composer .dshic-prompt-input{background:transparent;border-color:transparent;}
|
|
3503
3565
|
.dshic-composer-extra{display:flex;flex-direction:column;gap:6px;padding:6px 12px 0;}
|
|
3566
|
+
/* 请求预览(0.20.2):折叠区展开后的只读快照(模型/参数/参考图顺序/校验/最终提示词全文) */
|
|
3567
|
+
.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;}
|
|
3568
|
+
.dshic-req-grid{display:flex;flex-direction:column;gap:4px;}
|
|
3569
|
+
.dshic-req-warns{display:flex;flex-direction:column;gap:3px;}
|
|
3570
|
+
.dshic-req-prompt{max-height:180px;overflow:auto;font-size:11px;line-height:16px;white-space:pre-wrap;word-break:break-word;
|
|
3571
|
+
padding:6px 8px;border-radius:6px;background:color-mix(in srgb,var(--dshic-ink) 5%,transparent);
|
|
3572
|
+
scrollbar-width:thin;scrollbar-color:var(--dshic-ink3, rgba(128,128,128,.5)) transparent;}
|
|
3504
3573
|
/* 「更多」折叠开关:面板默认只显示「参考图条 / 提示词 / 一行控件」;
|
|
3505
3574
|
高级项收进这里,默认收起、不渲染(不占版面),点开才出现。 */
|
|
3506
3575
|
.dshic-composer-morebar{display:flex;align-items:center;flex:none;padding:2px 12px 0;}
|
|
@@ -9463,7 +9532,10 @@ function queueThumb(assetId) {
|
|
|
9463
9532
|
}));
|
|
9464
9533
|
}
|
|
9465
9534
|
/** 本地一致性检查:分镜里出现的角色/场景/道具(含 visual/motion 文本里的 @提及)是否都在
|
|
9466
|
-
* 设定集/资产中登记;两级告警——「未登记」与「已登记但描述为空(待补全)」。
|
|
9535
|
+
* 设定集/资产中登记;两级告警——「未登记」与「已登记但描述为空(待补全)」。
|
|
9536
|
+
* 台词碎片豁免:名字以「的」结尾且出现在对白文本里的角色/场景/道具视为描述性片段(如台词
|
|
9537
|
+
* 「来了个带纸的」被抽成道具「带纸的」),未登记不告警——与 Host index.js
|
|
9538
|
+
* storyboardConsistencyWarnings 同规则,两边必须字面同构(防漂移)。 */
|
|
9467
9539
|
async function checkShotConsistency(shots) {
|
|
9468
9540
|
const bible = loadBible(S.activeId);
|
|
9469
9541
|
const entries = [];
|
|
@@ -9479,7 +9551,13 @@ function queueThumb(assetId) {
|
|
|
9479
9551
|
const warnings = [];
|
|
9480
9552
|
const seen = new Set();
|
|
9481
9553
|
const warn = (line) => { if (!seen.has(line) && warnings.length < 12) { seen.add(line); warnings.push(line); } };
|
|
9482
|
-
|
|
9554
|
+
// 台词碎片收集(与 Host index.js storyboardConsistencyWarnings 同规则——两边必须字面同构,防漂移):
|
|
9555
|
+
// 拼接同 shots 数组内全部对白文本;shots 无 dialogue 字段(旧数据)时按「无对白可查」自然不跳过。
|
|
9556
|
+
let dialogueAll = '';
|
|
9557
|
+
for (const sh of shots || []) {
|
|
9558
|
+
for (const d of ((sh && sh.dialogue) || [])) dialogueAll += ' ' + String((d && d.line) || '');
|
|
9559
|
+
}
|
|
9560
|
+
const check = (title, kind, name, entity) => {
|
|
9483
9561
|
const q = String(name || '').trim().toLowerCase();
|
|
9484
9562
|
if (!q) return;
|
|
9485
9563
|
const exact = entries.find((e) => e.lower === q);
|
|
@@ -9487,17 +9565,19 @@ function queueThumb(assetId) {
|
|
|
9487
9565
|
if (!exact.desc.trim()) warn(`${title} · ${kind}「${exact.name}」${T('warnEmptyDesc')}`);
|
|
9488
9566
|
return;
|
|
9489
9567
|
}
|
|
9568
|
+
// 台词碎片跳过:仅 角色/场景/道具 三类(entity=true);@提及 通道绝不跳过,「已登记但描述为空」路径(上方)不跳过
|
|
9569
|
+
if (entity && String(name || '').trim().endsWith('的') && dialogueAll.includes(String(name || '').trim())) return;
|
|
9490
9570
|
for (const k of known) { if (k.includes(q) || q.includes(k)) return; }
|
|
9491
9571
|
warn(`${title} · ${kind}「${String(name).trim()}」${T('warnUnregistered')}`);
|
|
9492
9572
|
};
|
|
9493
9573
|
for (const sh of shots) {
|
|
9494
9574
|
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);
|
|
9575
|
+
for (const nm of (sh.characters || [])) check(title, T('catCharacter'), nm, true);
|
|
9576
|
+
check(title, T('catScene'), sh.scene, true);
|
|
9577
|
+
for (const nm of (sh.props || [])) check(title, T('catProp'), nm, true);
|
|
9498
9578
|
// visual/motion 文本里的 @资产名@ 提及同样纳入检查(未登记的会提示补充资产——这是检查的价值所在)
|
|
9499
9579
|
const text = String(sh.visual || '') + ' ' + String(sh.motion || '');
|
|
9500
|
-
for (const mm of parseMentions(text)) check(title, T('catMention'), mm.name);
|
|
9580
|
+
for (const mm of parseMentions(text)) check(title, T('catMention'), mm.name, false);
|
|
9501
9581
|
}
|
|
9502
9582
|
return warnings;
|
|
9503
9583
|
}
|
|
@@ -9602,6 +9682,9 @@ function queueThumb(assetId) {
|
|
|
9602
9682
|
menu: null, // {x, y, kind:'add'}
|
|
9603
9683
|
composerId: null, // 生成面板当前挂靠的节点 id(单例;纯 UI 状态,不持久化)
|
|
9604
9684
|
assetsTick: 0,
|
|
9685
|
+
// 设定集更新信号:编辑器 persist 后自增,分镜详情据此自动重算一致性告警(旧告警自动消失,免手动 revalidate)。
|
|
9686
|
+
// 不复用 assetsTick——它在资产事件上到处自增,会让无关事件反复触发重算。
|
|
9687
|
+
bibleTick: 0,
|
|
9605
9688
|
tick: 0,
|
|
9606
9689
|
craftStatus: null, // {at, data} | {at, error}
|
|
9607
9690
|
dataRoot: null, // 数据根目录(Host 配置);null = 未设置(资产走 IndexedDB)
|
|
@@ -10718,6 +10801,15 @@ function queueThumb(assetId) {
|
|
|
10718
10801
|
}
|
|
10719
10802
|
}
|
|
10720
10803
|
|
|
10804
|
+
/** 提交留痕写入(0.20.2 能力③):追加到项目目录 submissions.jsonl
|
|
10805
|
+
* (宿主侧统一 redact + 500 行裁剪;entry 形状见 index.js submissionLogAppend)。
|
|
10806
|
+
* 留痕默认开启、自动、无感(预览面板不放入口);写失败绝不影响生成主链路。 */
|
|
10807
|
+
async function logVideoSubmission(entry) {
|
|
10808
|
+
try {
|
|
10809
|
+
await hostRpc('submissionLogAppend', { projectId: S.activeId, entry });
|
|
10810
|
+
} catch { /* 留痕尽力而为:Host 不在/目录不可写都不能挡住生成 */ }
|
|
10811
|
+
}
|
|
10812
|
+
|
|
10721
10813
|
async function runGenNode(n) {
|
|
10722
10814
|
const type = n.type;
|
|
10723
10815
|
const settings = loadSettings(); // 模型解析(供应商+模型)用
|
|
@@ -10800,55 +10892,12 @@ function queueThumb(assetId) {
|
|
|
10800
10892
|
if (!cases.length) throw new Error(T('noResult'));
|
|
10801
10893
|
} else {
|
|
10802
10894
|
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
|
-
})();
|
|
10895
|
+
// —— 决策基座(分镜切片/时长策略/衔接规划):与「请求预览」共用同一份(assembleVideoRequest)——
|
|
10896
|
+
const vctx = videoRequestContext(n);
|
|
10848
10897
|
// 首帧来源:① frame 口连线(用户显式)② 续帧链自动取「上一个视频」的尾帧
|
|
10849
10898
|
let frameBlob = await resolveAssetBlob(n.id, 'frame');
|
|
10850
10899
|
let frameAuto = false;
|
|
10851
|
-
if (!frameBlob && plan.chain) {
|
|
10900
|
+
if (!frameBlob && vctx.plan.chain) {
|
|
10852
10901
|
const prevVid = autoPrevVideoNode(n);
|
|
10853
10902
|
if (prevVid && prevVid.data.assetId) {
|
|
10854
10903
|
try {
|
|
@@ -10870,89 +10919,62 @@ function queueThumb(assetId) {
|
|
|
10870
10919
|
} catch { /* 取不到尾帧则降级为纯参考图生成 */ }
|
|
10871
10920
|
}
|
|
10872
10921
|
}
|
|
10873
|
-
|
|
10922
|
+
// 组装最终请求(与请求预览**同一函数**;p 内容与旧内联实现逐字等价——重构红线)
|
|
10923
|
+
const assembled = await assembleVideoRequest(n, {
|
|
10924
|
+
prompt, bible,
|
|
10925
|
+
refs: refs.map((r) => ({ name: r.name, category: r.category, entity: r.entity || '' })),
|
|
10926
|
+
entities,
|
|
10927
|
+
audioNames: audioBlobs.map((a) => a.name),
|
|
10928
|
+
hasFrame: !!frameBlob,
|
|
10929
|
+
frameAuto,
|
|
10930
|
+
});
|
|
10931
|
+
const p = assembled.p;
|
|
10932
|
+
const params = assembled.params;
|
|
10933
|
+
const autoDuration = params.duration;
|
|
10934
|
+
const frameMode = params.frameMode;
|
|
10935
|
+
const hardFrame = params.hardFrame;
|
|
10874
10936
|
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
10937
|
const mcfg = resolveVideoModelCfg(settings, nodeVideoModelRef(n));
|
|
10939
10938
|
if (!mcfg) throw new Error(T('errNoVideoModel'));
|
|
10940
|
-
|
|
10941
|
-
|
|
10939
|
+
// 提交前校验门(能力①):warnings 单一事实源来自 assembleVideoRequest,生成时逐条显式提示
|
|
10940
|
+
// (含旧有的「已连接分镜但暂无镜头时长」原文)——绝不静默修改请求
|
|
10941
|
+
for (const w of params.warnings) addWarn(w);
|
|
10942
|
+
// 脱敏留痕(能力③):失败/未完成也要留底(saveAssetRecord 只在成功后写,追溯不到失败)。
|
|
10943
|
+
// entry 绝不含 taskQueryUrl(带签名地址)/apiKey/素材数据——redact 在宿主侧统一执行。
|
|
10944
|
+
const logBase = () => ({
|
|
10945
|
+
at: Date.now(), projectId: S.activeId, nodeId: n.id, nodeLabel: (n.data && n.data.label) || '',
|
|
10946
|
+
kind: 'video',
|
|
10947
|
+
model: mcfg ? { provider: mcfg.providerName || mcfg.providerId, id: mcfg.model } : { provider: '', id: '' },
|
|
10942
10948
|
duration: autoDuration, resolution: n.data.resolution, ratio: n.data.ratio,
|
|
10943
|
-
frameMode,
|
|
10944
|
-
|
|
10945
|
-
|
|
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), // 角色声音参考(@引用实体名下的音频资产)
|
|
10949
|
+
frameMode, hardFrame,
|
|
10950
|
+
refNames: params.refNames, audioNames: params.audioNames,
|
|
10951
|
+
promptChars: p.length, effectivePrompt: p, taskId: '', status: 'submitted',
|
|
10955
10952
|
});
|
|
10953
|
+
let subTid = ''; // onTask 回传的任务 id(失败留痕要能对上已提交的任务)
|
|
10954
|
+
let blob = null;
|
|
10955
|
+
try {
|
|
10956
|
+
blob = await apiVideo(p, useFrame ? frameBlob : null, mcfg, {
|
|
10957
|
+
duration: autoDuration, resolution: n.data.resolution, ratio: n.data.ratio,
|
|
10958
|
+
frameMode, // auto=尾帧降级为参考图(保留实体参考图)/ hard=硬首帧(放弃参考图)/ off=忽略首帧
|
|
10959
|
+
hardFrame,
|
|
10960
|
+
refs: refs.map((r) => r.blob),
|
|
10961
|
+
refNames: refs.map((r) => r.entity || r.name || ''), // 跨镜衔接标注用(图2..N 的实体名)
|
|
10962
|
+
nodeExtra: n.data.vidExtra, // 节点级扩展参数(手动参数框,如 {"use_context_ir":true})
|
|
10963
|
+
warn: addWarn, // 参考素材超限等告警回传(节点上可见)
|
|
10964
|
+
// 任务提交成功即持久化 task id:轮询中断/页面关闭后仍可凭 id 回查结果(钱花了就必须能找回)
|
|
10965
|
+
onTask: (tid, qurl) => {
|
|
10966
|
+
update((s) => { const nd = s.graph.nodes[n.id]; if (nd) { nd.data.taskId = String(tid || ''); nd.data.taskQueryUrl = String(qurl || ''); } });
|
|
10967
|
+
flushSave();
|
|
10968
|
+
subTid = String(tid || '');
|
|
10969
|
+
logVideoSubmission({ ...logBase(), taskId: subTid, status: 'submitted' }); // 提交留痕(自动、无感)
|
|
10970
|
+
},
|
|
10971
|
+
audioRefs: audioBlobs.map((a) => a.blob), // 角色声音参考(@引用实体名下的音频资产)
|
|
10972
|
+
});
|
|
10973
|
+
} catch (eSub) {
|
|
10974
|
+
// 失败留痕(本能力的主要价值):throw 前先落一条 failed,再原样抛出(异常时序与旧实现一致)
|
|
10975
|
+
logVideoSubmission({ ...logBase(), taskId: subTid, status: 'failed', error: String((eSub && eSub.message) || eSub) });
|
|
10976
|
+
throw eSub;
|
|
10977
|
+
}
|
|
10956
10978
|
const rec = await saveAssetRecord(S.activeId, 'video', blob, {
|
|
10957
10979
|
name: assetNameFor(n, entities, 'video'),
|
|
10958
10980
|
prompt: stripMentionMarks(prompt), effectivePrompt: p,
|
|
@@ -10962,6 +10984,7 @@ function queueThumb(assetId) {
|
|
|
10962
10984
|
nodeLabel: (n.data && n.data.label) || '',
|
|
10963
10985
|
category: 'finalcut', // 节点生成的视频 = 成片(实体归属由 entities 字段承担,不占用分类)
|
|
10964
10986
|
});
|
|
10987
|
+
logVideoSubmission({ ...logBase(), taskId: subTid, status: 'done' }); // 终态留痕(fire-and-forget,不改变回写时序)
|
|
10965
10988
|
// 记录续帧来源(节点上可追溯:本段是从哪一段接过来的)
|
|
10966
10989
|
if (useFrame) {
|
|
10967
10990
|
update((s) => {
|
|
@@ -11019,14 +11042,14 @@ function queueThumb(assetId) {
|
|
|
11019
11042
|
});
|
|
11020
11043
|
}
|
|
11021
11044
|
// 接缝校验:本段首帧 vs 上一段尾帧(续帧段才有意义)。不达标 → 节点上可见告警(不静默)
|
|
11022
|
-
if (useFrame && plan.chain) {
|
|
11045
|
+
if (useFrame && vctx.plan.chain) {
|
|
11023
11046
|
try {
|
|
11024
11047
|
const first = await extractFirstFrame(blob);
|
|
11025
11048
|
if (first) {
|
|
11026
11049
|
const ga = await grayThumb(frameBlob, 32);
|
|
11027
11050
|
const gb = await grayThumb(first, 32);
|
|
11028
11051
|
const met = frameSeamMetrics(ga, gb);
|
|
11029
|
-
const v = seamVerdict(met, plan.join);
|
|
11052
|
+
const v = seamVerdict(met, vctx.plan.join);
|
|
11030
11053
|
update((s) => {
|
|
11031
11054
|
const nd = s.graph.nodes[n.id];
|
|
11032
11055
|
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 +12326,207 @@ function queueThumb(assetId) {
|
|
|
12303
12326
|
return { controlled: false, value: cfg > 0 ? round1(cfg) : 5 };
|
|
12304
12327
|
}
|
|
12305
12328
|
|
|
12329
|
+
// ============================================================
|
|
12330
|
+
// 视频请求组装(0.20.2):run 路径与「请求预览」的单一事实源
|
|
12331
|
+
// ============================================================
|
|
12332
|
+
// 背景(外部用户 issue 三能力):① 提交前自动校验(排除/降级素材时显式提示,不静默);
|
|
12333
|
+
// ② 真预览——与正式提交**同一组装逻辑**(不是另做一个近似预览),且普通生成零新增点击;
|
|
12334
|
+
// ③ 失败可追溯(脱敏留痕见 index.js submissionLogAppend)。
|
|
12335
|
+
// 因此把 runGenNode 视频分支里「从分镜切片到最终提示词」的纯决策+组装抽出来,
|
|
12336
|
+
// run 与预览都调 assembleVideoRequest——p 逐字一致是重构红线(test-submission-log 断言)。
|
|
12337
|
+
/** 本段镜头区间元数据(按镜头切段铺开时节点上写有 segShotFrom/To/Index/Count)。 */
|
|
12338
|
+
function videoSegMetaOf(n, shotListAll) {
|
|
12339
|
+
const d = (n.data || {});
|
|
12340
|
+
if (!shotListAll.length) return null;
|
|
12341
|
+
const from = Number(d.segShotFrom);
|
|
12342
|
+
const to = Number(d.segShotTo);
|
|
12343
|
+
if (!Number.isFinite(from) || !Number.isFinite(to) || to < from) return null;
|
|
12344
|
+
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') };
|
|
12345
|
+
}
|
|
12346
|
+
/** 分镜衔接规划:段落类型(续帧/换场/新角色/特写插入)+ 首镜承接口 + 是否接力尾帧。
|
|
12347
|
+
* 全部是同步图读取——同一节点同一图状态下结果恒定,run 与预览共用。 */
|
|
12348
|
+
function videoContinuityPlan(n, shotList, segMeta, sbUp, zh) {
|
|
12349
|
+
if (!shotList.length) return { first: null, chain: false, join: 'loose', seg: 'opening', fromShot: false };
|
|
12350
|
+
const first = shotContinuityPlan(shotList[0], null, 0);
|
|
12351
|
+
// 分镜衔接总开关(分镜表 cont):关掉 = 不做跨段承接、不自动取尾帧、不写衔接块
|
|
12352
|
+
const contOn = sbUp ? sbUp.data.cont !== false : true;
|
|
12353
|
+
// 跨分镜表承接:上游分镜表「衔接上一镜」输入口 ← 上一个分镜表「尾镜」输出口
|
|
12354
|
+
const prevSb = (() => {
|
|
12355
|
+
const e2 = S.graph.edges.find((x) => x.toNode === (sbUp && sbUp.id) && x.toPort === 'prev');
|
|
12356
|
+
const src = e2 && S.graph.nodes[e2.fromNode];
|
|
12357
|
+
return src && src.type === 'storyboard' ? src : null;
|
|
12358
|
+
})();
|
|
12359
|
+
const prevNote = prevSb ? storyboardContinuityNote(prevSb.data.shots || [], String(prevSb.data.label || ''), zh) : null;
|
|
12360
|
+
let seg = first.seg;
|
|
12361
|
+
// 第 1 镜没有表内上一镜时,可承接上一个分镜表 → 实质是续帧
|
|
12362
|
+
if (seg === 'opening' && prevNote) seg = 'continuation';
|
|
12363
|
+
const join = (seg === 'scene_change' || seg === 'new_character') ? 'loose' : seg === 'closeup' ? 'cut' : 'strict';
|
|
12364
|
+
// 接力判定:切段铺开时以**规划器**为准(它知道本段是否从切点开始);
|
|
12365
|
+
// 直接把整表塞一次生成的旧路径才退回"首镜是续帧就接力"。
|
|
12366
|
+
const chain = contOn && (segMeta ? (segMeta.needsTailChain && seg === 'continuation') : seg === 'continuation');
|
|
12367
|
+
return { first, chain, seg, join, fromShot: contOn && (segMeta ? segMeta.needsTailChain : !!prevNote), contOn, segMeta };
|
|
12368
|
+
}
|
|
12369
|
+
/** 跨段承接说明:本分镜第 1 镜承接上一个分镜表尾镜(续帧时首帧图已带画面,这里补文字约束)。 */
|
|
12370
|
+
function videoContinuityText(plan, shotList, zh) {
|
|
12371
|
+
if (!plan.fromShot) return '';
|
|
12372
|
+
const st = shotList[0] || {};
|
|
12373
|
+
const tail = String(st.tail || '').trim();
|
|
12374
|
+
const bits = [];
|
|
12375
|
+
if (plan.seg === 'continuation') {
|
|
12376
|
+
bits.push(zh ? '本段是上一段的直接续帧:第 1 帧从上一段结尾接着演,不重演、不重新建立场景、不切换机位' : 'This segment continues the previous one: start from its last frame, no replay, no re-establishing, no camera reset');
|
|
12377
|
+
if (tail) bits.push((zh ? '起始状态:' : 'Start state: ') + tail);
|
|
12378
|
+
} else if (plan.seg === 'scene_change') {
|
|
12379
|
+
bits.push(zh ? '本段换场:不承接上一段画面,但环境声/情绪可延续' : 'Scene change: do not continue the previous frame; ambience and mood may carry over');
|
|
12380
|
+
} else if (plan.seg === 'new_character') {
|
|
12381
|
+
// 特效入场(灯闪现身/影子凝聚/影化实)合法:首镜 vfx/start 写明特效进入时不逼"走入"
|
|
12382
|
+
const fxEntry = /凝聚|凭空|灯闪|黑场|影子|化实|现身|浮现/.test(
|
|
12383
|
+
String(st.vfx || '') + String(st.start || '') + String(st.visual || '') + String(st.motion || ''));
|
|
12384
|
+
bits.push(zh
|
|
12385
|
+
? (fxEntry
|
|
12386
|
+
? '本段有新角色入场(特效进入):灯闪/黑场后已在场、从影子凝聚立起、浮现成形——不得缓慢走入'
|
|
12387
|
+
: '本段有新角色入场:新角色必须从画面内自然进入(走入/被带入),不得凭空出现')
|
|
12388
|
+
: (fxEntry
|
|
12389
|
+
? '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'
|
|
12390
|
+
: 'A new character enters: they must enter naturally from within the frame, never pop in'));
|
|
12391
|
+
}
|
|
12392
|
+
return bits.join(zh ? ';' : '; ');
|
|
12393
|
+
}
|
|
12394
|
+
/** 视频请求的公共决策基座:分镜输入/段元数据/切片/时长策略/手写判定/衔接规划。
|
|
12395
|
+
* run 路径(自动续帧要读 plan.chain)与 assembleVideoRequest 都从这里取,保证两边一致。 */
|
|
12396
|
+
function videoRequestContext(n) {
|
|
12397
|
+
const sbUp = storyboardInputOf(n);
|
|
12398
|
+
const shotListAll = sbUp && Array.isArray(sbUp.data.shots) ? sbUp.data.shots : [];
|
|
12399
|
+
const segMeta = videoSegMetaOf(n, shotListAll);
|
|
12400
|
+
const shotList = segMeta ? shotListAll.slice(segMeta.from, segMeta.to + 1) : shotListAll;
|
|
12401
|
+
// 时长策略:未连分镜用节点秒数;已连分镜按本段镜头节拍求和(节点秒数不进请求)
|
|
12402
|
+
const durationPlan = videoDurationFor(n, shotList, !!sbUp);
|
|
12403
|
+
const autoDuration = durationPlan.value || 5;
|
|
12404
|
+
const handWritten = String(n.data.prompt || '').trim();
|
|
12405
|
+
// 手写厂商结构化提示词 = 高级直通路径:保留用户的 subject/shot 结构,
|
|
12406
|
+
// 只补实体设定文字;风格锁与承接前置块都不再追加,避免污染厂商协议格式。
|
|
12407
|
+
const handStructured = handWritten.includes('subject_definitions');
|
|
12408
|
+
const zh = effLang() !== 'en';
|
|
12409
|
+
const plan = videoContinuityPlan(n, shotList, segMeta, sbUp, zh);
|
|
12410
|
+
return { sbUp, shotListAll, segMeta, shotList, durationPlan, autoDuration, handWritten, handStructured, zh, plan };
|
|
12411
|
+
}
|
|
12412
|
+
/** 组装一次视频请求(blob 无关):
|
|
12413
|
+
* - inputs = { prompt, bible, refs, entities, audioNames, hasFrame, frameAuto }
|
|
12414
|
+
* refs 传描述符 {name, category, entity}(组装只消费这三个字段,blob 由 run 路径在
|
|
12415
|
+
* 真正调用 apiVideo 时映射);hasFrame/frameAuto 由调用方按各自口径给
|
|
12416
|
+
* (run=blob 实际存在,预览=连线存在性),组装决策对两边一致。
|
|
12417
|
+
* - 返回 { p, params: { duration, resolution, ratio, frameMode, hardFrame, anchorRole,
|
|
12418
|
+
* useFrame, frameAuto, refNames, refRoles, audioNames, modelLabel, segMeta, warnings } }
|
|
12419
|
+
* - warnings = 提交前校验门(单一事实源):每条都是显式提示,绝不静默修改请求;
|
|
12420
|
+
* run 路径逐条 addWarn(生成时节点可见),预览面板原样展示。 */
|
|
12421
|
+
async function assembleVideoRequest(n, inputs) {
|
|
12422
|
+
const i = inputs || {};
|
|
12423
|
+
const refs = Array.isArray(i.refs) ? i.refs : [];
|
|
12424
|
+
const entities = Array.isArray(i.entities) ? i.entities : [];
|
|
12425
|
+
const audioNames = Array.isArray(i.audioNames) ? i.audioNames : [];
|
|
12426
|
+
const hasFrame = !!i.hasFrame;
|
|
12427
|
+
const frameAuto = !!i.frameAuto;
|
|
12428
|
+
// 与旧内联实现同名(重构红线:p 逐字等价的最强自证——本函数体即原 runGenNode 视频分支原文)
|
|
12429
|
+
const { shotList, autoDuration, handWritten, handStructured, zh, plan, durationPlan, sbUp, segMeta: segMetaRef } = videoRequestContext(n);
|
|
12430
|
+
const prompt = String(i.prompt ?? '');
|
|
12431
|
+
const bible = i.bible || null;
|
|
12432
|
+
const frameMode = n.data.frameMode || 'auto';
|
|
12433
|
+
const useFrame = frameMode !== 'off' && hasFrame;
|
|
12434
|
+
// 硬首帧只在"不挂实体参考图"时可用(多数厂商 first_frame 与 reference_image 互斥);
|
|
12435
|
+
// 续帧段若还要实体参考图 → 尾帧降级为首张参考图 + 软锚定(frameAnchorText 会写明)
|
|
12436
|
+
const hardFrame = useFrame && frameMode === 'hard';
|
|
12437
|
+
const anchorRole = (useFrame && !hardFrame && refs.length) ? 'reference_image' : 'first_frame';
|
|
12438
|
+
let music = '';
|
|
12439
|
+
try { const ex2 = parseExtraParams(n.data.vidExtra); if (ex2 && typeof ex2.music === 'string') music = ex2.music; } catch { /* 扩展参数非法时忽略音乐提示 */ }
|
|
12440
|
+
// 跨段承接说明:本分镜第 1 镜承接上一个分镜表尾镜(续帧时首帧图已带画面,这里补文字约束)
|
|
12441
|
+
const continuity = videoContinuityText(plan, shotList, zh);
|
|
12442
|
+
let p;
|
|
12443
|
+
// 图1=尾帧(降级模式)时实体参考图为图2..N+1:两条提示词组装路径都要同步偏移
|
|
12444
|
+
const effOpts = { picOffset: (useFrame && anchorRole === 'reference_image') ? 1 : 0 };
|
|
12445
|
+
if (handStructured) {
|
|
12446
|
+
p = handWritten; // 高级用法:手写结构化提示词,结构原样保留
|
|
12447
|
+
// 只追加 series_bible 文字块:不动用户写好的主体/镜头结构,也不追加任何参考图与风格锁。
|
|
12448
|
+
if (!/series_bible/i.test(p)) {
|
|
12449
|
+
const bb = entityBibleBlock(entities, bible, zh);
|
|
12450
|
+
if (bb) p = p + '\n' + bb;
|
|
12451
|
+
}
|
|
12452
|
+
} else if (shotList.length) {
|
|
12453
|
+
p = buildStructuredVideoPrompt(shotList, refs, bible, {
|
|
12454
|
+
zh, prompt: handWritten, music, hasFrame: useFrame, frameRole: anchorRole, continuity,
|
|
12455
|
+
// @引用命中实体的设定文字(外观/声音):只注入文本,参考图仍严格只取 ref 连线
|
|
12456
|
+
entities,
|
|
12457
|
+
});
|
|
12458
|
+
if (!p) p = buildEffectivePrompt(prompt, refs, entities, bible, false, effOpts); // 无参考图时回退
|
|
12459
|
+
} else {
|
|
12460
|
+
p = buildEffectivePrompt(prompt, refs, entities, bible, false, effOpts);
|
|
12461
|
+
}
|
|
12462
|
+
// 非结构化路径(无参考图/手写提示词)也要有首帧锚定与承接说明
|
|
12463
|
+
if ((!shotList.length || !p.includes('subject_definitions')) && !handStructured) {
|
|
12464
|
+
const pre = [frameAnchorText({ hasFrame: useFrame, role: anchorRole, zh }), continuity].filter(Boolean).join(zh ? ';' : '; ');
|
|
12465
|
+
if (pre) p = pre + '\n' + p;
|
|
12466
|
+
}
|
|
12467
|
+
// 自动组装路径才追加技能包风格锁;手写厂商结构化提示词保持用户协议结构
|
|
12468
|
+
if (!handStructured) {
|
|
12469
|
+
try {
|
|
12470
|
+
const lock = await buildShotLockText('prompt');
|
|
12471
|
+
if (lock) p = p + '\n' + lock;
|
|
12472
|
+
} catch { /* 技能包不可用时不影响生成 */ }
|
|
12473
|
+
}
|
|
12474
|
+
const mcfg = resolveVideoModelCfg(loadSettings(), nodeVideoModelRef(n));
|
|
12475
|
+
const frameWired = S.graph.edges.some((x) => x.toNode === n.id && x.toPort === 'frame');
|
|
12476
|
+
// —— 提交前校验门(显式提示,绝不静默)——
|
|
12477
|
+
const warnings = [];
|
|
12478
|
+
if (!mcfg) warnings.push('未配置视频模型:请到画布设置里选择视频模型后再生成');
|
|
12479
|
+
if (sbUp && !durationPlan.value) warnings.push('已连接分镜但暂无镜头时长:视频时长回退 5s(先生成分镜镜头后重跑)');
|
|
12480
|
+
if (autoDuration > 15) warnings.push('时长 ' + autoDuration + 's 超过单次生成上限 15s:厂商可能直接拒绝(如中转站 400)——建议按镜头切段或压缩镜头');
|
|
12481
|
+
if (refs.length > 4) warnings.push('参考图 ' + refs.length + ' 张可能超过厂商常见上限(4 张):超出部分可能被忽略——请核对厂商文档');
|
|
12482
|
+
if (useFrame && !hardFrame && refs.length) warnings.push('硬首帧与实体参考图互斥:已降级为参考图锚定');
|
|
12483
|
+
if (frameMode === 'off' && frameWired) warnings.push('首帧已接线但 frameMode=off:本请求不带首帧');
|
|
12484
|
+
return {
|
|
12485
|
+
p,
|
|
12486
|
+
params: {
|
|
12487
|
+
duration: autoDuration, resolution: n.data.resolution, ratio: n.data.ratio,
|
|
12488
|
+
frameMode, hardFrame, anchorRole, useFrame, frameAuto,
|
|
12489
|
+
refNames: refs.map((r) => r.entity || r.name || ''),
|
|
12490
|
+
refRoles: refs.map((r) => r.category || ''),
|
|
12491
|
+
audioNames,
|
|
12492
|
+
modelLabel: mcfg ? ((mcfg.providerName || mcfg.providerId) + ' / ' + mcfg.model) : '',
|
|
12493
|
+
segMeta: segMetaRef,
|
|
12494
|
+
warnings,
|
|
12495
|
+
},
|
|
12496
|
+
};
|
|
12497
|
+
}
|
|
12498
|
+
/** 请求预览的轻量 inputs(零 blob 解码):连线存在性代替 blob 存在性
|
|
12499
|
+
* (frame 口有连线+上游 assetId → hasFrame=true;续帧链上有已生成的上一段 → frameAuto)。
|
|
12500
|
+
* refs 名称/分类取资产元数据缓存(assetMem),取不到退回节点标签——
|
|
12501
|
+
* 组装只消费 name/category/entity 三个字段,与 run 路径的 collectRefs 产物同构。 */
|
|
12502
|
+
async function previewVideoInputs(n) {
|
|
12503
|
+
const bible = loadBible(S.activeId);
|
|
12504
|
+
// 与 run 路径同口径:先做未闭合引用自愈(预览只读,不回写节点)
|
|
12505
|
+
const prompt = repairUnclosedMentions(resolvePrompt(n), bibleNames(bible));
|
|
12506
|
+
// @引用解析先行:idbByProject 会顺带预热 assetMem(资产元数据缓存),ref 名称从它取
|
|
12507
|
+
// (先建 ref 再解析会把首帧预览锁在冷缓存上,名称退回节点标签)
|
|
12508
|
+
const bundle = await resolveMentionBundle(prompt, bible, S.activeId);
|
|
12509
|
+
const audioNames = (bundle.audioRefs || []).map((r) => r.name);
|
|
12510
|
+
const refEdges = S.graph.edges.filter((e) => e.toNode === n.id && e.toPort === 'ref');
|
|
12511
|
+
const refs = orderedRefEdgeIds(n, refEdges).map((id) => {
|
|
12512
|
+
const e = refEdges.find((x) => x.id === id);
|
|
12513
|
+
const src = e && S.graph.nodes[e.fromNode];
|
|
12514
|
+
const aid = src ? servedAssetId(src, e.fromPort) : null;
|
|
12515
|
+
const rec = aid ? assetMem.get(aid) : null;
|
|
12516
|
+
return { name: String((rec && rec.name) || (src && (src.data.label || src.data.placeholderName)) || '…'), category: (rec && rec.category) || 'general', entity: '' };
|
|
12517
|
+
});
|
|
12518
|
+
let hasFrame = false;
|
|
12519
|
+
let frameAuto = false;
|
|
12520
|
+
const fe = S.graph.edges.find((x) => x.toNode === n.id && x.toPort === 'frame');
|
|
12521
|
+
const faid = fe ? servedAssetId(S.graph.nodes[fe.fromNode], fe.fromPort) : null;
|
|
12522
|
+
if (faid) hasFrame = true;
|
|
12523
|
+
if (!hasFrame && videoRequestContext(n).plan.chain) {
|
|
12524
|
+
const pv = autoPrevVideoNode(n);
|
|
12525
|
+
if (pv && pv.data.assetId) { hasFrame = true; frameAuto = true; }
|
|
12526
|
+
}
|
|
12527
|
+
return { prompt, bible, refs, entities: bundle.entities, audioNames, hasFrame, frameAuto };
|
|
12528
|
+
}
|
|
12529
|
+
|
|
12306
12530
|
/** 自定义数值的统一夹取:低于下限视为无效(0 是“自动”等保留值,不能悄悄变成 1);
|
|
12307
12531
|
* 超上限夹回上限;整数/一位小数口径固定;非法输入回退当前值。 */
|
|
12308
12532
|
function clampCustomNumber(raw, opts) {
|
|
@@ -12989,6 +13213,7 @@ function queueThumb(assetId) {
|
|
|
12989
13213
|
})
|
|
12990
13214
|
: null,
|
|
12991
13215
|
(isImage || isVideo) ? h(MentionInfo, { n }) : null,
|
|
13216
|
+
isVideo ? h(RequestPreview, { n }) : null, // 请求预览(0.20.2):只读折叠区,打开才计算,零新增点击
|
|
12992
13217
|
(n.data.history || []).length > 1
|
|
12993
13218
|
? h('div', { className: 'dshic-hist' },
|
|
12994
13219
|
(n.data.history || []).map((hh) => h(HistThumb, {
|
|
@@ -13492,6 +13717,104 @@ function queueThumb(assetId) {
|
|
|
13492
13717
|
);
|
|
13493
13718
|
}
|
|
13494
13719
|
|
|
13720
|
+
/** 请求预览(0.20.2 能力①②):只读、按需计算、普通生成零新增点击。
|
|
13721
|
+
* 折叠区打开时才调 assembleVideoRequest——与正式提交**同一组装函数**(轻量 inputs:
|
|
13722
|
+
* 连线存在性代替 blob 存在性),展示模型/时长/分辨率/锚定角色/参考图顺序/声音参考/
|
|
13723
|
+
* 校验 warnings/最终提示词全文。不是另做的近似预览,p 与正式提交逐字一致。 */
|
|
13724
|
+
function RequestPreview({ n }) {
|
|
13725
|
+
const [open, setOpen] = useState(false);
|
|
13726
|
+
const [snap, setSnap] = useState(null); // { p, params, error }
|
|
13727
|
+
useEffect(() => {
|
|
13728
|
+
if (!open) return undefined;
|
|
13729
|
+
let alive = true;
|
|
13730
|
+
(async () => {
|
|
13731
|
+
try {
|
|
13732
|
+
const inputs = await previewVideoInputs(n);
|
|
13733
|
+
const out = await assembleVideoRequest(n, inputs);
|
|
13734
|
+
if (alive) setSnap({ error: null, p: out.p, params: out.params });
|
|
13735
|
+
} catch (e) {
|
|
13736
|
+
if (alive) setSnap({ error: String((e && e.message) || e), p: null, params: null });
|
|
13737
|
+
}
|
|
13738
|
+
})();
|
|
13739
|
+
return () => { alive = false; };
|
|
13740
|
+
}, [open, n && n.data.prompt, n && n.data.frameMode, n && n.data.duration, n && n.data.resolution,
|
|
13741
|
+
n && n.data.ratio, n && n.data.vidExtra, ((n && n.data.refOrder) || []).length, S.assetsTick, S.activeId]);
|
|
13742
|
+
const toggle = (v) => (e) => { e.stopPropagation(); setOpen(v); };
|
|
13743
|
+
if (!open) {
|
|
13744
|
+
return h('button', {
|
|
13745
|
+
type: 'button', className: 'dshic-mini is-ghost', 'data-req-preview': 'closed', title: T('reqPreviewHint'),
|
|
13746
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
13747
|
+
onClick: toggle(true),
|
|
13748
|
+
}, '👁 ' + T('reqPreview'));
|
|
13749
|
+
}
|
|
13750
|
+
const ps = snap && snap.params;
|
|
13751
|
+
const modeLabel = (m) => (m === 'hard' ? T('frameModeHard') : m === 'off' ? T('frameModeOff') : T('frameModeAuto'));
|
|
13752
|
+
// 图1=尾帧(降级锚定)时实体参考图实际是图2..N+1——与请求侧 picOffset 同一口径
|
|
13753
|
+
const off = ps && ps.useFrame && ps.anchorRole === 'reference_image' ? 1 : 0;
|
|
13754
|
+
return h('div', { className: 'dshic-req-preview', 'data-req-preview': 'open', onPointerDown: (e) => e.stopPropagation() },
|
|
13755
|
+
h('div', { className: 'dshic-row', style: { gap: 6, alignItems: 'center' } },
|
|
13756
|
+
h('span', { className: 'dshic-shot-label' }, T('reqPreview')),
|
|
13757
|
+
h('span', { style: { flex: 1 } }),
|
|
13758
|
+
h('button', {
|
|
13759
|
+
type: 'button', className: 'dshic-mini is-ghost', title: T('lbHint'),
|
|
13760
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
13761
|
+
onClick: toggle(false),
|
|
13762
|
+
}, '▾')),
|
|
13763
|
+
snap && snap.error ? h('div', { className: 'dshic-err' }, T('reqPreviewFail') + ':' + snap.error) : null,
|
|
13764
|
+
!snap ? h('div', { className: 'dshic-hint' }, '…') : null,
|
|
13765
|
+
ps ? h('div', { className: 'dshic-req-grid' },
|
|
13766
|
+
h('div', { className: 'dshic-row' },
|
|
13767
|
+
h('span', { className: 'dshic-shot-label', style: { flex: 'none' } }, T('reqPreviewModel')),
|
|
13768
|
+
h('span', { className: 'dshic-hint', style: { flex: 1, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, ps.modelLabel || '—')),
|
|
13769
|
+
h('div', { className: 'dshic-row' },
|
|
13770
|
+
h('span', { className: 'dshic-shot-label', style: { flex: 'none' } }, T('durationLabel')),
|
|
13771
|
+
h('span', { className: 'dshic-hint' }, ps.duration + 's')),
|
|
13772
|
+
h('div', { className: 'dshic-row' },
|
|
13773
|
+
h('span', { className: 'dshic-shot-label', style: { flex: 'none' } }, T('resolutionLabel')),
|
|
13774
|
+
h('span', { className: 'dshic-hint' }, String(ps.resolution || '—') + ' · ' + String(ps.ratio || '—'))),
|
|
13775
|
+
h('div', { className: 'dshic-row' },
|
|
13776
|
+
h('span', { className: 'dshic-shot-label', style: { flex: 'none' } }, T('reqPreviewFrame')),
|
|
13777
|
+
h('span', { className: 'dshic-hint', style: { flex: 1, minWidth: 0 } },
|
|
13778
|
+
modeLabel(ps.frameMode) + ' · ' + (ps.frameMode === 'off'
|
|
13779
|
+
? T('frameOffNone')
|
|
13780
|
+
: (ps.anchorRole === 'reference_image' ? T('anchorRefImage') : T('anchorFirstFrame')))
|
|
13781
|
+
+ (ps.frameAuto ? ' · ' + T('frameAutoTail') : ''))),
|
|
13782
|
+
h('div', { className: 'dshic-shot-label' }, T('reqPreviewRefs') + '(' + ps.refNames.length + ')'),
|
|
13783
|
+
ps.refNames.length
|
|
13784
|
+
? ps.refNames.map((nm, i2) => h('div', { key: i2, className: 'dshic-row', style: { gap: 5 } },
|
|
13785
|
+
h('span', { className: 'dshic-mention' }, '[图' + (i2 + 1 + off) + ']'),
|
|
13786
|
+
h('span', { className: 'dshic-hint', style: { flex: 1, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } },
|
|
13787
|
+
String(nm || '—') + (ps.refRoles[i2] ? '(' + catLabel(ps.refRoles[i2]) + ')' : ''))))
|
|
13788
|
+
: h('div', { className: 'dshic-hint' }, '—'),
|
|
13789
|
+
ps.useFrame && off
|
|
13790
|
+
? h('div', { className: 'dshic-row', style: { gap: 5 } },
|
|
13791
|
+
h('span', { className: 'dshic-mention' }, '[图1]'),
|
|
13792
|
+
h('span', { className: 'dshic-hint' }, T('frameModeAuto') + (ps.frameAuto ? '(' + T('frameAutoTail') + ')' : '')))
|
|
13793
|
+
: null,
|
|
13794
|
+
h('div', { className: 'dshic-row' },
|
|
13795
|
+
h('span', { className: 'dshic-shot-label', style: { flex: 'none' } }, T('reqPreviewAudio')),
|
|
13796
|
+
h('span', { className: 'dshic-hint', style: { flex: 1, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } },
|
|
13797
|
+
ps.audioNames.length ? ps.audioNames.join('、') : '—')),
|
|
13798
|
+
ps.warnings.length
|
|
13799
|
+
? h('div', { className: 'dshic-req-warns', 'data-req-warnings': String(ps.warnings.length) },
|
|
13800
|
+
ps.warnings.map((w, i2) => h('div', { key: i2, className: 'dshic-hint', style: { color: 'var(--dsw-alias-state-warning-primary, #d08700)' } }, '⚠ ' + w)))
|
|
13801
|
+
: null,
|
|
13802
|
+
h('div', { className: 'dshic-row', style: { gap: 6, alignItems: 'center' } },
|
|
13803
|
+
h('span', { className: 'dshic-shot-label' }, T('reqPreviewPrompt')),
|
|
13804
|
+
h('span', { style: { flex: 1 } }),
|
|
13805
|
+
h('button', {
|
|
13806
|
+
type: 'button', className: 'dshic-mini is-ghost',
|
|
13807
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
13808
|
+
onClick: (e) => {
|
|
13809
|
+
e.stopPropagation();
|
|
13810
|
+
try { navigator.clipboard.writeText(snap.p).then(() => toast(T('copiedOk'))).catch(() => {}); } catch { /* 剪贴板不可用时忽略 */ }
|
|
13811
|
+
},
|
|
13812
|
+
}, '⧉ ' + T('reqPreviewCopy'))),
|
|
13813
|
+
h('div', { className: 'dshic-req-prompt', 'data-req-prompt': '1' }, snap.p),
|
|
13814
|
+
) : null,
|
|
13815
|
+
);
|
|
13816
|
+
}
|
|
13817
|
+
|
|
13495
13818
|
/** 文本节点:只显示正文结果(内容在生成面板里编辑;@资产名@ 仍高亮) */
|
|
13496
13819
|
function TextNodeBody({ n }) {
|
|
13497
13820
|
const text = String(n.data.text || '');
|
|
@@ -13751,8 +14074,8 @@ function queueThumb(assetId) {
|
|
|
13751
14074
|
// 切段预览:把"这张分镜表会被切成几次生成、每次几镜几秒、哪些段要接尾帧"直接显示在节点上,
|
|
13752
14075
|
// 用户铺开前就知道会切成什么样——不用等到生成完才发现接不上。
|
|
13753
14076
|
const segPlan = shots.length ? planShotSegments(shots, { maxSeconds: Number(n.data.segMaxSeconds) || 15 }) : null;
|
|
13754
|
-
//
|
|
13755
|
-
//
|
|
14077
|
+
// 一致性告警的重校验:告警是**生成时刻**算的;设定集更新后有 bibleTick 自动重算(见下),
|
|
14078
|
+
// 这里保留手动入口兜底——点刷新按当前设定集重算(checkShotConsistency 读的是实时 bible/资产名索引)
|
|
13756
14079
|
const [wvChecking, setWvChecking] = useState(false);
|
|
13757
14080
|
const revalidate = async () => {
|
|
13758
14081
|
if (wvChecking || !shots.length) return;
|
|
@@ -13763,6 +14086,15 @@ function queueThumb(assetId) {
|
|
|
13763
14086
|
} catch { /* 校验失败保留旧告警 */ }
|
|
13764
14087
|
setWvChecking(false);
|
|
13765
14088
|
};
|
|
14089
|
+
// 设定集更新自动刷新:bibleTick 在设定集编辑器 persist 后自增——变化时按当前设定集重算告警,
|
|
14090
|
+
// 补全描述后节点上的旧告警自动消失,不再依赖用户点 revalidate(宿主侧重算只写 Host 文档,够不着本地状态)。
|
|
14091
|
+
// ref 记上次已响应的 tick:首渲染(打开面板/重挂载)不触发;wvChecking 防重入。
|
|
14092
|
+
const lastBibleTickRef = useRef(S.bibleTick);
|
|
14093
|
+
useEffect(() => {
|
|
14094
|
+
if (S.bibleTick === lastBibleTickRef.current) return;
|
|
14095
|
+
lastBibleTickRef.current = S.bibleTick;
|
|
14096
|
+
revalidate();
|
|
14097
|
+
}, [S.bibleTick]);
|
|
13766
14098
|
return [
|
|
13767
14099
|
h('div', { key: 'sum', className: 'dshic-shot-summary' },
|
|
13768
14100
|
h('b', {}, shots.length ? (shots.length + ' ' + T('shotsUnit')) : T('noShotsYet')),
|
|
@@ -19772,9 +20104,16 @@ const DIRECTOR_KEY_HELP = [
|
|
|
19772
20104
|
);
|
|
19773
20105
|
}
|
|
19774
20106
|
/** 图片模型桥接卡(0.20.0):检测 dsh-image-gen 并直接选用它的服务商/模型(密钥留在它宿主侧)。 */
|
|
19775
|
-
/**
|
|
20107
|
+
/** 自动创作卡(实验):开关 + 状态 + 快捷动作区。对话仍是主入口(canvas_auto_* 工具带完整上下文),
|
|
20108
|
+
* 此卡提供与对话同 RPC 的快捷操作,不切对话也能:启动创作(brief)→ 刷新预算(autoQuote)→
|
|
20109
|
+
* 批准付费(行内确认,quoteId+confirm)→ 开始生成(全量;部分选场是 T9 对话侧能力,卡片不放)→ 中止。
|
|
20110
|
+
* 批准令牌语义:quoteId 用卡片最近一次 autoQuote 返回值(不自动重刷——预算指纹绑定,卡片刷新的即当前指纹)。
|
|
20111
|
+
* 纪律:不新增轮询、不新增 RPC;单一 busy 防重入(动作互斥,避免并发计费操作);错误 catch 接住显示卡内。 */
|
|
19776
20112
|
function AutoModeCard() {
|
|
19777
20113
|
const [st, setSt] = useState(null);
|
|
20114
|
+
// 动作区状态(一个对象收口):brief 输入 / 最近预算单 quote(quoteId+摘要)/ 行内确认开合与文本 /
|
|
20115
|
+
// busy(在跑的动作名,防重入)/ msg 成功小字 / err 错误小字
|
|
20116
|
+
const [act, setAct] = useState(() => ({ brief: '', confirm: '', quote: null, confirmOpen: false, busy: null, msg: '', err: '' }));
|
|
19778
20117
|
const refresh = async () => {
|
|
19779
20118
|
try {
|
|
19780
20119
|
const r = await hostRpc('autoModeGet');
|
|
@@ -19794,6 +20133,54 @@ const DIRECTOR_KEY_HELP = [
|
|
|
19794
20133
|
setSt({ ...st, busy: false });
|
|
19795
20134
|
}
|
|
19796
20135
|
};
|
|
20136
|
+
const pid = S.activeId || '';
|
|
20137
|
+
const multiAgent = !!(st && st.caps && st.caps.multiAgent);
|
|
20138
|
+
const actionsOn = !!(st && !st.oldHost && st.enabled && multiAgent);
|
|
20139
|
+
// 动作通用壳:结果 {ok:false,error} 视为业务失败,与网络异常同样接住显示在卡内
|
|
20140
|
+
const runAction = async (key, fn, okMsgOf) => {
|
|
20141
|
+
if (!pid || act.busy) return;
|
|
20142
|
+
setAct((a) => ({ ...a, busy: key, err: '', msg: '' }));
|
|
20143
|
+
try {
|
|
20144
|
+
const r = await fn();
|
|
20145
|
+
if (r && r.ok === false) throw new Error(r.error || T('autoFail'));
|
|
20146
|
+
setAct((a) => ({ ...a, busy: null, msg: okMsgOf ? okMsgOf(r) : T('autoDone'), err: '' }));
|
|
20147
|
+
refresh();
|
|
20148
|
+
} catch (e) {
|
|
20149
|
+
setAct((a) => ({ ...a, busy: null, err: String((e && e.message) || e) || T('autoFail') }));
|
|
20150
|
+
}
|
|
20151
|
+
};
|
|
20152
|
+
// 预算小字:场/镜/秒/待调用次数 + 估算金额或单价引导(T9 锚点「视频每秒单价」)
|
|
20153
|
+
const quoteLine = (r) => T('autoQuoteSummary').replace('{s}', String(r.sceneCount || 0)).replace('{sh}', String(r.shotCount || 0))
|
|
20154
|
+
.replace('{sec}', String(r.totalSeconds || 0)).replace('{calls}', String(r.videoCalls || 0))
|
|
20155
|
+
+ ' · ' + (r.estimatedCost != null
|
|
20156
|
+
? T('autoQuoteCost').replace('{cost}', String(r.estimatedCost))
|
|
20157
|
+
: T('autoQuoteNoPrice'));
|
|
20158
|
+
const doQuote = () => runAction('quote', async () => {
|
|
20159
|
+
const r = await hostRpc('autoQuote', { projectId: pid });
|
|
20160
|
+
if (r && r.ok !== false && r.quoteId) {
|
|
20161
|
+
// 批准令牌只信这次刷新返回的 quoteId(指纹绑定);旧的行内确认随之作废收起
|
|
20162
|
+
setAct((a) => ({ ...a, quote: { quoteId: r.quoteId, summary: quoteLine(r) }, confirmOpen: false, confirm: '' }));
|
|
20163
|
+
}
|
|
20164
|
+
return r;
|
|
20165
|
+
});
|
|
20166
|
+
const doStart = () => {
|
|
20167
|
+
const brief = act.brief.trim();
|
|
20168
|
+
if (!brief) return;
|
|
20169
|
+
runAction('start', () => hostRpc('autoStart', { projectId: pid, brief }), (r) => (r && r.note) || T('autoDone'));
|
|
20170
|
+
};
|
|
20171
|
+
const doApprove = () => {
|
|
20172
|
+
if (!act.quote) return;
|
|
20173
|
+
const words = act.confirm.trim();
|
|
20174
|
+
if (!words) { setAct((a) => ({ ...a, err: T('autoApproveNeedConfirm') })); return; }
|
|
20175
|
+
runAction('approve', () => hostRpc('autoApprove', { projectId: pid, quoteId: act.quote.quoteId, confirm: words }),
|
|
20176
|
+
(r) => T('autoApproved').replace('{calls}', String((r && r.videoCalls) || '')));
|
|
20177
|
+
};
|
|
20178
|
+
const doGenerate = () => runAction('generate', () => hostRpc('autoGenerate', { projectId: pid }), (r) => (r && r.note) || T('autoDone'));
|
|
20179
|
+
const doAbort = () => runAction('abort', () => hostRpc('autoAbort', { projectId: pid }), () => T('autoAborted'));
|
|
20180
|
+
const miniBtn = (role, label, onClick, disabled, extra) => h('button', Object.assign({
|
|
20181
|
+
type: 'button', className: 'dshic-mini', 'data-role': role, disabled: !!disabled || !!act.busy,
|
|
20182
|
+
onPointerDown: (e) => e.stopPropagation(), onClick,
|
|
20183
|
+
}, extra || {}), label);
|
|
19797
20184
|
const lines = [];
|
|
19798
20185
|
if (!st) lines.push(T('storageLoading'));
|
|
19799
20186
|
else if (st.oldHost) lines.push(T('autoOldHost'));
|
|
@@ -19801,7 +20188,7 @@ const DIRECTOR_KEY_HELP = [
|
|
|
19801
20188
|
lines.push(st.enabled ? T('autoOn') : T('autoOff'));
|
|
19802
20189
|
lines.push(st.caps && st.caps.multiAgent ? T('autoCapsOk') : T('autoCapsNo'));
|
|
19803
20190
|
}
|
|
19804
|
-
return h('div', { className: 'dshic-card' },
|
|
20191
|
+
return h('div', { className: 'dshic-card', 'data-role': 'auto-mode-card' },
|
|
19805
20192
|
h('div', { className: 'dshic-row' },
|
|
19806
20193
|
Ic('spark', 12),
|
|
19807
20194
|
h('strong', { style: { fontSize: 12, flex: 1, minWidth: 0 } }, T('autoTitle')),
|
|
@@ -19813,6 +20200,37 @@ const DIRECTOR_KEY_HELP = [
|
|
|
19813
20200
|
: null,
|
|
19814
20201
|
),
|
|
19815
20202
|
h('div', { className: 'dshic-hint', style: { marginTop: 4 }, 'data-role': 'auto-mode-status' }, lines.join(' · ')),
|
|
20203
|
+
actionsOn ? h('div', { 'data-role': 'auto-actions', style: { marginTop: 6 } },
|
|
20204
|
+
// 启动创作:brief 输入(为空禁用)+ 按钮
|
|
20205
|
+
h('textarea', {
|
|
20206
|
+
className: 'dshic-input', 'data-role': 'auto-brief-input', rows: 1, value: act.brief,
|
|
20207
|
+
placeholder: T('autoBriefPh'), style: { width: '100%', fontSize: 11, resize: 'vertical', marginBottom: 4 },
|
|
20208
|
+
onPointerDown: (e) => e.stopPropagation(), onChange: (e) => setAct((a) => ({ ...a, brief: e.target.value })),
|
|
20209
|
+
}),
|
|
20210
|
+
h('div', { className: 'dshic-row', style: { gap: 6, flexWrap: 'wrap' } },
|
|
20211
|
+
miniBtn('auto-start-btn', T('autoStartBtn'), doStart, !act.brief.trim() || !pid),
|
|
20212
|
+
miniBtn('auto-quote-btn', T('autoQuoteBtn'), doQuote, !pid),
|
|
20213
|
+
miniBtn('auto-approve-btn', T('autoApproveBtn'),
|
|
20214
|
+
() => setAct((a) => ({ ...a, confirmOpen: !a.confirmOpen, err: '', msg: '' })),
|
|
20215
|
+
!act.quote || !pid, { title: act.quote ? '' : T('autoNeedQuote') }),
|
|
20216
|
+
miniBtn('auto-generate-btn', T('autoGenerateBtn'), doGenerate, !pid),
|
|
20217
|
+
miniBtn('auto-abort-btn', T('autoAbortBtn'), doAbort, !pid),
|
|
20218
|
+
),
|
|
20219
|
+
// 最近一次刷新的预算单(批准令牌来源)+ 行内确认输入(confirm 用户原话)
|
|
20220
|
+
act.quote ? h('div', { className: 'dshic-hint', 'data-role': 'auto-quote-line', style: { marginTop: 4 } }, act.quote.summary) : null,
|
|
20221
|
+
act.quote && act.confirmOpen ? h('div', { className: 'dshic-row', style: { gap: 6, marginTop: 4 } },
|
|
20222
|
+
h('input', {
|
|
20223
|
+
className: 'dshic-input', 'data-role': 'auto-confirm-input', value: act.confirm,
|
|
20224
|
+
placeholder: T('autoApprovePh'), style: { flex: 1, minWidth: 0, fontSize: 11 },
|
|
20225
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
20226
|
+
onChange: (e) => setAct((a) => ({ ...a, confirm: e.target.value })),
|
|
20227
|
+
onKeyDown: (e) => { if (e.key === 'Enter') { e.preventDefault(); doApprove(); } },
|
|
20228
|
+
}),
|
|
20229
|
+
miniBtn('auto-confirm-submit', T('autoApproveSubmit'), doApprove, !act.confirm.trim()),
|
|
20230
|
+
) : null,
|
|
20231
|
+
act.msg ? h('div', { className: 'dshic-hint', 'data-role': 'auto-act-msg', style: { marginTop: 4 } }, act.msg) : null,
|
|
20232
|
+
act.err ? h('div', { className: 'dshic-err', 'data-role': 'auto-act-err', style: { marginTop: 4 } }, act.err) : null,
|
|
20233
|
+
) : null,
|
|
19816
20234
|
);
|
|
19817
20235
|
}
|
|
19818
20236
|
|
|
@@ -20132,7 +20550,9 @@ const DIRECTOR_KEY_HELP = [
|
|
|
20132
20550
|
const [bible, setBible] = useState(() => loadBible(S.activeId));
|
|
20133
20551
|
const [busy, setBusy] = useState(false);
|
|
20134
20552
|
useEffect(() => { setBible(loadBible(S.activeId)); }, [S.activeId, S.assetsTick]);
|
|
20135
|
-
|
|
20553
|
+
// persist:本地保存 + 推送防抖 + bibleTick 自增(分镜详情监听它自动重算一致性告警——
|
|
20554
|
+
// 宿主侧重算只写 Host 文档,客户端本地节点的旧告警必须靠这条信号自己刷新)
|
|
20555
|
+
const persist = (next) => { setBible(next); saveBible(S.activeId, next); update((s) => { s.bibleTick++; }); };
|
|
20136
20556
|
/** 从项目里的创作意图/剧本一键起草设定集(设定集先行)。 */
|
|
20137
20557
|
const draft = async () => {
|
|
20138
20558
|
if (busy) return;
|
|
@@ -21757,6 +22177,8 @@ const DIRECTOR_KEY_HELP = [
|
|
|
21757
22177
|
if (typeof window !== 'undefined' && window.__DSH_IC_SMOKE__) {
|
|
21758
22178
|
window.__DSH_IC_TABS__ = {
|
|
21759
22179
|
ProjectsTab, AssetsTab, BibleTab, SettingsTab, DataRootCard, CanvasPage, ShortcutsPanel, CanvasHostedApp, SkillPalette,
|
|
22180
|
+
// 自动创作卡(0.20.2 T12):快捷动作区(启动/预算/批准/生成/中止)——供 test-panel-layout 直渲染与断言
|
|
22181
|
+
AutoModeCard,
|
|
21760
22182
|
// 面板结构重构(左侧图标列 / 顶部工具栏 / 右侧面板 / 统一弹窗)
|
|
21761
22183
|
Toolbar, Rightbar, IconRail, StudioModal, ProjectNameDialog,
|
|
21762
22184
|
// 技能页(四层图标瓦片):组件 + 图标表 + 配置读写 + 切片入口
|
|
@@ -21878,6 +22300,10 @@ const DIRECTOR_KEY_HELP = [
|
|
|
21878
22300
|
// 供 scripts/test-segment-plan.mjs 直接断言
|
|
21879
22301
|
window.__DSH_IC_SEGMENT__ = { planShotSegments, isCutPoint, segmentNeedsHardFrame, videoSegmentOf, shotContinuityPlan };
|
|
21880
22302
|
window.__DSH_IC_STORYBOARD_PROMPT__ = { buildStoryboardVideoPrompt };
|
|
22303
|
+
// 视频请求组装(0.20.2):run 与「请求预览」的单一事实源——
|
|
22304
|
+
// assembleVideoRequest(组装+校验门)/ previewVideoInputs(预览轻量 inputs)/ videoRequestContext(决策基座)
|
|
22305
|
+
// 供 scripts/test-submission-log.mjs 断言 p 逐字一致与 warnings 三条逐一触发
|
|
22306
|
+
window.__DSH_IC_VIDEO_REQUEST__ = { assembleVideoRequest, previewVideoInputs, videoRequestContext };
|
|
21881
22307
|
// 3D 导演台:引擎在 assets/director/engine.js(代码分割),这里只导出面板与
|
|
21882
22308
|
// 引擎加载器;引擎内部的纯函数由测试直接 ESM import engine.js 断言——
|
|
21883
22309
|
// 两端同一份代码,不存在"测试测的是拷贝"的问题。
|