dsh-game-material-master 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/wire.js ADDED
@@ -0,0 +1,535 @@
1
+ /**
2
+ * gameStudio 远程服务的 wire 协议。
3
+ *
4
+ * 约定:**每个方法只有一个 `payload` 对象参数**(无参方法则为空)。
5
+ * 这样一份 manifest 描述符就能同时被宿主网关和浏览器半区复用,
6
+ * 不必为每个字段单独写一遍 positional 参数描述。
7
+ */
8
+ import { z } from "zod";
9
+ /** 复杂返回体(配置视图、项目视图)用宽松的 JSON 对象,避免协议层过度约束。 */
10
+ const jsonObject = z.record(z.string(), z.unknown());
11
+ const startedSchema = z.object({ started: z.boolean(), reason: z.string().optional() });
12
+ const okSchema = z.object({ ok: z.boolean(), message: z.string().optional() });
13
+ const configViewSchema = jsonObject;
14
+ const projectViewSchema = jsonObject;
15
+ const projectListSchema = z.object({ projects: z.array(jsonObject) });
16
+ const saveConfigSchema = z.record(z.string(), z.unknown());
17
+ const createProjectSchema = z.object({ name: z.string().optional() });
18
+ const projectIdSchema = z.object({ projectId: z.string() });
19
+ const renameSchema = z.object({ projectId: z.string(), name: z.string() });
20
+ const uploadSchema = z.object({
21
+ projectId: z.string(),
22
+ name: z.string().optional(),
23
+ /** 原始文件字节的 base64(不带 data: 前缀)。 */
24
+ data: z.string()
25
+ });
26
+ const promptsSchema = z.object({
27
+ projectId: z.string(),
28
+ images: z.record(z.string(), z.string()).optional(),
29
+ video: z.string().optional(),
30
+ videoPerDirection: z.record(z.string(), z.string()).optional(),
31
+ /** 统一附加提示词:追加到每个方向的生图提示词末尾;空串表示关闭。 */
32
+ suffix: z.string().optional(),
33
+ /** 一键把八个方向的生图提示词重置为当前默认模板。 */
34
+ resetImagesToDefault: z.boolean().optional(),
35
+ /** 一键把视频提示词重置为当前默认模板。 */
36
+ resetVideoToDefault: z.boolean().optional()
37
+ });
38
+ const settingsSchema = z.object({ projectId: z.string(), settings: z.record(z.string(), z.unknown()) });
39
+ const approvedSchema = z.object({
40
+ projectId: z.string(),
41
+ stage: z.enum(["images", "videos", "frames", "sheet"]),
42
+ key: z.string().optional(),
43
+ approved: z.boolean()
44
+ });
45
+ /**
46
+ * 审核模式:`auto` = agent 自己审完就往下走;`manual` = 每一步都停下来等用户看。
47
+ * 固定流程里必须先问用户选哪个,选完记在目标上,之后所有步骤都按它走。
48
+ */
49
+ const setReviewModeSchema = z.object({
50
+ id: z.string(),
51
+ /** 四个模块都要能设审核模式——骨骼动画(rig)早期漏了,见 index.ts 的注释。 */
52
+ module: z.enum(["sprite", "image", "sequence", "rig"]),
53
+ reviewMode: z.enum(["auto", "manual"])
54
+ });
55
+ const runImageSchema = z.object({ projectId: z.string(), key: z.string(), prompt: z.string().optional() });
56
+ const runImagesSchema = z.object({ projectId: z.string(), force: z.boolean().optional() });
57
+ const runKeysSchema = z.object({ projectId: z.string(), keys: z.array(z.string()).optional() });
58
+ const runVideosSchema = z.object({
59
+ projectId: z.string(),
60
+ keys: z.array(z.string()).optional(),
61
+ /**
62
+ * 「重新生成」:已经完成的视频也重新提交。
63
+ *
64
+ * 不带这个标记时 `runVideos` 会跳过 ready 的方向(防止重复提交把任务覆盖成
65
+ * 无人认领的孤儿),所以单方向「重新生成」必须显式声明,宿主才知道要先作废
66
+ * 旧视频与它抽出来的帧。必须与 `keys` 一起用:批量提交带这个标记会把八段
67
+ * 视频全部重跑一遍(真金白银)。
68
+ */
69
+ regenerate: z.boolean().optional()
70
+ });
71
+ // ── 图片生成模块 ────────────────────────────────────────────────────────
72
+ const imageJobIdSchema = z.object({ jobId: z.string() });
73
+ const createImageJobSchema = z.object({ name: z.string().optional() });
74
+ const saveImageJobSchema = z.object({
75
+ jobId: z.string(),
76
+ name: z.string().optional(),
77
+ prompt: z.string().optional(),
78
+ suffix: z.string().optional(),
79
+ settings: z.record(z.string(), z.unknown()).optional(),
80
+ keying: z.record(z.string(), z.unknown()).optional(),
81
+ /** 验收打标:不带 index 就是整个任务,带 index 只改那一张。 */
82
+ approved: z.boolean().optional(),
83
+ index: z.number().nullable().optional()
84
+ });
85
+ const uploadSchema2 = z.object({ jobId: z.string(), name: z.string().optional(), data: z.string() });
86
+ const removeRefSchema2 = z.object({ jobId: z.string(), file: z.string() });
87
+ const removeItemSchema2 = z.object({ jobId: z.string(), index: z.number() });
88
+ const runImageJobSchema = z.object({ jobId: z.string(), count: z.number().optional() });
89
+ // ── 序列帧生成模块 ──────────────────────────────────────────────────────
90
+ const sequenceJobIdSchema = z.object({ jobId: z.string() });
91
+ const createSequenceJobSchema = z.object({ name: z.string().optional() });
92
+ const saveSequenceJobSchema = z.object({
93
+ jobId: z.string(),
94
+ name: z.string().optional(),
95
+ mode: z.enum(["frames", "reference"]).optional(),
96
+ prompt: z.string().optional(),
97
+ suffix: z.string().optional(),
98
+ settings: z.record(z.string(), z.unknown()).optional(),
99
+ keying: z.record(z.string(), z.unknown()).optional(),
100
+ /** 验收打标:不带 step 就是三步全打,带 step 只改那一步。 */
101
+ approved: z.boolean().optional(),
102
+ step: z.enum(["video", "frames", "sheet"]).nullable().optional()
103
+ });
104
+ const uploadSequenceRefSchema = z.object({
105
+ jobId: z.string(),
106
+ kind: z.enum(["firstFrame", "lastFrame", "referenceImage", "referenceVideo"]),
107
+ name: z.string().optional(),
108
+ data: z.string()
109
+ });
110
+ const removeSequenceRefSchema = z.object({
111
+ jobId: z.string(),
112
+ kind: z.enum(["firstFrame", "lastFrame", "referenceImage", "referenceVideo"]),
113
+ file: z.string().optional()
114
+ });
115
+ const runSequenceFramesSchema = z.object({ jobId: z.string(), count: z.number().optional() });
116
+ const projectOnlySchema = z.object({ projectId: z.string() });
117
+ // ── 骨骼动画生成模块 ────────────────────────────────────────────────────
118
+ const rigJobIdSchema = z.object({ jobId: z.string() });
119
+ const createRigJobSchema = z.object({ name: z.string().optional() });
120
+ const saveRigJobSchema = z.object({
121
+ jobId: z.string(),
122
+ name: z.string().optional(),
123
+ /** 拆件提示词与统一附加提示词。 */
124
+ sheetPrompt: z.string().optional(),
125
+ suffix: z.string().optional(),
126
+ resetSheetPrompt: z.boolean().optional(),
127
+ settings: z.record(z.string(), z.unknown()).optional(),
128
+ /** 验收打标:不带 stage 就是全部阶段,带 stage 只改那一个。 */
129
+ approved: z.boolean().optional(),
130
+ stage: z.enum(["parts", "layout", "rig", "atlas"]).nullable().optional(),
131
+ /** 只对某个部件打通过(配合 stage="parts")。 */
132
+ part: z.string().nullable().optional()
133
+ });
134
+ const uploadRigSourceSchema = z.object({ jobId: z.string(), name: z.string().optional(), data: z.string() });
135
+ const uploadRigPartSchema = z.object({ jobId: z.string(), name: z.string().optional(), data: z.string() });
136
+ const removeRigPartSchema = z.object({ jobId: z.string(), name: z.string() });
137
+ const renameRigPartSchema = z.object({ jobId: z.string(), from: z.string(), to: z.string() });
138
+ const rigPartFlagSchema = z.object({ jobId: z.string(), name: z.string(), hidden: z.boolean() });
139
+ const rigLayoutItemSchema = z.object({
140
+ jobId: z.string(),
141
+ name: z.string(),
142
+ x: z.number().optional(),
143
+ y: z.number().optional(),
144
+ width: z.number().optional(),
145
+ height: z.number().optional(),
146
+ rotation: z.number().optional(),
147
+ z: z.number().optional()
148
+ });
149
+ const runRigLayoutSchema = z.object({ jobId: z.string(), names: z.array(z.string()).optional() });
150
+ const saveRigLayoutItemsSchema = z.object({
151
+ jobId: z.string(),
152
+ /** 一次手动装配动作里的全部改动(拖动 / 缩放 / 键盘微调 / 改层级)。 */
153
+ items: z.array(z.object({
154
+ name: z.string(),
155
+ x: z.number().optional(),
156
+ y: z.number().optional(),
157
+ width: z.number().optional(),
158
+ height: z.number().optional(),
159
+ rotation: z.number().optional(),
160
+ z: z.number().optional(),
161
+ /** false = 收回未摆放状态(从画布上取下来)。 */
162
+ placed: z.boolean().optional()
163
+ }))
164
+ });
165
+ const setRigLayoutHintsSchema = z.object({
166
+ jobId: z.string(),
167
+ /**
168
+ * 部件名 → 它在参考图里的大致像素框;传 null 表示清除该部件的先验。
169
+ * 由多模态模型看一眼图给出来(对话里就是 agent 自己),不需要精确。
170
+ */
171
+ hints: z.record(z.string(), z
172
+ .object({ x: z.number(), y: z.number(), width: z.number(), height: z.number() })
173
+ .nullable())
174
+ });
175
+ /**
176
+ * 语义层(阶段③)。
177
+ *
178
+ * 只传**要改的字段**:这是细粒度失效传播的前提——改一个部件的 `parent`
179
+ * 不该让整份语义表重新生成,也不该丢掉别人调过的锚点。
180
+ */
181
+ /**
182
+ * 手工骨骼偏移(三通道的中间那一层)。
183
+ *
184
+ * 只传要改的字段;`origin` 由布局与语义算出来、每次重跑都会重算,
185
+ * 而这里写下的偏置**任何自动重跑都不碰**(重跑骨骼、重跑装配、改语义都不影响它)。
186
+ * 全零的条目会被自动删除——「改回去了」等于「没有这条记录」。
187
+ */
188
+ const setRigBoneOffsetsSchema = z.object({
189
+ jobId: z.string(),
190
+ bones: z.array(z.object({
191
+ name: z.string(),
192
+ x: z.number().optional(),
193
+ y: z.number().optional(),
194
+ rotation: z.number().optional()
195
+ })),
196
+ by: z.enum(["ai", "human"]).optional(),
197
+ label: z.string().optional()
198
+ });
199
+ const resetRigBoneOffsetsSchema = z.object({
200
+ jobId: z.string(),
201
+ /** 不传或传空数组 = 清除全部手工偏移。 */
202
+ names: z.array(z.string()).optional()
203
+ });
204
+ /**
205
+ * 动画参数(M3)。
206
+ *
207
+ * 只传要改的字段;两个旋钮覆盖绝大多数真实诉求:
208
+ * - `amplitude` 统一缩放旋转与位移(「动作太大了」);
209
+ * - `duration` 改一个循环的时长(「这是慢节奏的 NPC」)。
210
+ * 「生成哪些动作」仍由 `saveRigJob` 的 `settings.animations` 决定,不在这里重复。
211
+ */
212
+ const setRigAnimationSettingsSchema = z.object({
213
+ jobId: z.string(),
214
+ animations: z.array(z.object({
215
+ id: z.string(),
216
+ duration: z.number().optional(),
217
+ amplitude: z.number().optional()
218
+ })),
219
+ by: z.enum(["ai", "human"]).optional()
220
+ });
221
+ const resetRigAnimationSettingsSchema = z.object({
222
+ jobId: z.string(),
223
+ /** 不传或传空数组 = 重置全部。 */
224
+ ids: z.array(z.string()).optional()
225
+ });
226
+ /**
227
+ * 关键帧编辑(M3 的时间轴编辑器)。
228
+ *
229
+ * 逐台取、整份存:「取一台动画的可编辑数据」与「整份写回」。
230
+ * 不做逐关键帧的 patch——时间轴的增删改三者互相牵连(删一帧会同时改两个段的
231
+ * 缓动归属),服务端再去解析 patch 等于把同一套语义实现两遍,多一处能出错的地方。
232
+ */
233
+ const getRigAnimationSchema = z.object({ jobId: z.string(), id: z.string() });
234
+ const saveRigAnimationSchema = z.object({
235
+ jobId: z.string(),
236
+ id: z.string(),
237
+ /**
238
+ * 不传 = **实例化**:按当前参数把预设烘成显式关键帧,之后以数据为准。
239
+ * 传了 = 整份替换。结构见 `riggen.RigCustomAnimation`。
240
+ */
241
+ animation: z.unknown().optional()
242
+ });
243
+ const resetRigAnimationSchema = z.object({ jobId: z.string(), id: z.string() });
244
+ /**
245
+ * 拆件质检(阶段①②之间)。
246
+ *
247
+ * `expectedParts`(参考图里大致有几个独立部位)只能靠视觉判断,所以由 agent
248
+ * 看图后填;不填就跳过这项判断——宁可不报,也不要瞎报。
249
+ */
250
+ const runRigQaSchema = z.object({
251
+ jobId: z.string(),
252
+ expectedParts: z.number().int().positive().max(200).optional()
253
+ });
254
+ /**
255
+ * IK 约束(M5)。
256
+ *
257
+ * `chain` 是「链长」:1 = 末端骨 + 它的父级两根骨。目标骨不在骨架里时宿主会自动
258
+ * 补一根可拖的点——让用户手工去建那样一根骨头是没有意义的负担。
259
+ */
260
+ const setRigConstraintsSchema = z.object({
261
+ jobId: z.string(),
262
+ constraints: z.array(z.object({
263
+ name: z.string(),
264
+ bone: z.string(),
265
+ target: z.string().optional(),
266
+ chain: z.number().int().min(1).max(8).optional(),
267
+ bendPositive: z.boolean().optional(),
268
+ /** 软 IK 权重 0~1。 */
269
+ weight: z.number().min(0).max(1).optional()
270
+ })),
271
+ by: z.enum(["ai", "human"]).optional()
272
+ });
273
+ const resetRigConstraintsSchema = z.object({
274
+ jobId: z.string(),
275
+ /** 不传或传空数组 = 清空全部约束。 */
276
+ names: z.array(z.string()).optional()
277
+ });
278
+ /**
279
+ * 蒙皮网格与 FFD 变形(M5 的 L1 / L3)。
280
+ *
281
+ * `cols/rows` 是网格密度(规则三角化,确定性重算,不落盘);`deform` 是波形变形,
282
+ * 传 `null` 表示只保留网格、不加变形。
283
+ */
284
+ const setRigMeshSchema = z.object({
285
+ jobId: z.string(),
286
+ meshes: z.array(z.object({
287
+ name: z.string(),
288
+ cols: z.number().int().min(1).max(16).optional(),
289
+ rows: z.number().int().min(1).max(16).optional(),
290
+ deform: z
291
+ .object({
292
+ amplitude: z.number().min(0).max(400).optional(),
293
+ cycles: z.number().min(0.25).max(8).optional(),
294
+ direction: z.number().optional(),
295
+ anchor: z.enum(["top", "bottom", "none"]).optional(),
296
+ duration: z.number().min(0.1).max(10).optional()
297
+ })
298
+ .nullable()
299
+ .optional()
300
+ })),
301
+ by: z.enum(["ai", "human"]).optional()
302
+ });
303
+ /** Path 约束(M5):把一串骨沿折线铺开。`points` 是扁平的 `[x0,y0,x1,y1,…]`(参考图像素)。 */
304
+ const setRigPathSchema = z.object({
305
+ jobId: z.string(),
306
+ paths: z.array(z.object({
307
+ name: z.string(),
308
+ points: z.array(z.number()).optional(),
309
+ closed: z.boolean().optional(),
310
+ bones: z.array(z.string()).optional(),
311
+ spacing: z.number().min(0).max(4000).optional(),
312
+ translateMix: z.number().min(0).max(1).optional(),
313
+ rotateMix: z.number().min(0).max(1).optional()
314
+ })),
315
+ by: z.enum(["ai", "human"]).optional()
316
+ });
317
+ const resetRigPathSchema = z.object({
318
+ jobId: z.string(),
319
+ names: z.array(z.string()).optional()
320
+ });
321
+ const resetRigMeshSchema = z.object({
322
+ jobId: z.string(),
323
+ /** 不传或传空数组 = 清除全部网格。 */
324
+ names: z.array(z.string()).optional()
325
+ });
326
+ /**
327
+ * 贴图版本(阶段⑦)。
328
+ *
329
+ * 每一次换色 / 重绘 / 手工上传都**新增一版**,永不覆盖原图——于是「这张不行
330
+ * 换回原版」是改一个字段,而且每一版都可复现、可审计。
331
+ */
332
+ const setRigTextureVersionSchema = z.object({
333
+ jobId: z.string(),
334
+ name: z.string(),
335
+ version: z.number()
336
+ });
337
+ const removeRigTextureVersionSchema = z.object({
338
+ jobId: z.string(),
339
+ name: z.string(),
340
+ version: z.number()
341
+ });
342
+ /** 换色参数;滑杆取值域抄自 reskin-app 的 `imaging.py`。 */
343
+ const tintSchema = z.object({
344
+ hue: z.number().optional(),
345
+ saturation: z.number().optional(),
346
+ lightness: z.number().optional(),
347
+ brightness: z.number().optional(),
348
+ contrast: z.number().optional(),
349
+ rgb: z.tuple([z.number(), z.number(), z.number()]).optional()
350
+ });
351
+ const tintRigPartsSchema = z.object({
352
+ jobId: z.string(),
353
+ /** 点名几个部件;与 `tag` 二选一。 */
354
+ names: z.array(z.string()).optional(),
355
+ /** 或者按语义标签批量(`tags` 来自语义层)。 */
356
+ tag: z.string().optional(),
357
+ tint: tintSchema,
358
+ note: z.string().optional(),
359
+ by: z.enum(["ai", "human"]).optional()
360
+ });
361
+ const uploadRigTextureSchema = z.object({
362
+ jobId: z.string(),
363
+ name: z.string(),
364
+ /** 原始文件字节的 base64(不带 data: 前缀)。 */
365
+ data: z.string(),
366
+ note: z.string().optional()
367
+ });
368
+ /**
369
+ * AI 逐部件重绘(**花钱**:一次 Seedream 调用)。
370
+ *
371
+ * 一个部件进、一个部件出——所以 reskin-app 那套「整张图重绘后再用 SAM /
372
+ * 连通域反向切回各 slot」完全不需要(见方案 §3.1 的范围裁剪)。
373
+ * 结果落成新版本,不满意随时切回上一版。
374
+ */
375
+ const runRigRedrawSchema = z.object({
376
+ jobId: z.string(),
377
+ name: z.string(),
378
+ /** 想怎么改(例如「换成深蓝色」「加上金属高光」)。 */
379
+ prompt: z.string(),
380
+ /** 边缘腐蚀半径(像素),用来削掉 AI 生成部件常见的白晕。默认 1。 */
381
+ erode: z.number().optional()
382
+ });
383
+ const setRigSemanticsSchema = z.object({
384
+ jobId: z.string(),
385
+ parts: z.array(z.object({
386
+ name: z.string(),
387
+ role: z.string().optional(),
388
+ /** null 表示挂到 root。 */
389
+ parent: z.string().nullable().optional(),
390
+ proximal: z.tuple([z.number(), z.number()]).optional(),
391
+ distal: z.tuple([z.number(), z.number()]).optional(),
392
+ tags: z.array(z.string()).optional()
393
+ })),
394
+ /** 强制按人形校验(不给时按「有没有 head 角色」自动判断)。 */
395
+ humanoid: z.boolean().optional(),
396
+ /** 改动来源,用于把 `semanticsSource` 记成 ai 还是 human。 */
397
+ by: z.enum(["ai", "human"]).optional()
398
+ });
399
+ /**
400
+ * 浏览器半区上报自己真实的 `location.origin`。
401
+ *
402
+ * 宿主不知道对外 origin(可能被反代改写过),而模型要在回复里贴出可点的
403
+ * 深链接,只能由页面自己上报一次。见 src/links.ts。
404
+ */
405
+ const reportOriginSchema = z.object({ origin: z.string() });
406
+ export const METHODS = [
407
+ { method: "getConfig", result: configViewSchema },
408
+ { method: "saveConfig", payload: saveConfigSchema, result: configViewSchema },
409
+ { method: "testArk", result: jsonObject },
410
+ { method: "testMinimax", result: jsonObject },
411
+ // 浏览器半区在挂载时上报 origin,供宿主拼深链接;不是用户可调用的功能。
412
+ { method: "reportClientOrigin", payload: reportOriginSchema, result: okSchema, clientOnly: true },
413
+ { method: "listProjects", result: projectListSchema },
414
+ { method: "createProject", payload: createProjectSchema, result: jsonObject },
415
+ { method: "getProject", payload: projectIdSchema, result: projectViewSchema },
416
+ { method: "deleteProject", payload: projectIdSchema, result: okSchema },
417
+ { method: "renameProject", payload: renameSchema, result: okSchema },
418
+ { method: "uploadSource", payload: uploadSchema, result: okSchema },
419
+ { method: "savePrompts", payload: promptsSchema, result: okSchema },
420
+ { method: "saveSettings", payload: settingsSchema, result: okSchema },
421
+ { method: "setApproved", payload: approvedSchema, result: okSchema },
422
+ { method: "setReviewMode", payload: setReviewModeSchema, result: okSchema },
423
+ { method: "revealProject", payload: projectIdSchema, result: okSchema },
424
+ { method: "runImage", payload: runImageSchema, result: startedSchema },
425
+ { method: "runImages", payload: runImagesSchema, result: startedSchema },
426
+ { method: "runVideos", payload: runVideosSchema, result: startedSchema },
427
+ { method: "pollVideos", payload: projectOnlySchema, result: okSchema },
428
+ { method: "clearVideos", payload: runKeysSchema, result: okSchema },
429
+ { method: "runFrames", payload: runKeysSchema, result: startedSchema },
430
+ { method: "rekey", payload: projectOnlySchema, result: startedSchema },
431
+ { method: "compose", payload: projectOnlySchema, result: startedSchema },
432
+ // 图片生成
433
+ { method: "listImageJobs", result: z.object({ jobs: z.array(jsonObject) }) },
434
+ { method: "createImageJob", payload: createImageJobSchema, result: jsonObject },
435
+ { method: "getImageJob", payload: imageJobIdSchema, result: projectViewSchema },
436
+ { method: "deleteImageJob", payload: imageJobIdSchema, result: okSchema },
437
+ { method: "saveImageJob", payload: saveImageJobSchema, result: okSchema },
438
+ { method: "uploadImageRef", payload: uploadSchema2, result: okSchema },
439
+ { method: "removeImageRef", payload: removeRefSchema2, result: okSchema },
440
+ { method: "addImageItem", payload: uploadSchema2, result: okSchema },
441
+ { method: "removeImageItem", payload: removeItemSchema2, result: okSchema },
442
+ { method: "runImageJob", payload: runImageJobSchema, result: startedSchema },
443
+ { method: "keyImageJob", payload: imageJobIdSchema, result: startedSchema },
444
+ // 序列帧生成
445
+ { method: "listSequenceJobs", result: z.object({ jobs: z.array(jsonObject) }) },
446
+ { method: "createSequenceJob", payload: createSequenceJobSchema, result: jsonObject },
447
+ { method: "getSequenceJob", payload: sequenceJobIdSchema, result: projectViewSchema },
448
+ { method: "deleteSequenceJob", payload: sequenceJobIdSchema, result: okSchema },
449
+ { method: "saveSequenceJob", payload: saveSequenceJobSchema, result: okSchema },
450
+ { method: "uploadSequenceRef", payload: uploadSequenceRefSchema, result: okSchema },
451
+ { method: "removeSequenceRef", payload: removeSequenceRefSchema, result: okSchema },
452
+ { method: "runSequenceVideo", payload: sequenceJobIdSchema, result: startedSchema },
453
+ { method: "pollSequenceVideo", payload: sequenceJobIdSchema, result: okSchema },
454
+ { method: "clearSequenceVideo", payload: sequenceJobIdSchema, result: okSchema },
455
+ { method: "runSequenceFrames", payload: runSequenceFramesSchema, result: startedSchema },
456
+ { method: "keySequenceFrames", payload: sequenceJobIdSchema, result: startedSchema },
457
+ { method: "composeSequence", payload: sequenceJobIdSchema, result: startedSchema },
458
+ // 骨骼动画生成
459
+ { method: "listRigJobs", result: z.object({ jobs: z.array(jsonObject) }) },
460
+ { method: "createRigJob", payload: createRigJobSchema, result: jsonObject },
461
+ { method: "getRigJob", payload: rigJobIdSchema, result: projectViewSchema },
462
+ { method: "deleteRigJob", payload: rigJobIdSchema, result: okSchema },
463
+ { method: "saveRigJob", payload: saveRigJobSchema, result: okSchema },
464
+ { method: "uploadRigSource", payload: uploadRigSourceSchema, result: okSchema },
465
+ { method: "uploadRigPart", payload: uploadRigPartSchema, result: okSchema },
466
+ { method: "removeRigPart", payload: removeRigPartSchema, result: okSchema },
467
+ { method: "renameRigPart", payload: renameRigPartSchema, result: okSchema },
468
+ { method: "setRigPartVisibility", payload: rigPartFlagSchema, result: okSchema },
469
+ { method: "saveRigLayoutItem", payload: rigLayoutItemSchema, result: okSchema },
470
+ { method: "saveRigLayoutItems", payload: saveRigLayoutItemsSchema, result: okSchema },
471
+ { method: "setRigLayoutHints", payload: setRigLayoutHintsSchema, result: okSchema },
472
+ { method: "setRigSemantics", payload: setRigSemanticsSchema, result: jsonObject },
473
+ { method: "setRigBoneOffsets", payload: setRigBoneOffsetsSchema, result: jsonObject },
474
+ { method: "resetRigBoneOffsets", payload: resetRigBoneOffsetsSchema, result: jsonObject },
475
+ { method: "setRigAnimationSettings", payload: setRigAnimationSettingsSchema, result: jsonObject },
476
+ { method: "resetRigAnimationSettings", payload: resetRigAnimationSettingsSchema, result: jsonObject },
477
+ { method: "getRigAnimation", payload: getRigAnimationSchema, result: jsonObject },
478
+ { method: "saveRigAnimation", payload: saveRigAnimationSchema, result: jsonObject },
479
+ { method: "resetRigAnimation", payload: resetRigAnimationSchema, result: jsonObject },
480
+ { method: "runRigQa", payload: runRigQaSchema, result: jsonObject },
481
+ { method: "setRigConstraints", payload: setRigConstraintsSchema, result: jsonObject },
482
+ { method: "resetRigConstraints", payload: resetRigConstraintsSchema, result: jsonObject },
483
+ { method: "setRigMesh", payload: setRigMeshSchema, result: jsonObject },
484
+ { method: "resetRigMesh", payload: resetRigMeshSchema, result: jsonObject },
485
+ { method: "setRigPath", payload: setRigPathSchema, result: jsonObject },
486
+ { method: "resetRigPath", payload: resetRigPathSchema, result: jsonObject },
487
+ { method: "tintRigParts", payload: tintRigPartsSchema, result: jsonObject },
488
+ { method: "uploadRigTexture", payload: uploadRigTextureSchema, result: jsonObject },
489
+ { method: "setRigTextureVersion", payload: setRigTextureVersionSchema, result: jsonObject },
490
+ { method: "removeRigTextureVersion", payload: removeRigTextureVersionSchema, result: jsonObject },
491
+ { method: "runRigRedraw", payload: runRigRedrawSchema, result: startedSchema },
492
+ { method: "runRigSheet", payload: rigJobIdSchema, result: startedSchema },
493
+ { method: "runRigSegment", payload: rigJobIdSchema, result: startedSchema },
494
+ { method: "runRigLayout", payload: runRigLayoutSchema, result: startedSchema },
495
+ { method: "runRigBones", payload: rigJobIdSchema, result: startedSchema },
496
+ { method: "runRigAtlas", payload: rigJobIdSchema, result: startedSchema }
497
+ ];
498
+ export const PACKAGE_NAME = "dsh-game-material-master";
499
+ export const SERVICE_NAME = "gameStudio";
500
+ /** 注册给宿主 typert 网关的 package face。 */
501
+ export const MANIFEST = {
502
+ package: PACKAGE_NAME,
503
+ face: "host",
504
+ schemas: [],
505
+ invocations: METHODS.map((spec) => ({
506
+ id: `${PACKAGE_NAME}#${SERVICE_NAME}/${spec.method}`,
507
+ service: SERVICE_NAME,
508
+ namespace: SERVICE_NAME,
509
+ method: spec.method,
510
+ invocation: { kind: "direct" },
511
+ parameters: spec.payload === undefined
512
+ ? []
513
+ : [
514
+ {
515
+ name: "payload",
516
+ wire: "payload",
517
+ source: "json",
518
+ codec: { mode: "strict", typeSymbol: `${PACKAGE_NAME}#${spec.method}Payload`, schema: spec.payload }
519
+ }
520
+ ],
521
+ result: { mode: "strict", typeSymbol: `${PACKAGE_NAME}#${spec.method}Result`, schema: spec.result }
522
+ })),
523
+ model: { services: [], events: [], objects: [] }
524
+ };
525
+ /** 客户端只需要方法名与是否有 payload;这里导出给浏览器半区复用同一张清单。 */
526
+ export const METHOD_NAMES = METHODS.map((spec) => ({
527
+ method: spec.method,
528
+ payload: spec.payload !== undefined,
529
+ clientOnly: spec.clientOnly === true
530
+ }));
531
+ /**
532
+ * 暴露成模型工具的方法(`game_material_call` 的 method 枚举)。
533
+ * 顺序即清单顺序,方便在工具描述里按模块分组。
534
+ */
535
+ export const TOOL_METHODS = METHODS.filter((spec) => spec.clientOnly !== true).map((spec) => ({ method: spec.method, payload: spec.payload !== undefined }));
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "dsh-game-material-master",
3
+ "version": "0.1.0",
4
+ "description": "游戏素材大师:DSH 插件,包含八方向图生成、图片生成、序列帧生成三个游戏素材模块。火山方舟 Seedream 生图 + MiniMax 图生视频 + 本地抠绿幕合成。",
5
+ "type": "module",
6
+ "main": "lib/index.js",
7
+ "exports": {
8
+ ".": "./lib/index.js",
9
+ "./client": "./lib/client.js",
10
+ "./package.json": "./package.json"
11
+ },
12
+ "dsh": {
13
+ "client": {
14
+ "platform": "web",
15
+ "inject": [
16
+ "@deepseek-ai/dsh-api-gateway"
17
+ ]
18
+ },
19
+ "bundle": {
20
+ "patch": "./cordis.patch.yml"
21
+ }
22
+ },
23
+ "license": "MIT",
24
+ "files": [
25
+ "lib",
26
+ "README.md",
27
+ "cordis.patch.yml"
28
+ ],
29
+ "scripts": {
30
+ "build": "tsc -p tsconfig.json && node scripts/strip-client-export.mjs",
31
+ "typecheck": "tsc -p tsconfig.json --noEmit"
32
+ },
33
+ "devDependencies": {
34
+ "@deepseek-ai/cordis": "^4.0.1",
35
+ "@deepseek-ai/dsh-typert-protocol": "*",
36
+ "@types/node": "^26.2.0",
37
+ "typescript": "^7.0.2",
38
+ "zod": "^4.4.3"
39
+ },
40
+ "keywords": [
41
+ "dsh",
42
+ "dsh-plugin",
43
+ "game-assets",
44
+ "sprite-sheet",
45
+ "chroma-key",
46
+ "seedream",
47
+ "minimax"
48
+ ]
49
+ }