dsh-novel-image 0.0.0 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +116 -0
- package/README.md +137 -6
- package/client.js +1059 -0
- package/docs/DETAIL.md +113 -0
- package/icon.svg +8 -0
- package/index.js +875 -11
- package/lib/assets/store.mjs +173 -0
- package/lib/canon/extract.mjs +333 -0
- package/lib/canon/merge.mjs +44 -0
- package/lib/canon/store.mjs +188 -0
- package/lib/core/errors.mjs +22 -0
- package/lib/core/ids.mjs +9 -0
- package/lib/core/storage.mjs +113 -0
- package/lib/cover/plan.mjs +64 -0
- package/lib/critique/parse.mjs +112 -0
- package/lib/critique/prompt.mjs +78 -0
- package/lib/critique/revision.mjs +96 -0
- package/lib/generate/comfyui.mjs +95 -0
- package/lib/generate/incremental.mjs +36 -0
- package/lib/generate/limits.mjs +43 -0
- package/lib/generate/mock.mjs +29 -0
- package/lib/generate/openai.mjs +138 -0
- package/lib/generate/state.mjs +29 -0
- package/lib/generate/store.mjs +186 -0
- package/lib/generate/workflow.mjs +76 -0
- package/lib/generate/workflows.mjs +59 -0
- package/lib/prompt/compile.mjs +390 -0
- package/lib/prompt/platforms.mjs +102 -0
- package/lib/prompt/profiles.mjs +109 -0
- package/lib/remote-contract.js +81 -0
- package/lib/remote.js +403 -0
- package/lib/schema.mjs +213 -0
- package/lib/service.mjs +1180 -0
- package/lib/source/import.mjs +191 -0
- package/lib/styles/prompt.mjs +54 -0
- package/lib/styles/store.mjs +79 -0
- package/lib/typert-bind.js +28 -0
- package/locale/en.json +1 -0
- package/locale/zh-CN.json +1 -0
- package/package.json +82 -11
package/index.js
CHANGED
|
@@ -1,11 +1,875 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
/**
|
|
2
|
+
* dsh-novel-image — Host half.
|
|
3
|
+
*
|
|
4
|
+
* Registers model-facing tools. All persistence lives under
|
|
5
|
+
* `<workspace>/.dsh-novel-image/`; this plugin never writes another novel
|
|
6
|
+
* plugin's directory and never trains or calls an image model.
|
|
7
|
+
*/
|
|
8
|
+
import { ImageService } from "./lib/service.mjs";
|
|
9
|
+
import { listProfiles } from "./lib/prompt/profiles.mjs";
|
|
10
|
+
import { PLATFORM_PRESETS } from "./lib/prompt/platforms.mjs";
|
|
11
|
+
|
|
12
|
+
export const name = "novel-image";
|
|
13
|
+
export const inject = ["tools", "llm", "agentDefaultModel", "attachments", "web"];
|
|
14
|
+
|
|
15
|
+
const output = {
|
|
16
|
+
schema: { type: "object", additionalProperties: true },
|
|
17
|
+
render: (_args, value) => [
|
|
18
|
+
{ type: "text", text: typeof value === "string" ? value : JSON.stringify(value, null, 2) },
|
|
19
|
+
],
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const dirParam = {
|
|
23
|
+
type: "string",
|
|
24
|
+
description: "工作区根目录(绝对路径)。插件只在这个目录下的 .dsh-novel-image/ 读写。",
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
let hostCtx = null;
|
|
28
|
+
|
|
29
|
+
function fail(code, message) {
|
|
30
|
+
const error = new Error(message);
|
|
31
|
+
error.code = code;
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async function requireDir(args, exec) {
|
|
36
|
+
const raw = args?.dir ?? exec?.cwd;
|
|
37
|
+
if (typeof raw !== "string" || !raw.trim()) fail("bad-dir", "dir 不能为空(传工作区绝对路径)");
|
|
38
|
+
return raw;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function serviceFor(args, exec) {
|
|
42
|
+
const dir = await requireDir(args, exec);
|
|
43
|
+
const selection = args?.provider && args?.model ? { provider: String(args.provider), model: String(args.model) } : undefined;
|
|
44
|
+
const service = new ImageService({ dir, ctx: hostCtx, selection });
|
|
45
|
+
await service.init();
|
|
46
|
+
return service;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function guarded(fn) {
|
|
50
|
+
return async (args, deps, exec) => {
|
|
51
|
+
try {
|
|
52
|
+
return await fn(args ?? {}, exec);
|
|
53
|
+
} catch (error) {
|
|
54
|
+
return { error: error?.code ?? "image-failed", message: error instanceof Error ? error.message : String(error) };
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const tools = [
|
|
60
|
+
{
|
|
61
|
+
name: "image_import_text",
|
|
62
|
+
description:
|
|
63
|
+
"导入一本小说正文到 dsh-novel-image:切章、记录 hash、按剧透边界建立初版视觉设定(确定性抽取,可选角色名)。只写 .dsh-novel-image/,不改正文。",
|
|
64
|
+
parameters: {
|
|
65
|
+
type: "object",
|
|
66
|
+
properties: {
|
|
67
|
+
dir: dirParam,
|
|
68
|
+
title: { type: "string", description: "作品名;缺省用“未命名作品”" },
|
|
69
|
+
text: { type: "string", description: "小说正文(TXT/MD 文本)" },
|
|
70
|
+
maxChapterIndex: { type: "number", description: "剧透边界:只处理到第 N 章;缺省为全部章节" },
|
|
71
|
+
characterNames: {
|
|
72
|
+
type: "array",
|
|
73
|
+
items: { type: "string" },
|
|
74
|
+
description: "要抽取视觉锚点的角色名;缺省自动猜(可能不准,建议显式给)",
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
required: ["dir", "text"],
|
|
78
|
+
additionalProperties: false,
|
|
79
|
+
},
|
|
80
|
+
output,
|
|
81
|
+
timeoutMs: 120000,
|
|
82
|
+
execute: guarded(async (args, exec) => {
|
|
83
|
+
const service = await serviceFor(args, exec);
|
|
84
|
+
return service.importText({
|
|
85
|
+
title: args.title,
|
|
86
|
+
text: args.text,
|
|
87
|
+
maxChapterIndex: args.maxChapterIndex,
|
|
88
|
+
characterNames: args.characterNames,
|
|
89
|
+
});
|
|
90
|
+
}),
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: "image_list_works",
|
|
94
|
+
description: "列出 .dsh-novel-image/ 里已导入的作品(workId、标题、章节数、剧透边界)。只读本包。",
|
|
95
|
+
parameters: { type: "object", properties: { dir: dirParam }, required: ["dir"], additionalProperties: false },
|
|
96
|
+
output,
|
|
97
|
+
execute: guarded(async (args, exec) => {
|
|
98
|
+
const service = await serviceFor(args, exec);
|
|
99
|
+
return { works: await service.listWorks() };
|
|
100
|
+
}),
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: "image_get_work",
|
|
104
|
+
description: "读取一本作品的章节清单与剧透边界;不返回全文。",
|
|
105
|
+
parameters: {
|
|
106
|
+
type: "object",
|
|
107
|
+
properties: { dir: dirParam, workId: { type: "string" } },
|
|
108
|
+
required: ["dir", "workId"],
|
|
109
|
+
additionalProperties: false,
|
|
110
|
+
},
|
|
111
|
+
output,
|
|
112
|
+
execute: guarded(async (args, exec) => {
|
|
113
|
+
const service = await serviceFor(args, exec);
|
|
114
|
+
return service.getWork(String(args.workId));
|
|
115
|
+
}),
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
name: "image_extract_canon",
|
|
119
|
+
description:
|
|
120
|
+
"从正文重新抽取视觉设定:每条锚点带章节+原文引文;可选 useLlm 做补充(引文仍会校验)。导入时已生成初版,重新抽取必须带当前 canon.revision 的 expectedRevision,避免静默覆盖作者锁定项。",
|
|
121
|
+
parameters: {
|
|
122
|
+
type: "object",
|
|
123
|
+
properties: {
|
|
124
|
+
dir: dirParam,
|
|
125
|
+
workId: { type: "string" },
|
|
126
|
+
characterNames: { type: "array", items: { type: "string" } },
|
|
127
|
+
useLlm: { type: "boolean", description: "是否用当前模型补充抽取;默认 false,只用确定性规则" },
|
|
128
|
+
expectedRevision: { type: "number", description: "已有 canon 的当前 revision;首次抽取可省略" },
|
|
129
|
+
maxChapterIndex: { type: "number" },
|
|
130
|
+
provider: { type: "string" },
|
|
131
|
+
model: { type: "string" },
|
|
132
|
+
},
|
|
133
|
+
required: ["dir", "workId"],
|
|
134
|
+
additionalProperties: false,
|
|
135
|
+
},
|
|
136
|
+
output,
|
|
137
|
+
timeoutMs: 180000,
|
|
138
|
+
execute: guarded(async (args, exec) => {
|
|
139
|
+
const service = await serviceFor(args, exec);
|
|
140
|
+
return service.extractCanon({
|
|
141
|
+
workId: String(args.workId),
|
|
142
|
+
characterNames: args.characterNames,
|
|
143
|
+
useLlm: args.useLlm === true,
|
|
144
|
+
expectedRevision: args.expectedRevision,
|
|
145
|
+
maxChapterIndex: args.maxChapterIndex,
|
|
146
|
+
});
|
|
147
|
+
}),
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: "image_get_canon",
|
|
151
|
+
description: "读取视觉设定:角色、锚点(value/evidence/confidence/status)、场景、风格、封面 brief。",
|
|
152
|
+
parameters: {
|
|
153
|
+
type: "object",
|
|
154
|
+
properties: { dir: dirParam, workId: { type: "string" } },
|
|
155
|
+
required: ["dir", "workId"],
|
|
156
|
+
additionalProperties: false,
|
|
157
|
+
},
|
|
158
|
+
output,
|
|
159
|
+
execute: guarded(async (args, exec) => {
|
|
160
|
+
const service = await serviceFor(args, exec);
|
|
161
|
+
return service.getCanon(String(args.workId));
|
|
162
|
+
}),
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
name: "image_update_anchor",
|
|
166
|
+
description:
|
|
167
|
+
"作者对一条视觉锚点做决定:status=draft/confirmed/locked/rejected;value 改写;fromChapter/toChapter 章节备注。锁定锚点要解锁/改写必须显式 unlock/force。带 expectedRevision 防并发覆盖。",
|
|
168
|
+
parameters: {
|
|
169
|
+
type: "object",
|
|
170
|
+
properties: {
|
|
171
|
+
dir: dirParam,
|
|
172
|
+
workId: { type: "string" },
|
|
173
|
+
anchorId: { type: "string" },
|
|
174
|
+
expectedRevision: { type: "number" },
|
|
175
|
+
patch: {
|
|
176
|
+
type: "object",
|
|
177
|
+
description: "可含 status/value/confidence/fromChapter/toChapter/note;解锁用 unlock:true,改写锁定值用 force:true",
|
|
178
|
+
additionalProperties: true,
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
required: ["dir", "workId", "anchorId", "patch"],
|
|
182
|
+
additionalProperties: false,
|
|
183
|
+
},
|
|
184
|
+
output,
|
|
185
|
+
execute: guarded(async (args, exec) => {
|
|
186
|
+
const service = await serviceFor(args, exec);
|
|
187
|
+
return service.updateAnchor({
|
|
188
|
+
workId: String(args.workId),
|
|
189
|
+
anchorId: String(args.anchorId),
|
|
190
|
+
patch: args.patch ?? {},
|
|
191
|
+
expectedRevision: args.expectedRevision,
|
|
192
|
+
});
|
|
193
|
+
}),
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
name: "image_compile_prompt",
|
|
197
|
+
description:
|
|
198
|
+
"把视觉设定编译成提示词包:task=cover/portrait/scene/sheet;profileId=natural-zh/natural-en/sd-tags/midjourney/comfyui/generic;可选 characterIds/chapterIndex/platformId/styleId。只编译,不出图。",
|
|
199
|
+
parameters: {
|
|
200
|
+
type: "object",
|
|
201
|
+
properties: {
|
|
202
|
+
dir: dirParam,
|
|
203
|
+
workId: { type: "string" },
|
|
204
|
+
task: { type: "string", enum: ["cover", "portrait", "scene", "sheet"] },
|
|
205
|
+
profileId: { type: "string", description: "工具 profile;见 image_list_profiles" },
|
|
206
|
+
characterIds: { type: "array", items: { type: "string" } },
|
|
207
|
+
chapterIndex: { type: "number", description: "目标章节;用于剧透边界与章节变体备注" },
|
|
208
|
+
platformId: { type: "string", description: "封面平台预设;见 image_platform_presets" },
|
|
209
|
+
includeDraft: { type: "boolean", description: "是否把 draft 锚点也编进去;默认 false" },
|
|
210
|
+
styleId: { type: "string", description: "套用哪个已学习的风格档案;见 image_list_styles" },
|
|
211
|
+
},
|
|
212
|
+
required: ["dir", "workId", "task", "profileId"],
|
|
213
|
+
additionalProperties: false,
|
|
214
|
+
},
|
|
215
|
+
output,
|
|
216
|
+
execute: guarded(async (args, exec) => {
|
|
217
|
+
const service = await serviceFor(args, exec);
|
|
218
|
+
return service.compile({
|
|
219
|
+
workId: String(args.workId),
|
|
220
|
+
task: String(args.task),
|
|
221
|
+
profileId: String(args.profileId),
|
|
222
|
+
characterIds: args.characterIds,
|
|
223
|
+
chapterIndex: args.chapterIndex,
|
|
224
|
+
platformId: args.platformId,
|
|
225
|
+
includeDraft: args.includeDraft === true,
|
|
226
|
+
styleId: args.styleId,
|
|
227
|
+
});
|
|
228
|
+
}),
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
name: "image_export_prompt",
|
|
232
|
+
description: "导出提示词包:format=text(粘贴块)/markdown(人看)/json(存档)。",
|
|
233
|
+
parameters: {
|
|
234
|
+
type: "object",
|
|
235
|
+
properties: {
|
|
236
|
+
dir: dirParam,
|
|
237
|
+
workId: { type: "string" },
|
|
238
|
+
packId: { type: "string" },
|
|
239
|
+
format: { type: "string", enum: ["text", "markdown", "json"] },
|
|
240
|
+
},
|
|
241
|
+
required: ["dir", "workId", "packId"],
|
|
242
|
+
additionalProperties: false,
|
|
243
|
+
},
|
|
244
|
+
output,
|
|
245
|
+
execute: guarded(async (args, exec) => {
|
|
246
|
+
const service = await serviceFor(args, exec);
|
|
247
|
+
return service.exportPack({ workId: String(args.workId), packId: String(args.packId), format: args.format });
|
|
248
|
+
}),
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
name: "image_import_draft",
|
|
252
|
+
description:
|
|
253
|
+
"导入外部 AI 生成的首稿(path 或 dataBase64 + mime),存到本作品 drafts/。导入后可用 image_critique_draft 读图对照视觉设定。",
|
|
254
|
+
parameters: {
|
|
255
|
+
type: "object",
|
|
256
|
+
properties: {
|
|
257
|
+
dir: dirParam,
|
|
258
|
+
workId: { type: "string" },
|
|
259
|
+
packId: { type: "string", description: "这张首稿对应的提示词包;可稍后补" },
|
|
260
|
+
path: { type: "string", description: "本地图片路径(PNG/JPEG/WebP/GIF)" },
|
|
261
|
+
dataBase64: { type: "string", description: "图片 base64(可带 data: 前缀)" },
|
|
262
|
+
mime: { type: "string", description: "image/png 等;给 path 时可省略" },
|
|
263
|
+
},
|
|
264
|
+
required: ["dir", "workId"],
|
|
265
|
+
additionalProperties: false,
|
|
266
|
+
},
|
|
267
|
+
output,
|
|
268
|
+
timeoutMs: 60000,
|
|
269
|
+
execute: guarded(async (args, exec) => {
|
|
270
|
+
const service = await serviceFor(args, exec);
|
|
271
|
+
return service.importDraft({
|
|
272
|
+
workId: String(args.workId),
|
|
273
|
+
packId: args.packId ? String(args.packId) : "",
|
|
274
|
+
path: args.path,
|
|
275
|
+
dataBase64: args.dataBase64,
|
|
276
|
+
mime: args.mime,
|
|
277
|
+
});
|
|
278
|
+
}),
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
name: "image_critique_draft",
|
|
282
|
+
description:
|
|
283
|
+
"读一张首稿,对照视觉设定逐条检查锁定/确认锚点,输出 keep/fix/add 与构图/风格/封面检查。需要支持图片输入的模型;不支持会明确报错。",
|
|
284
|
+
parameters: {
|
|
285
|
+
type: "object",
|
|
286
|
+
properties: {
|
|
287
|
+
dir: dirParam,
|
|
288
|
+
workId: { type: "string" },
|
|
289
|
+
draftId: { type: "string" },
|
|
290
|
+
packId: { type: "string", description: "缺省用首稿导入时关联的 pack" },
|
|
291
|
+
provider: { type: "string" },
|
|
292
|
+
model: { type: "string" },
|
|
293
|
+
},
|
|
294
|
+
required: ["dir", "workId", "draftId"],
|
|
295
|
+
additionalProperties: false,
|
|
296
|
+
},
|
|
297
|
+
output,
|
|
298
|
+
timeoutMs: 180000,
|
|
299
|
+
execute: guarded(async (args, exec) => {
|
|
300
|
+
const service = await serviceFor(args, exec);
|
|
301
|
+
return service.critiqueDraft({
|
|
302
|
+
workId: String(args.workId),
|
|
303
|
+
draftId: String(args.draftId),
|
|
304
|
+
packId: args.packId ? String(args.packId) : undefined,
|
|
305
|
+
selection: args.provider && args.model ? { provider: String(args.provider), model: String(args.model) } : undefined,
|
|
306
|
+
});
|
|
307
|
+
}),
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
name: "image_revise_draft",
|
|
311
|
+
description:
|
|
312
|
+
"把审稿报告变成两版修改提示词:edit(保留构图改局部)与 regenerate(改完整提示词重抽)。只生成文字,不调用生图。",
|
|
313
|
+
parameters: {
|
|
314
|
+
type: "object",
|
|
315
|
+
properties: {
|
|
316
|
+
dir: dirParam,
|
|
317
|
+
workId: { type: "string" },
|
|
318
|
+
critiqueId: { type: "string" },
|
|
319
|
+
packId: { type: "string" },
|
|
320
|
+
mode: { type: "string", enum: ["edit", "regenerate"] },
|
|
321
|
+
},
|
|
322
|
+
required: ["dir", "workId", "critiqueId"],
|
|
323
|
+
additionalProperties: false,
|
|
324
|
+
},
|
|
325
|
+
output,
|
|
326
|
+
execute: guarded(async (args, exec) => {
|
|
327
|
+
const service = await serviceFor(args, exec);
|
|
328
|
+
return service.reviseDraft({
|
|
329
|
+
workId: String(args.workId),
|
|
330
|
+
critiqueId: String(args.critiqueId),
|
|
331
|
+
packId: args.packId ? String(args.packId) : undefined,
|
|
332
|
+
mode: args.mode,
|
|
333
|
+
});
|
|
334
|
+
}),
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
name: "image_import_asset",
|
|
338
|
+
description:
|
|
339
|
+
"导入一张角色参考图/约稿图/风格图到资产库(path 或 dataBase64),可绑定角色与用途;绑定后编译提示词包会自动生成参考图槽位。",
|
|
340
|
+
parameters: {
|
|
341
|
+
type: "object",
|
|
342
|
+
properties: {
|
|
343
|
+
dir: dirParam,
|
|
344
|
+
workId: { type: "string" },
|
|
345
|
+
path: { type: "string" },
|
|
346
|
+
dataBase64: { type: "string" },
|
|
347
|
+
mime: { type: "string" },
|
|
348
|
+
characterId: { type: "string", description: "绑定到哪个角色;可空" },
|
|
349
|
+
kind: { type: "string", enum: ["face", "full-body", "outfit", "style", "scene", "other"], description: "参考图用途;默认 other" },
|
|
350
|
+
source: { type: "string", enum: ["user", "draft", "external"], description: "来源;默认 user" },
|
|
351
|
+
license: { type: "string", description: "来源/许可说明(作者自填)" },
|
|
352
|
+
note: { type: "string" },
|
|
353
|
+
packId: { type: "string" },
|
|
354
|
+
},
|
|
355
|
+
required: ["dir", "workId"],
|
|
356
|
+
additionalProperties: false,
|
|
357
|
+
},
|
|
358
|
+
output,
|
|
359
|
+
timeoutMs: 60000,
|
|
360
|
+
execute: guarded(async (args, exec) => {
|
|
361
|
+
const service = await serviceFor(args, exec);
|
|
362
|
+
return service.importAsset({
|
|
363
|
+
workId: String(args.workId),
|
|
364
|
+
path: args.path,
|
|
365
|
+
dataBase64: args.dataBase64,
|
|
366
|
+
mime: args.mime,
|
|
367
|
+
characterId: args.characterId,
|
|
368
|
+
kind: args.kind,
|
|
369
|
+
source: args.source,
|
|
370
|
+
license: args.license,
|
|
371
|
+
note: args.note,
|
|
372
|
+
packId: args.packId,
|
|
373
|
+
});
|
|
374
|
+
}),
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
name: "image_list_assets",
|
|
378
|
+
description: "列出某作品的资产库(参考图/约稿图/风格图),含绑定角色、用途、是否已设为参考。",
|
|
379
|
+
parameters: {
|
|
380
|
+
type: "object",
|
|
381
|
+
properties: { dir: dirParam, workId: { type: "string" } },
|
|
382
|
+
required: ["dir", "workId"],
|
|
383
|
+
additionalProperties: false,
|
|
384
|
+
},
|
|
385
|
+
output,
|
|
386
|
+
execute: guarded(async (args, exec) => {
|
|
387
|
+
const service = await serviceFor(args, exec);
|
|
388
|
+
return service.listAssets(String(args.workId));
|
|
389
|
+
}),
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
name: "image_set_asset_reference",
|
|
393
|
+
description: "把一张资产设为/取消角色参考图,可改绑定角色、用途与权重。",
|
|
394
|
+
parameters: {
|
|
395
|
+
type: "object",
|
|
396
|
+
properties: {
|
|
397
|
+
dir: dirParam,
|
|
398
|
+
workId: { type: "string" },
|
|
399
|
+
assetId: { type: "string" },
|
|
400
|
+
characterId: { type: "string" },
|
|
401
|
+
kind: { type: "string", enum: ["face", "full-body", "outfit", "style", "scene", "other"] },
|
|
402
|
+
reference: { type: "boolean" },
|
|
403
|
+
weight: { type: "number", description: "0–1;默认 1" },
|
|
404
|
+
license: { type: "string" },
|
|
405
|
+
note: { type: "string" },
|
|
406
|
+
},
|
|
407
|
+
required: ["dir", "workId", "assetId"],
|
|
408
|
+
additionalProperties: false,
|
|
409
|
+
},
|
|
410
|
+
output,
|
|
411
|
+
execute: guarded(async (args, exec) => {
|
|
412
|
+
const service = await serviceFor(args, exec);
|
|
413
|
+
return service.setAssetReference({
|
|
414
|
+
workId: String(args.workId),
|
|
415
|
+
assetId: String(args.assetId),
|
|
416
|
+
characterId: args.characterId,
|
|
417
|
+
kind: args.kind,
|
|
418
|
+
reference: args.reference,
|
|
419
|
+
weight: args.weight,
|
|
420
|
+
license: args.license,
|
|
421
|
+
note: args.note,
|
|
422
|
+
});
|
|
423
|
+
}),
|
|
424
|
+
},
|
|
425
|
+
{
|
|
426
|
+
name: "image_list_critiques",
|
|
427
|
+
description: "列出某作品的首稿审稿历史(可按 packId/draftId 过滤),用于回改对比。",
|
|
428
|
+
parameters: {
|
|
429
|
+
type: "object",
|
|
430
|
+
properties: {
|
|
431
|
+
dir: dirParam,
|
|
432
|
+
workId: { type: "string" },
|
|
433
|
+
packId: { type: "string" },
|
|
434
|
+
draftId: { type: "string" },
|
|
435
|
+
limit: { type: "number" },
|
|
436
|
+
},
|
|
437
|
+
required: ["dir", "workId"],
|
|
438
|
+
additionalProperties: false,
|
|
439
|
+
},
|
|
440
|
+
output,
|
|
441
|
+
execute: guarded(async (args, exec) => {
|
|
442
|
+
const service = await serviceFor(args, exec);
|
|
443
|
+
return service.listCritiques({
|
|
444
|
+
workId: String(args.workId),
|
|
445
|
+
packId: args.packId ? String(args.packId) : undefined,
|
|
446
|
+
draftId: args.draftId ? String(args.draftId) : undefined,
|
|
447
|
+
limit: args.limit,
|
|
448
|
+
});
|
|
449
|
+
}),
|
|
450
|
+
},
|
|
451
|
+
{
|
|
452
|
+
name: "image_compare_critiques",
|
|
453
|
+
description: "对比两次读图审稿:哪些问题已解决、哪些还在、哪些新引入。用于 v1→v2 回改验收。",
|
|
454
|
+
parameters: {
|
|
455
|
+
type: "object",
|
|
456
|
+
properties: {
|
|
457
|
+
dir: dirParam,
|
|
458
|
+
workId: { type: "string" },
|
|
459
|
+
baseCritiqueId: { type: "string" },
|
|
460
|
+
nextCritiqueId: { type: "string" },
|
|
461
|
+
},
|
|
462
|
+
required: ["dir", "workId", "baseCritiqueId", "nextCritiqueId"],
|
|
463
|
+
additionalProperties: false,
|
|
464
|
+
},
|
|
465
|
+
output,
|
|
466
|
+
execute: guarded(async (args, exec) => {
|
|
467
|
+
const service = await serviceFor(args, exec);
|
|
468
|
+
return service.compareCritiques({
|
|
469
|
+
workId: String(args.workId),
|
|
470
|
+
baseCritiqueId: String(args.baseCritiqueId),
|
|
471
|
+
nextCritiqueId: String(args.nextCritiqueId),
|
|
472
|
+
});
|
|
473
|
+
}),
|
|
474
|
+
},
|
|
475
|
+
{
|
|
476
|
+
name: "image_analyze_style",
|
|
477
|
+
description:
|
|
478
|
+
"让视觉模型分析一张参考图(封面/人物设计),提取可复用的风格与布局档案(媒介、配色、构图、标题区、排版、光影、正向/负向前缀)。这是推理时风格提取,不训练模型。",
|
|
479
|
+
parameters: {
|
|
480
|
+
type: "object",
|
|
481
|
+
properties: {
|
|
482
|
+
dir: dirParam,
|
|
483
|
+
workId: { type: "string" },
|
|
484
|
+
assetId: { type: "string" },
|
|
485
|
+
name: { type: "string", description: "风格档案名;可空" },
|
|
486
|
+
kind: { type: "string", enum: ["cover", "character"], description: "参考图类型;默认 cover" },
|
|
487
|
+
},
|
|
488
|
+
required: ["dir", "workId", "assetId"],
|
|
489
|
+
additionalProperties: false,
|
|
490
|
+
},
|
|
491
|
+
output,
|
|
492
|
+
timeoutMs: 180000,
|
|
493
|
+
execute: guarded(async (args, exec) => {
|
|
494
|
+
const service = await serviceFor(args, exec);
|
|
495
|
+
return service.analyzeStyle({
|
|
496
|
+
workId: String(args.workId),
|
|
497
|
+
assetId: String(args.assetId),
|
|
498
|
+
name: args.name,
|
|
499
|
+
kind: args.kind,
|
|
500
|
+
});
|
|
501
|
+
}),
|
|
502
|
+
},
|
|
503
|
+
{
|
|
504
|
+
name: "image_list_styles",
|
|
505
|
+
description: "列出某作品已学习的风格档案(来源参考图、媒介、配色、构图、排版、正负向前缀)。",
|
|
506
|
+
parameters: {
|
|
507
|
+
type: "object",
|
|
508
|
+
properties: { dir: dirParam, workId: { type: "string" } },
|
|
509
|
+
required: ["dir", "workId"],
|
|
510
|
+
additionalProperties: false,
|
|
511
|
+
},
|
|
512
|
+
output,
|
|
513
|
+
execute: guarded(async (args, exec) => {
|
|
514
|
+
const service = await serviceFor(args, exec);
|
|
515
|
+
return service.listStyles(String(args.workId));
|
|
516
|
+
}),
|
|
517
|
+
},
|
|
518
|
+
{
|
|
519
|
+
name: "image_search_references",
|
|
520
|
+
description: "联网搜索封面/人物设计参考(返回标题、链接、摘要);不自动下载图片。找到后保存到本地再用 image_import_asset 导入。",
|
|
521
|
+
parameters: {
|
|
522
|
+
type: "object",
|
|
523
|
+
properties: {
|
|
524
|
+
query: { type: "string" },
|
|
525
|
+
maxResults: { type: "number", description: "1–10;默认 8" },
|
|
526
|
+
},
|
|
527
|
+
required: ["query"],
|
|
528
|
+
additionalProperties: false,
|
|
529
|
+
},
|
|
530
|
+
output,
|
|
531
|
+
timeoutMs: 60000,
|
|
532
|
+
execute: guarded(async (args, exec) => {
|
|
533
|
+
if (!hostCtx?.web?.search) fail("web-unavailable", "当前宿主没有挂载联网搜索服务");
|
|
534
|
+
const result = await hostCtx.web.search({ query: String(args.query), maxResults: Math.max(1, Math.min(10, Number(args.maxResults ?? 8))) });
|
|
535
|
+
return {
|
|
536
|
+
content: result.content ?? "",
|
|
537
|
+
sources: (result.sources ?? []).map((source) => ({
|
|
538
|
+
url: source.url,
|
|
539
|
+
title: source.title ?? "",
|
|
540
|
+
snippet: source.snippet ?? source.summary ?? "",
|
|
541
|
+
})),
|
|
542
|
+
};
|
|
543
|
+
}),
|
|
544
|
+
},
|
|
545
|
+
{
|
|
546
|
+
name: "image_cover_plan",
|
|
547
|
+
description:
|
|
548
|
+
"生成封面构图方案:平台尺寸、标题安全区、主体位置、缩略图检查、多人/书名过长风险。只给布局建议,不合成图片。",
|
|
549
|
+
parameters: {
|
|
550
|
+
type: "object",
|
|
551
|
+
properties: {
|
|
552
|
+
dir: dirParam,
|
|
553
|
+
workId: { type: "string" },
|
|
554
|
+
platformId: { type: "string", description: "qidian/fanqie/jinjiang/weread/douban/kdp/apple-books" },
|
|
555
|
+
layout: { type: "string", enum: ["top", "bottom", "center", "split"], description: "默认 top" },
|
|
556
|
+
title: { type: "string" },
|
|
557
|
+
author: { type: "string" },
|
|
558
|
+
},
|
|
559
|
+
required: ["dir", "workId"],
|
|
560
|
+
additionalProperties: false,
|
|
561
|
+
},
|
|
562
|
+
output,
|
|
563
|
+
execute: guarded(async (args, exec) => {
|
|
564
|
+
const service = await serviceFor(args, exec);
|
|
565
|
+
return service.coverPlan({
|
|
566
|
+
workId: String(args.workId),
|
|
567
|
+
platformId: args.platformId ? String(args.platformId) : undefined,
|
|
568
|
+
layout: args.layout,
|
|
569
|
+
title: args.title,
|
|
570
|
+
author: args.author,
|
|
571
|
+
});
|
|
572
|
+
}),
|
|
573
|
+
},
|
|
574
|
+
{
|
|
575
|
+
name: "image_add_variant",
|
|
576
|
+
description:
|
|
577
|
+
"给角色增加章节变体(受伤/换装/年龄/伪装/身份揭露):默认复制当前锚点,按 fromChapter–toChapter 生效;激活时同 kind 的 base 锚点被变体替换。",
|
|
578
|
+
parameters: {
|
|
579
|
+
type: "object",
|
|
580
|
+
properties: {
|
|
581
|
+
dir: dirParam,
|
|
582
|
+
workId: { type: "string" },
|
|
583
|
+
characterId: { type: "string" },
|
|
584
|
+
label: { type: "string" },
|
|
585
|
+
fromChapter: { type: "number" },
|
|
586
|
+
toChapter: { type: "number" },
|
|
587
|
+
reason: { type: "string" },
|
|
588
|
+
anchors: { type: "array", items: { type: "object", additionalProperties: true }, description: "可选;不给则复制当前非否决锚点" },
|
|
589
|
+
expectedRevision: { type: "number" },
|
|
590
|
+
},
|
|
591
|
+
required: ["dir", "workId", "characterId", "label", "fromChapter"],
|
|
592
|
+
additionalProperties: false,
|
|
593
|
+
},
|
|
594
|
+
output,
|
|
595
|
+
execute: guarded(async (args, exec) => {
|
|
596
|
+
const service = await serviceFor(args, exec);
|
|
597
|
+
return service.addVariant({
|
|
598
|
+
workId: String(args.workId),
|
|
599
|
+
characterId: String(args.characterId),
|
|
600
|
+
label: String(args.label),
|
|
601
|
+
fromChapter: Number(args.fromChapter),
|
|
602
|
+
toChapter: args.toChapter ? Number(args.toChapter) : undefined,
|
|
603
|
+
reason: args.reason,
|
|
604
|
+
anchors: args.anchors,
|
|
605
|
+
expectedRevision: args.expectedRevision,
|
|
606
|
+
});
|
|
607
|
+
}),
|
|
608
|
+
},
|
|
609
|
+
{
|
|
610
|
+
name: "image_remove_variant",
|
|
611
|
+
description: "删除一个角色章节变体。",
|
|
612
|
+
parameters: {
|
|
613
|
+
type: "object",
|
|
614
|
+
properties: {
|
|
615
|
+
dir: dirParam,
|
|
616
|
+
workId: { type: "string" },
|
|
617
|
+
characterId: { type: "string" },
|
|
618
|
+
variantId: { type: "string" },
|
|
619
|
+
expectedRevision: { type: "number" },
|
|
620
|
+
},
|
|
621
|
+
required: ["dir", "workId", "characterId", "variantId"],
|
|
622
|
+
additionalProperties: false,
|
|
623
|
+
},
|
|
624
|
+
output,
|
|
625
|
+
execute: guarded(async (args, exec) => {
|
|
626
|
+
const service = await serviceFor(args, exec);
|
|
627
|
+
return service.removeVariant({
|
|
628
|
+
workId: String(args.workId),
|
|
629
|
+
characterId: String(args.characterId),
|
|
630
|
+
variantId: String(args.variantId),
|
|
631
|
+
expectedRevision: args.expectedRevision,
|
|
632
|
+
});
|
|
633
|
+
}),
|
|
634
|
+
},
|
|
635
|
+
{
|
|
636
|
+
name: "image_list_providers",
|
|
637
|
+
description: "列出生图后端 profile(mock / ComfyUI / OpenAI 兼容 / manual)。不返回密钥。",
|
|
638
|
+
parameters: { type: "object", properties: { dir: dirParam }, required: ["dir"], additionalProperties: false },
|
|
639
|
+
output,
|
|
640
|
+
execute: guarded(async (args, exec) => {
|
|
641
|
+
const service = await serviceFor(args, exec);
|
|
642
|
+
return { providers: await service.listProviders() };
|
|
643
|
+
}),
|
|
644
|
+
},
|
|
645
|
+
{
|
|
646
|
+
name: "image_save_provider",
|
|
647
|
+
description: "保存生图后端 profile(端点/模型/workflow/参考图能力);不保存明文 Key。凭据引用只能由界面设置,模型工具不能绑定。登记后由 image_submit_job 触发调用。",
|
|
648
|
+
parameters: {
|
|
649
|
+
type: "object",
|
|
650
|
+
properties: {
|
|
651
|
+
dir: dirParam,
|
|
652
|
+
profileId: { type: "string" },
|
|
653
|
+
label: { type: "string" },
|
|
654
|
+
kind: { type: "string", enum: ["mock", "comfyui", "openai-compatible", "manual"] },
|
|
655
|
+
endpoint: { type: "string" },
|
|
656
|
+
model: { type: "string" },
|
|
657
|
+
workflowId: { type: "string" },
|
|
658
|
+
capabilities: { type: "object", additionalProperties: true },
|
|
659
|
+
maxAttempts: { type: "number", description: "1–5;仅 429 自动重试" },
|
|
660
|
+
retryDelayMs: { type: "number", description: "重试间隔,默认 800ms" },
|
|
661
|
+
minIntervalMs: { type: "number", description: "同 provider 最小提交间隔,默认 0" },
|
|
662
|
+
},
|
|
663
|
+
required: ["dir", "kind"],
|
|
664
|
+
additionalProperties: false,
|
|
665
|
+
},
|
|
666
|
+
output,
|
|
667
|
+
execute: guarded(async (args, exec) => {
|
|
668
|
+
if (args.kind === "comfyui" && args.endpoint && !/^http:\/\/(127\.0\.0\.1|localhost|\[::1\])(:|\/|$)/.test(String(args.endpoint))) {
|
|
669
|
+
fail("endpoint-not-allowed", "模型工具只能登记本机 ComfyUI;远程端点请在插件界面配置");
|
|
670
|
+
}
|
|
671
|
+
const service = await serviceFor(args, exec);
|
|
672
|
+
return service.saveProvider(args);
|
|
673
|
+
}),
|
|
674
|
+
},
|
|
675
|
+
{
|
|
676
|
+
name: "image_submit_job",
|
|
677
|
+
description: "把一个提示词包提交给生图后端:mock(离线)、comfyui(/prompt+/history+/view)、openai-compatible(文生图 /v1/images/generations;有参考图时 /v1/images/edits)。真实网络由作者显式配置 provider 后触发。",
|
|
678
|
+
parameters: {
|
|
679
|
+
type: "object",
|
|
680
|
+
properties: {
|
|
681
|
+
dir: dirParam,
|
|
682
|
+
workId: { type: "string" },
|
|
683
|
+
packId: { type: "string" },
|
|
684
|
+
providerId: { type: "string", description: "缺省 mock" },
|
|
685
|
+
},
|
|
686
|
+
required: ["dir", "workId", "packId"],
|
|
687
|
+
additionalProperties: false,
|
|
688
|
+
},
|
|
689
|
+
output,
|
|
690
|
+
timeoutMs: 180000,
|
|
691
|
+
execute: guarded(async (args, exec) => {
|
|
692
|
+
const service = await serviceFor(args, exec);
|
|
693
|
+
return service.submitJob({ workId: String(args.workId), packId: String(args.packId), providerId: args.providerId });
|
|
694
|
+
}),
|
|
695
|
+
},
|
|
696
|
+
{
|
|
697
|
+
name: "image_save_workflow",
|
|
698
|
+
description: "保存 ComfyUI workflow 模板(JSON 节点对象,含 {{positive}}/{{negative}}/{{width}}/{{height}}/{{seed}}/{{ref_image}} 占位符);只存本地,不发网络。",
|
|
699
|
+
parameters: {
|
|
700
|
+
type: "object",
|
|
701
|
+
properties: {
|
|
702
|
+
dir: dirParam,
|
|
703
|
+
workflowId: { type: "string" },
|
|
704
|
+
name: { type: "string" },
|
|
705
|
+
note: { type: "string" },
|
|
706
|
+
workflow: { type: "object", additionalProperties: true },
|
|
707
|
+
},
|
|
708
|
+
required: ["dir", "workflowId", "workflow"],
|
|
709
|
+
additionalProperties: false,
|
|
710
|
+
},
|
|
711
|
+
output,
|
|
712
|
+
execute: guarded(async (args, exec) => {
|
|
713
|
+
const service = await serviceFor(args, exec);
|
|
714
|
+
return service.saveWorkflow(args);
|
|
715
|
+
}),
|
|
716
|
+
},
|
|
717
|
+
{
|
|
718
|
+
name: "image_list_workflows",
|
|
719
|
+
description: "列出已保存的 ComfyUI workflow 模板(不返回完整 JSON)。",
|
|
720
|
+
parameters: { type: "object", properties: { dir: dirParam }, required: ["dir"], additionalProperties: false },
|
|
721
|
+
output,
|
|
722
|
+
execute: guarded(async (args, exec) => {
|
|
723
|
+
const service = await serviceFor(args, exec);
|
|
724
|
+
return service.listWorkflows();
|
|
725
|
+
}),
|
|
726
|
+
},
|
|
727
|
+
{
|
|
728
|
+
name: "image_job_status",
|
|
729
|
+
description: "读取一个生图任务的状态、事件与结果资产。",
|
|
730
|
+
parameters: {
|
|
731
|
+
type: "object",
|
|
732
|
+
properties: { dir: dirParam, workId: { type: "string" }, jobId: { type: "string" } },
|
|
733
|
+
required: ["dir", "workId", "jobId"],
|
|
734
|
+
additionalProperties: false,
|
|
735
|
+
},
|
|
736
|
+
output,
|
|
737
|
+
execute: guarded(async (args, exec) => {
|
|
738
|
+
const service = await serviceFor(args, exec);
|
|
739
|
+
return service.getJob(String(args.workId), String(args.jobId));
|
|
740
|
+
}),
|
|
741
|
+
},
|
|
742
|
+
{
|
|
743
|
+
name: "image_list_jobs",
|
|
744
|
+
description: "列出一部作品的生图任务(按创建时间倒序)。",
|
|
745
|
+
parameters: {
|
|
746
|
+
type: "object",
|
|
747
|
+
properties: { dir: dirParam, workId: { type: "string" } },
|
|
748
|
+
required: ["dir", "workId"],
|
|
749
|
+
additionalProperties: false,
|
|
750
|
+
},
|
|
751
|
+
output,
|
|
752
|
+
execute: guarded(async (args, exec) => {
|
|
753
|
+
const service = await serviceFor(args, exec);
|
|
754
|
+
return service.listJobs(String(args.workId));
|
|
755
|
+
}),
|
|
756
|
+
},
|
|
757
|
+
{
|
|
758
|
+
name: "image_cancel_job",
|
|
759
|
+
description: "取消一个生图任务;先请求远端,无法确认时标 stopped-local,不假装已取消。",
|
|
760
|
+
parameters: {
|
|
761
|
+
type: "object",
|
|
762
|
+
properties: { dir: dirParam, workId: { type: "string" }, jobId: { type: "string" } },
|
|
763
|
+
required: ["dir", "workId", "jobId"],
|
|
764
|
+
additionalProperties: false,
|
|
765
|
+
},
|
|
766
|
+
output,
|
|
767
|
+
execute: guarded(async (args, exec) => {
|
|
768
|
+
const service = await serviceFor(args, exec);
|
|
769
|
+
return service.cancelJob({ workId: String(args.workId), jobId: String(args.jobId) });
|
|
770
|
+
}),
|
|
771
|
+
},
|
|
772
|
+
{
|
|
773
|
+
name: "image_incremental_plan",
|
|
774
|
+
description: "对比新正文与已导入章节 hash,列出新增/修改/删除章节和受影响提示词包;不改数据、不自动重抽。",
|
|
775
|
+
parameters: {
|
|
776
|
+
type: "object",
|
|
777
|
+
properties: {
|
|
778
|
+
dir: dirParam,
|
|
779
|
+
workId: { type: "string" },
|
|
780
|
+
text: { type: "string", description: "更新后的完整正文(TXT/MD 文本)" },
|
|
781
|
+
},
|
|
782
|
+
required: ["dir", "workId", "text"],
|
|
783
|
+
additionalProperties: false,
|
|
784
|
+
},
|
|
785
|
+
output,
|
|
786
|
+
execute: guarded(async (args, exec) => {
|
|
787
|
+
const service = await serviceFor(args, exec);
|
|
788
|
+
return service.incrementalPlan({ workId: String(args.workId), text: String(args.text) });
|
|
789
|
+
}),
|
|
790
|
+
},
|
|
791
|
+
{
|
|
792
|
+
name: "image_apply_incremental",
|
|
793
|
+
description: "确认应用新正文:更新章节/source hash;可选 reextract=true 重抽(锁定/确认锚点与变体保留)。不删除旧资产/pack。",
|
|
794
|
+
parameters: {
|
|
795
|
+
type: "object",
|
|
796
|
+
properties: {
|
|
797
|
+
dir: dirParam,
|
|
798
|
+
workId: { type: "string" },
|
|
799
|
+
text: { type: "string" },
|
|
800
|
+
reextract: { type: "boolean" },
|
|
801
|
+
maxChapterIndex: { type: "number" },
|
|
802
|
+
expectedRevision: { type: "number" },
|
|
803
|
+
},
|
|
804
|
+
required: ["dir", "workId", "text"],
|
|
805
|
+
additionalProperties: false,
|
|
806
|
+
},
|
|
807
|
+
output,
|
|
808
|
+
timeoutMs: 180000,
|
|
809
|
+
execute: guarded(async (args, exec) => {
|
|
810
|
+
const service = await serviceFor(args, exec);
|
|
811
|
+
return service.applyIncremental({
|
|
812
|
+
workId: String(args.workId),
|
|
813
|
+
text: String(args.text),
|
|
814
|
+
reextract: args.reextract === true,
|
|
815
|
+
maxChapterIndex: args.maxChapterIndex,
|
|
816
|
+
expectedRevision: args.expectedRevision,
|
|
817
|
+
});
|
|
818
|
+
}),
|
|
819
|
+
},
|
|
820
|
+
{
|
|
821
|
+
name: "image_retry_job",
|
|
822
|
+
description: "把失败/取消/本地停止的任务按同一 pack/provider 重跑为新 job;原 job 保留审计。",
|
|
823
|
+
parameters: {
|
|
824
|
+
type: "object",
|
|
825
|
+
properties: { dir: dirParam, workId: { type: "string" }, jobId: { type: "string" } },
|
|
826
|
+
required: ["dir", "workId", "jobId"],
|
|
827
|
+
additionalProperties: false,
|
|
828
|
+
},
|
|
829
|
+
output,
|
|
830
|
+
timeoutMs: 180000,
|
|
831
|
+
execute: guarded(async (args, exec) => {
|
|
832
|
+
const service = await serviceFor(args, exec);
|
|
833
|
+
return service.retryJob({ workId: String(args.workId), jobId: String(args.jobId) });
|
|
834
|
+
}),
|
|
835
|
+
},
|
|
836
|
+
{
|
|
837
|
+
name: "image_test_provider",
|
|
838
|
+
description: "测试 provider 可达性/凭据(ComfyUI /system_stats、OpenAI 兼容 /v1/models),不出图。",
|
|
839
|
+
parameters: {
|
|
840
|
+
type: "object",
|
|
841
|
+
properties: { dir: dirParam, providerId: { type: "string" } },
|
|
842
|
+
required: ["dir", "providerId"],
|
|
843
|
+
additionalProperties: false,
|
|
844
|
+
},
|
|
845
|
+
output,
|
|
846
|
+
timeoutMs: 60000,
|
|
847
|
+
execute: guarded(async (args, exec) => {
|
|
848
|
+
const service = await serviceFor(args, exec);
|
|
849
|
+
return service.testProvider({ providerId: String(args.providerId) });
|
|
850
|
+
}),
|
|
851
|
+
},
|
|
852
|
+
{
|
|
853
|
+
name: "image_list_profiles",
|
|
854
|
+
description: "列出内置提示词工具 profile(方言/能力/默认比例);不包含模型版本号。",
|
|
855
|
+
parameters: { type: "object", properties: {}, additionalProperties: false },
|
|
856
|
+
output,
|
|
857
|
+
execute: guarded(async () => ({ profiles: listProfiles() })),
|
|
858
|
+
},
|
|
859
|
+
{
|
|
860
|
+
name: "image_platform_presets",
|
|
861
|
+
description: "列出封面平台预设(尺寸/比例/格式/是否已核实)。",
|
|
862
|
+
parameters: { type: "object", properties: {}, additionalProperties: false },
|
|
863
|
+
output,
|
|
864
|
+
execute: guarded(async () => ({ presets: PLATFORM_PRESETS })),
|
|
865
|
+
},
|
|
866
|
+
];
|
|
867
|
+
|
|
868
|
+
export function apply(ctx) {
|
|
869
|
+
hostCtx = ctx;
|
|
870
|
+
for (const definition of tools) {
|
|
871
|
+
if (typeof ctx.tools?.register !== "function") continue;
|
|
872
|
+
ctx.effect(() => ctx.tools.register(definition));
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
|