@muqian/xiangsu-mcp-plus 0.6.0 → 0.7.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.md +43 -26
- package/editor-plugin/features/assets.cjs +1 -1
- package/editor-plugin/features/community.cjs +153 -39
- package/editor-plugin/features/menu.cjs +8 -3
- package/editor-plugin/features/music.cjs +1 -1
- package/editor-plugin/features/preview.cjs +9 -4
- package/editor-plugin/features/search.cjs +2 -2
- package/editor-plugin/features/square.cjs +2 -2
- package/editor-plugin/features/works.cjs +7 -7
- package/editor-plugin/library.cjs +4 -1
- package/package.json +4 -4
- package/src/bridge.mjs +30 -7
- package/src/calllog.mjs +32 -0
- package/src/outputs.mjs +122 -0
- package/src/server.mjs +195 -128
package/src/server.mjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// stdio MCP server: everything 像塑's official MCP offers (proxied unchanged), plus editor features the
|
|
3
3
|
// official server cannot reach, served by the XiangsuMcpExt editor plugin.
|
|
4
4
|
import fs from 'node:fs';
|
|
5
|
+
import { createRequire } from 'node:module';
|
|
5
6
|
import path from 'node:path';
|
|
6
7
|
import { setTimeout as sleep } from 'node:timers/promises';
|
|
7
8
|
import { fileURLToPath } from 'node:url';
|
|
@@ -21,6 +22,14 @@ import { makeupLayers } from './makeup.mjs';
|
|
|
21
22
|
import { cropImage, framesDir, resizeImage } from './frames.mjs';
|
|
22
23
|
import { DOWNLOAD_TTL_MS, Downloads, checkTarget, copyProject, editorRoot, outlineProject } from './works.mjs';
|
|
23
24
|
import { QrCodes } from './qrcodes.mjs';
|
|
25
|
+
import { CallLog } from './calllog.mjs';
|
|
26
|
+
import { MediaRefs, REF_PATTERN, Spill, withRefs } from './outputs.mjs';
|
|
27
|
+
|
|
28
|
+
const { INNOVATION_KINDS, MAX_MENU_PREVIEW, RANK_TYPES, RANK_FILTERS } = createRequire(import.meta.url)('../editor-plugin/library.cjs');
|
|
29
|
+
const rankFilter = (key) => z.array(z.enum(Object.keys(RANK_FILTERS[key].options))).optional();
|
|
30
|
+
const LIBRARY_PANELS_TEXT =
|
|
31
|
+
'general 为普通面板(如 3d_distortion=脸部变形/3D 变形、distortion=美型、gaoguai_gan/makeup_gan=AI 实时变脸、3d_makeup=美妆、3d_filter=滤镜、sticker=跟脸贴纸);square 为 aigc_material=素材广场(其他创作者分享的素材,含现成的 AI 图片、AI 妆容、自定义实时变脸,应用时不重新生成、不扣额度);collection 为 collection=收藏(当前账号收藏的素材)。需要扣额度现生成的 AI 面板不在其中。';
|
|
32
|
+
const RANK_TYPE_TEXT = Object.entries(RANK_TYPES).map(([k, name]) => `${k} ${name}`).join('、');
|
|
24
33
|
|
|
25
34
|
const VERSION = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version;
|
|
26
35
|
|
|
@@ -50,6 +59,17 @@ const IMAGE_VIEW_MAX = 8;
|
|
|
50
59
|
// Derived: the SDK's stdio transport drops a message over 10 MiB and with it the connection, and six
|
|
51
60
|
// animated GIFs from one task's content reached 16 MB of base64 (measured); this leaves room for the text.
|
|
52
61
|
const IMAGE_VIEW_BYTES = 8 * 1024 * 1024;
|
|
62
|
+
// Cursor ends a tool call that sends nothing for a while ("MCP tool call timed out (idle)", seen on a
|
|
63
|
+
// submit_prepare that waited for the page's checks). Picked: well inside the 25 s calls that went through.
|
|
64
|
+
const PROGRESS_MS = 5000;
|
|
65
|
+
// Appended to official tools whose work overlaps ours, saying which one to reach for.
|
|
66
|
+
const OFFICIAL_NOTES = {
|
|
67
|
+
capture_preview:
|
|
68
|
+
'窗口可见时这里就是官方截图:刚改完场景或切换预览视频后,它可能还是改之前的画面;要确认新画面请用 preview_frames(先重置预览、等到重载后的画面再截)。窗口最小化或不可见时,这里改为重置预览后从渲染结果截取。',
|
|
69
|
+
get_scene: '先摸清结构用 scene_tree(紧凑的缩进文本,也能不开窗口直接读下载的工程目录);要看多个对象的参数用 inspect_many。',
|
|
70
|
+
inspect: '一次看多个对象、按组件类型或属性名过滤、只留关键参数时用 inspect_many(逐个调用本工具并整理结果)。',
|
|
71
|
+
edit_by_dsl: '删除对象时,要连带找出并清理只被它使用的资源和素材包文件夹,用 object_remove(可撤销,资源默认只报告)。',
|
|
72
|
+
};
|
|
53
73
|
|
|
54
74
|
function saveDir(dir) {
|
|
55
75
|
if (!path.isAbsolute(dir)) throw Error(`SAVE_TO_NOT_ABSOLUTE: ${dir}`);
|
|
@@ -87,6 +107,8 @@ class Seen {
|
|
|
87
107
|
}
|
|
88
108
|
|
|
89
109
|
const text = (value) => ({ content: [{ type: 'text', text: JSON.stringify(value, null, 2) }] });
|
|
110
|
+
const REF_NOTE = '\n\n返回里的图片、视频、音频给的是短引用(*_ref / *_refs,如 img:12、video:3),交给 image_view:图片直接显示,视频和音频返回原地址;引用在 MCP 服务这次运行期间有效。';
|
|
111
|
+
const KIND_TEXT = { video: '视频', audio: '音频' };
|
|
90
112
|
const failure = (error) => ({ content: [{ type: 'text', text: String(error?.message ?? error) }], isError: true });
|
|
91
113
|
|
|
92
114
|
async function imageContent(d, { url, file }) {
|
|
@@ -116,6 +138,7 @@ export function createServer(deps = {}) {
|
|
|
116
138
|
closeTimeoutMs: 30000,
|
|
117
139
|
instanceTimeoutMs: 30000,
|
|
118
140
|
saveTimeoutMs: 15000,
|
|
141
|
+
progressMs: PROGRESS_MS,
|
|
119
142
|
...deps,
|
|
120
143
|
};
|
|
121
144
|
const server = new Server({ name: 'xiangsu-mcp-ext', version: VERSION }, { capabilities: { tools: { listChanged: true } } });
|
|
@@ -124,6 +147,9 @@ export function createServer(deps = {}) {
|
|
|
124
147
|
const projects = new Projects(d);
|
|
125
148
|
d.downloads = d.downloads ?? new Downloads();
|
|
126
149
|
d.qrCodes = d.qrCodes ?? new QrCodes();
|
|
150
|
+
d.callLog = d.callLog ?? new CallLog();
|
|
151
|
+
d.refs = d.refs ?? new MediaRefs();
|
|
152
|
+
d.spill = d.spill ?? new Spill();
|
|
127
153
|
d.qrCodes.prune();
|
|
128
154
|
// Library assets and homepage works seen in this session, kept here rather than in a window:
|
|
129
155
|
// windows open and close while an agent works, and a later apply or download may be served by a
|
|
@@ -162,20 +188,18 @@ export function createServer(deps = {}) {
|
|
|
162
188
|
if (hits.length === 1) return String(hits[0].instance_id);
|
|
163
189
|
throw Error(project_path ? `NO_UNIQUE_INSTANCE for ${project_path}: ${hits.length} matches` : `AMBIGUOUS_INSTANCE: ${list.length} editor windows; pass project_path or instance_id`);
|
|
164
190
|
};
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
const projectPath = await projects.resolveProjectPath({ project_path, instance_id });
|
|
168
|
-
return text(seenLib.keep(await d.callPlugin(method, params, { projectPath })));
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
// Homepage works do not depend on the project, so any window serves them (the lowest pid when no
|
|
172
|
-
// target is given).
|
|
191
|
+
// Homepage works, the asset library and the add-object menu do not depend on the project, so any
|
|
192
|
+
// window serves them (the lowest pid when no target is given).
|
|
173
193
|
const homeWindow = async ({ project_path, instance_id }) => {
|
|
174
194
|
if (project_path !== undefined || instance_id !== undefined) return { projectPath: await projects.resolveProjectPath({ project_path, instance_id }) };
|
|
175
195
|
const pids = d.listInstances().map((s) => s.pid).sort((a, b) => a - b);
|
|
176
196
|
if (!pids.length) throw Error('NO_EDITOR_WINDOW: open any project window first (works are served by the XiangsuMcpExt plugin inside it)');
|
|
177
197
|
return { pid: pids[0] };
|
|
178
198
|
};
|
|
199
|
+
const library = (method) => async (args) => {
|
|
200
|
+
const { project_path, instance_id, ...params } = args;
|
|
201
|
+
return text(seenLib.keep(await d.callPlugin(method, params, await homeWindow({ project_path, instance_id }))));
|
|
202
|
+
};
|
|
179
203
|
const works = (method) => async (args) => {
|
|
180
204
|
const { project_path, instance_id, ...params } = args;
|
|
181
205
|
return text(seenWorks.keep(await d.callPlugin(method, params, await homeWindow({ project_path, instance_id }))));
|
|
@@ -209,9 +233,9 @@ export function createServer(deps = {}) {
|
|
|
209
233
|
};
|
|
210
234
|
const workSort = z.enum(['suggest', 'latest', 'effect_usage', 'project_usage']).optional().describe('排序:suggest 推荐(默认)、latest 最新、effect_usage 特效使用量、project_usage 工程使用量。');
|
|
211
235
|
const workPage = {
|
|
212
|
-
category_id: z.string().optional().describe('
|
|
236
|
+
category_id: z.string().optional().describe('works_list 返回的 categories 里的分类 ID;省略时用第一个分类(推荐)。'),
|
|
213
237
|
cursor: z.string().min(1).optional().describe('翻页游标,原样取上一页的 next_cursor;最后一页的 next_cursor 是 null。'),
|
|
214
|
-
count: z.number().int().min(1).max(100).optional().describe('每页数量,默认
|
|
238
|
+
count: z.number().int().min(1).max(100).optional().describe('每页数量,默认 20。'),
|
|
215
239
|
sort: workSort,
|
|
216
240
|
};
|
|
217
241
|
|
|
@@ -254,16 +278,24 @@ export function createServer(deps = {}) {
|
|
|
254
278
|
},
|
|
255
279
|
{
|
|
256
280
|
name: 'image_view',
|
|
257
|
-
description:
|
|
258
|
-
shape: { images: z.array(z.string().min(1)).min(1).max(IMAGE_VIEW_MAX).describe('http(s) 图片地址,或本机图片文件的绝对路径。') },
|
|
281
|
+
description: `查看图片。列表类工具(素材、作品、灵感、任务、排行榜、音乐等)返回的是短引用 *_ref / *_refs(如 img:12),详情类工具(inspiration_detail 的 images、menu_list details 的 image_url)返回地址,都交给本工具;也可以传本机图片文件的绝对路径(如 menu_list details 的 image_file)。视频和音频引用(video:3、audio:5)看不了画面,返回它的原地址。一次最多 ${IMAGE_VIEW_MAX} 张,只认 png / jpeg / gif / webp,单张失败只在该项写明原因;图片很大(如动图)时一次给不完,没给的列在 not_returned 里,再调用一次即可。`,
|
|
282
|
+
shape: { images: z.array(z.string().min(1)).min(1).max(IMAGE_VIEW_MAX).describe('其它工具返回的引用(img:12)、http(s) 图片地址,或本机图片文件的绝对路径。') },
|
|
259
283
|
run: async ({ images }) => {
|
|
260
284
|
const content = [];
|
|
261
285
|
let bytes = 0;
|
|
262
286
|
let shown = 0;
|
|
263
287
|
for (const src of images) {
|
|
264
|
-
const
|
|
288
|
+
const hit = REF_PATTERN.test(src) ? d.refs.get(src) : null;
|
|
289
|
+
if (REF_PATTERN.test(src) && (!hit || hit.kind !== 'image')) {
|
|
290
|
+
const said = hit ? `${src} 是${KIND_TEXT[hit.kind]},看不了画面,原地址:${hit.url}` : `图片读取失败:引用 ${src} 已失效(MCP 服务重启过,或是很久以前的列表),重新调用返回它的工具`;
|
|
291
|
+
content.push({ type: 'text', text: `第 ${shown + 1} 张:${src}` }, { type: 'text', text: said });
|
|
292
|
+
shown++;
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
295
|
+
const where = hit ? hit.url : src;
|
|
296
|
+
const remote = /^https?:\/\//.test(where);
|
|
265
297
|
const img =
|
|
266
|
-
remote || path.isAbsolute(
|
|
298
|
+
remote || path.isAbsolute(where) ? await imageContent(d, remote ? { url: where } : { file: where }) : { type: 'text', text: '图片读取失败:不是引用、http(s) 地址或绝对路径' };
|
|
267
299
|
const size = img.data ? img.data.length : 0;
|
|
268
300
|
if (shown && bytes + size > IMAGE_VIEW_BYTES) break;
|
|
269
301
|
bytes += size;
|
|
@@ -275,43 +307,43 @@ export function createServer(deps = {}) {
|
|
|
275
307
|
return { content };
|
|
276
308
|
},
|
|
277
309
|
},
|
|
278
|
-
{
|
|
279
|
-
name: 'library_nav',
|
|
280
|
-
description:
|
|
281
|
-
'列出像塑官方素材库里可直接应用的分类面板(panel_key)和类型 kind:general 为普通面板(如 3d_distortion=脸部变形/3D 变形、distortion=美型、gaoguai_gan/makeup_gan=AI 实时变脸、3d_makeup=美妆、3d_filter=滤镜、sticker=跟脸贴纸);square 为 aigc_material=素材广场(其他创作者分享的素材,含现成的 AI 图片、AI 妆容、自定义实时变脸,应用时不重新生成、不扣额度);collection 为 collection=收藏(当前账号收藏的素材)。需要扣额度现生成的 AI 面板不在其中。',
|
|
282
|
-
shape: { ...target },
|
|
283
|
-
run: plugin('library_nav'),
|
|
284
|
-
},
|
|
285
310
|
{
|
|
286
311
|
name: 'library_list',
|
|
287
|
-
|
|
312
|
+
refs: true,
|
|
313
|
+
description: `不传 panel_key 时列出可直接应用的分类面板(panel_key)和类型 kind:${LIBRARY_PANELS_TEXT}传 panel_key 时分页列出该面板里的素材:子分类、素材(template_id、title、kind、封面 cover_ref 等)和翻页游标。素材广场的子分类是妆容、图片、实时变脸、跟脸贴纸、前景贴纸、画面特效、3D 模型、3D 饰品;收藏的子分类是全部、美妆、滤镜等目录。没有可应用内容的广场卡片不列出,只在 unsupported 里计数。按画面挑选时把 cover_ref 交给 image_view 看;知道要找什么时用 library_search 按关键词搜,本工具适合按面板和子分类浏览。拿到 template_id 后用 library_apply 应用,AI 图片卡片(kind=ai_image)的整组结果图用 library_images 取。`,
|
|
288
314
|
shape: {
|
|
289
315
|
...target,
|
|
290
|
-
panel_key: z.string().describe('
|
|
316
|
+
panel_key: z.string().optional().describe('面板,取不传 panel_key 时返回的 panels 里的 panel_key;省略时只返回面板清单。'),
|
|
291
317
|
category_id: z.string().optional().describe('子分类 ID(收藏为目录名);省略时用第一个子分类(通常是「全部」)。'),
|
|
292
318
|
cursor: z.union([z.number().int().min(0), z.string()]).optional().describe('翻页游标,原样取上一页的 next_cursor(收藏是字符串)。'),
|
|
293
|
-
count: z.number().int().min(1).max(100).optional().describe('每页数量,默认
|
|
319
|
+
count: z.number().int().min(1).max(100).optional().describe('每页数量,默认 20。'),
|
|
320
|
+
},
|
|
321
|
+
run: async (a) => {
|
|
322
|
+
if (a.panel_key !== undefined) return library('library_list')(a);
|
|
323
|
+
const { project_path, instance_id } = a;
|
|
324
|
+
return text(await d.callPlugin('library_nav', {}, await homeWindow({ project_path, instance_id })));
|
|
294
325
|
},
|
|
295
|
-
run: library('library_list'),
|
|
296
326
|
},
|
|
297
327
|
{
|
|
298
328
|
name: 'library_search',
|
|
329
|
+
refs: true,
|
|
299
330
|
description:
|
|
300
|
-
'按关键词搜索官方素材库(美妆、滤镜、脸部变形、AI 实时变脸、贴纸、画面特效、音效、素材广场等)。除了标题匹配,词正好是面板名或子分类名时也带出那里的素材:「滤镜」→ 滤镜面板,「腮红」→ 美妆/腮红、跟脸贴纸/腮红(这些素材标题里多半没有这个词),「复古滤镜」→ 滤镜/复古;每个面板或子分类最多 300 条。结果按标题完全相同 > 标题开头 > 标题包含 > 分类匹配 > 其余排序,每条的 matched 说明命中方式(title、category:面板/分类、panel:面板)。queries 一次搜多个近义词(最多 8 个)并合并去重。按 offset / count 分页(结果缓存 10 分钟,翻页不重新请求),每条带 template_id、title、panel_key、kind、
|
|
331
|
+
'按关键词搜索官方素材库(美妆、滤镜、脸部变形、AI 实时变脸、贴纸、画面特效、音效、素材广场等)。除了标题匹配,词正好是面板名或子分类名时也带出那里的素材:「滤镜」→ 滤镜面板,「腮红」→ 美妆/腮红、跟脸贴纸/腮红(这些素材标题里多半没有这个词),「复古滤镜」→ 滤镜/复古;每个面板或子分类最多 300 条。结果按标题完全相同 > 标题开头 > 标题包含 > 分类匹配 > 其余排序,每条的 matched 说明命中方式(title、category:面板/分类、panel:面板)。queries 一次搜多个近义词(最多 8 个)并合并去重。按 offset / count 分页(结果缓存 10 分钟,翻页不重新请求),每条带 template_id、title、panel_key、kind、cover_ref,另返回 total、by_panel(各面板条数,可再用 panel_key 缩小)、matched_categories(展开了哪些分类)、related_categories(名字里含这个词、没有展开的分类,可用 library_list 列出)。kind:package 素材包、ai_image AI 图片、ai_makeup AI 妆容、custom_gan 自定义实时变脸、foreground_sticker 前景贴纸、face_sticker 跟脸贴纸、filter 滤镜。',
|
|
301
332
|
shape: {
|
|
302
333
|
...target,
|
|
303
334
|
query: z.string().min(1).optional().describe('搜索关键词,如「芒果脸」「腮红」「复古滤镜」。与 queries 二选一。'),
|
|
304
335
|
queries: z.array(z.string().min(1)).min(1).max(8).optional().describe('一次搜多个词并合并,如 ["冷艳", "猫眼", "烟熏", "风格妆"]。与 query 二选一。'),
|
|
305
|
-
panel_key: z.string().optional().describe('只搜这个面板(
|
|
336
|
+
panel_key: z.string().optional().describe('只搜这个面板(library_list 不传 panel_key 时返回的 panel_key,如 aigc_material)。'),
|
|
306
337
|
offset: z.number().int().min(0).optional().describe('分页起点,取上一页的 next_offset;默认 0。'),
|
|
307
|
-
count: z.number().int().min(1).max(200).optional().describe('每页数量,默认
|
|
338
|
+
count: z.number().int().min(1).max(200).optional().describe('每页数量,默认 20。'),
|
|
308
339
|
},
|
|
309
340
|
run: library('library_search'),
|
|
310
341
|
},
|
|
311
342
|
{
|
|
312
343
|
name: 'library_images',
|
|
344
|
+
refs: true,
|
|
313
345
|
description:
|
|
314
|
-
'一张 AI 图片卡片(kind=ai_image
|
|
346
|
+
'一张 AI 图片卡片(kind=ai_image)的整组结果图 image_ref,按 image_index 编号;用 image_view 看图,应用时用 library_apply 的 image_index 选择。template_id 须来自本会话的 library_list / library_search。',
|
|
315
347
|
shape: { ...target, template_id: z.string().describe('library_list / library_search 返回的 template_id。') },
|
|
316
348
|
run: async ({ project_path, instance_id, template_id }) => {
|
|
317
349
|
const { slim, raw } = seenLib.get(template_id);
|
|
@@ -336,40 +368,34 @@ export function createServer(deps = {}) {
|
|
|
336
368
|
return text(await d.callPlugin('library_apply', params, { projectPath, timeoutMs: 180000 }));
|
|
337
369
|
},
|
|
338
370
|
},
|
|
339
|
-
{
|
|
340
|
-
name: 'works_nav',
|
|
341
|
-
description: '列出像塑首页「模板」里的作品分类(推荐、官方工程、新手必做、游戏、妆容、AI玩法等)和可用排序。首页作品是完整的像塑工程(官方工程和用户投稿),可下载到本地阅读、学习其场景和脚本做法。任意一个工程窗口开着即可。',
|
|
342
|
-
shape: { ...target },
|
|
343
|
-
run: async (a) => {
|
|
344
|
-
const { project_path, instance_id } = a;
|
|
345
|
-
return text(await d.callPlugin('works_nav', {}, await homeWindow({ project_path, instance_id })));
|
|
346
|
-
},
|
|
347
|
-
},
|
|
348
371
|
{
|
|
349
372
|
name: 'works_list',
|
|
350
|
-
|
|
373
|
+
refs: true,
|
|
374
|
+
description: '分页列出像塑首页「模板」某个分类下的作品。首页作品是完整的像塑工程(官方工程和用户投稿),可下载到本地阅读、学习其场景和脚本做法;任意一个工程窗口开着即可。每次都带上全部分类 categories(推荐、官方工程、新手必做、游戏、妆容、AI玩法等)。每条作品有 template_id、标题、标签、已发布到抖音的特效 ID 和发布量(effect_id / publish_count,没有则为 null)、使用量、工程包大小、封面 cover_ref 和动图 gif_ref(交给 image_view 看)。拿到 template_id 后用 works_download 下载工程。',
|
|
351
375
|
shape: { ...target, ...workPage },
|
|
352
376
|
run: works('works_list'),
|
|
353
377
|
},
|
|
354
378
|
{
|
|
355
379
|
name: 'works_search',
|
|
380
|
+
refs: true,
|
|
356
381
|
description:
|
|
357
382
|
'按作品名搜索首页作品(与首页搜索框同一个接口)。不给 category_id 时搜全部分类并合并去重:「推荐」翻到底只有约 300 条,「美化」「友友天地」等分类里还有它没有的作品。合并顺序是先「推荐」里的(按 sort),再按分类顺序追加只在其它分类出现的;每个分类最多 300 条。每条带 found_in(出现在哪些分类),另返回 total、by_category(各分类条数)。queries 一次搜多个词(最多 8 个)并合并,每条带 matched_queries。按 offset / count 分页,结果缓存 10 分钟,翻页不重新请求。某个分类翻页时服务端一直给同一页,会列在 incomplete 里。其余字段同 works_list。按特效 ID 查用 works_by_effect。',
|
|
358
383
|
shape: {
|
|
359
384
|
...target,
|
|
360
385
|
query: z.string().min(1).optional().describe('作品名关键词,如「合掌」「转场」「换装」。与 queries 二选一。'),
|
|
361
386
|
queries: z.array(z.string().min(1)).min(1).max(8).optional().describe('一次搜多个词并合并,如 ["头套", "头饰"]。与 query 二选一。'),
|
|
362
|
-
category_id: z.string().optional().describe('只搜这个分类(
|
|
387
|
+
category_id: z.string().optional().describe('只搜这个分类(works_list 返回的 categories 里的分类 ID);省略时搜全部分类。'),
|
|
363
388
|
offset: z.number().int().min(0).optional().describe('分页起点,取上一页的 next_offset;默认 0。'),
|
|
364
|
-
count: z.number().int().min(1).max(200).optional().describe('每页数量,默认
|
|
389
|
+
count: z.number().int().min(1).max(200).optional().describe('每页数量,默认 20。'),
|
|
365
390
|
sort: workSort,
|
|
366
391
|
},
|
|
367
392
|
run: works('works_search'),
|
|
368
393
|
},
|
|
369
394
|
{
|
|
370
395
|
name: 'works_by_effect',
|
|
396
|
+
refs: true,
|
|
371
397
|
description:
|
|
372
|
-
'按特效 ID 查排行榜等处给出的特效(rank_list / rank_subjects /
|
|
398
|
+
'按特效 ID 查排行榜等处给出的特效(rank_list / rank_subjects / rank_innovation 的 effect_id)在首页有没有工程,与首页搜索框「特效ID」搜索同一个接口。逐个返回 status:found 首页有这个特效的工程;same_name 首页没有它、只有同名作品(effect_id 不同,可能是别人的同名作品,不能当成同一个特效);not_on_homepage 作者没把工程分享到首页,拿不到工程。found 和 same_name 的作品在 items 里(字段同 works_list),template_id 可直接用于 works_download / works_open。默认在「推荐」里查:按特效 ID 查时「推荐」也能查到只在其它分类出现的作品,在别的分类里按 ID 查反而查不到,所以一般不用给 category_id。每个特效一到两次请求,20 个约 6 秒。',
|
|
373
399
|
shape: {
|
|
374
400
|
...target,
|
|
375
401
|
effects: z
|
|
@@ -518,18 +544,13 @@ export function createServer(deps = {}) {
|
|
|
518
544
|
};
|
|
519
545
|
},
|
|
520
546
|
},
|
|
521
|
-
{
|
|
522
|
-
name: 'inspiration_nav',
|
|
523
|
-
description: '列出像塑「灵感」页的分类(全部、热门音源、头饰、变形等)。灵感是官方和创作者发布的特效创意(图、玩法说明、奖励),首页右侧「灵感」页签就是它。任意一个工程窗口开着即可,用当前登录的账号请求。',
|
|
524
|
-
shape: { ...target },
|
|
525
|
-
run: community('inspiration_nav'),
|
|
526
|
-
},
|
|
527
547
|
{
|
|
528
548
|
name: 'inspiration_list',
|
|
529
|
-
|
|
549
|
+
refs: true,
|
|
550
|
+
description: '分页列出某个分类下的灵感(灵感是官方和创作者发布的特效创意,首页右侧「灵感」页签就是它):inspiration_id、标题、标签(如「激励」)、作者、收藏数、是否已收藏、是否 AI 灵感、关联热点 hotspot、封面 cover_ref(交给 image_view 看)。每次都带上全部分类 tabs。拿到 inspiration_id 后用 inspiration_detail 看详情。',
|
|
530
551
|
shape: {
|
|
531
552
|
...target,
|
|
532
|
-
tab: z.string().optional().describe('
|
|
553
|
+
tab: z.string().optional().describe('分类名,取上次返回的 tabs 里的一个(全部、热门音源、头饰、变形等);省略时用第一个(全部)。'),
|
|
533
554
|
cursor: z.number().int().min(0).optional().describe('翻页游标,取上一页的 next_cursor。'),
|
|
534
555
|
// The server answers code 1 at 100 (measured); 50 works.
|
|
535
556
|
count: z.number().int().min(1).max(50).optional().describe('每页数量,默认 20。'),
|
|
@@ -538,7 +559,7 @@ export function createServer(deps = {}) {
|
|
|
538
559
|
},
|
|
539
560
|
{
|
|
540
561
|
name: 'inspiration_detail',
|
|
541
|
-
description: '一个灵感的详情:玩法说明、特效类型、激励说明、全部图片的地址 images(用 image_view
|
|
562
|
+
description: '一个灵感的详情:玩法说明、特效类型、激励说明、全部图片的地址 images(用 image_view 看)、作者、奖励(金额、说明、时间)、关联热点(热度和标签,如「66条热点相关灵感」)、关联官方工程、已有的同灵感特效及发布量、示例视频 videos(抖音视频的播放地址 url、封面 cover_url、作者、点赞数、尺寸)、贴纸 stickers,以及当前账号是否已收藏和总收藏数。',
|
|
542
563
|
shape: { ...target, inspiration_id: z.string().min(1).describe('inspiration_list / rank_hotspots / task_detail 返回的 inspiration_id,或像塑 / 抖音 App 灵感页里的灵感 ID。') },
|
|
543
564
|
run: community('inspiration_detail'),
|
|
544
565
|
},
|
|
@@ -554,32 +575,44 @@ export function createServer(deps = {}) {
|
|
|
554
575
|
},
|
|
555
576
|
{
|
|
556
577
|
name: 'inspiration_bind',
|
|
557
|
-
description:
|
|
578
|
+
description:
|
|
579
|
+
'按 inspiration_id 把一条创作灵感绑定到当前工程(编辑器给 agent 的同一接口),之后 save_project 落盘,打开提交窗口时会自动带出。只在提交时选灵感的话,也可以直接给 submit_prepare 传 inspiration:它在提交窗口的下拉里按名称选,只列当前账号收藏的灵感和热点。',
|
|
558
580
|
shape: { ...target, inspiration_id: z.string().min(1).describe('要绑定的 inspiration_id。') },
|
|
559
581
|
run: plugin('inspiration_bind'),
|
|
560
582
|
},
|
|
561
583
|
{
|
|
562
584
|
name: 'tasks_list',
|
|
585
|
+
refs: true,
|
|
563
586
|
description:
|
|
564
|
-
'
|
|
565
|
-
shape: {
|
|
587
|
+
'按 offset / count 分页列出首页活动中心的任务。kind=effect(默认)为活动和特效征集任务:标题、状态(如 WAIT_RECEIVE 待领取 / WAIT_SUBMIT 待提交)、是否已领取、状态说明(如「查看官方指导,帮您完成任务」)、剩余天数、收益、上下线时间、可完成次数;kind=growth 为活动中心里的成长任务:奖励金额、参考工程(特效师等级、每级目标和进度在 growth_route)。拿到 task_id 后用 task_detail 看详情、task_receive 领取、task_bind 绑定到工程(bindable=true 的才能绑)。',
|
|
588
|
+
shape: {
|
|
589
|
+
...target,
|
|
590
|
+
kind: z.enum(['effect', 'growth']).optional().describe('effect 活动与征集任务(默认),growth 成长任务。'),
|
|
591
|
+
offset: z.number().int().min(0).optional().describe('分页起点,取上一页的 next_offset;默认 0。'),
|
|
592
|
+
count: z.number().int().min(1).max(100).optional().describe('每页数量,默认 20。'),
|
|
593
|
+
},
|
|
566
594
|
run: async (a) => {
|
|
567
|
-
const { project_path, instance_id, ...params } = a;
|
|
568
|
-
|
|
595
|
+
const { project_path, instance_id, offset = 0, count = 20, ...params } = a;
|
|
596
|
+
const { items, ...rest } = seenTasks.keep(await d.callPlugin('tasks_list', params, await homeWindow({ project_path, instance_id })));
|
|
597
|
+
const next = offset + count;
|
|
598
|
+
return text({ ...rest, total: items.length, items: items.slice(offset, next), next_offset: next, has_more: next < items.length });
|
|
569
599
|
},
|
|
570
600
|
},
|
|
571
601
|
{
|
|
572
602
|
name: 'task_detail',
|
|
603
|
+
refs: true,
|
|
573
604
|
description:
|
|
574
|
-
'
|
|
575
|
-
shape: { ...target, task_id: z.string().min(1).describe('tasks_list 返回的 task_id。') },
|
|
605
|
+
'一个任务的详情。征集任务返回状态、奖励时间、下线时间、我提交到这个任务的特效 my_effects(名称、effect_id、审核状态、拍摄数、播放数、投稿峰值、获奖金额、是否符合主题、赛道)、完成状态、是否分档任务,和整理过的任务说明 content:每个内容块(参与要求、奖项详情、近期热门、任务说明等)有名称 name、条目 items 和链接 links;条目有标题 title、正文 text(页面里的链接标记已换成文字,链接放进 links)、参考图 image_refs 和参考视频 video_refs,奖项条目另有页面原样给的金额 money、发放方式 money_mode 和名额 people(unlimited 为不限);空地址和 blob: 地址任务页里也显示不出来,只在 unusable_media 里计数;读不懂的字段原样放进 unread。要原始返回时传 save_to。成长任务返回奖励、参考工程、相关灵感(封面 cover_ref)和教程。task_id 须来自本会话的 tasks_list;活动没有详情。',
|
|
606
|
+
shape: { ...target, task_id: z.string().min(1).describe('tasks_list 返回的 task_id。'), save_to: saveTo.describe('把接口的原始返回另存到这个目录(绝对路径),文件名 task_detail-<task_id>.json,长期保留。') },
|
|
576
607
|
run: async (a) => {
|
|
577
|
-
const { project_path, instance_id, task_id } = a;
|
|
608
|
+
const { project_path, instance_id, task_id, save_to } = a;
|
|
578
609
|
const t = seenTasks.get(task_id);
|
|
579
610
|
if (t.raw.kind === 'activity') throw Error(`NO_TASK_DETAIL: ${task_id} is an activity; only effect and growth tasks have details`);
|
|
580
611
|
const id = t.raw.kind === 'task' ? t.raw.item_id : t.slim.task_id;
|
|
581
|
-
const out = await d.callPlugin('task_detail', { kind: t.raw.kind, id }, await homeWindow({ project_path, instance_id }));
|
|
582
|
-
return text({ task_id, ...out });
|
|
612
|
+
const { raw, ...out } = await d.callPlugin('task_detail', { kind: t.raw.kind, id }, await homeWindow({ project_path, instance_id }));
|
|
613
|
+
if (save_to === undefined) return text({ task_id, ...out });
|
|
614
|
+
const file = saveFile(save_to, `task_detail-${task_id}.json`, JSON.stringify(raw ?? out, null, 2));
|
|
615
|
+
return text({ task_id, ...out, raw_saved_to: file });
|
|
583
616
|
},
|
|
584
617
|
},
|
|
585
618
|
{
|
|
@@ -596,7 +629,7 @@ export function createServer(deps = {}) {
|
|
|
596
629
|
{
|
|
597
630
|
name: 'task_bind',
|
|
598
631
|
description:
|
|
599
|
-
'把工程绑定到一个已领取的任务,和从任务详情页点「去创作」打开的工程一样,提交时会带上该任务。编辑器只在打开工程时写入任务信息,所以本工具会先关闭该工程的窗口(有未保存改动时拒绝,先 save_project),再带着任务信息重新打开,返回新的 pid 和 instance_id。task_id 须来自本会话的 tasks_list
|
|
632
|
+
'把工程绑定到一个已领取的任务,和从任务详情页点「去创作」打开的工程一样,提交时会带上该任务。编辑器只在打开工程时写入任务信息,所以本工具会先关闭该工程的窗口(有未保存改动时拒绝,先 save_project),再带着任务信息重新打开,返回新的 pid 和 instance_id。task_id 须来自本会话的 tasks_list。只在提交时选任务的话,直接给 submit_prepare 传 task(已领取任务的标题),不用重开窗口。',
|
|
600
633
|
shape: {
|
|
601
634
|
path: z.string().min(1).describe('工程文件夹的绝对路径。'),
|
|
602
635
|
task_id: z.string().min(1).describe('tasks_list 返回的 task_id(须 bindable=true)。'),
|
|
@@ -611,27 +644,25 @@ export function createServer(deps = {}) {
|
|
|
611
644
|
},
|
|
612
645
|
},
|
|
613
646
|
{
|
|
614
|
-
name: '
|
|
615
|
-
description:
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
date: z.string().optional().describe('榜单日期 YYYY-MM-DD,默认最新一期。'),
|
|
620
|
-
},
|
|
621
|
-
run: community('rank_nav'),
|
|
647
|
+
name: 'growth_route',
|
|
648
|
+
description:
|
|
649
|
+
'像塑移动版的「成长之路」:当前账号的特效师等级 current_level,以及每一级(新手特效师、潜力特效师……大师特效师)的现金奖励、状态(done 已完成 / in_progress 进行中 / locked 未解锁)和要达成的目标:每个目标的说明(如「绑定「灵感」上线 0/3 个作品」)、当前进度 current / 目标 target、对应奖励。最高级给的是权益 rights。任意一个工程窗口开着即可,用编辑器里登录的账号读取。活动中心里一个个带参考工程和教程的成长任务用 tasks_list 的 kind=growth。',
|
|
650
|
+
shape: { ...target },
|
|
651
|
+
run: community('growth_route'),
|
|
622
652
|
},
|
|
623
653
|
{
|
|
624
654
|
name: 'rank_list',
|
|
625
|
-
|
|
655
|
+
refs: true,
|
|
656
|
+
description: '分页读取一个排行榜(与像塑移动版排行榜页同一个接口):名次、特效名、effect_id、等级、投稿量(峰值 / 累计)、跟拍量、男女比例、年轻喜爱度、热玩分、总收益等。可按日期、分类(每级一个,如只看「人像美化 › 美妆」)和筛选项过滤,每页都带上该榜当天的分类 categories(level 1 大类如人像美化、游戏玩法、人设扮演、AI 玩法,level 2 细类如基础头饰、测一测、不露脸壁纸;每个榜不同)。按主题的专题榜(如「热爆美妆特效榜」)见 rank_subjects。要看某个特效的工程,把 effect_id 和 name 交给 works_by_effect,查它在不在首页。',
|
|
626
657
|
shape: {
|
|
627
658
|
...target,
|
|
628
|
-
rank_type: z.number().int().optional().describe(
|
|
659
|
+
rank_type: z.number().int().optional().describe(`榜单:${RANK_TYPE_TEXT};默认 1。`),
|
|
629
660
|
date: z.string().optional().describe('榜单日期 YYYY-MM-DD,默认最新一期。'),
|
|
630
|
-
categories: z.array(z.string()).max(3).optional().describe('
|
|
631
|
-
levels:
|
|
632
|
-
panels:
|
|
633
|
-
preferences:
|
|
634
|
-
tools:
|
|
661
|
+
categories: z.array(z.string()).max(3).optional().describe('分类名,取上一页返回的 categories,每级最多一个,可叠加,如 ["人像美化","美妆"](大类 + 细类)。'),
|
|
662
|
+
levels: rankFilter('levels').describe('特效等级,如 ["S","A+"]。'),
|
|
663
|
+
panels: rankFilter('panels').describe('面板,如 ["头饰","美妆"]。'),
|
|
664
|
+
preferences: rankFilter('preferences').describe('偏好。'),
|
|
665
|
+
tools: rankFilter('tools').describe('来自工具。'),
|
|
635
666
|
young_like_scores: z.array(z.number().int().min(1).max(10)).optional().describe('年轻喜爱度 1–10。'),
|
|
636
667
|
cursor: z.number().int().min(0).optional().describe('翻页游标,取上一页的 next_cursor。'),
|
|
637
668
|
// The server answers code 1 above 20 (measured).
|
|
@@ -641,16 +672,19 @@ export function createServer(deps = {}) {
|
|
|
641
672
|
},
|
|
642
673
|
{
|
|
643
674
|
name: 'rank_hotspots',
|
|
644
|
-
|
|
675
|
+
refs: true,
|
|
676
|
+
description: '热点榜(按热度排序的抖音热点,每小时更新),按 offset / count 分页:名次、topic_id、标题、说明、热度、相关灵感数、封面 cover_ref。传 topic_id 时改为返回该热点下的灵感(inspiration_id、标题、标签、说明、封面 cover_ref,交给 image_view 看)。',
|
|
645
677
|
shape: {
|
|
646
678
|
...target,
|
|
647
|
-
|
|
679
|
+
offset: z.number().int().min(0).optional().describe('分页起点,取上一页的 next_offset;默认 0。'),
|
|
680
|
+
count: z.number().int().min(1).max(100).optional().describe('每页数量,默认 20。'),
|
|
648
681
|
topic_id: z.string().min(1).optional().describe('只看这个热点下的灵感(rank_hotspots 返回的 topic_id)。'),
|
|
649
682
|
},
|
|
650
683
|
run: community('rank_hotspots'),
|
|
651
684
|
},
|
|
652
685
|
{
|
|
653
686
|
name: 'rank_subjects',
|
|
687
|
+
refs: true,
|
|
654
688
|
description: '像塑移动版「专题合集」里按主题的榜单,最新的在前:kind=effect 为特效专题榜(近 200 期,如「测一测玩法特效榜 - 11月」「热爆美妆特效榜」「熊出没IP特效榜」「主题创新优胜特效榜」、各期征集活动优质特效),kind=template 为模板专题榜(如「歌词玩法模板榜」「AI配文创意模板榜」「氛围转场模板榜」)。每个榜带前几个特效、浏览量。keyword 按榜名搜索全部期;传 subject_id 时返回该榜的全部特效(最多 20 个)。',
|
|
655
689
|
shape: {
|
|
656
690
|
...target,
|
|
@@ -664,61 +698,50 @@ export function createServer(deps = {}) {
|
|
|
664
698
|
run: community('rank_subjects'),
|
|
665
699
|
},
|
|
666
700
|
{
|
|
667
|
-
name: '
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
run: community('rank_creators_month'),
|
|
671
|
-
},
|
|
672
|
-
{
|
|
673
|
-
name: 'rank_innovation_picks',
|
|
674
|
-
description: '创新计划官方精选(像塑移动版发现页的精选列表):特效名、effect_id、标签、投稿量、总收益、入选日期、封面。kind=template 为模板(移动版展示的就是这个),kind=effect 为特效。',
|
|
701
|
+
name: 'rank_innovation',
|
|
702
|
+
refs: true,
|
|
703
|
+
description: '创新计划的榜单。kind=template / effect 为官方精选(像塑移动版发现页的精选列表,移动版展示的是模板):特效名、effect_id、标签、投稿量、总收益、入选日期、封面;kind=creators 为创作者月榜:名次、创作者 uid 和昵称、上榜素材数、跟拍量、预计奖金(元)。',
|
|
675
704
|
shape: {
|
|
676
705
|
...target,
|
|
677
|
-
kind: z.enum(
|
|
706
|
+
kind: z.enum(INNOVATION_KINDS).optional().describe('template 精选模板(默认),effect 精选特效,creators 创作者月榜。'),
|
|
678
707
|
offset: z.number().int().min(0).optional().describe('翻页偏移,取上一页的 next_offset。'),
|
|
679
|
-
count: z.number().int().min(1).max(100).optional().describe('每页数量,默认 20
|
|
708
|
+
count: z.number().int().min(1).max(100).optional().describe('每页数量,默认 20;精选由服务端过滤,实际条数可能略少。'),
|
|
680
709
|
},
|
|
681
|
-
run: community('
|
|
710
|
+
run: community('rank_innovation'),
|
|
682
711
|
},
|
|
683
712
|
{
|
|
684
|
-
name: '
|
|
713
|
+
name: 'my_effects',
|
|
714
|
+
refs: true,
|
|
685
715
|
description:
|
|
686
|
-
'当前登录账号提交过的特效,最新的在前(与像塑移动版「作品」同一个接口):effect_id、名称、审核状态 status 和 status_text(100 审核中、101 审核未通过、111 测试中、112 测试未通过、120 测试通过、103 已上线、104 已下线、113 延后上线、118 申诉重审中、119 申诉审核未通过)、提交和上线时间、绑定的任务 / 灵感 / 热点、能否编辑 / 删除 / 申诉及申诉类型、投稿量。101、112、119 的特效带 review:最近一条审核记录,text 是去掉标记的原因正文,refuse_reasons 是分条原因,links 是正文里的链接(如审核规则)。完整审核时间线用
|
|
716
|
+
'当前登录账号提交过的特效,最新的在前(与像塑移动版「作品」同一个接口):effect_id、名称、审核状态 status 和 status_text(100 审核中、101 审核未通过、111 测试中、112 测试未通过、120 测试通过、103 已上线、104 已下线、113 延后上线、118 申诉重审中、119 申诉审核未通过)、提交和上线时间、绑定的任务 / 灵感 / 热点、能否编辑 / 删除 / 申诉及申诉类型、投稿量。101、112、119 的特效带 review:最近一条审核记录,text 是去掉标记的原因正文,refuse_reasons 是分条原因,links 是正文里的链接(如审核规则)。完整审核时间线用 my_effect_reviews。',
|
|
687
717
|
shape: {
|
|
688
718
|
...target,
|
|
689
719
|
cursor: z.string().min(1).optional().describe('翻页游标,原样取上一页的 next_cursor。'),
|
|
690
720
|
// Picked, not measured: every failed effect on a page costs one or two more requests.
|
|
691
721
|
count: z.number().int().min(1).max(50).optional().describe('每页数量,默认 20(最大 50)。'),
|
|
692
722
|
},
|
|
693
|
-
run: community('
|
|
723
|
+
run: community('my_effects'),
|
|
694
724
|
},
|
|
695
725
|
{
|
|
696
|
-
name: '
|
|
726
|
+
name: 'my_effect_reviews',
|
|
697
727
|
description:
|
|
698
728
|
'一个自己的特效的审核记录,与像塑移动版「审核记录」页同一组接口:名称、当前状态、绑定的任务,reviews 为「上线审核」时间线(最新的在前,提交成功、审核中、审核未通过等,每条有时间、去掉标记的正文 text、分条原因 refuse_reasons、链接 links),innovation_reviews 为「精选审核」时间线(没有时为空)。',
|
|
699
|
-
shape: { ...target, effect_id: z.string().regex(/^\d+$/).describe('
|
|
700
|
-
run: community('
|
|
701
|
-
},
|
|
702
|
-
{
|
|
703
|
-
name: 'music_categories',
|
|
704
|
-
description: '列出抖音音乐库的分类(像塑原创、推荐、抖音收藏、潮流心选等),返回 code 和名称。',
|
|
705
|
-
shape: { ...target },
|
|
706
|
-
run: async (a) => {
|
|
707
|
-
const { project_path, instance_id } = a;
|
|
708
|
-
return text(await d.callPlugin('music_categories', {}, await homeWindow({ project_path, instance_id })));
|
|
709
|
-
},
|
|
729
|
+
shape: { ...target, effect_id: z.string().regex(/^\d+$/).describe('my_effects 返回的 effect_id。') },
|
|
730
|
+
run: community('my_effect_reviews'),
|
|
710
731
|
},
|
|
711
732
|
{
|
|
712
733
|
name: 'music_list',
|
|
713
|
-
|
|
734
|
+
refs: true,
|
|
735
|
+
description: '列出抖音音乐:两个参数都不传时返回音乐库的分类(像塑原创、推荐、抖音收藏、潮流心选等)的 code 和名称;传 query 按关键词搜索,或传 category_code 看某个分类的第一页(35 首)。返回 music_id、标题、作者、时长 duration_sec、封面 cover_ref、试听 preview_ref(音频引用)和 has_copyright(音乐库给的版权标记,false 或 null 的不要用于要发布的特效)。',
|
|
714
736
|
shape: {
|
|
715
737
|
...target,
|
|
716
738
|
query: z.string().min(1).optional().describe('搜索关键词。'),
|
|
717
|
-
category_code: z.string().min(1).optional().describe('分类 code
|
|
739
|
+
category_code: z.string().min(1).optional().describe('分类 code(不带参数调用时返回);与 query 二选一。'),
|
|
718
740
|
},
|
|
719
741
|
run: async (a) => {
|
|
720
742
|
const { project_path, instance_id, query, category_code } = a;
|
|
721
|
-
if (
|
|
743
|
+
if (query !== undefined && category_code !== undefined) throw Error('INVALID_ARGUMENTS(music_list): pass query or category_code, not both');
|
|
744
|
+
if (query === undefined && category_code === undefined) return text(await d.callPlugin('music_categories', {}, await homeWindow({ project_path, instance_id })));
|
|
722
745
|
const res = await d.callPlugin('music_list', query !== undefined ? { query } : { category_code }, await homeWindow({ project_path, instance_id }));
|
|
723
746
|
return text(seenMusic.keep(res, { category_code: category_code ?? null }));
|
|
724
747
|
},
|
|
@@ -744,7 +767,7 @@ export function createServer(deps = {}) {
|
|
|
744
767
|
{
|
|
745
768
|
name: 'scene_tree',
|
|
746
769
|
description:
|
|
747
|
-
'把场景结构输出成紧凑的缩进文本:渲染组,以及每个对象的 guid
|
|
770
|
+
'把场景结构输出成紧凑的缩进文本:渲染组,以及每个对象的 guid、名称、是否隐藏、组件类型。比官方 get_scene 的 JSON 好读,适合先摸清结构再用 inspect_many 查参数;要渲染组和对象的完整 JSON 用 get_scene。subtree 只看某个对象(guid 或名称),depth 控制展开层数(默认 6);没展开的子对象会注明数量。传 project_dir(工程目录,如 works_download 下载的作品)时不需要打开窗口,直接读 Assets/main.scene 和 main.scene.extra,对象写成 #序号,组件类型和窗口里显示的一致(编辑器数据缺失时退回场景文件里的名称);没有渲染组这一层,渲染组本身作为根对象列出。save_to 是目录的绝对路径,结果另存为其中的 scene_tree.txt,长期保留。',
|
|
748
771
|
shape: {
|
|
749
772
|
...target,
|
|
750
773
|
project_dir: z.string().min(1).optional().describe('不开窗口、直接读这个工程目录的场景文件;给了它就不看 project_path / instance_id。'),
|
|
@@ -772,7 +795,7 @@ export function createServer(deps = {}) {
|
|
|
772
795
|
{
|
|
773
796
|
name: 'inspect_many',
|
|
774
797
|
description:
|
|
775
|
-
'一次查看多个对象的组件参数(逐个调用官方 inspect),值里的 {type, data} 包装直接展开成值,超长数组只给长度和前几项;绑定的资源写成 {resource, type, file},引用的对象写成 {object, name}。component_types 只留某些组件(如 ["Transform"]),fields 只留属性名包含这些片段的属性(不分大小写,如 ["intensity", "position"])。preset="key" 自动留下通常决定效果的参数:位置/缩放/旋转、显隐与启用、强度/不透明度/权重/颜色类属性、文字内容(str)与 2D 尺寸(sizeDelta)、绑定的资源,以及场景文件里脚本组件的全部参数(这份清单是按已做过的妆容、形变、贴纸、文字效果拍的,缺的用 fields 补,可与 fields 同时用)。传 project_dir 时不开窗口、直接读场景文件(含编辑器面板里的参数,如妆容的贴图和强度),guids 用 scene_tree 给出的 #序号;内置资源写成 {builtin: id},组件运行时生成、工程里没有文件的资源写成 {path}。单个对象失败只在该项写明原因。save_to 是目录的绝对路径,结果另存为其中的 inspect_many.json,长期保留。',
|
|
798
|
+
'一次查看多个对象的组件参数(逐个调用官方 inspect;只看一个对象的完整原始数据时直接用 inspect),值里的 {type, data} 包装直接展开成值,超长数组只给长度和前几项;绑定的资源写成 {resource, type, file},引用的对象写成 {object, name}。component_types 只留某些组件(如 ["Transform"]),fields 只留属性名包含这些片段的属性(不分大小写,如 ["intensity", "position"])。preset="key" 自动留下通常决定效果的参数:位置/缩放/旋转、显隐与启用、强度/不透明度/权重/颜色类属性、文字内容(str)与 2D 尺寸(sizeDelta)、绑定的资源,以及场景文件里脚本组件的全部参数(这份清单是按已做过的妆容、形变、贴纸、文字效果拍的,缺的用 fields 补,可与 fields 同时用)。传 project_dir 时不开窗口、直接读场景文件(含编辑器面板里的参数,如妆容的贴图和强度),guids 用 scene_tree 给出的 #序号;内置资源写成 {builtin: id},组件运行时生成、工程里没有文件的资源写成 {path}。单个对象失败只在该项写明原因。save_to 是目录的绝对路径,结果另存为其中的 inspect_many.json,长期保留。',
|
|
776
799
|
shape: {
|
|
777
800
|
...target,
|
|
778
801
|
project_dir: z.string().min(1).optional().describe('不开窗口、直接读这个工程目录的场景文件;给了它就不看 project_path / instance_id。'),
|
|
@@ -916,16 +939,16 @@ export function createServer(deps = {}) {
|
|
|
916
939
|
{
|
|
917
940
|
name: 'menu_list',
|
|
918
941
|
description:
|
|
919
|
-
|
|
920
|
-
shape: {
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
942
|
+
`列出像塑「添加对象」菜单里的全部官方功能项(工具栏美妆、美型、AI 实时变脸,及人脸/身体/2D/3D/AI 玩法/互动/宠物/音乐等),返回 menu_id、中文名、路径、类型。官方 add_builtin_object 只覆盖其中一部分;美容(面部提拉、祛皱纹)、面部生成(烟熏妆、卡通脸)、表情生成(香肠嘴、呲牙尬笑)、性别年龄、五官处理、身体换装等用 menu_add。query 按名称、路径或 menu_id 过滤。details=true 时每项再带说明 description 和示意图(编辑器悬停提示里的图:在 CDN 上的给 image_url,随编辑器安装的给本机文件 image_file,都没有为 null),按画面挑选 AI 变脸、美容等效果时把它交给 image_view 看;details 一次最多 ${MAX_MENU_PREVIEW} 项,query 匹配更多时报错。云端 AI 生成项不在列表中;拍照后云端生图的「AI 组合效果」用 ai_combine_new / ai_combine_apply。`,
|
|
943
|
+
shape: {
|
|
944
|
+
...target,
|
|
945
|
+
query: z.string().optional().describe('按中文名、路径或 menu_id 过滤,如「表情」「美容」「烟熏妆」。'),
|
|
946
|
+
details: z.boolean().optional().describe(`同时返回说明和示意图,默认 false;匹配项须不超过 ${MAX_MENU_PREVIEW} 个。`),
|
|
947
|
+
},
|
|
948
|
+
run: async (a) => {
|
|
949
|
+
const { project_path, instance_id, ...params } = a;
|
|
950
|
+
return text(await d.callPlugin('menu_list', params, await homeWindow({ project_path, instance_id })));
|
|
951
|
+
},
|
|
929
952
|
},
|
|
930
953
|
{
|
|
931
954
|
name: 'menu_add',
|
|
@@ -968,7 +991,7 @@ export function createServer(deps = {}) {
|
|
|
968
991
|
{
|
|
969
992
|
name: 'object_remove',
|
|
970
993
|
description:
|
|
971
|
-
'删除一个场景对象(含子对象,可撤销),并找出只被它使用的工程资源:删除前后对比场景引用,删除前被引用、删除后不再被引用的即为孤儿(unused_paths 已合并到素材包文件夹,只含磁盘上存在的路径)。editor_only_paths 是素材放进场景时编辑器按对象名建的文件夹(如「复古清冷_滤镜」),只在编辑器里、尚未写到磁盘,对象删除后下次保存就会消失,不用删。delete_unused_resources=true 时一并删除 unused_paths(资源删除不可撤销);默认只报告,可之后用 resource_delete_unused 删除。object_path 用完整层级路径或能唯一定位的末尾几段(渲染组本身请用官方 delete_render_group
|
|
994
|
+
'删除一个场景对象(含子对象,可撤销),并找出只被它使用的工程资源:删除前后对比场景引用,删除前被引用、删除后不再被引用的即为孤儿(unused_paths 已合并到素材包文件夹,只含磁盘上存在的路径)。editor_only_paths 是素材放进场景时编辑器按对象名建的文件夹(如「复古清冷_滤镜」),只在编辑器里、尚未写到磁盘,对象删除后下次保存就会消失,不用删。delete_unused_resources=true 时一并删除 unused_paths(资源删除不可撤销);默认只报告,可之后用 resource_delete_unused 删除。object_path 用完整层级路径或能唯一定位的末尾几段(渲染组本身请用官方 delete_render_group)。只删对象、不关心资源时官方 edit_by_dsl 也能删;要知道删完哪些资源没人用了,用本工具。',
|
|
972
995
|
shape: {
|
|
973
996
|
...target,
|
|
974
997
|
object_path: z.string().min(1).describe('对象的层级路径,如「面部拉伸/小屁桃_美型」,或能唯一定位的末尾几段。'),
|
|
@@ -1019,19 +1042,22 @@ export function createServer(deps = {}) {
|
|
|
1019
1042
|
};
|
|
1020
1043
|
|
|
1021
1044
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
1022
|
-
const mine = [...own.values()].map((t) => ({ name: t.name, description: t.description, inputSchema: z.toJSONSchema(t.schema) }));
|
|
1023
|
-
const official = (await d.official.listTools())
|
|
1045
|
+
const mine = [...own.values()].map((t) => ({ name: t.name, description: t.refs ? `${t.description}${REF_NOTE}` : t.description, inputSchema: z.toJSONSchema(t.schema) }));
|
|
1046
|
+
const official = (await d.official.listTools())
|
|
1047
|
+
.filter((t) => !own.has(t.name))
|
|
1048
|
+
.map((t) => (Object.prototype.hasOwnProperty.call(OFFICIAL_NOTES, t.name) ? { ...t, description: `${t.description || ''}\n\n(xiangsu-mcp-plus)${OFFICIAL_NOTES[t.name]}` } : t));
|
|
1024
1049
|
return { tools: [...mine, ...official] };
|
|
1025
1050
|
});
|
|
1026
1051
|
|
|
1027
|
-
|
|
1028
|
-
const { name, arguments: args = {} } = req.params;
|
|
1052
|
+
const callTool = async (name, args) => {
|
|
1029
1053
|
const t = own.get(name);
|
|
1030
1054
|
if (t) {
|
|
1031
1055
|
const parsed = t.schema.safeParse(args);
|
|
1032
1056
|
if (!parsed.success) return failure(`INVALID_ARGUMENTS(${name}): ${parsed.error.issues.map((i) => `${i.path.join('.') || '(root)'} ${i.message}`).join('; ')}`);
|
|
1033
1057
|
try {
|
|
1034
|
-
|
|
1058
|
+
let res = await t.run(parsed.data);
|
|
1059
|
+
if (t.refs && !res.isError) res = { ...res, content: res.content.map((c) => (c.type === 'text' ? { ...c, text: JSON.stringify(withRefs(JSON.parse(c.text), d.refs), null, 2) } : c)) };
|
|
1060
|
+
return d.spill.apply(name, res);
|
|
1035
1061
|
} catch (e) {
|
|
1036
1062
|
return failure(e);
|
|
1037
1063
|
}
|
|
@@ -1049,6 +1075,36 @@ export function createServer(deps = {}) {
|
|
|
1049
1075
|
if (e instanceof McpError) return failure(`OFFICIAL_TOOL_ERROR(${name}): ${e.message}`);
|
|
1050
1076
|
return failure(`OFFICIAL_MCP_UNAVAILABLE(${name}): ${e.message};确认像塑已启动(${d.official.url})`);
|
|
1051
1077
|
}
|
|
1078
|
+
};
|
|
1079
|
+
|
|
1080
|
+
// While a call runs, a client that asked for progress gets a beat every progressMs, so long calls
|
|
1081
|
+
// (frames over seconds, waiting for checks) are not ended as idle.
|
|
1082
|
+
server.setRequestHandler(CallToolRequestSchema, async (req, extra) => {
|
|
1083
|
+
const { name, arguments: args = {} } = req.params;
|
|
1084
|
+
const token = req.params._meta?.progressToken;
|
|
1085
|
+
const started = Date.now();
|
|
1086
|
+
let beats = 0;
|
|
1087
|
+
const timer =
|
|
1088
|
+
token === undefined
|
|
1089
|
+
? null
|
|
1090
|
+
: setInterval(() => {
|
|
1091
|
+
beats += 1;
|
|
1092
|
+
extra
|
|
1093
|
+
.sendNotification({ method: 'notifications/progress', params: { progressToken: token, progress: beats, message: `${name}: ${Math.round((Date.now() - started) / 1000)} s` } })
|
|
1094
|
+
.catch(() => {});
|
|
1095
|
+
}, d.progressMs);
|
|
1096
|
+
let result;
|
|
1097
|
+
let error;
|
|
1098
|
+
try {
|
|
1099
|
+
result = await callTool(name, args);
|
|
1100
|
+
return result;
|
|
1101
|
+
} catch (e) {
|
|
1102
|
+
error = String(e?.message ?? e);
|
|
1103
|
+
throw e;
|
|
1104
|
+
} finally {
|
|
1105
|
+
clearInterval(timer);
|
|
1106
|
+
d.callLog.call({ tool: name, ms: Date.now() - started, result, error, progress: token === undefined ? 'none' : beats });
|
|
1107
|
+
}
|
|
1052
1108
|
});
|
|
1053
1109
|
|
|
1054
1110
|
return server;
|
|
@@ -1059,6 +1115,17 @@ if (process.argv[1] && fileURLToPath(import.meta.url) === fs.realpathSync(proces
|
|
|
1059
1115
|
official.watch();
|
|
1060
1116
|
// The official-MCP watcher keeps the event loop alive, so a closed client would leave this process
|
|
1061
1117
|
// running forever.
|
|
1062
|
-
|
|
1063
|
-
|
|
1118
|
+
const callLog = new CallLog();
|
|
1119
|
+
process.stdin.on('end', () => {
|
|
1120
|
+
callLog.write({ event: 'client_closed' });
|
|
1121
|
+
process.exit(0);
|
|
1122
|
+
});
|
|
1123
|
+
for (const kind of ['uncaughtException', 'unhandledRejection']) {
|
|
1124
|
+
process.on(kind, (e) => {
|
|
1125
|
+
callLog.write({ event: kind, error: String(e?.stack ?? e).slice(0, 2000) });
|
|
1126
|
+
process.exit(1);
|
|
1127
|
+
});
|
|
1128
|
+
}
|
|
1129
|
+
callLog.write({ event: 'started' });
|
|
1130
|
+
await createServer({ official, callLog }).connect(new StdioServerTransport());
|
|
1064
1131
|
}
|