dsh-game-material-master 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +35 -13
- package/README.md +34 -14
- package/lib/client.js +605 -27
- package/lib/config.js +24 -2
- package/lib/index.js +164 -3
- package/lib/links.js +4 -2
- package/lib/musicapi.js +7 -0
- package/lib/musicgen.js +106 -20
- package/lib/sfxapi.js +391 -0
- package/lib/sfxgen.js +819 -0
- package/lib/tools.js +189 -24
- package/lib/wire.js +67 -2
- package/package.json +7 -3
package/lib/tools.js
CHANGED
|
@@ -34,11 +34,12 @@ import { listRigJobs, readRigJob, rigSnapshot } from "./riggen.js";
|
|
|
34
34
|
import { listTileProjects, readTileProject, tileSnapshot } from "./tilegen.js";
|
|
35
35
|
import { listMapProjects, mapSnapshot, readMapProject } from "./mapgen.js";
|
|
36
36
|
import { listMusicJobs, musicSnapshot, readMusicJob } from "./musicgen.js";
|
|
37
|
+
import { listSfxJobs, readSfxJob, sfxNextActions, sfxSnapshot } from "./sfxgen.js";
|
|
37
38
|
import { TOOL_METHODS } from "./wire.js";
|
|
38
|
-
import { MUSIC_STAGES, MAP_STAGES, PANEL_KEY, STUDIO_MODULES, assetBasePath, buildOpenLink, originForLinks } from "./links.js";
|
|
39
|
+
import { MUSIC_STAGES, MAP_STAGES, SFX_STAGES, PANEL_KEY, STUDIO_MODULES, assetBasePath, buildOpenLink, originForLinks } from "./links.js";
|
|
39
40
|
import { loadConfig } from "./config.js";
|
|
40
41
|
/**
|
|
41
|
-
*
|
|
42
|
+
* 八个模块的 key 与界面里的模块 key 完全一致。
|
|
42
43
|
*
|
|
43
44
|
* 真源是 `links.ts` 的 `STUDIO_MODULES`(配置层的 `hiddenModules` 也按它收敛),
|
|
44
45
|
* 这里只是换个短名字。
|
|
@@ -52,7 +53,8 @@ export const MODULE_LABELS = {
|
|
|
52
53
|
rig: "骨骼动画生成",
|
|
53
54
|
tile: "45°地图地块生成",
|
|
54
55
|
map: "地图编辑器(导入 tileset)",
|
|
55
|
-
music: "音乐生成编辑"
|
|
56
|
+
music: "音乐生成编辑",
|
|
57
|
+
sfx: "音效生成"
|
|
56
58
|
};
|
|
57
59
|
/**
|
|
58
60
|
* 远程方法 → 它属于哪个模块。
|
|
@@ -223,7 +225,20 @@ export const METHOD_MODULE = {
|
|
|
223
225
|
renderMusicEdit: "music",
|
|
224
226
|
saveMusicVersion: "music",
|
|
225
227
|
deleteMusicVersion: "music",
|
|
226
|
-
exportMusic: "music"
|
|
228
|
+
exportMusic: "music",
|
|
229
|
+
// 模块八 音效生成
|
|
230
|
+
listSfxJobs: "sfx",
|
|
231
|
+
createSfxJob: "sfx",
|
|
232
|
+
getSfxJob: "sfx",
|
|
233
|
+
saveSfxJob: "sfx",
|
|
234
|
+
deleteSfxJob: "sfx",
|
|
235
|
+
uploadSfxRef: "sfx",
|
|
236
|
+
removeSfxRef: "sfx",
|
|
237
|
+
runSfxGeneration: "sfx",
|
|
238
|
+
cancelSfxGeneration: "sfx",
|
|
239
|
+
setSfxApproved: "sfx",
|
|
240
|
+
revealSfxJob: "sfx",
|
|
241
|
+
exportSfx: "sfx"
|
|
227
242
|
};
|
|
228
243
|
/**
|
|
229
244
|
* 不隶属于任何模块的方法:配置类 + 跨模块的审核模式
|
|
@@ -238,6 +253,7 @@ export const SHARED_TOOL_METHODS = new Set([
|
|
|
238
253
|
"testComfy",
|
|
239
254
|
"testMusic",
|
|
240
255
|
"testMusicScore",
|
|
256
|
+
"testSfx",
|
|
241
257
|
"setReviewMode"
|
|
242
258
|
]);
|
|
243
259
|
/**
|
|
@@ -289,7 +305,7 @@ const clampInt = (value, fallback, min, max) => {
|
|
|
289
305
|
function moduleOf(value) {
|
|
290
306
|
return typeof value === "string" && MODULES.includes(value) ? value : undefined;
|
|
291
307
|
}
|
|
292
|
-
/** 任务 id 前缀决定它属于哪个模块(p… / i… / s… / r… / t… / m… / a…)。 */
|
|
308
|
+
/** 任务 id 前缀决定它属于哪个模块(p… / i… / s… / r… / t… / m… / a… / f…)。 */
|
|
293
309
|
export function moduleForId(id) {
|
|
294
310
|
if (/^p[a-z0-9]+$/.test(id))
|
|
295
311
|
return "sprite";
|
|
@@ -305,6 +321,8 @@ export function moduleForId(id) {
|
|
|
305
321
|
return "map";
|
|
306
322
|
if (/^a[a-z0-9]+$/.test(id))
|
|
307
323
|
return "music";
|
|
324
|
+
if (/^f[a-z0-9]+$/.test(id))
|
|
325
|
+
return "sfx";
|
|
308
326
|
return undefined;
|
|
309
327
|
}
|
|
310
328
|
/** 产物相对路径 → 浏览器可直接打开的绝对 URL。 */
|
|
@@ -576,6 +594,12 @@ async function snapshotOf(module, id) {
|
|
|
576
594
|
throw new Error(`找不到音乐任务:${id}`);
|
|
577
595
|
return musicSnapshot(job, originForLinks());
|
|
578
596
|
}
|
|
597
|
+
if (module === "sfx") {
|
|
598
|
+
const job = await readSfxJob(id);
|
|
599
|
+
if (job === undefined)
|
|
600
|
+
throw new Error(`找不到音效任务:${id}`);
|
|
601
|
+
return sfxSnapshot(job, originForLinks());
|
|
602
|
+
}
|
|
579
603
|
const job = await readRigJob(id);
|
|
580
604
|
if (job === undefined)
|
|
581
605
|
throw new Error(`找不到骨骼动画任务:${id}`);
|
|
@@ -626,6 +650,14 @@ function musicStageOf(method) {
|
|
|
626
650
|
}
|
|
627
651
|
return undefined;
|
|
628
652
|
}
|
|
653
|
+
/** 音效方法对应的界面阶段:生成 / 导出。 */
|
|
654
|
+
function sfxStageOf(method) {
|
|
655
|
+
if (method === "exportSfx")
|
|
656
|
+
return "export";
|
|
657
|
+
if (method === "setSfxApproved" || method === "revealSfxJob" || method === "deleteSfxJob")
|
|
658
|
+
return undefined;
|
|
659
|
+
return "generate";
|
|
660
|
+
}
|
|
629
661
|
/**
|
|
630
662
|
* 从一次远程调用的入参(和已经拿到的返回值)里推断该打开哪个界面。
|
|
631
663
|
* 推断不出来(例如 listProjects)就不给链接,免得把用户带到一个空页面上。
|
|
@@ -693,7 +725,9 @@ function intentFromCall(method, payload, value) {
|
|
|
693
725
|
? method === "getMusicJob" && value?.workflow === "compose"
|
|
694
726
|
? "compose"
|
|
695
727
|
: musicStageOf(method)
|
|
696
|
-
:
|
|
728
|
+
: owner === "sfx"
|
|
729
|
+
? sfxStageOf(method)
|
|
730
|
+
: undefined;
|
|
697
731
|
const effectiveStage = stage ?? autoStage;
|
|
698
732
|
const scoreId = typeof value?.scoreId === "string" && value.scoreId !== "" ? value.scoreId : undefined;
|
|
699
733
|
return targetId === ""
|
|
@@ -725,6 +759,8 @@ function intentFromCall(method, payload, value) {
|
|
|
725
759
|
return { module: "map" };
|
|
726
760
|
if (method.startsWith("listMusicJob") || method.startsWith("createMusicJob"))
|
|
727
761
|
return { module: "music" };
|
|
762
|
+
if (method.startsWith("listSfxJob") || method.startsWith("createSfxJob"))
|
|
763
|
+
return { module: "sfx" };
|
|
728
764
|
if (method.startsWith("listImageJob") || method.startsWith("createImageJob"))
|
|
729
765
|
return { module: "image" };
|
|
730
766
|
if (method.startsWith("listSequenceJob") || method.startsWith("createSequenceJob"))
|
|
@@ -737,7 +773,7 @@ function intentFromCall(method, payload, value) {
|
|
|
737
773
|
/** `game_material_call` 的描述:把每个远程方法的用途与入参写清楚。 */
|
|
738
774
|
const CALL_DESCRIPTION = [
|
|
739
775
|
"调用「游戏素材大师」插件的任意远程方法——插件界面上的每个功能都能在这里调用。",
|
|
740
|
-
"配置:getConfig() / saveConfig(payload: 任意配置字段,如 arkApiKey、arkModel、imageProvider(ark|custom)、customProtocol(openai|comfyui|sdwebui)、customBaseUrl、customModel、customWorkflow、minimaxModel、cellWidth…) / testArk() / testCustomImage() / testMinimax() / testComfy()",
|
|
776
|
+
"配置:getConfig() / saveConfig(payload: 任意配置字段,如 arkApiKey、arkModel、imageProvider(ark|custom)、customProtocol(openai|comfyui|sdwebui)、customBaseUrl、customModel、customWorkflow、minimaxModel、sfxApiKey、sfxModel、sfxBaseUrl、cellWidth…) / testArk() / testCustomImage() / testMinimax() / testComfy() / testSfx()",
|
|
741
777
|
" ★ 生图后端有两种:`ark`(火山方舟 Seedream,默认)与 `custom`(用户自己的服务,协议可选 openai / comfyui / sdwebui)。",
|
|
742
778
|
" 换后端只改 imageProvider 一个字段,八方向图 / 图片生成 / 骨骼动画 / 地图地块全都跟着走;图生视频走 MiniMax,也可以改走本机 / 远端 ComfyUI(comfyVideo 开关)。",
|
|
743
779
|
" ⚠️ 用户可以在「设置 → 游戏素材大师 → 功能管理」里隐藏某些功能模块。被隐藏的模块**工具面一律拒绝**(界面也看不到),",
|
|
@@ -825,6 +861,11 @@ const CALL_DESCRIPTION = [
|
|
|
825
861
|
" saveMusicVersion({jobId,versionId,label?}) / deleteMusicVersion({jobId,versionId}) / exportMusic({jobId,songId?,versionId?,scoreId?,format?,name?,zip?})【导出到 out/,返回可下载 URL;给 scoreId 时导出乐谱包 MIDI+试听+方案+compose.py】",
|
|
826
862
|
" ★ 直接生成:先 getMusicGuide;用户给完整歌词时以歌词为权威文本;Suno 每次提交返回 2 首;已有歌曲后再生成必须 regenerate:true;生成后用 game_material_wait,再做后期或让用户点 openUrl 回界面。",
|
|
827
863
|
" ★ 谱曲模式:先 saveMusicScorePlan(方案用用户语言输出给用户看;manual 停下等确认)→ runMusicScore(本地免费)→ 贴 openUrl 让用户试听 → 有意见就 runMusicScore 出新版本(basedOn)→ 只有用户明确要求才 submitMusicScoreToSuno(计费;先上传试听音频再 cover,不上传 MIDI 原文件)。",
|
|
864
|
+
"音效生成(模块八;火山引擎 Seed-Audio,每次生成真实计费):listSfxJobs() / createSfxJob({name?,prompt,settings?:{format?,sampleRate?,speechRate?,loudnessRate?,pitchRate?,watermark?},reviewMode?}) / getSfxJob({jobId}) / saveSfxJob({jobId,name?,prompt?,settings?,reviewMode?}) / deleteSfxJob({jobId}) /",
|
|
865
|
+
" uploadSfxRef({jobId,kind:image|audio,name?,data})【参考图 1 张 / 参考音频 ≤3 条,两者互斥,单文件 ≤10MB】/ removeSfxRef({jobId,kind,file?}) /",
|
|
866
|
+
" runSfxGeneration({jobId})【★计费:同步接口,宿主包成后台任务;一次一条 take,失败不自动重试】/ cancelSfxGeneration({jobId})【只停本地请求,远端可能仍会完成并计费】/",
|
|
867
|
+
" setSfxApproved({jobId,stage?:generate|export,approved}) / revealSfxJob({jobId}) / exportSfx({jobId,takeId?,zip?})【导出到 out/;zip 打包全部 take】/",
|
|
868
|
+
" ★ 音效提示词当导演脚本写:声源 + 环境 + 强度/节奏 + 时长;单次输出上限 120 秒(没有 duration 参数)。参考音频在提示词里用 @音频1…@音频3;参考图与参考音频不能混用。失败重试会再计费,先问用户。",
|
|
828
869
|
"说明:key 是方向英文字面量(front/back/downLeft/downRight/upLeft/upRight/left/right);data 是原始文件字节的 base64(不带 data: 前缀);",
|
|
829
870
|
"生成类方法立刻返回 {started:true},接着用 game_material_wait 等它跑完,再用 game_material_review 拿验收包。",
|
|
830
871
|
"调用结果里若带 openUrl,请把它作为 Markdown 链接贴给用户,用户点击即切换到插件对应页面。"
|
|
@@ -932,14 +973,15 @@ export function registerStudioTools(host, gateway) {
|
|
|
932
973
|
if (id === "") {
|
|
933
974
|
// 只列可见模块的清单:隐藏的模块连「有哪些项目」都不给模型看一眼。
|
|
934
975
|
await assertModuleVisible(moduleOf(args?.module));
|
|
935
|
-
const [projects, images, sequences, rigs, tiles, maps, music] = await Promise.all([
|
|
976
|
+
const [projects, images, sequences, rigs, tiles, maps, music, sfx] = await Promise.all([
|
|
936
977
|
hidden.has("sprite") ? [] : listProjects(),
|
|
937
978
|
hidden.has("image") ? [] : listImageJobs(),
|
|
938
979
|
hidden.has("sequence") ? [] : listSequenceJobs(),
|
|
939
980
|
hidden.has("rig") ? [] : listRigJobs(),
|
|
940
981
|
hidden.has("tile") ? [] : listTileProjects(),
|
|
941
982
|
hidden.has("map") ? [] : listMapProjects(),
|
|
942
|
-
hidden.has("music") ? [] : listMusicJobs()
|
|
983
|
+
hidden.has("music") ? [] : listMusicJobs(),
|
|
984
|
+
hidden.has("sfx") ? [] : listSfxJobs()
|
|
943
985
|
]);
|
|
944
986
|
const links = {};
|
|
945
987
|
for (const key of MODULES)
|
|
@@ -955,8 +997,9 @@ export function registerStudioTools(host, gateway) {
|
|
|
955
997
|
tileProjects: tiles,
|
|
956
998
|
mapProjects: maps,
|
|
957
999
|
musicJobs: music,
|
|
1000
|
+
sfxJobs: sfx,
|
|
958
1001
|
links,
|
|
959
|
-
hint: "用 game_material_status({module,id}) 看某个目标的细节;八方向图的四步是 images → videos → frames → sheet,45°地图地块是 generate → review → map → export,地图编辑器是 assets(素材)→ rules(自动连接)→ paint(地图)→ export(导出),全本地不花钱;音乐是 generate(生成)→ edit(编辑)→ export(导出),生成按谱乐 AI
|
|
1002
|
+
hint: "用 game_material_status({module,id}) 看某个目标的细节;八方向图的四步是 images → videos → frames → sheet,45°地图地块是 generate → review → map → export,地图编辑器是 assets(素材)→ rules(自动连接)→ paint(地图)→ export(导出),全本地不花钱;音乐是 generate(生成)→ edit(编辑)→ export(导出),生成按谱乐 AI 积分计费;音效是 generate(生成,火山引擎 Seed-Audio)→ export(导出),每次生成真实计费。"
|
|
960
1003
|
};
|
|
961
1004
|
}
|
|
962
1005
|
// ⚠️ 这里**不能**再按 module 短路:`status({module:'tile', id})` 也走到这里,
|
|
@@ -1018,7 +1061,7 @@ export function registerStudioTools(host, gateway) {
|
|
|
1018
1061
|
"参数 `path` 是文件的绝对路径或相对当前工作目录的路径,宿主自己读盘,**不要把 base64 贴进来**。",
|
|
1019
1062
|
"kind 取值:sprite=source(源设定图)| video(**本地自选视频**,要用 `key` 指定槽位:turn=转圈视频,或 front/back/downLeft/downRight/upLeft/upRight/left/right 之一);",
|
|
1020
1063
|
"image=ref(参考图,最多 10 张)| item(直接加一张图,只做抠像用);",
|
|
1021
|
-
"sequence=firstFrame | lastFrame | referenceImage | referenceVideo;rig=source(角色整图)| part(单个部件 PNG,文件名即部件名);map=tileset
|
|
1064
|
+
"sequence=firstFrame | lastFrame | referenceImage | referenceVideo;rig=source(角色整图)| part(单个部件 PNG,文件名即部件名);map=tileset(图集原图);sfx=referenceImage(参考图)| referenceAudio(参考音频)。",
|
|
1022
1065
|
"限制:图片 ≤30MB,视频 ≤40MB(平台请求体上限 64MB;界面上那条本地上传路更宽),类型按文件头嗅探。"
|
|
1023
1066
|
].join("\n"),
|
|
1024
1067
|
parameters: {
|
|
@@ -1027,7 +1070,7 @@ export function registerStudioTools(host, gateway) {
|
|
|
1027
1070
|
properties: {
|
|
1028
1071
|
module: { type: "string", enum: [...MODULES], description: "目标所属模块。" },
|
|
1029
1072
|
id: { type: "string", description: "项目 id(p…)或任务 id(i… / s…)。" },
|
|
1030
|
-
kind: { type: "string", enum: ["source", "video", "ref", "item", "firstFrame", "lastFrame", "referenceImage", "referenceVideo", "part", "tileset"], description: "上传到哪个槽位。" },
|
|
1073
|
+
kind: { type: "string", enum: ["source", "video", "ref", "item", "firstFrame", "lastFrame", "referenceImage", "referenceVideo", "part", "tileset", "referenceAudio"], description: "上传到哪个槽位。" },
|
|
1031
1074
|
key: { type: "string", description: "仅 sprite + kind=video 用:槽位 `turn`(转圈视频)或某个方向 key。" },
|
|
1032
1075
|
path: { type: "string", description: "本机文件路径。" },
|
|
1033
1076
|
name: { type: "string", description: "可选:展示用的文件名。" }
|
|
@@ -1139,7 +1182,7 @@ export function registerStudioTools(host, gateway) {
|
|
|
1139
1182
|
id: { type: "string", description: "项目 id(p…)/ 图片任务 id(i…)/ 序列帧任务 id(s…)。" },
|
|
1140
1183
|
stage: {
|
|
1141
1184
|
type: "string",
|
|
1142
|
-
enum: ["images", "videos", "frames", "sheet", "generate", "review", "map", "export", "parts", "layout", "rig", "atlas", ...MAP_STAGES, ...MUSIC_STAGES],
|
|
1185
|
+
enum: ["images", "videos", "frames", "sheet", "generate", "review", "map", "export", "parts", "layout", "rig", "atlas", ...MAP_STAGES, ...MUSIC_STAGES, ...SFX_STAGES],
|
|
1143
1186
|
description: "八方向图 / 地图地块 / 地图编辑器 / 骨骼动画专用:只看某一个阶段。"
|
|
1144
1187
|
},
|
|
1145
1188
|
direction: { type: "string", description: "八方向图专用:只看某一个方位(front/back/…)。" },
|
|
@@ -1279,6 +1322,23 @@ export function registerStudioTools(host, gateway) {
|
|
|
1279
1322
|
packet.songsReady = snapshot.songsReady;
|
|
1280
1323
|
packet.nextActions = musicNextActions(snapshot, stage);
|
|
1281
1324
|
}
|
|
1325
|
+
else if (module === "sfx") {
|
|
1326
|
+
const sfxStages = snapshot.stages;
|
|
1327
|
+
const stageKeys = Object.keys(sfxStages ?? {});
|
|
1328
|
+
if (stage !== undefined && !stageKeys.includes(stage)) {
|
|
1329
|
+
throw new Error(`未知阶段:${stage}(可选:${stageKeys.join(" / ")})`);
|
|
1330
|
+
}
|
|
1331
|
+
packet.stages = stageKeys
|
|
1332
|
+
.filter((key) => stage === undefined || key === stage)
|
|
1333
|
+
.map((key) => ({ stage: key, ...sfxStages[key] }));
|
|
1334
|
+
packet.prompt = snapshot.prompt;
|
|
1335
|
+
packet.settings = snapshot.settings;
|
|
1336
|
+
packet.refs = snapshot.refs;
|
|
1337
|
+
packet.takes = snapshot.takes;
|
|
1338
|
+
packet.exports = snapshot.exports;
|
|
1339
|
+
packet.blocker = snapshot.blocker;
|
|
1340
|
+
packet.nextActions = sfxNextActions(snapshot);
|
|
1341
|
+
}
|
|
1282
1342
|
else {
|
|
1283
1343
|
// 骨骼动画(模块四)
|
|
1284
1344
|
const stages = snapshot.stages.filter((entry) => stage === undefined || entry.stage === stage);
|
|
@@ -1302,7 +1362,8 @@ export function registerStudioTools(host, gateway) {
|
|
|
1302
1362
|
"序列帧:module=sequence,id=任务 id,step=video|frames|sheet(省略即全部三步)。",
|
|
1303
1363
|
"骨骼动画:module=rig,id=任务 id,stage=parts|layout|rig|atlas(省略即四个阶段全打);stage=parts 时可再带 part 只对某个部件生效。",
|
|
1304
1364
|
"地图编辑器:module=map,id=项目 id,stage=assets|rules|paint|export(省略即四个阶段全打)。这条链路全本地,打勾只是记录「这步看过了」。",
|
|
1305
|
-
"音乐:module=music,id=任务 id,stage=compose|generate|edit|export;也可以带 songId / versionId / scoreId 只对某一首/某一版/某一版谱曲打勾。"
|
|
1365
|
+
"音乐:module=music,id=任务 id,stage=compose|generate|edit|export;也可以带 songId / versionId / scoreId 只对某一首/某一版/某一版谱曲打勾。",
|
|
1366
|
+
"音效:module=sfx,id=任务 id,stage=generate|export(省略即两个阶段全打)。"
|
|
1306
1367
|
].join("\n"),
|
|
1307
1368
|
parameters: {
|
|
1308
1369
|
type: "object",
|
|
@@ -1310,7 +1371,7 @@ export function registerStudioTools(host, gateway) {
|
|
|
1310
1371
|
properties: {
|
|
1311
1372
|
module: { type: "string", enum: [...MODULES], description: "目标所属模块;可省略,按 id 前缀判断。" },
|
|
1312
1373
|
id: { type: "string", description: "项目 / 任务 id。" },
|
|
1313
|
-
stage: { type: "string", enum: ["images", "videos", "frames", "sheet", ...MAP_STAGES, ...MUSIC_STAGES], description: "八方向图 / 地图编辑器 /
|
|
1374
|
+
stage: { type: "string", enum: ["images", "videos", "frames", "sheet", ...MAP_STAGES, ...MUSIC_STAGES, ...SFX_STAGES], description: "八方向图 / 地图编辑器 / 音乐 / 音效:阶段。" },
|
|
1314
1375
|
songId: { type: "string", description: "音乐:只对某一首歌生效。" },
|
|
1315
1376
|
versionId: { type: "string", description: "音乐:只对某个版本生效。" },
|
|
1316
1377
|
scoreId: { type: "string", description: "音乐:只对某一版谱曲(MIDI)生效。" },
|
|
@@ -1394,6 +1455,14 @@ export function registerStudioTools(host, gateway) {
|
|
|
1394
1455
|
: { jobId: id, approved, ...(stage === undefined ? {} : { stage }), ...(songId === undefined ? {} : { songId }), ...(versionId === undefined ? {} : { versionId }), ...(scoreId === undefined ? {} : { scoreId }) });
|
|
1395
1456
|
return { module, id, stage: stage ?? null, songId: songId ?? null, versionId: versionId ?? null, scoreId: scoreId ?? null, approved, ...openInfo({ module: "music", jobId: id, stage, ...(scoreId === undefined ? {} : { scoreId }) }, "点开看验收结果") };
|
|
1396
1457
|
}
|
|
1458
|
+
if (module === "sfx") {
|
|
1459
|
+
const stage = asString(args?.stage) || undefined;
|
|
1460
|
+
if (stage !== undefined && !SFX_STAGES.includes(stage)) {
|
|
1461
|
+
throw new Error(`未知阶段:${stage}(可选:${SFX_STAGES.join(" / ")})`);
|
|
1462
|
+
}
|
|
1463
|
+
await gateway.setSfxApproved({ jobId: id, approved, ...(stage === undefined ? {} : { stage }) });
|
|
1464
|
+
return { module, id, stage: stage ?? null, approved, ...openInfo({ module: "sfx", jobId: id, stage }, "点开看验收结果") };
|
|
1465
|
+
}
|
|
1397
1466
|
const rigJob = await readRigJob(id);
|
|
1398
1467
|
if (rigJob === undefined)
|
|
1399
1468
|
throw new Error(`找不到骨骼动画任务:${id}`);
|
|
@@ -1418,7 +1487,7 @@ export function registerStudioTools(host, gateway) {
|
|
|
1418
1487
|
}
|
|
1419
1488
|
const PROMPT_SECTION = [
|
|
1420
1489
|
"## 游戏素材大师(game-material-master)",
|
|
1421
|
-
"本机已挂载「游戏素材大师」插件:八方向图生成 / 图片生成 / 序列帧生成 / 骨骼动画生成 / 45°地图地块 / 地图编辑器 /
|
|
1490
|
+
"本机已挂载「游戏素材大师」插件:八方向图生成 / 图片生成 / 序列帧生成 / 骨骼动画生成 / 45°地图地块 / 地图编辑器 / 音乐生成编辑 / 音效生成八个模块,界面在侧栏「游戏素材大师」面板。",
|
|
1422
1491
|
"工具:`game_material_intake`(固定流程第 0 步)、`game_material_call`(万能通道,插件全部方法)、`game_material_upload`(按路径上传素材)、",
|
|
1423
1492
|
"`game_material_reviewMode`、`game_material_status`、`game_material_wait`、`game_material_review`、`game_material_approve`。",
|
|
1424
1493
|
"一律走这些工具,不要用 bash/shell 直接改 `<DSH_HOME>/game-material-master/` 下的 JSON——那会绕过宿主的复用与校验。",
|
|
@@ -1526,7 +1595,15 @@ const PROMPT_SECTION = [
|
|
|
1526
1595
|
"流程:`getMusicScoreGuide` 读 scoremill 指南 → 分析用户想法 → **用用户的语言把方案(曲风/调性/BPM/段落表/配器/主题/力度弧)输出给用户看** → `saveMusicScorePlan` → manual 模式停下等确认 → 写 `compose.py`(scoremill)→ `runMusicScore({jobId,title,plan,script})`(本地免费,宿主跑 Python + 渲染试听)→ 把 `openUrl` 贴给用户试听 → 有修改意见就再 `runMusicScore`(`basedOn` 指上一版,每版都保留)。",
|
|
1527
1596
|
"只有用户**明确要求**「用 Suno 生成正式版 / 交给 Suno」时才调 `submitMusicScoreToSuno({jobId,scoreId,confirm:true})`:★真实计费;插件会先把这一版的**试听音频**上传给 Suno 作为参考(标准上传免费),再走 **cover** 生成。Suno 不接受 MIDI 原文件,但接受音频,所以「MIDI → 渲染音频 → 上传 cover」才是正确链路;结果不会逐音一致。若 Suno 判定版权,会返回 needsCopyrightConsent,用户确认后传 `copyrightAudio:true` 走付费版权通道。已有歌曲时必须 `regenerate:true`,并先问用户。",
|
|
1528
1597
|
"谱曲脚本只做记谱:必须 `s.save('score.mid')`;不要自己渲染音频、不要联网。报错按 scoremill 的小节号只改那一处,最多重试 3 次。",
|
|
1529
|
-
"谱曲依赖本机 Python 3 + scoremill;缺了会在 `getConfig().musicScoreStatus` / `testMusicScore` 里说明。谱曲不需要谱乐 AI Key,交 Suno 才需要。"
|
|
1598
|
+
"谱曲依赖本机 Python 3 + scoremill;缺了会在 `getConfig().musicScoreStatus` / `testMusicScore` 里说明。谱曲不需要谱乐 AI Key,交 Suno 才需要。",
|
|
1599
|
+
"",
|
|
1600
|
+
"### 音效生成(模块八,火山引擎 Seed-Audio)",
|
|
1601
|
+
"用户要音效 / 环境音 / UI 声 / 生物吼叫 / 角色配音时:先 `game_material_intake({module:'sfx'})` 问清「要什么声音 / 要不要参考」与审核模式。",
|
|
1602
|
+
"流程:`createSfxJob({name,prompt,settings:{format,sampleRate,speechRate?,loudnessRate?,pitchRate?,watermark?},reviewMode})` →(可选)`game_material_upload({module:'sfx', id, kind:'referenceImage'|'referenceAudio', path})` → `runSfxGeneration({jobId})`(★每次真实计费)→ `game_material_wait({module:'sfx', id})` → `game_material_review` → 把 `openUrl` 原样贴成 Markdown 链接。",
|
|
1603
|
+
"提示词要写成**导演脚本**:声源 + 环境 + 强度/节奏 + 时长(例如「暴雨中的金属撞击,短促有力,约 1 秒,带一点尾音」)。单次输出上限 120 秒;没有 duration 参数。",
|
|
1604
|
+
"参考:参考图最多 1 张;参考音频最多 3 条(每条 ≤30 秒 / ≤10MB),提示词里用 `@音频1…@音频3` 引用;**参考图与参考音频不能同时用**。",
|
|
1605
|
+
"一次生成 = 一条 take,永不覆盖;再生成一条会再计费。失败不自动重试,重试前先问用户。manual 模式生成后先贴链接并停下等用户说「通过」;auto 模式自己核对后继续。",
|
|
1606
|
+
"`seed-audio-1.0` 需要在火山引擎语音控制台开通;Key 是语音控制台的 API Key(`X-Api-Key`),不是火山方舟的 `ARK_API_KEY`。"
|
|
1530
1607
|
].join("\n");
|
|
1531
1608
|
function sleep(ms, signal) {
|
|
1532
1609
|
return new Promise((resolve, reject) => {
|
|
@@ -1694,6 +1771,28 @@ function intakeFor(module, id, told, config, target) {
|
|
|
1694
1771
|
ask("musicEngine", "(仅直接生成 / 交 Suno)引擎有偏好吗?(Suno / Mureka / MiniMax / ACE-Step;默认 Suno chirp-v6,纯音乐或需要固定 BPM 时 ACE-Step 更稳)", "不同引擎的模式、参数与计费方式不同;谱曲模式的本地部分不需要选引擎。", "直接生成:runMusicGeneration({jobId, engine, mode, params});交 Suno:submitMusicScoreToSuno({jobId, scoreId, confirm:true, model?})。");
|
|
1695
1772
|
ask("musicReview", "(仅直接生成)生成后要不要做后期处理?(裁剪掉头尾 / 调音量 / 淡入淡出 / 标准化到 -14 LUFS;默认不处理,保留原曲)", "后期是本地免费的,但会多出一些版本;谱曲模式的试听已经是本地渲染。", "renderMusicEdit({jobId, songId, ops:{start,end,gainDb,fadeIn,fadeOut,normalize}}) → game_material_wait。");
|
|
1696
1773
|
}
|
|
1774
|
+
if (module === "sfx") {
|
|
1775
|
+
if (config?.sfxBlocker !== null && config?.sfxBlocker !== undefined) {
|
|
1776
|
+
blockers.push(config.sfxBlocker);
|
|
1777
|
+
}
|
|
1778
|
+
known.平台 = "火山引擎豆包语音 · 生成式音频(seed-audio-1.0)";
|
|
1779
|
+
known.BaseURL = config?.sfxBaseUrl ?? "https://openspeech.bytedance.com";
|
|
1780
|
+
known.默认模型 = config?.sfxModel ?? "seed-audio-1.0";
|
|
1781
|
+
known.单次上限 = "120 秒;没有 duration 参数,时长要写进提示词";
|
|
1782
|
+
known.计费 = "每次生成一条 take 都真实计费(按 original_duration);失败重试会再计费,先问用户。";
|
|
1783
|
+
known.参考规则 = "参考图最多 1 张;参考音频最多 3 条(每条 ≤30 秒 / ≤10MB);两者不能同时使用;提示词里用 @音频1…@音频3 引用。";
|
|
1784
|
+
known.两个阶段 = "generate(生成)→ export(导出);v1 不做本地剪辑。";
|
|
1785
|
+
if (target?.prompt)
|
|
1786
|
+
known.提示词原文 = String(target.prompt).slice(0, 200);
|
|
1787
|
+
if (target?.settings)
|
|
1788
|
+
known.输出参数 = `${target.settings.format ?? "?"} / ${target.settings.sampleRate ?? "?"}Hz`;
|
|
1789
|
+
if (target?.reviewMode)
|
|
1790
|
+
known.审核模式 = target.reviewMode;
|
|
1791
|
+
if (!hasPrompt) {
|
|
1792
|
+
ask("sfxPrompt", "要什么声音?写清声源、环境、强度/节奏与大致时长,例如「暴雨中的金属撞击,短促有力,约 1 秒,带一点尾音」。", "生成式音频把提示词当导演脚本;写得越具体越稳。单次上限 120 秒。", "用 game_material_call({method:'createSfxJob', payload:{name, prompt, settings:{format,sampleRate}, reviewMode}}) 建任务,再 runSfxGeneration({jobId})(★计费)。");
|
|
1793
|
+
}
|
|
1794
|
+
ask("sfxRefs", "要不要参考图或参考音频?(可选;参考图与参考音频不能同时用。参考音频最多 3 条、每条 ≤30 秒。)", "参考图适合「按形象生成声线」,参考音频适合「按这个音色/风格生成」;不用参考也可以。", "用 game_material_upload({module:'sfx', id, kind:'referenceImage'|'referenceAudio', path}),或 uploadSfxRef({jobId, kind, name, data})。");
|
|
1795
|
+
}
|
|
1697
1796
|
if (id === "") {
|
|
1698
1797
|
questions.push({
|
|
1699
1798
|
key: "target",
|
|
@@ -1709,9 +1808,11 @@ function intakeFor(module, id, told, config, target) {
|
|
|
1709
1808
|
? "新建一个地图项目,还是在已有项目上继续?"
|
|
1710
1809
|
: module === "music"
|
|
1711
1810
|
? "新建一个音乐任务,还是在已有任务上继续?"
|
|
1712
|
-
: "
|
|
1811
|
+
: module === "sfx"
|
|
1812
|
+
? "新建一个音效任务,还是在已有任务上继续?"
|
|
1813
|
+
: "新建一个骨骼动画任务,还是在已有任务上继续?",
|
|
1713
1814
|
why: "后面的参数都挂在项目 / 任务上。",
|
|
1714
|
-
how: "新建:game_material_call({method:'createProject'|'createImageJob'|'createSequenceJob'|'createRigJob'|'createTileProject'|'createMapProject'|'createMusicJob', payload:{name}}),返回的 id 就是后续 payload 里的 projectId / jobId。"
|
|
1815
|
+
how: "新建:game_material_call({method:'createProject'|'createImageJob'|'createSequenceJob'|'createRigJob'|'createTileProject'|'createMapProject'|'createMusicJob'|'createSfxJob', payload:{name}}),返回的 id 就是后续 payload 里的 projectId / jobId。"
|
|
1715
1816
|
});
|
|
1716
1817
|
}
|
|
1717
1818
|
if (module === "sprite") {
|
|
@@ -1785,6 +1886,8 @@ function intakeFor(module, id, told, config, target) {
|
|
|
1785
1886
|
// ── 上传:宿主自己读盘,模型只给路径 ────────────────────────────────────
|
|
1786
1887
|
const IMAGE_MAX_BYTES = 30 * 1024 * 1024;
|
|
1787
1888
|
const VIDEO_MAX_BYTES = 40 * 1024 * 1024;
|
|
1889
|
+
/** 音效参考(图 / 音频)平台上限是 10MB。 */
|
|
1890
|
+
const SFX_REF_MAX_BYTES = 10 * 1024 * 1024;
|
|
1788
1891
|
/** 各模块允许的 kind,避免把「源图」传到「参考视频」这类错位。 */
|
|
1789
1892
|
const UPLOAD_KINDS = {
|
|
1790
1893
|
sprite: ["source", "video"],
|
|
@@ -1799,7 +1902,9 @@ const UPLOAD_KINDS = {
|
|
|
1799
1902
|
map: ["tileset"],
|
|
1800
1903
|
// 音乐模块 v1 不导入本地音频:只编辑本任务生成/下载的歌曲。留空数组让
|
|
1801
1904
|
// 上传这条路给出明确报错,而不是掉进 sequence 分支做别的事。
|
|
1802
|
-
music: []
|
|
1905
|
+
music: [],
|
|
1906
|
+
// 音效模块:参考图 / 参考音频(两者互斥,上限 10MB)。
|
|
1907
|
+
sfx: ["referenceImage", "referenceAudio"]
|
|
1803
1908
|
};
|
|
1804
1909
|
/** sprite 的本地视频槽位:`turn`(转圈)或八个方向之一。 */
|
|
1805
1910
|
const SPRITE_VIDEO_SLOTS = ["turn", "front", "back", "downLeft", "downRight", "upLeft", "upRight", "left", "right"];
|
|
@@ -1823,14 +1928,16 @@ async function uploadFromPath(gateway, module, id, kind, path, name, key) {
|
|
|
1823
1928
|
// 上限与嗅探都跟着它走:落到图片那条路上会被图片嗅探当场拒掉,而且 30MB 的上限
|
|
1824
1929
|
// 会让一段正常的手机视频莫名其妙传不进来。
|
|
1825
1930
|
const isVideo = kind === "referenceVideo" || kind === "video";
|
|
1826
|
-
|
|
1931
|
+
// 音效的参考音频不是图片:不能走 sniffImage,上限也是平台规定的 10MB。
|
|
1932
|
+
const isAudio = kind === "referenceAudio";
|
|
1933
|
+
const limit = isVideo ? VIDEO_MAX_BYTES : isAudio ? SFX_REF_MAX_BYTES : IMAGE_MAX_BYTES;
|
|
1827
1934
|
if (info.size > limit) {
|
|
1828
1935
|
throw new Error(`文件 ${(info.size / 1024 / 1024).toFixed(1)}MB 超过上限 ${(limit / 1024 / 1024).toFixed(0)}MB:${absolute}`);
|
|
1829
1936
|
}
|
|
1830
1937
|
const bytes = await readFile(absolute);
|
|
1831
1938
|
const base64 = bytes.toString("base64");
|
|
1832
1939
|
const fileName = name ?? basename(absolute);
|
|
1833
|
-
if (!isVideo && sniffImage(base64) === undefined) {
|
|
1940
|
+
if (!isVideo && !isAudio && sniffImage(base64) === undefined) {
|
|
1834
1941
|
throw new Error(`无法识别的图片格式(支持 PNG / JPEG / WebP / GIF / BMP):${absolute}`);
|
|
1835
1942
|
}
|
|
1836
1943
|
const call = gateway;
|
|
@@ -1882,6 +1989,14 @@ async function uploadFromPath(gateway, module, id, kind, path, name, key) {
|
|
|
1882
1989
|
else if (module === "music") {
|
|
1883
1990
|
throw new Error("音乐模块 v1 不导入本地音频:只用 runMusicGeneration 生成的歌曲;要编辑本地文件请等后续版本。");
|
|
1884
1991
|
}
|
|
1992
|
+
else if (module === "sfx") {
|
|
1993
|
+
await call.uploadSfxRef({
|
|
1994
|
+
jobId: id,
|
|
1995
|
+
kind: kind === "referenceAudio" ? "audio" : "image",
|
|
1996
|
+
name: fileName,
|
|
1997
|
+
data: base64
|
|
1998
|
+
});
|
|
1999
|
+
}
|
|
1885
2000
|
else {
|
|
1886
2001
|
await call.uploadSequenceRef({ jobId: id, kind, name: fileName, data: base64 });
|
|
1887
2002
|
}
|
|
@@ -2121,6 +2236,50 @@ function renderMusicSummary(value) {
|
|
|
2121
2236
|
}
|
|
2122
2237
|
return lines;
|
|
2123
2238
|
}
|
|
2239
|
+
/** 音效任务的摘要:阶段 / 提示词 / 参考 / takes / 导出。 */
|
|
2240
|
+
function renderSfxSummary(value) {
|
|
2241
|
+
const lines = [];
|
|
2242
|
+
const stageLabels = { generate: "生成", export: "导出" };
|
|
2243
|
+
if (Array.isArray(value.stages)) {
|
|
2244
|
+
lines.push(` 阶段:${value.stages
|
|
2245
|
+
.map((stage) => `${stageLabels[stage.stage] ?? stage.stage}:${stage.status ?? "idle"}${stage.approved ? " · 已通过" : ""}${stage.error ? ` · ${stage.error}` : ""}`)
|
|
2246
|
+
.join(" ")}`);
|
|
2247
|
+
}
|
|
2248
|
+
else if (value.stages !== null && value.stages !== undefined) {
|
|
2249
|
+
lines.push(` 阶段:${Object.entries(value.stages)
|
|
2250
|
+
.map(([key, stage]) => `${stageLabels[key] ?? key}:${stage?.status ?? "idle"}${stage?.approved ? " · 已通过" : ""}${stage?.error ? ` · ${stage.error}` : ""}`)
|
|
2251
|
+
.join(" ")}`);
|
|
2252
|
+
}
|
|
2253
|
+
if (typeof value.prompt === "string" && value.prompt !== "")
|
|
2254
|
+
lines.push(` 提示词:${value.prompt.slice(0, 300)}`);
|
|
2255
|
+
if (value.settings !== undefined && value.settings !== null) {
|
|
2256
|
+
lines.push(` 输出:${value.settings.format ?? "?"} / ${value.settings.sampleRate ?? "?"}Hz`);
|
|
2257
|
+
}
|
|
2258
|
+
const refs = value.refs ?? {};
|
|
2259
|
+
if (refs.image !== undefined && refs.image !== null) {
|
|
2260
|
+
lines.push(` 参考图:${refs.image.name ?? refs.image.file}${typeof refs.image.url === "string" ? ` · ${refs.image.url}` : ""}`);
|
|
2261
|
+
}
|
|
2262
|
+
if (Array.isArray(refs.audios) && refs.audios.length > 0) {
|
|
2263
|
+
lines.push(` 参考音频(${refs.audios.length} 条):${refs.audios.map((entry) => entry.name ?? entry.file).join(" / ")}`);
|
|
2264
|
+
}
|
|
2265
|
+
if (typeof value.error === "string" && value.error !== "")
|
|
2266
|
+
lines.push(` ⚠ 上次失败:${value.error}`);
|
|
2267
|
+
if (typeof value.blocker === "string" && value.blocker !== "")
|
|
2268
|
+
lines.push(` ⚠ ${value.blocker}`);
|
|
2269
|
+
for (const take of value.takes ?? []) {
|
|
2270
|
+
lines.push(` take ${take.id}:${take.format}${take.duration ? ` · ${Number(take.duration).toFixed(2)}s` : ""}${take.originalDuration ? `(计费 ${Number(take.originalDuration).toFixed(2)}s)` : ""} · ${take.bytes} 字节`);
|
|
2271
|
+
if (typeof take.prompt === "string" && take.prompt !== "")
|
|
2272
|
+
lines.push(` 提示词:${take.prompt.slice(0, 200)}`);
|
|
2273
|
+
if (typeof take.url === "string")
|
|
2274
|
+
lines.push(` ${take.url}`);
|
|
2275
|
+
}
|
|
2276
|
+
for (const entry of value.exports ?? []) {
|
|
2277
|
+
lines.push(` 导出:${entry.file}`);
|
|
2278
|
+
if (typeof entry.downloadUrl === "string")
|
|
2279
|
+
lines.push(` ${entry.downloadUrl}`);
|
|
2280
|
+
}
|
|
2281
|
+
return lines;
|
|
2282
|
+
}
|
|
2124
2283
|
function renderStatus(value) {
|
|
2125
2284
|
if (Array.isArray(value.projects)) {
|
|
2126
2285
|
const lines = [
|
|
@@ -2132,6 +2291,8 @@ function renderStatus(value) {
|
|
|
2132
2291
|
...value.sequenceJobs.map((j) => ` - ${j.id} ${j.name} — 视频${j.videoReady ? "✓" : "✗"} 帧${j.frameReady ? "✓" : "✗"} 条图${j.sheetReady ? "✓" : "✗"}`),
|
|
2133
2292
|
`音乐任务(${(value.musicJobs ?? []).length}):`,
|
|
2134
2293
|
...(value.musicJobs ?? []).map((j) => ` - ${j.id} ${j.name} — ${j.workflow === "compose" ? `谱曲 ${j.compositions ?? 0} 版 · ` : ""}${j.songsReady}/${j.songsTotal} 首 · ${j.versions} 个版本${j.busy ? " · ⏳" : ""}`),
|
|
2294
|
+
`音效任务(${(value.sfxJobs ?? []).length}):`,
|
|
2295
|
+
...(value.sfxJobs ?? []).map((j) => ` - ${j.id} ${j.name} — ${j.takes ?? 0} 条${j.latestDuration === null || j.latestDuration === undefined ? "" : ` · 最新 ${Number(j.latestDuration).toFixed(2)}s`}${j.busy ? " · ⏳" : ""}`),
|
|
2135
2296
|
...(Array.isArray(value.hiddenModules) && value.hiddenModules.length > 0
|
|
2136
2297
|
? [`已隐藏的功能(工具面同样不可调用):${value.hiddenModules.map((key) => MODULE_LABELS[key] ?? key).join("、")}`]
|
|
2137
2298
|
: []),
|
|
@@ -2146,7 +2307,9 @@ function renderStatus(value) {
|
|
|
2146
2307
|
}
|
|
2147
2308
|
if (value.module === "music")
|
|
2148
2309
|
lines.push(...renderMusicSummary(value));
|
|
2149
|
-
if (value.module
|
|
2310
|
+
if (value.module === "sfx")
|
|
2311
|
+
lines.push(...renderSfxSummary(value));
|
|
2312
|
+
if (value.module !== "music" && value.module !== "sfx" && Array.isArray(value.stages)) {
|
|
2150
2313
|
for (const stage of value.stages) {
|
|
2151
2314
|
lines.push(` ${renderStageLine(stage)}`);
|
|
2152
2315
|
// 骨骼动画:阶段名之后直接把产物 URL 贴上,否则用户点不到东西。
|
|
@@ -2226,7 +2389,9 @@ function renderReview(value) {
|
|
|
2226
2389
|
lines.push(...renderMapSummary(value));
|
|
2227
2390
|
if (value.module === "music")
|
|
2228
2391
|
lines.push(...renderMusicSummary(value));
|
|
2229
|
-
if (value.module
|
|
2392
|
+
if (value.module === "sfx")
|
|
2393
|
+
lines.push(...renderSfxSummary(value));
|
|
2394
|
+
if (value.module !== "music" && value.module !== "sfx" && Array.isArray(value.stages)) {
|
|
2230
2395
|
for (const stage of value.stages) {
|
|
2231
2396
|
lines.push(`${stage.title}${stage.stale ? " · 需重做" : ""}`);
|
|
2232
2397
|
// 骨骼动画的阶段**没有 cells**(产物是每阶段固定的几个 URL),
|
package/lib/wire.js
CHANGED
|
@@ -85,7 +85,7 @@ const setReviewModeSchema = z.object({
|
|
|
85
85
|
* ⚠️ 这个枚举漏一个模块,那条模块的「固定流程必须问清审核模式」就落不了地
|
|
86
86
|
* (骨骼动画与地图地块都踩过:走到宿主才抛「未知模块」)。模块六(map)同理。
|
|
87
87
|
*/
|
|
88
|
-
module: z.enum(["sprite", "image", "sequence", "rig", "tile", "map", "music"]),
|
|
88
|
+
module: z.enum(["sprite", "image", "sequence", "rig", "tile", "map", "music", "sfx"]),
|
|
89
89
|
reviewMode: z.enum(["auto", "manual"])
|
|
90
90
|
});
|
|
91
91
|
const runImageSchema = z.object({ projectId: z.string(), key: z.string(), prompt: z.string().optional() });
|
|
@@ -965,6 +965,56 @@ const exportMusicSchema = z.object({
|
|
|
965
965
|
name: z.string().optional(),
|
|
966
966
|
zip: z.boolean().optional()
|
|
967
967
|
});
|
|
968
|
+
// ── 音效生成(模块八,火山引擎 Seed-Audio)─────────────────────────────
|
|
969
|
+
//
|
|
970
|
+
// ⚠️ 这一组字段必须逐个写进 schema:typert 会静默丢掉 schema 外的键,
|
|
971
|
+
// 界面表现就是「改了没反应 / 保存成功但没生效」,而且不报任何错。
|
|
972
|
+
const sfxSettingsSchema = z.object({
|
|
973
|
+
format: z.enum(["mp3", "wav", "ogg_opus"]).optional(),
|
|
974
|
+
sampleRate: z.number().optional(),
|
|
975
|
+
speechRate: z.number().optional(),
|
|
976
|
+
loudnessRate: z.number().optional(),
|
|
977
|
+
pitchRate: z.number().optional(),
|
|
978
|
+
watermark: z.boolean().optional()
|
|
979
|
+
});
|
|
980
|
+
const sfxJobIdSchema = z.object({ jobId: z.string() });
|
|
981
|
+
const createSfxJobSchema = z.object({
|
|
982
|
+
name: z.string().optional(),
|
|
983
|
+
prompt: z.string(),
|
|
984
|
+
settings: sfxSettingsSchema.optional(),
|
|
985
|
+
reviewMode: z.enum(["auto", "manual"]).optional()
|
|
986
|
+
});
|
|
987
|
+
const saveSfxJobSchema = z.object({
|
|
988
|
+
jobId: z.string(),
|
|
989
|
+
name: z.string().optional(),
|
|
990
|
+
prompt: z.string().optional(),
|
|
991
|
+
settings: sfxSettingsSchema.optional(),
|
|
992
|
+
reviewMode: z.enum(["auto", "manual"]).optional()
|
|
993
|
+
});
|
|
994
|
+
const uploadSfxRefSchema = z.object({
|
|
995
|
+
jobId: z.string(),
|
|
996
|
+
kind: z.enum(["image", "audio"]),
|
|
997
|
+
name: z.string().optional(),
|
|
998
|
+
/** 原始文件字节的 base64(不带 data: 前缀)。 */
|
|
999
|
+
data: z.string()
|
|
1000
|
+
});
|
|
1001
|
+
const removeSfxRefSchema = z.object({
|
|
1002
|
+
jobId: z.string(),
|
|
1003
|
+
kind: z.enum(["image", "audio"]),
|
|
1004
|
+
/** 音频参考按文件删;省略 = 删全部音频参考。 */
|
|
1005
|
+
file: z.string().optional()
|
|
1006
|
+
});
|
|
1007
|
+
const setSfxApprovedSchema = z.object({
|
|
1008
|
+
jobId: z.string(),
|
|
1009
|
+
/** `generate` / `export`;空 = 全部阶段。 */
|
|
1010
|
+
stage: z.enum(["generate", "export"]).optional(),
|
|
1011
|
+
approved: z.boolean()
|
|
1012
|
+
});
|
|
1013
|
+
const exportSfxSchema = z.object({
|
|
1014
|
+
jobId: z.string(),
|
|
1015
|
+
takeId: z.string().optional(),
|
|
1016
|
+
zip: z.boolean().optional()
|
|
1017
|
+
});
|
|
968
1018
|
export const METHODS = [{ method: "getConfig", result: configViewSchema },
|
|
969
1019
|
{ method: "saveConfig", payload: saveConfigSchema, result: configViewSchema },
|
|
970
1020
|
{ method: "testArk", result: jsonObject },
|
|
@@ -974,6 +1024,8 @@ export const METHODS = [{ method: "getConfig", result: configViewSchema },
|
|
|
974
1024
|
{ method: "testComfy", result: jsonObject },
|
|
975
1025
|
// 谱乐 AI 连接自检(读一页历史,不生成、不扣生成积分)。
|
|
976
1026
|
{ method: "testMusic", result: jsonObject },
|
|
1027
|
+
// 火山引擎音效生成自检(★会真实生成一条极短音效,产生少量费用)。
|
|
1028
|
+
{ method: "testSfx", result: jsonObject },
|
|
977
1029
|
// 浏览器半区在挂载时上报 origin,供宿主拼深链接;不是用户可调用的功能。
|
|
978
1030
|
{ method: "reportClientOrigin", payload: reportOriginSchema, result: okSchema, clientOnly: true },
|
|
979
1031
|
{ method: "listProjects", result: projectListSchema },
|
|
@@ -1136,7 +1188,20 @@ export const METHODS = [{ method: "getConfig", result: configViewSchema },
|
|
|
1136
1188
|
{ method: "renderMusicEdit", payload: renderMusicEditSchema, result: jsonObject },
|
|
1137
1189
|
{ method: "saveMusicVersion", payload: saveMusicVersionSchema, result: jsonObject },
|
|
1138
1190
|
{ method: "deleteMusicVersion", payload: deleteMusicVersionSchema, result: okSchema },
|
|
1139
|
-
{ method: "exportMusic", payload: exportMusicSchema, result: jsonObject }
|
|
1191
|
+
{ method: "exportMusic", payload: exportMusicSchema, result: jsonObject },
|
|
1192
|
+
// 音效生成(模块八)
|
|
1193
|
+
{ method: "listSfxJobs", result: z.object({ jobs: z.array(jsonObject) }) },
|
|
1194
|
+
{ method: "createSfxJob", payload: createSfxJobSchema, result: jsonObject },
|
|
1195
|
+
{ method: "getSfxJob", payload: sfxJobIdSchema, result: jsonObject },
|
|
1196
|
+
{ method: "saveSfxJob", payload: saveSfxJobSchema, result: jsonObject },
|
|
1197
|
+
{ method: "deleteSfxJob", payload: sfxJobIdSchema, result: okSchema },
|
|
1198
|
+
{ method: "uploadSfxRef", payload: uploadSfxRefSchema, result: jsonObject },
|
|
1199
|
+
{ method: "removeSfxRef", payload: removeSfxRefSchema, result: jsonObject },
|
|
1200
|
+
{ method: "runSfxGeneration", payload: sfxJobIdSchema, result: startedSchema },
|
|
1201
|
+
{ method: "cancelSfxGeneration", payload: sfxJobIdSchema, result: jsonObject },
|
|
1202
|
+
{ method: "setSfxApproved", payload: setSfxApprovedSchema, result: jsonObject },
|
|
1203
|
+
{ method: "revealSfxJob", payload: sfxJobIdSchema, result: okSchema },
|
|
1204
|
+
{ method: "exportSfx", payload: exportSfxSchema, result: jsonObject }
|
|
1140
1205
|
];
|
|
1141
1206
|
export const PACKAGE_NAME = "dsh-game-material-master";
|
|
1142
1207
|
export const SERVICE_NAME = "gameStudio";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-game-material-master",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "游戏素材大师:DSH
|
|
3
|
+
"version": "0.9.0",
|
|
4
|
+
"description": "游戏素材大师:DSH 插件,包含八方向图生成、图片生成、序列帧生成、地图编辑器、音乐生成编辑、音效生成六个正式模块(地图编辑器参考 AsLib 的 RPG Map Maker 重做:一屏、纯图标、零术语,地图四周环绕、素材自动识别与自动连接、动画地块、内置素材、一键生成,全本地零计费;音乐生成编辑接谱乐 AI:灵感/歌词 → 不挂靠项目的新对话 → agent 扩写/选引擎生成 → 回界面裁剪/音量/淡入淡出/标准化/导出,生成按平台积分计费;另有谱曲模式:先给方案 → scoremill 本地写 MIDI → 渲染试听 → 逐版修改 → 可选交 Suno,谱曲/试听/导出本地免费;音效生成接火山引擎 Seed-Audio:一句话描述 → 音效/环境音/角色配音,可带参考图或参考音频,每次生成真实计费),以及实验性的 45° 地图地块生成与骨骼动画生成模块。界面与内置提示词跟随 DSH 语言设置(中 / 英)。八方向图默认「转圈截帧」(一段原地匀速转一圈的绿幕视频 → 按时间轴截出八个方向),也可逐方向生图;45° 地图地块用「几何交给代码、内容交给 AI」的方式拼成整张地图。生图后端可选火山方舟 Seedream,或自定义生图模型(OpenAI API / ComfyUI API / Stable Diffusion WebUI API 三种协议);图生视频走 MiniMax;抠绿幕合成与音乐后期全部在本地。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"repository": {
|
|
@@ -69,6 +69,10 @@
|
|
|
69
69
|
"midi-composition",
|
|
70
70
|
"audio-editing",
|
|
71
71
|
"puyue",
|
|
72
|
-
"suno"
|
|
72
|
+
"suno",
|
|
73
|
+
"sound-effects",
|
|
74
|
+
"sfx",
|
|
75
|
+
"seed-audio",
|
|
76
|
+
"volcengine"
|
|
73
77
|
]
|
|
74
78
|
}
|