@q253595422/dsh-imagegen-video 1.23.1 → 1.24.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/CHANGELOG.md CHANGED
@@ -5,6 +5,13 @@ Attribution for third-party code is in [NOTICE](./NOTICE).
5
5
 
6
6
  ## Releases
7
7
 
8
+ ### 1.24.0 — Google 原生渠道协议;URL 型模板图不再 404
9
+
10
+ - **渠道「接口协议」新增 Google 原生(#28)。** 用 Google API Key 直连 Generative Language `:generateContent`:`x-goog-api-key` 鉴权,参考图最多 5 张走 `inlineData`,比例/清晰度嵌套在 `generationConfig.imageConfig`,auto 省略;body 不带 `n`,多张由并行单图请求满足;响应跳过 `thought` 部分、兼容 `inline_data`、缺 mimeType 按字节嗅探,空结果报 `blockReason`。配置地址带 `/models`、`:generateContent`、`/interactions` 后缀时自动剥回基址。GIF 请求在网络调用前拒绝,不静默降级成静图计费。
11
+ - **google-native 渠道支持模型检测。** GET models 列表解析 `name` 字段、剥 `models/` 前缀、只留图像模型;完整 URL 模式下检测按钮放行。新增「Google Gemini 官方(原生)」预设(v1beta,预填 gemini-3-pro-image / gemini-2.5-flash-image),协议选项与提示补齐 zh/en/ru;参考图上限对 google-native 给 5 张。
12
+ - **URL 型模板图缩略图全部 404 修复(#29)。** `imageFileFrom` 的空段校验把解码后 `https://` 的 `//` 判成空段,五个 URL 型模板源的引用恒死在路由层。仅对模板路由放行 URL 型引用(空段不拦、复合上限 400→4100),`.`/`..`/绝对路径照旧拒绝,主机白名单仍由 store 兜底;其余图片路由不受影响。
13
+ - 新增 `smoke-google-native.mjs`(桩 fetch、零网络、直接 import src)接入 `pnpm test` 与 `test:negative`;smoke 新增 C6a2(URL 型模板图透传/穿越/超长/作用域)与 D4(客户端 google-native 接线)。反向用例 6 条全部 RED as expected。
14
+
8
15
  ### 1.23.1 — 服饰穿戴:草稿读失败不再把整张表单锁死
9
16
 
10
17
  - **「角色搭配」点不动的根因是草稿读失败变成了永久禁用。** 面板在草稿读回来之前会把整张
@@ -0,0 +1,53 @@
1
+ # v1.24.0 · Google 原生渠道协议;URL 型模板图不再 404
2
+
3
+ > 各版本改动见 [CHANGELOG.md](../../CHANGELOG.md)。
4
+
5
+ ## Google 原生渠道协议(#28)
6
+
7
+ 渠道的「接口协议」新增 **Google 原生**:用 Google API Key 直连 Generative Language
8
+ 的 `:generateContent`,不再要求中转站把 Gemini 包成 OpenAI 兼容接口。
9
+
10
+ - **请求整形**:`contents[].parts` 携带提示词与参考图(`inlineData`,最多 5 张、每张
11
+ ≤10MB);`generationConfig` 固定 `candidateCount: 1`、`responseModalities: ['TEXT','IMAGE']`,
12
+ 比例与清晰度嵌套在 `imageConfig`(`aspectRatio` / `imageSize`),auto/空值省略不发。
13
+ 鉴权走 `x-goog-api-key` 头,不发 Bearer。
14
+ - **URL 容错**:配置地址带 `/models`、`/models/<id>:generateContent` 或 `/interactions`
15
+ 后缀时自动剥回版本基址再拼目标端点;query/hash 不随请求发出。
16
+ - **模型检测**:google-native 渠道支持「检测模型」(GET models 列表,解析 `name`
17
+ 字段并剥 `models/` 前缀,只保留图像模型);完整 URL 模式下检测按钮不再禁用。
18
+ - **数量与响应**:body 不带 `n`,多张由并行单图请求满足;响应跳过 `thought` 部分,
19
+ 兼容 `inlineData` / `inline_data`,缺 mimeType 按字节嗅探;空结果报
20
+ `promptFeedback.blockReason`。
21
+ - **GIF 前置拒绝**:Gemini 图像模型不出动图,google-native 渠道的 GIF 请求在网络调用
22
+ 之前报错(`gif-protocol-unsupported`),不会静默降级成静图照常计费。
23
+ - **预设与文案**:新增「Google Gemini 官方(原生)」预设
24
+ (`https://generativelanguage.googleapis.com/v1beta`,预填 gemini-3-pro-image /
25
+ gemini-2.5-flash-image);协议选项与提示文案补齐 zh/en/ru 三套。参考图上限对
26
+ google-native 给 5 张(此前 gemini id 落 nanobanana 族只给 1 张)。
27
+
28
+ ## URL 型模板图修复(#29)
29
+
30
+ 工作室「灵感案例」墙里 itgoyo / evolink / songtianlun / prompt-signal / handraw 五个
31
+ URL 型源的缩略图全部 404:`imageFileFrom` 的空段校验把解码后 `https://` 里的 `//`
32
+ 判成空段,引用恒死在路由层,到不了主机白名单。
33
+
34
+ - 仅对模板路由放行 URL 型引用:空段不再拦截,复合路径上限 400 → 4100(对应 store
35
+ 侧 4000 字符 URL 上限 + sourceId);`.` / `..` / 绝对路径 / 反斜杠 / NUL 照旧拒绝,
36
+ 主机白名单仍由 templates-store 兜底。
37
+ - 其余图片路由(history / gallery / canvas / model)保持严格校验,不受影响。
38
+
39
+ ## 检查
40
+
41
+ - `pnpm run typecheck`:exit 0。
42
+ - `pnpm test`(独占运行):exit 0,含新增 `smoke-google-native.mjs`(10 组断言)与
43
+ smoke C6a2 / D4。
44
+ - 反向验证:google-native 组 3/3、smoke 组客户端 2/2、#29 空段用例 1/1 均 RED as expected。
45
+ - #29 按报告同款接线本地复现:修复前 URL 型 404 且后端未被调用,修复后 200 且完整
46
+ URL 原样透传。
47
+
48
+ ## 已知边界
49
+
50
+ - google-native 未做真实 Google 上游的付费验证(无 API Key);请求/响应形状按官方
51
+ API 与仓库内 Antigravity 既有 Gemini 原生实现核对,桩 fetch 套件覆盖各分支。
52
+ - 预设不带协议字段:从「Google Gemini 官方(原生)」预设建渠道后需手动把接口协议选为
53
+ 「Google 原生」(预设提示文案已说明)。
package/lib/client.js CHANGED
@@ -36,7 +36,7 @@ window.__ModuleLoader__.load({
36
36
  let _deepseek_ai_dsh_client_store = require("@deepseek-ai/dsh-client-store");
37
37
  //#region src/protocol.ts
38
38
  /** Published package version shared by the host updater and the client UI. */
39
- const PLUGIN_VERSION = "1.23.1";
39
+ const PLUGIN_VERSION = "1.24.0";
40
40
  /** Same-origin route family (loopback-only, mirroring the dsh-ssh fence). */
41
41
  const SETTINGS_API = {
42
42
  describe: "/api/dsh-imagegen/settings/describe",
@@ -66,7 +66,7 @@ window.__ModuleLoader__.load({
66
66
  }
67
67
  /** Resolve a channel preference without changing legacy behavior by default. */
68
68
  function resolveChannelProtocol(apiUrl, preference = "auto") {
69
- if (preference === "images" || preference === "chat-completions") return preference;
69
+ if (preference === "images" || preference === "chat-completions" || preference === "google-native") return preference;
70
70
  return isChatCompletionsUrl(apiUrl) ? "chat-completions" : "images";
71
71
  }
72
72
  /** Subscription channels with a fixed image model. */
@@ -1342,7 +1342,8 @@ probe: "/api/dsh-imagegen/code/probe" };
1342
1342
  "channels.protocolAuto": "自动检测",
1343
1343
  "channels.protocolImages": "Images API",
1344
1344
  "channels.protocolChat": "Chat Completions",
1345
- "channels.protocolHint": "自动:完整 URL 以 /chat/completions 结尾时使用 Chat 协议;也可以手动指定。",
1345
+ "channels.protocolGoogle": "Google 原生",
1346
+ "channels.protocolHint": "自动:完整 URL 以 /chat/completions 结尾时使用 Chat 协议;也可以手动指定。Google 原生直连 Gemini :generateContent,密钥填 Google API Key。",
1346
1347
  "channels.apiUrlFull": "完整 URL",
1347
1348
  "channels.apiUrlFullHint": "开启后精确请求此地址,不再拼接 /images/generations 或 /images/edits;Chat Completions 地址仍可从其上级路径自动检测 /models。",
1348
1349
  "channels.watermark": "图片添加「AI 生成」水印",
@@ -2945,7 +2946,8 @@ probe: "/api/dsh-imagegen/code/probe" };
2945
2946
  "channels.protocolAuto": "Auto detect",
2946
2947
  "channels.protocolImages": "Images API",
2947
2948
  "channels.protocolChat": "Chat Completions",
2948
- "channels.protocolHint": "Auto uses Chat when the exact URL ends in /chat/completions; manual selection is also supported.",
2949
+ "channels.protocolGoogle": "Google Native",
2950
+ "channels.protocolHint": "Auto uses Chat when the exact URL ends in /chat/completions; manual selection is also supported. Google Native calls Gemini :generateContent with a Google API key.",
2949
2951
  "channels.apiUrlFull": "Exact URL",
2950
2952
  "channels.apiUrlFullHint": "Use this URL verbatim without appending /images/generations or /images/edits. Chat Completions URLs can still derive /models from their parent path.",
2951
2953
  "channels.watermark": "Add the “AI generated” watermark",
@@ -4549,7 +4551,8 @@ probe: "/api/dsh-imagegen/code/probe" };
4549
4551
  "channels.protocolAuto": "Автоопределение",
4550
4552
  "channels.protocolImages": "Images API",
4551
4553
  "channels.protocolChat": "Chat Completions",
4552
- "channels.protocolHint": "Авто использует Chat, если полный URL заканчивается на /chat/completions; можно выбрать вручную.",
4554
+ "channels.protocolGoogle": "Google Native",
4555
+ "channels.protocolHint": "Авто использует Chat, если полный URL заканчивается на /chat/completions; можно выбрать вручную. Google Native обращается к Gemini :generateContent с ключом Google API.",
4553
4556
  "channels.apiUrlFull": "Полный URL",
4554
4557
  "channels.apiUrlFullHint": "Использовать URL как есть, без добавления /images/generations или /images/edits. Для Chat Completions /models всё ещё выводится из родительского пути.",
4555
4558
  "channels.watermark": "Добавлять водяной знак «AI сгенерировано»",
@@ -42800,7 +42803,8 @@ probe: "/api/dsh-imagegen/code/probe" };
42800
42803
  /** Current adapter capabilities, not a claim about every vendor's API. */
42801
42804
  function editReferenceLimit(model, channel) {
42802
42805
  if (channel?.auth === "subscription") return 5;
42803
- if (resolveChannelProtocol(channel?.apiUrl ?? "", channel?.protocol) === "chat-completions") return 5;
42806
+ const protocol = resolveChannelProtocol(channel?.apiUrl ?? "", channel?.protocol);
42807
+ if (protocol === "chat-completions" || protocol === "google-native") return 5;
42804
42808
  const { family } = describeModel(channel?.models.find((item) => item.alias === model)?.id || model);
42805
42809
  if (family === "grok" || family === "nanobanana" || family === "dall-e") return 1;
42806
42810
  if (!channel?.apiUrlFull) {
@@ -78397,8 +78401,10 @@ probe: "/api/dsh-imagegen/code/probe" };
78397
78401
  if (props.usage === null) return 0;
78398
78402
  return (props.usage.byChannel[channel.id] ?? props.usage.byChannel[`name:${channel.name}`] ?? {})[alias] ?? props.usage.totals[alias] ?? 0;
78399
78403
  };
78404
+ const resolvedProtocol = resolveChannelProtocol(channel.apiUrl, channel.protocol);
78405
+ const detectable = !channel.apiUrlFull || resolvedProtocol === "chat-completions" || resolvedProtocol === "google-native";
78400
78406
  const detect = () => {
78401
- if (channel.apiUrlFull && resolveChannelProtocol(channel.apiUrl, channel.protocol) !== "chat-completions") return;
78407
+ if (!detectable) return;
78402
78408
  setDetecting(true);
78403
78409
  setDetectError(null);
78404
78410
  const payload = {
@@ -78470,7 +78476,7 @@ probe: "/api/dsh-imagegen/code/probe" };
78470
78476
  (0, react.useEffect)(() => {
78471
78477
  if (autoDetected.current) return;
78472
78478
  autoDetected.current = true;
78473
- if (!subscriptionMode && (!channel.apiUrlFull || resolveChannelProtocol(channel.apiUrl, channel.protocol) === "chat-completions") && channel.apiUrl.trim() !== "" && (props.keyHeld || keyDraft.trim() !== "")) detect();
78479
+ if (!subscriptionMode && detectable && channel.apiUrl.trim() !== "" && (props.keyHeld || keyDraft.trim() !== "")) detect();
78474
78480
  }, []);
78475
78481
  const addManual = () => {
78476
78482
  const id = manualId.trim();
@@ -78773,6 +78779,10 @@ probe: "/api/dsh-imagegen/code/probe" };
78773
78779
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
78774
78780
  value: "chat-completions",
78775
78781
  children: t("channels.protocolChat")
78782
+ }),
78783
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
78784
+ value: "google-native",
78785
+ children: t("channels.protocolGoogle")
78776
78786
  })
78777
78787
  ]
78778
78788
  })]
@@ -78876,7 +78886,7 @@ probe: "/api/dsh-imagegen/code/probe" };
78876
78886
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
78877
78887
  type: "button",
78878
78888
  className: settings_card_module_css_default.modelFetch,
78879
- disabled: !props.writable || detecting || channel.apiUrlFull && resolveChannelProtocol(channel.apiUrl, channel.protocol) !== "chat-completions",
78889
+ disabled: !props.writable || detecting || !detectable,
78880
78890
  onClick: detect,
78881
78891
  children: detecting ? t("channels.detecting") : candidates === null && channel.models.length === 0 ? t("channels.detectFirst") : t("channels.detect")
78882
78892
  }),