dsh-mo-image 1.0.1 → 1.0.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 CHANGED
@@ -1,5 +1,16 @@
1
1
  # 更新日志
2
2
 
3
+ ## v1.0.3
4
+
5
+ - **更新优化:** 设置页中的自动更新按钮UI优化,自动更新时默认使用国内源。
6
+ - **ComfyUI工作流适配优化:**系统将自动识别提示词、尺寸、质量、参考图这类参数。
7
+
8
+ ## v1.0.2
9
+
10
+ - **删除提供商需要二次确认:** 设置页里点行右侧的「删除」不再立刻生效:弹出与「设置 → 对话模型」同源的确认弹窗。
11
+ - **优化官网路径:**进入官网时将直接进入API KEY的获取页面。
12
+ - **新增预设**:新增腾讯云TokenHub预设。
13
+
3
14
  ## v1.0.1
4
15
 
5
16
  - **修复 Stability AI 生图报错。** 使用 Core 生图或 SD3.5 生图、改图时,插件会自动发送接口要求的图片返回格式。已有预设无需重新配置。
package/LICENSE CHANGED
@@ -19,3 +19,37 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
22
+
23
+ Third-party notices
24
+ -------------------
25
+
26
+ dsh-codex-model-effort-selector
27
+
28
+ The Codex-skin geometry (272×104 popover, 30px knob, rail padding), the
29
+ per-level colour ramps (light/dark), the deterministic sparkle/bloom
30
+ distribution, the ⚡ Fast toggle/`fast-mode` class contract, the peak
31
+ gradient/sparkle treatment and several interaction details in `lib/client.js`
32
+ are adapted from dsh-codex-model-effort-selector
33
+ (https://github.com/ABING1111/dsh-codex-model-effort-selector).
34
+
35
+ MIT License
36
+
37
+ Copyright (c) 2026 dsh-codex-model-effort-selector contributors
38
+
39
+ Permission is hereby granted, free of charge, to any person obtaining a copy
40
+ of this software and associated documentation files (the "Software"), to deal
41
+ in the Software without restriction, including without limitation the rights
42
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
43
+ copies of the Software, and to permit persons to whom the Software is
44
+ furnished to do so, subject to the following conditions:
45
+
46
+ The above copyright notice and this permission notice shall be included in all
47
+ copies or substantial portions of the Software.
48
+
49
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
50
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
51
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
52
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
53
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
54
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
55
+ SOFTWARE.
package/README.md CHANGED
@@ -50,16 +50,16 @@ dsh plugin --profile desktop add github:CM-Silence/dsh-mo-image
50
50
 
51
51
  ## 更新
52
52
 
53
- DSH 每次启动会查一次 npm 上的最新版本(`registry.npmjs.org`,不通时退 `registry.npmmirror.com`)。有新版时,设置 → 生图模型 页顶部会出现「有可用更新」:点开能看到版本号和这次改了什么,点「更新」后插件在后台换成新版本,重启 DSH 后生效。
53
+ 插件启动后会从 `registry.npmmirror.com` 检查最新版本。有新版时,设置页的「生图模型」标题旁会显示「有可用更新」。点开可以查看版本号和更新说明,确认后交给 DSH 安装。镜像同步到新版本后才会显示更新提示。
54
54
 
55
55
  更新说明来自包里的 `CHANGELOG.md`(按版本从 jsDelivr / unpkg / npmmirror 读取);那个版本没写说明时,对话框显示「暂无更新说明」。
56
56
 
57
57
  - 用 `link:` 方式安装的开发环境不会自动改文件,点更新只会提示你自己 `git pull`。
58
- - 检测和安装都走 npm:点更新时按 `dsh-mo-image@x.y.z` 的版本规格安装,不依赖 GitHub。从 npm 安装的走 DSH 原生的 `updateBundle`(先卸旧版再装新版,装失败会自动装回旧版);早期用 `github:` 装的会被换成 npm 版——这条「先卸载再装」的路径没有 DSH 的自动回滚,所以 npm 安装失败时会按原来的规格装回去,并明确提示「更新安装失败,已装回原来的版本」;万一连装回也失败,会提示你去插件管理里重装,不会静默失败。
59
- - 没有桌面版的插件管理器时,手动更新:
58
+ - 安装时会把 `registry.npmmirror.com` 作为首选源传给 DSH,并按 `dsh-mo-image@x.y.z` 安装。DSH 仍会按宿主配置处理备用源和回滚。从 npm 安装的插件由 DSH 原生更新。早期从 `github:` 安装的插件会迁移到 npm 版,迁移失败时会尝试恢复原安装。
59
+ - 使用 `dsh web` 时也可以手动更新,把 `web` 换成实际使用的 profile。
60
60
 
61
61
  ~~~bash
62
- dsh plugin --profile desktop add dsh-mo-image
62
+ dsh plugin --profile web add dsh-mo-image --registry=https://registry.npmmirror.com
63
63
  ~~~
64
64
 
65
65
  维护者发版:
@@ -88,6 +88,7 @@ npm run release -- minor --dry-run # 只看会做什么
88
88
  | 显示名称 | 可选;对话里的模型名,留空就用模型 ID |
89
89
 
90
90
  保存后,在对话输入框右侧选择当前生图模型。
91
+ 删除提供商(行右侧的红色「删除」)会先弹确认:用的是设置页那套共用的弹窗原语,标题「删除 X?」、说明里写明会移除配置并清掉已保存的 API 密钥,取消在左、红色删除在右。显示名太长时,标题与按钮里的名字会按显示宽度截断并补省略号(说明那一段仍是全名,方便确认删的是哪一个)。
91
92
 
92
93
  「模型目录」沿用 DSH 对话模型设置页的模型行:拖动手柄(或聚焦手柄后按上下方向键)调整顺序,顺序就是选择器里的顺序;「获取可用模型」会把上游列出的模型连同显示名一起带回来,已加入列表的模型默认勾选,勾选结果就是新的模型列表。
93
94
 
@@ -358,8 +359,10 @@ $DSH_HOME/.credentials.yaml
358
359
  **ComfyUI 工作流与参数表**
359
360
 
360
361
  - 工作流优先级:模型选项里的自定义工作流 > 内置模板(按模型自动选,见上)。自定义工作流支持 `{{prompt}}` / `{{negative_prompt}}` / `{{width}}` / `{{height}}` / `{{seed}}` / `{{model}}` / `{{image}}` 七个占位符,占位符之外的部分原样发送。
361
- - 不写占位符也能用:「解析工作流」会从图里找出采样器、正/负 `CLIPTextEncode`、尺寸、seed、模型、参考图的落点并自动填好映射;映射面板只把手动可能要改的**宽 / 高 / 参考图**列出来(提示词与负面词由工具参数直接写入,seed 与模型是参数表里的普通行)。
362
- - 「解析参数」把工作流里所有原始值输入(例如 `steps`、`cfg`、`sampler_name`、`denoise`)列成候选,勾中即写入「常规」参数表:默认值取当前值、类型按值推断、参数名只是给对话模型看的键。
362
+ - 「解析工作流」自动映射提示词、宽高、可识别的质量档位和唯一的参考图输入。尺寸和质量统一在模型选择器里调整,设为「自动」后可由对话模型选择。未指定时保留工作流已有的值。
363
+ - 多参考图工作流可把图像输入设为 `{{image_1}}`、`{{image_2}}` 等,从 1 连续编号,最多 16 张。把对应节点命名为「主体图」「风格图」等,插件会把用途交给对话模型,按编号顺序传图。同一编号可在多个节点复用,`{{image}}` 仍代表第一张。未标记的图片保留原值。
364
+ - API 格式中接入输出链路的标准 `LoadImage` 可直接用于图生图。自定义节点的上传控件由「解析工作流」根据 ComfyUI 节点定义识别。没有可用参考图入口时,插件会在上传和提交前拒绝图生图。
365
+ - `steps`、`cfg`、`sampler_name`、`denoise`、种子等工作流参数保留在「常规」参数表里,默认沿用工作流原值。
363
366
  - 参数表才是运行时真正写工作流的东西:默认值非空的行随请求写入;清空默认值 = 不碰工作流里的原值;勾了「暴露」的行才出现在给对话模型的参数清单里。行级锁只挡一键配置,不挡手改。
364
367
  - 提示词与负面词不在参数表里;要手控落点就在工作流里写 `{{prompt}}` / `{{negative_prompt}}` 占位符。
365
368
 
@@ -538,7 +541,7 @@ $DSH_HOME/.credentials.yaml
538
541
 
539
542
  每个模型行末尾的折叠箭头打开该模型的选项。**预设来源的提供商箭头照旧在,只是禁用**(云端预设,以及走 OpenAI 兼容字段的本地预设 sd-server / localai / openai-gateway):预设定死了输入与返回,箭头禁用表示「这里本来有东西,只是这份配置不由你改」——删掉它反而会让列表里有的行有箭头、有的没有,看着像漏渲染。剩下两类才真能展开:
540
543
 
541
- - **ComfyUI / A1111 / SwarmUI**:参数归部署端(装了哪个 sampler、模型目录里有哪几个 checkpoint、工作流里有哪些节点),所以留「输入设置」。ComfyUI / A1111 只有「常规」参数表(外加各自的 `enum` 方框):ComfyUI 在表前多一块自定义工作流(JSON 文本框,右上角一个无边框的「插入示例模板」;填了内容后在下方出现有边框的「解析工作流」),参数行由解析产生、不显示「添加参数」;A1111 第一次展开时按内置六行 sdapi 参数预置。尺寸与质量写在 workflow / sdapi 参数里,所以没有尺寸 / 质量 / 参考图块。
544
+ - **ComfyUI / A1111 / SwarmUI**:参数归部署端(装了哪个 sampler、模型目录里有哪几个 checkpoint、工作流里有哪些节点),所以留「输入设置」。ComfyUI / A1111 使用「常规」参数表和枚举方框。ComfyUI 的参数行由工作流解析产生,尺寸和支持的质量档位通过模型选择器写入工作流。A1111 第一次展开时显示六行预置的 sdapi 参数。
542
545
  - **自配的(没有预设来源:自定义 API、中转站、老配置)**:`常规`、`模型`、各 `enum` 方框,再加 `尺寸`、`质量`、`参考图`——请求形状未知,只能用户自己定。
543
546
 
544
547
  **两块折叠区的标题行**:「输入设置」与「输出设置」是同一行结构(两块 details 直接挂在模型行上、同一份内联样式,中间不套容器;标题在左、操作区在右),左边一条基线、右边一条基线,右端的控件落同一条竖线。自配来源和相应的本地部署可同时显示两块。云端预设使用内置请求与返回格式。右端各只放一个控件或一对控件:输入那行是「一键配置」(按钮样式与模型目录的「获取可用模型」是同一个 `linkButton`)加一把整块锁(与输出那行的锁同一个图标按钮),输出那行是锁图标。展开「输入设置」后第一眼就是参数表——原来那条「说明 + 全部解锁」的工具条整行删掉了。
@@ -573,7 +576,7 @@ $DSH_HOME/.credentials.yaml
573
576
  |---|---|---|---|
574
577
  | 云端 / 中转 / 自定义 | `{ name, type, default, description, expose, options?, locked? }` | 请求体里的路径,支持 `a.b.c` 嵌套 | 手填「+ 添加参数」 |
575
578
  | A1111 / Forge / SD.Next | 同上 | sdapi 字段名(`steps`、`cfg_scale`、`sampler_name`…) | 第一次展开时按内置清单摆好六行 |
576
- | ComfyUI | 加 `node` / `input`(落在工作流节点的某个输入),`name` 只是给对话模型看的键 | 工作流里某个节点的某个输入 | 「解析工作流」自动补落点;「解析参数」把所有原始值输入列成候选,勾中即变成表行(默认值 = 当前值、类型按值推断) |
579
+ | ComfyUI | 加 `node` / `input`(落在工作流节点的某个输入),`name` 只是给对话模型看的键 | 工作流里某个节点的某个输入 | 「解析工作流」自动补齐映射和可选工作流参数 |
577
580
 
578
581
  类型只有四个:`text` / `number` / `boolean` / `enum`。`enum` 行不留在主表里——它搬进自己的方框,选项表(显示名 / 值 / 默认 / 删除)就是下拉的数据源。
579
582
 
@@ -699,4 +702,4 @@ Fireworks 和 Novita 的旧配置可以重新从目录添加新版预设以采
699
702
 
700
703
  ## License
701
704
 
702
- MIT。Codex 皮肤的几何、色板与粒子分布改编自 [dsh-codex-model-effort-selector](https://github.com/ABING1111/dsh-codex-model-effort-selector)(MIT),完整许可见 [THIRD-PARTY-NOTICES.md](THIRD-PARTY-NOTICES.md)。
705
+ MIT。Codex 皮肤的几何、色板与粒子分布改编自 [dsh-codex-model-effort-selector](https://github.com/ABING1111/dsh-codex-model-effort-selector)(MIT)。项目和第三方许可见 [LICENSE](LICENSE)。
@@ -1,15 +1,16 @@
1
1
  /**
2
- * OpenAI 家族的三条自拼 body 协议。
2
+ * 使用 OpenAI 风格消息或图片结构的原生协议。
3
3
  *
4
4
  * - openai-responses:Responses API 的 image_generation 工具(图片在 output[].result,裸 base64)
5
5
  * - openrouter-images:OpenRouter 专用 /api/v1/images(data[].b64_json + media_type)
6
6
  * - openai-chat:中转生态的 chat/completions + modalities,响应形态不唯一,要多形态探测
7
+ * - tokenhub-hy-image:腾讯云 TokenHub 的混元 3.5 生图协议,使用 messages 和最终图像帧
7
8
  *
8
9
  * Azure OpenAI 不在这里:它与 `openai-images` 的地址三元组、传输方式、字段模板完全一样,
9
10
  * 只差鉴权方式,所以是 `openai-images` + 提供商字段 `auth.mode: 'api-key'`
10
11
  * (见 lib/adapter-kit.js 的 AUTH_MODES 与 adapters.js 的 LEGACY_PROTOCOL_ALIASES)。
11
12
  *
12
- * 其中这三条自己拼 body 的协议不再持有字段名:prompt / negative /
13
+ * 这些协议的通用字段不硬编码:prompt / negative /
13
14
  * model / n 写在哪,由字段模板(`fieldsFor()` 或协议自带默认模板)说了算,再用
14
15
  * applyFields / promptParts 写进去。
15
16
  * 留在协议里的有两类东西:
@@ -24,6 +25,7 @@ import {
24
25
  import { requestProvider } from '../request-auth.js';
25
26
  import { applyFields, promptParts, resolveFields } from '../field-templates.js';
26
27
  import { outputProfile } from '../output-profiles.js';
28
+ import { TOKENHUB_HY_IMAGE } from '../model-rules.js';
27
29
  // 循环依赖:adapters.js 先 import 本模块、再求值完。fieldsFor 是函数声明(已提升),
28
30
  // 只在 execute() 里调用,所以安全。
29
31
  import { executeBuiltImage, fieldsFor } from '../adapters.js';
@@ -104,6 +106,8 @@ const CHAT_FIELDS = {
104
106
  quality: null
105
107
  };
106
108
 
109
+ const TOKENHUB_HY_PATH = '/wand/hunyuan-image/v35-generation';
110
+
107
111
  /**
108
112
  * OpenRouter 的默认模板(预设有同款):OpenRouter 主机会命中模型字段规则,
109
113
  * 但有人把这条协议挂到别的主机上时规则不命中,兜底不能是空模板。
@@ -234,6 +238,56 @@ export const OPENAI_ADAPTERS = [
234
238
  return executeBuiltImage(kind, this, provider, input, '/images', body, signal, undefined, hooks);
235
239
  }
236
240
  },
241
+ {
242
+ id: 'tokenhub-hy-image',
243
+ label: 'protocol.tokenhub-hy-image',
244
+ acceptsHttpParams: true,
245
+ match: (provider, model) => /^tokenhub(?:-intl)?\.tencentmaas\.(?:com|cn)$/.test(hostOf(provider))
246
+ && (!model || TOKENHUB_HY_IMAGE.test(model)),
247
+ local: false,
248
+ endpoints: { generate: TOKENHUB_HY_PATH, edit: TOKENHUB_HY_PATH },
249
+ routes: { generate: TOKENHUB_HY_PATH, edit: TOKENHUB_HY_PATH, models: '/models' },
250
+ transport: { generate: 'json', edit: 'json' },
251
+ maxN: 1,
252
+ editFields: [],
253
+ output: outputProfile({
254
+ kind: 'json',
255
+ pick: [{ path: 'choices.0.delta.image.url', as: 'url' }],
256
+ maxBytes: 2 * 1024 * 1024,
257
+ emptyMessage: '腾讯云 TokenHub 没有返回最终图片,请在 TokenHub 查看请求状态。'
258
+ }, 'tokenhub-hy-image'),
259
+ async listModelEntries(provider, signal) {
260
+ const response = await requestProvider(joinEndpoint(baseUrlOf(provider), this.routes.models), {
261
+ headers: headersFor(provider, false, null, this), signal
262
+ }, provider, this);
263
+ const payload = await readJsonResponse(response, 5 * 1024 * 1024, provider, this);
264
+ const entries = [];
265
+ for (const item of Array.isArray(payload?.data) ? payload.data : []) {
266
+ const id = String(item?.id || '').trim();
267
+ if (!TOKENHUB_HY_IMAGE.test(id)) continue;
268
+ if (item.status && !['online', 'pre-offline'].includes(item.status)) continue;
269
+ entries.push({ id, name: item.name === id ? '' : item.name });
270
+ }
271
+ return entries;
272
+ },
273
+ async execute(kind, provider, input, signal, hooks) {
274
+ if (!TOKENHUB_HY_IMAGE.test(input.model)) throw new Error('此 TokenHub 协议仅支持混元 Hy-Image-3.5-preview 系列。');
275
+ const fields = fieldsWithDefaults(CHAT_FIELDS, provider, input.model);
276
+ const images = kind === 'edit' ? referenceImages(input) : [];
277
+ if (kind === 'edit' && !images.length) throw new Error('混元图生图需要至少一张参考图。');
278
+ if (images.length > 20 || images.some((image) => image.buffer.length > 20 * 1024 * 1024)) {
279
+ throw new Error('混元图生图最多接受 20 张参考图,每张不超过 20 MB。');
280
+ }
281
+ const content = [{ type: 'text', text: foldedPrompt(fields, input) }, ...imageParts(images)];
282
+ const body = { messages: [{ role: 'user', content }] };
283
+ applyFields(body, { model: fields.model }, { model: input.model });
284
+ const size = sizeTextOf(input);
285
+ if (size) body.size = size;
286
+ return executeBuiltImage(kind, this, provider, input, TOKENHUB_HY_PATH, body, signal, {
287
+ protectedPaths: ['model', 'messages', 'size']
288
+ }, hooks);
289
+ }
290
+ },
237
291
  {
238
292
  id: 'openai-chat',
239
293
  label: 'protocol.openai-chat',
package/lib/adapters.js CHANGED
@@ -677,6 +677,12 @@ export function qualityOverrideOf(provider, model) {
677
677
 
678
678
  /** 规则 + 覆盖合并成一份质量说明;两边都没有就是"不发这个字段"。 */
679
679
  function qualitySpecFor(provider, model, adapter) {
680
+ if (adapter?.id === 'comfyui') {
681
+ const target = provider?.modelOptions?.[model]?.mapping?.quality;
682
+ const saved = target && comfyCustomWorkflow(provider, model) && qualityOverrideOf(provider, model);
683
+ if (!saved?.supported || !saved.options.length) return null;
684
+ return { ...saved, field: target.input, default: saved.options.includes(saved.default) ? saved.default : saved.options[0] };
685
+ }
680
686
  // 有实际接收档位的请求字段才提供选择器。自定义操作可以分别声明或关闭质量参数。
681
687
  let field;
682
688
  if (adapter?.id === 'custom') {
@@ -892,7 +898,8 @@ export function filterImageModels(models) {
892
898
 
893
899
  import {
894
900
  parseWorkflow, uiToApi, analyzeWorkflow, injectByMapping, applyWorkflowParams, listWorkflowInputs,
895
- PROMPT_ROLE_NAMES
901
+ findWorkflowPrompt, isManagedWorkflowInput, workflowPlaceholders, workflowInputPlaceholders, workflowReferenceTarget,
902
+ isWorkflowImagePlaceholder, workflowImageSlots, assertComfyReferenceCount, WORKFLOW_REFERENCE_LIMIT
896
903
  } from './comfy-workflow.js';
897
904
 
898
905
  const OBJECT_INFO_TTL = 5 * 60 * 1000;
@@ -1061,7 +1068,6 @@ async function comfyUploadImage(base, provider, image, signal) {
1061
1068
  const form = new FormData();
1062
1069
  form.append('image', new Blob([image.buffer], { type: image.contentType || 'image/png' }),
1063
1070
  image.filename || 'reference.png');
1064
- form.append('overwrite', 'true');
1065
1071
  const response = await requestProvider(joinEndpoint(base, '/upload/image'), {
1066
1072
  method: 'POST', headers: headersFor(provider, true), body: form, signal
1067
1073
  }, provider);
@@ -1268,16 +1274,12 @@ export const COMFY_WORKFLOW_PLACEHOLDERS = [
1268
1274
 
1269
1275
  const PLACEHOLDER_EXACT = /^\{\{\s*([A-Za-z_][A-Za-z0-9_]*)\s*\}\}$/;
1270
1276
  const PLACEHOLDER_ANY = /\{\{\s*([A-Za-z_][A-Za-z0-9_]*)\s*\}\}/g;
1271
- const COMFY_MANAGED_ROLES = ['prompt', 'negative_prompt', 'model', 'width', 'height', 'image'];
1272
-
1273
- function workflowPlaceholders(text) {
1274
- return new Set(Array.from(text.matchAll(PLACEHOLDER_ANY), (match) =>
1275
- match[1] === 'negativePrompt' ? 'negative_prompt' : match[1]));
1276
- }
1277
+ const COMFY_MANAGED_ROLES = ['prompt', 'negative_prompt', 'model', 'width', 'height', 'quality', 'image'];
1277
1278
 
1278
1279
  function placeholderError(key) {
1279
1280
  return new Error('自定义工作流里有未知占位符 {{' + key + '}};可用:'
1280
- + COMFY_WORKFLOW_PLACEHOLDERS.map((name) => '{{' + name + '}}').join('、'));
1281
+ + COMFY_WORKFLOW_PLACEHOLDERS.map((name) => '{{' + name + '}}').join('、')
1282
+ + ',或连续编号的 {{image_1}} 到 {{image_' + WORKFLOW_REFERENCE_LIMIT + '}}');
1281
1283
  }
1282
1284
 
1283
1285
  function fillString(text, values, lenient) {
@@ -1367,11 +1369,12 @@ export async function analyzeComfyWorkflow({ base, provider, workflow, signal })
1367
1369
  export async function listComfyParams({ base, provider, workflow, signal }) {
1368
1370
  const parsed = parseWorkflow(workflow);
1369
1371
  let graph = parsed.graph;
1372
+ let info;
1370
1373
  if (parsed.format === 'ui') {
1371
1374
  if (!String(base || '').trim()) {
1372
1375
  throw new Error('这是 UI 格式的工作流:解析参数要先把服务地址填好,或者改贴「导出(API)」的 JSON。');
1373
1376
  }
1374
- const info = await comfyObjectInfo(base, provider, signal);
1377
+ info = await comfyObjectInfo(base, provider, signal);
1375
1378
  const converted = uiToApi(parsed.ui, info);
1376
1379
  if (converted.missing.length) {
1377
1380
  throw new Error('工作流里的节点没有安装:' + converted.missing.join('、')
@@ -1379,13 +1382,13 @@ export async function listComfyParams({ base, provider, workflow, signal }) {
1379
1382
  }
1380
1383
  graph = converted.graph;
1381
1384
  }
1382
- const params = listWorkflowInputs(graph);
1385
+ const params = listWorkflowInputs(graph, info);
1383
1386
  return { format: parsed.format, params: params, count: params.length };
1384
1387
  }
1385
1388
 
1386
1389
  /** Protect a bound input even when the workflow parameter is listed under an alias. */
1387
1390
  export function isManagedComfyParam(param, mapping, graph) {
1388
- if (PROMPT_ROLE_NAMES.has(param?.name)) return true;
1391
+ if (isManagedWorkflowInput(param, mapping)) return true;
1389
1392
  if (param?.role && COMFY_MANAGED_ROLES.includes(param.name)) return true;
1390
1393
  if (COMFY_MANAGED_ROLES.some((role) => {
1391
1394
  const mapped = mapping?.[role];
@@ -1394,14 +1397,16 @@ export function isManagedComfyParam(param, mapping, graph) {
1394
1397
  const literal = graph?.[param?.node]?.inputs?.[param?.input];
1395
1398
  if (typeof literal !== 'string') return false;
1396
1399
  const placeholders = workflowPlaceholders(literal);
1397
- return COMFY_MANAGED_ROLES.some((role) => placeholders.has(role));
1400
+ return COMFY_MANAGED_ROLES.some((role) => placeholders.has(role))
1401
+ || [...placeholders].some(isWorkflowImagePlaceholder);
1398
1402
  }
1399
1403
 
1400
1404
  async function comfyCustomGraph(base, provider, { kind, input, model, width, height, seed, raw, signal }) {
1401
1405
  const parsed = parseWorkflow(raw);
1402
1406
  let graph = parsed.graph;
1407
+ let info;
1403
1408
  if (parsed.format === 'ui') {
1404
- const info = await comfyObjectInfo(base, provider, signal);
1409
+ info = await comfyObjectInfo(base, provider, signal);
1405
1410
  const converted = uiToApi(parsed.ui, info);
1406
1411
  if (converted.missing.length) {
1407
1412
  throw new Error('工作流里的节点没有安装:' + converted.missing.join('、')
@@ -1411,30 +1416,48 @@ async function comfyCustomGraph(base, provider, { kind, input, model, width, hei
1411
1416
  }
1412
1417
 
1413
1418
  const entry = provider && provider.modelOptions ? provider.modelOptions[model] : null;
1414
- const mapping = entry && entry.mapping ? entry.mapping : null;
1415
- const placeholders = workflowPlaceholders(raw);
1416
- const activeMapping = mapping && Object.fromEntries(Object.entries(mapping).filter(([role]) => !placeholders.has(role)));
1419
+ const mapping = entry?.mapping || {};
1420
+ const placeholders = raw.includes('{{') ? workflowInputPlaceholders(graph) : new Set();
1421
+ const activeMapping = Object.fromEntries(Object.entries(mapping).filter(([role]) => !placeholders.has(role)));
1422
+ const imageSlots = [...placeholders].some(isWorkflowImagePlaceholder) ? workflowImageSlots(graph) : [];
1423
+ if (kind === 'edit') {
1424
+ if (imageSlots.length) delete activeMapping.image;
1425
+ else {
1426
+ const target = workflowReferenceTarget(graph, activeMapping.image, info);
1427
+ if (!target) {
1428
+ throw new Error('该 ComfyUI 工作流不支持图生图:找不到可用的参考图输入。'
1429
+ + '请解析工作流,或将参考图节点的输入设为 {{image}}。');
1430
+ }
1431
+ activeMapping.image = target;
1432
+ }
1433
+ assertComfyReferenceCount(input.images?.length || 0, imageSlots.length || 1);
1434
+ }
1435
+ if (!placeholders.has('prompt')) {
1436
+ const target = activeMapping.prompt || findWorkflowPrompt(graph, info);
1437
+ if (!target || !Object.hasOwn(graph[target.node]?.inputs || {}, target.input)) {
1438
+ throw new Error('工作流中找不到可用的提示词输入。请将提示词输入设为 {{prompt}} 或重新解析工作流。');
1439
+ }
1440
+ activeMapping.prompt = target;
1441
+ }
1417
1442
  const values = {
1418
1443
  prompt: input.prompt || '',
1419
1444
  negative_prompt: input.negativePrompt || '',
1420
1445
  negativePrompt: input.negativePrompt || '',
1421
- width, height, seed, model
1446
+ width, height, seed, model,
1447
+ quality: mapQuality(provider, model, input.quality, { id: 'comfyui' })
1422
1448
  };
1423
1449
 
1424
1450
  if (kind === 'edit') {
1425
- if (!placeholders.has('image') && !activeMapping?.image) {
1426
- throw new Error('这个自定义工作流里既没有 {{image}} 占位符,也没有可用的参考图映射,不能用于图生图;'
1427
- + '请把参考图节点的 image 字段写成 {{image}},或在模型选项里解析并确认映射。');
1451
+ if (input.images.some((reference) => !reference?.buffer)) throw new Error('ComfyUI 编辑需要有效的参考图');
1452
+ for (const [index, reference] of input.images.entries()) {
1453
+ const uploaded = await comfyUploadImage(base, provider, reference, signal);
1454
+ for (const key of imageSlots[index]?.keys || ['image']) values[key] = uploaded;
1428
1455
  }
1429
- const reference = input.images && input.images[0];
1430
- if (!reference || !reference.buffer) throw new Error('ComfyUI 编辑需要一张参考图');
1431
- values.image = await comfyUploadImage(base, provider, reference, signal);
1432
1456
  }
1433
1457
 
1434
- if (!placeholders.size && !activeMapping) throw new Error('这个自定义工作流没有注入映射,请先在模型选项里解析并确认。');
1435
1458
  // 占位符必须有值,自动尺寸时使用和内置工作流一致的默认。映射仍可保留原图中的数值。
1436
1459
  let out = placeholders.size ? applyWorkflowTemplate(graph, { ...values, width: width ?? 1024, height: height ?? 1024 }) : graph;
1437
- if (activeMapping && Object.values(activeMapping).some(Boolean)) out = injectByMapping(out, activeMapping, values).graph;
1460
+ if (Object.values(activeMapping).some(Boolean)) out = injectByMapping(out, activeMapping, values).graph;
1438
1461
 
1439
1462
  // 对话模型塞进来的可调参数:认得的写进去,认不得的记下来告诉它。
1440
1463
  // 只认带节点落点的行(HTTP 参数行属于通用路径,不该在这里被当成工作流参数);
@@ -2345,6 +2368,7 @@ const ADAPTERS = [
2345
2368
  });
2346
2369
  return comfySubmitAndWait(provider, this, kind, input, built.graph, signal, hooks, built.note);
2347
2370
  }
2371
+ if (kind === 'edit') assertComfyReferenceCount(input.images?.length || 0, 1);
2348
2372
  const options = comfyOptionReader(base, provider, signal);
2349
2373
  const diffusionModels = await options('UNETLoader', 'unet_name');
2350
2374
  let workflow;
@@ -2906,7 +2930,7 @@ export const PROVIDER_PRESETS = definePresets([
2906
2930
  }
2907
2931
  },
2908
2932
  {
2909
- id: 'volcengine', name: '火山方舟', baseUrl: 'https://ark.cn-beijing.volces.com/api/v3', adapter: 'openai-images', website: 'https://console.volcengine.com/ark', models: [],
2933
+ id: 'volcengine', name: '火山方舟', baseUrl: 'https://ark.cn-beijing.volces.com/api/v3', adapter: 'openai-images', website: 'https://console.volcengine.com/ark/region:cn-beijing/apiKey', models: [],
2910
2934
  // 方舟的编辑也走 /images/generations,所以 edit:'same';seedream 一族不收负面词,
2911
2935
  // 参考图是 data URL 的 image。response_format / watermark 由请求常量规则按主机给。
2912
2936
  protocolOptions: { edit: 'same' },
@@ -2937,7 +2961,7 @@ export const PROVIDER_PRESETS = definePresets([
2937
2961
  {
2938
2962
  id: 'dashscope', name: '阿里云百炼 · Qwen-Image',
2939
2963
  baseUrl: 'https://dashscope.aliyuncs.com/api/v1', adapter: 'dashscope-qwen-image',
2940
- website: 'https://bailian.console.aliyun.com/',
2964
+ website: 'https://bailian.console.aliyun.com/cn-beijing/model/settings/api-key',
2941
2965
  models: ['qwen-image-3.0-pro', 'qwen-image-3.0'],
2942
2966
  // 照抄 dashscope-qwen-image 的 execute():提示词与参考图都追加到 input.messages[0].content[],
2943
2967
  // 负面词与张数在 parameters 里;参考图要用 wrap 包成 { image: dataUrl } 项。
@@ -2953,7 +2977,7 @@ export const PROVIDER_PRESETS = definePresets([
2953
2977
  {
2954
2978
  id: 'dashscope-wanx', name: '阿里云百炼 · 通义万相',
2955
2979
  baseUrl: 'https://dashscope.aliyuncs.com/api/v1', adapter: 'dashscope-wanx',
2956
- website: 'https://www.qianwenai.com/',
2980
+ website: 'https://platform.qianwenai.com/home/api-keys',
2957
2981
  models: ['wan2.6-t2i', 'wan2.7-image-pro', 'wan2.7-image', 'wanx2.1-t2i-turbo'],
2958
2982
  // 老模型使用 input.prompt。2.6 文生图与 2.7 图像模型由协议按模型切换成多模态消息。
2959
2983
  fields: {
@@ -2965,6 +2989,16 @@ export const PROVIDER_PRESETS = definePresets([
2965
2989
  quality: null
2966
2990
  }
2967
2991
  },
2992
+ {
2993
+ id: 'tencent-tokenhub', name: '腾讯云 TokenHub',
2994
+ baseUrl: 'https://tokenhub.tencentmaas.com/v1', adapter: 'tokenhub-hy-image',
2995
+ website: 'https://console.cloud.tencent.com/tokenhub/apikey',
2996
+ models: ['hy-image-v3.5-preview'],
2997
+ fields: {
2998
+ prompt: null, negative: { appendToPrompt: '\n\nAvoid: ' }, model: { path: 'model' },
2999
+ n: null, image: null, quality: null
3000
+ }
3001
+ },
2968
3002
  {
2969
3003
  id: 'siliconflow', name: '硅基流动', baseUrl: 'https://api.siliconflow.cn/v1', adapter: 'openai-images', website: 'https://cloud.siliconflow.cn/account/ak', models: [],
2970
3004
  // 硅基流动的编辑也走 /images/generations,所以 edit:'same';扁平字段、
@@ -2980,7 +3014,7 @@ export const PROVIDER_PRESETS = definePresets([
2980
3014
  }
2981
3015
  },
2982
3016
  {
2983
- id: 'bigmodel', name: '智谱 BigModel', baseUrl: 'https://open.bigmodel.cn/api/paas/v4', adapter: 'openai-images', website: 'https://bigmodel.cn/usercenter/apikeys', models: [],
3017
+ id: 'bigmodel', name: '智谱 BigModel', baseUrl: 'https://open.bigmodel.cn/api/paas/v4', adapter: 'openai-images', website: 'https://bigmodel.cn/apikey/platform', models: [],
2984
3018
  // 地址三元组与 OpenAI Images 一样(只有 /images/generations,没有编辑端点)。
2985
3019
  // 它的 body 本来就和通用 composeBody 一致:不收 n / response_format,负面词拼进提示词。
2986
3020
  protocolOptions: { edit: 'none' },
@@ -3128,7 +3162,7 @@ export const PROTOCOL_GROUPS = [
3128
3162
  id: 'native',
3129
3163
  adapters: [
3130
3164
  'google-gemini', 'recraft', 'ideogram', 'stability',
3131
- 'dashscope-qwen-image', 'dashscope-wanx'
3165
+ 'dashscope-qwen-image', 'dashscope-wanx', 'tokenhub-hy-image'
3132
3166
  ]
3133
3167
  },
3134
3168
  { id: 'local', adapters: ['a1111', 'comfyui', 'swarmui'] },
@@ -3432,7 +3466,8 @@ const PROBE_ROWS = [
3432
3466
  { protocol: 'google-gemini', accepts: ['gemini-models'] },
3433
3467
  { protocol: 'openai-chat', accepts: ['openai-data'] },
3434
3468
  { protocol: 'openai-responses', accepts: ['openai-data'] },
3435
- { protocol: 'openrouter-images', accepts: ['openai-data'] }
3469
+ { protocol: 'openrouter-images', accepts: ['openai-data'] },
3470
+ { protocol: 'tokenhub-hy-image', accepts: ['openai-data'] }
3436
3471
  ];
3437
3472
 
3438
3473
  /**