dsh-image-gen 0.8.0 → 0.8.5
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.en.md +418 -397
- package/README.md +418 -397
- package/README.zh-CN.md +3 -3
- package/lib/client.js +333 -245
- package/lib/index.js +558 -182
- package/lib/types/capabilities.d.ts +42 -0
- package/lib/types/client/image-result-node.d.ts +9 -17
- package/lib/types/client/index.d.ts +2 -0
- package/lib/types/client/multi-model-compare.d.ts +3 -1
- package/lib/types/config.d.ts +2 -2
- package/lib/types/openai-compatible.d.ts +20 -2
- package/lib/types/subscription/manager.d.ts +2 -1
- package/lib/types/subscription/vendors/antigravity.d.ts +2 -2
- package/lib/types/subscription.d.ts +11 -1
- package/lib/types/xai-params.d.ts +5 -0
- package/package.json +139 -142
- package/skills/install-dsh-image-gen/SKILL.md +22 -22
- package/lib/client.js.map +0 -1
package/lib/client.js
CHANGED
|
@@ -217,7 +217,7 @@ window.__ModuleLoader__.load({
|
|
|
217
217
|
const DEFAULT_SUBSCRIPTION_MODELS = {
|
|
218
218
|
"chatgpt-sub": "gpt-image-2.5-flare",
|
|
219
219
|
"grok-sub": "grok-imagine-image-2.0",
|
|
220
|
-
"google-sub": "gemini-3-
|
|
220
|
+
"google-sub": "gemini-3.1-flash-image"
|
|
221
221
|
};
|
|
222
222
|
const DEFAULT_MODELS = {
|
|
223
223
|
google: DEFAULT_GOOGLE_MODEL,
|
|
@@ -1978,6 +1978,49 @@ window.__ModuleLoader__.load({
|
|
|
1978
1978
|
const active = configured.find((profile) => profile.provider === activeProvider);
|
|
1979
1979
|
return (active === void 0 ? configured : [active, ...configured.filter((profile) => profile.provider !== activeProvider)]).slice(0, 2).map((profile) => profile.provider);
|
|
1980
1980
|
}
|
|
1981
|
+
const RATIO_SORT_ORDER = [
|
|
1982
|
+
"auto",
|
|
1983
|
+
"1:1",
|
|
1984
|
+
"3:2",
|
|
1985
|
+
"2:3",
|
|
1986
|
+
"4:3",
|
|
1987
|
+
"3:4",
|
|
1988
|
+
"4:5",
|
|
1989
|
+
"5:4",
|
|
1990
|
+
"16:9",
|
|
1991
|
+
"9:16",
|
|
1992
|
+
"21:9"
|
|
1993
|
+
];
|
|
1994
|
+
const QUALITY_SORT_ORDER = [
|
|
1995
|
+
"auto",
|
|
1996
|
+
"standard",
|
|
1997
|
+
"1k",
|
|
1998
|
+
"1K",
|
|
1999
|
+
"2k",
|
|
2000
|
+
"2K",
|
|
2001
|
+
"3K",
|
|
2002
|
+
"4K",
|
|
2003
|
+
"low",
|
|
2004
|
+
"medium",
|
|
2005
|
+
"high",
|
|
2006
|
+
"xhigh",
|
|
2007
|
+
"max",
|
|
2008
|
+
"hd"
|
|
2009
|
+
];
|
|
2010
|
+
/** Union of every configured profile's options, for the shared comparison pickers. */
|
|
2011
|
+
function comparisonOptionUnion(profiles, key) {
|
|
2012
|
+
const sortOrder = key === "ratioOptions" ? RATIO_SORT_ORDER : QUALITY_SORT_ORDER;
|
|
2013
|
+
const seen = /* @__PURE__ */ new Map();
|
|
2014
|
+
for (const profile of profiles) {
|
|
2015
|
+
if (!profile.configured) continue;
|
|
2016
|
+
for (const option of profile[key]) if (!seen.has(option.value)) seen.set(option.value, option);
|
|
2017
|
+
}
|
|
2018
|
+
const rank = (value) => {
|
|
2019
|
+
const index = sortOrder.indexOf(value);
|
|
2020
|
+
return index === -1 ? sortOrder.length : index;
|
|
2021
|
+
};
|
|
2022
|
+
return [...seen.values()].sort((a, b) => rank(a.value) - rank(b.value));
|
|
2023
|
+
}
|
|
1981
2024
|
//#endregion
|
|
1982
2025
|
//#region node_modules/.pnpm/@tldraw+utils@5.3.0/node_modules/@tldraw/utils/dist-esm/lib/version.mjs
|
|
1983
2026
|
const TLDRAW_LIBRARY_VERSION_KEY = "__TLDRAW_LIBRARY_VERSIONS__";
|
|
@@ -116834,6 +116877,8 @@ img.ProseMirror-separator {
|
|
|
116834
116877
|
model: "Model",
|
|
116835
116878
|
ratio: "比例",
|
|
116836
116879
|
quality: "清晰度",
|
|
116880
|
+
subscriptionParameterHint: "所选比例会自动补充到生成提示词中;实际尺寸和清晰度仍由 ChatGPT 决定,请以生成结果为准。",
|
|
116881
|
+
subscriptionRatioMismatch: "ChatGPT 订阅未按所选比例出图,请查看实际尺寸。",
|
|
116837
116882
|
start: "开始生成",
|
|
116838
116883
|
generating: "正在生成…",
|
|
116839
116884
|
cancelGenerate: "取消生成",
|
|
@@ -116971,6 +117016,8 @@ img.ProseMirror-separator {
|
|
|
116971
117016
|
model: "Model",
|
|
116972
117017
|
ratio: "Aspect ratio",
|
|
116973
117018
|
quality: "Quality",
|
|
117019
|
+
subscriptionParameterHint: "The selected aspect ratio is automatically added to the generation prompt. ChatGPT still determines the final dimensions and quality; check the generated result.",
|
|
117020
|
+
subscriptionRatioMismatch: "ChatGPT subscription returned a different aspect ratio. Check the actual dimensions.",
|
|
116974
117021
|
start: "Generate",
|
|
116975
117022
|
generating: "Generating…",
|
|
116976
117023
|
cancelGenerate: "Cancel",
|
|
@@ -117185,8 +117232,6 @@ img.ProseMirror-separator {
|
|
|
117185
117232
|
const maxReferences = comparisonEnabled ? comparisonProviders.includes("dashscope") ? 3 : 5 : provider === "dashscope" ? 3 : 5;
|
|
117186
117233
|
const referencesRef = (0, react.useRef)(references);
|
|
117187
117234
|
referencesRef.current = references;
|
|
117188
|
-
const comparisonSelectionsAllSubscription = comparisonEnabled && comparisonProviders.length > 0 && comparisonProviders.every((provider) => isSubscriptionProvider(provider));
|
|
117189
|
-
const singleProviderIsSubscription = !comparisonEnabled && isSubscriptionProvider(provider);
|
|
117190
117235
|
const t = (key, values) => {
|
|
117191
117236
|
let text = COPY$1[lang][key];
|
|
117192
117237
|
for (const [name, value] of Object.entries(values ?? {})) text = text.replace(`{${name}}`, value);
|
|
@@ -117349,6 +117394,8 @@ img.ProseMirror-separator {
|
|
|
117349
117394
|
ratio,
|
|
117350
117395
|
quality
|
|
117351
117396
|
]);
|
|
117397
|
+
const comparisonRatioOpts = (0, react.useMemo)(() => localizeRatioOptions(comparisonOptionUnion(comparisonProfiles, "ratioOptions"), lang), [comparisonProfiles, lang]);
|
|
117398
|
+
const comparisonQualityOpts = (0, react.useMemo)(() => localizeQualityOptions(comparisonOptionUnion(comparisonProfiles, "qualityOptions"), lang), [comparisonProfiles, lang]);
|
|
117352
117399
|
const applyProvider = (profile) => {
|
|
117353
117400
|
setProvider(profile.provider);
|
|
117354
117401
|
setModel(profile.model);
|
|
@@ -117690,6 +117737,7 @@ img.ProseMirror-separator {
|
|
|
117690
117737
|
success: String(successes.length),
|
|
117691
117738
|
failed: String(failed)
|
|
117692
117739
|
}));
|
|
117740
|
+
else if (galleryEntries.some(hasSubscriptionRatioMismatch)) flash(t("subscriptionRatioMismatch"));
|
|
117693
117741
|
return;
|
|
117694
117742
|
}
|
|
117695
117743
|
const response = await fetch(STUDIO_ROUTE, {
|
|
@@ -117753,6 +117801,7 @@ img.ProseMirror-separator {
|
|
|
117753
117801
|
success: String(generatedList.length),
|
|
117754
117802
|
failed: String(payload.failedCount)
|
|
117755
117803
|
}));
|
|
117804
|
+
else if (galleryEntries.some(hasSubscriptionRatioMismatch)) flash(t("subscriptionRatioMismatch"));
|
|
117756
117805
|
} catch (submitError) {
|
|
117757
117806
|
if (controller.signal.aborted) return;
|
|
117758
117807
|
setError(messageOf(submitError));
|
|
@@ -118505,7 +118554,8 @@ img.ProseMirror-separator {
|
|
|
118505
118554
|
(0, react_jsx_runtime.jsx)("span", { children: formatRelativeTime$1(selected.createdAt, lang) }),
|
|
118506
118555
|
(0, react_jsx_runtime.jsx)("span", { children: selected.provider }),
|
|
118507
118556
|
(0, react_jsx_runtime.jsx)("span", { children: selected.model }),
|
|
118508
|
-
(0, react_jsx_runtime.jsx)("span", { children: selected.attachment.width && selected.attachment.height ? `${selected.attachment.width} × ${selected.attachment.height}` : "—" })
|
|
118557
|
+
(0, react_jsx_runtime.jsx)("span", { children: selected.provider === "chatgpt-sub" ? selected.output : selected.attachment.width && selected.attachment.height ? `${selected.attachment.width} × ${selected.attachment.height}` : "—" }),
|
|
118558
|
+
hasSubscriptionRatioMismatch(selected) && (0, react_jsx_runtime.jsx)("span", { children: t("subscriptionRatioMismatch") })
|
|
118509
118559
|
]
|
|
118510
118560
|
})
|
|
118511
118561
|
] })
|
|
@@ -118689,82 +118739,70 @@ img.ProseMirror-separator {
|
|
|
118689
118739
|
onClick: () => toggleComparison(true),
|
|
118690
118740
|
children: [(0, react_jsx_runtime.jsx)(Copy, { size: 13 }), t("compareModels")]
|
|
118691
118741
|
})]
|
|
118692
|
-
}), comparisonEnabled ? (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
118693
|
-
|
|
118694
|
-
|
|
118695
|
-
|
|
118696
|
-
|
|
118697
|
-
|
|
118698
|
-
|
|
118699
|
-
|
|
118700
|
-
|
|
118701
|
-
|
|
118702
|
-
|
|
118703
|
-
|
|
118704
|
-
|
|
118705
|
-
|
|
118706
|
-
|
|
118707
|
-
|
|
118708
|
-
|
|
118709
|
-
|
|
118710
|
-
|
|
118711
|
-
|
|
118712
|
-
|
|
118713
|
-
|
|
118714
|
-
|
|
118715
|
-
|
|
118716
|
-
|
|
118717
|
-
|
|
118718
|
-
|
|
118719
|
-
|
|
118720
|
-
|
|
118721
|
-
|
|
118722
|
-
|
|
118723
|
-
|
|
118724
|
-
|
|
118725
|
-
|
|
118726
|
-
|
|
118727
|
-
|
|
118728
|
-
|
|
118729
|
-
|
|
118730
|
-
|
|
118731
|
-
|
|
118732
|
-
|
|
118733
|
-
|
|
118734
|
-
|
|
118735
|
-
|
|
118736
|
-
|
|
118737
|
-
|
|
118738
|
-
|
|
118739
|
-
|
|
118740
|
-
|
|
118741
|
-
|
|
118742
|
-
|
|
118743
|
-
|
|
118744
|
-
}
|
|
118745
|
-
|
|
118746
|
-
|
|
118747
|
-
|
|
118748
|
-
|
|
118749
|
-
|
|
118750
|
-
|
|
118751
|
-
|
|
118752
|
-
|
|
118753
|
-
|
|
118754
|
-
|
|
118755
|
-
|
|
118756
|
-
children: [(0, react_jsx_runtime.jsx)(FieldSelect, {
|
|
118757
|
-
label: t("ratio"),
|
|
118758
|
-
value: ratio,
|
|
118759
|
-
onChange: setRatio,
|
|
118760
|
-
options: comparisonRatioOptions(lang)
|
|
118761
|
-
}), (0, react_jsx_runtime.jsx)(FieldSelect, {
|
|
118762
|
-
label: t("quality"),
|
|
118763
|
-
value: quality,
|
|
118764
|
-
onChange: setQuality,
|
|
118765
|
-
options: comparisonQualityOptions(lang)
|
|
118766
|
-
})]
|
|
118767
|
-
})] }) : (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
118742
|
+
}), comparisonEnabled ? (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
118743
|
+
(0, react_jsx_runtime.jsxs)("div", {
|
|
118744
|
+
className: "dsh-ig-compare-box",
|
|
118745
|
+
children: [
|
|
118746
|
+
(0, react_jsx_runtime.jsxs)("div", {
|
|
118747
|
+
className: "dsh-ig-compare-heading",
|
|
118748
|
+
children: [(0, react_jsx_runtime.jsxs)("div", { children: [(0, react_jsx_runtime.jsx)("strong", { children: t("compareSelect") }), (0, react_jsx_runtime.jsx)("small", { children: t("compareHint") })] }), (0, react_jsx_runtime.jsx)("span", { children: t("compareSelected", { count: String(comparisonTargets.length) }) })]
|
|
118749
|
+
}),
|
|
118750
|
+
(0, react_jsx_runtime.jsx)("div", {
|
|
118751
|
+
className: "dsh-ig-model-checks",
|
|
118752
|
+
children: comparisonProfiles.map((item) => {
|
|
118753
|
+
const target = comparisonTargets.find((candidate) => candidate.profile.provider === item.provider);
|
|
118754
|
+
return (0, react_jsx_runtime.jsxs)("button", {
|
|
118755
|
+
type: "button",
|
|
118756
|
+
className: target ? "is-selected" : "",
|
|
118757
|
+
"aria-pressed": Boolean(target),
|
|
118758
|
+
onClick: () => toggleComparisonProvider(item.provider),
|
|
118759
|
+
children: [
|
|
118760
|
+
(0, react_jsx_runtime.jsx)("span", {
|
|
118761
|
+
className: "dsh-ig-model-checkmark",
|
|
118762
|
+
children: target ? (0, react_jsx_runtime.jsx)(Check, { size: 12 }) : null
|
|
118763
|
+
}),
|
|
118764
|
+
(0, react_jsx_runtime.jsxs)("span", {
|
|
118765
|
+
className: "dsh-ig-model-copy",
|
|
118766
|
+
children: [(0, react_jsx_runtime.jsx)("strong", { children: item.label }), (0, react_jsx_runtime.jsx)("small", {
|
|
118767
|
+
title: item.model,
|
|
118768
|
+
children: item.model
|
|
118769
|
+
})]
|
|
118770
|
+
}),
|
|
118771
|
+
target && (0, react_jsx_runtime.jsxs)("span", {
|
|
118772
|
+
className: "dsh-ig-model-settings",
|
|
118773
|
+
children: [
|
|
118774
|
+
target.ratio,
|
|
118775
|
+
" · ",
|
|
118776
|
+
target.quality,
|
|
118777
|
+
target.adjusted ? (0, react_jsx_runtime.jsx)("em", { children: t("compareAdjusted") }) : null
|
|
118778
|
+
]
|
|
118779
|
+
})
|
|
118780
|
+
]
|
|
118781
|
+
}, item.provider);
|
|
118782
|
+
})
|
|
118783
|
+
}),
|
|
118784
|
+
(0, react_jsx_runtime.jsx)("p", { children: t("compareParameterHint") })
|
|
118785
|
+
]
|
|
118786
|
+
}),
|
|
118787
|
+
(0, react_jsx_runtime.jsxs)("div", {
|
|
118788
|
+
className: "dsh-ig-field-grid",
|
|
118789
|
+
children: [(0, react_jsx_runtime.jsx)(FieldSelect, {
|
|
118790
|
+
label: t("ratio"),
|
|
118791
|
+
value: ratio,
|
|
118792
|
+
onChange: setRatio,
|
|
118793
|
+
options: comparisonRatioOpts
|
|
118794
|
+
}), (0, react_jsx_runtime.jsx)(FieldSelect, {
|
|
118795
|
+
label: t("quality"),
|
|
118796
|
+
value: quality,
|
|
118797
|
+
onChange: setQuality,
|
|
118798
|
+
options: comparisonQualityOpts
|
|
118799
|
+
})]
|
|
118800
|
+
}),
|
|
118801
|
+
comparisonTargets.some((target) => target.profile.provider === "chatgpt-sub") && (0, react_jsx_runtime.jsx)("div", {
|
|
118802
|
+
className: "dsh-ig-inline-note",
|
|
118803
|
+
children: t("subscriptionParameterHint")
|
|
118804
|
+
})
|
|
118805
|
+
] }) : (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
118768
118806
|
(0, react_jsx_runtime.jsxs)("div", {
|
|
118769
118807
|
className: "dsh-ig-field-grid",
|
|
118770
118808
|
children: [(0, react_jsx_runtime.jsx)(FieldSelect, {
|
|
@@ -118785,26 +118823,7 @@ img.ProseMirror-separator {
|
|
|
118785
118823
|
}]
|
|
118786
118824
|
})]
|
|
118787
118825
|
}),
|
|
118788
|
-
|
|
118789
|
-
className: "dsh-ig-field-grid",
|
|
118790
|
-
children: [(0, react_jsx_runtime.jsx)(FieldSelect, {
|
|
118791
|
-
label: t("ratio"),
|
|
118792
|
-
value: "auto",
|
|
118793
|
-
onChange: () => {},
|
|
118794
|
-
options: [{
|
|
118795
|
-
value: "auto",
|
|
118796
|
-
label: lang === "en" ? "Channel default" : "通道默认"
|
|
118797
|
-
}]
|
|
118798
|
-
}), (0, react_jsx_runtime.jsx)(FieldSelect, {
|
|
118799
|
-
label: t("quality"),
|
|
118800
|
-
value: "auto",
|
|
118801
|
-
onChange: () => {},
|
|
118802
|
-
options: [{
|
|
118803
|
-
value: "auto",
|
|
118804
|
-
label: lang === "en" ? "Channel default" : "通道默认"
|
|
118805
|
-
}]
|
|
118806
|
-
})]
|
|
118807
|
-
}) : (0, react_jsx_runtime.jsxs)("div", {
|
|
118826
|
+
(0, react_jsx_runtime.jsxs)("div", {
|
|
118808
118827
|
className: "dsh-ig-field-grid",
|
|
118809
118828
|
children: [(0, react_jsx_runtime.jsx)(FieldSelect, {
|
|
118810
118829
|
label: t("ratio"),
|
|
@@ -118818,6 +118837,10 @@ img.ProseMirror-separator {
|
|
|
118818
118837
|
options: localizeQualityOptions(activeProfile?.qualityOptions ?? [], lang)
|
|
118819
118838
|
})]
|
|
118820
118839
|
}),
|
|
118840
|
+
provider === "chatgpt-sub" && (0, react_jsx_runtime.jsx)("div", {
|
|
118841
|
+
className: "dsh-ig-inline-note",
|
|
118842
|
+
children: t("subscriptionParameterHint")
|
|
118843
|
+
}),
|
|
118821
118844
|
(0, react_jsx_runtime.jsxs)("div", {
|
|
118822
118845
|
className: "dsh-ig-field",
|
|
118823
118846
|
children: [(0, react_jsx_runtime.jsx)("label", { children: t("count") }), (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -119133,6 +119156,15 @@ img.ProseMirror-separator {
|
|
|
119133
119156
|
]
|
|
119134
119157
|
});
|
|
119135
119158
|
};
|
|
119159
|
+
function hasSubscriptionRatioMismatch(item) {
|
|
119160
|
+
if (item.provider !== "chatgpt-sub" || item.aspectRatio === "auto") return false;
|
|
119161
|
+
const width = item.attachment.width;
|
|
119162
|
+
const height = item.attachment.height;
|
|
119163
|
+
if (width === void 0 || height === void 0 || width <= 0 || height <= 0) return false;
|
|
119164
|
+
const parts = item.aspectRatio?.split(":").map(Number);
|
|
119165
|
+
if (parts === void 0 || parts.length !== 2 || !(parts[0] > 0) || !(parts[1] > 0)) return false;
|
|
119166
|
+
return Math.abs(width / height / (parts[0] / parts[1]) - 1) > .12;
|
|
119167
|
+
}
|
|
119136
119168
|
const FieldSelect = ({ label, value, options, onChange }) => (0, react_jsx_runtime.jsxs)("label", {
|
|
119137
119169
|
className: "dsh-ig-field-select",
|
|
119138
119170
|
children: [(0, react_jsx_runtime.jsx)("span", { children: label }), (0, react_jsx_runtime.jsx)("select", {
|
|
@@ -119169,6 +119201,14 @@ img.ProseMirror-separator {
|
|
|
119169
119201
|
zh: "3:4 竖向",
|
|
119170
119202
|
en: "3:4 Portrait"
|
|
119171
119203
|
},
|
|
119204
|
+
"4:5": {
|
|
119205
|
+
zh: "4:5 肖像",
|
|
119206
|
+
en: "4:5 Portrait"
|
|
119207
|
+
},
|
|
119208
|
+
"5:4": {
|
|
119209
|
+
zh: "5:4 横向",
|
|
119210
|
+
en: "5:4 Landscape"
|
|
119211
|
+
},
|
|
119172
119212
|
"16:9": {
|
|
119173
119213
|
zh: "16:9 宽屏",
|
|
119174
119214
|
en: "16:9 Widescreen"
|
|
@@ -119176,6 +119216,10 @@ img.ProseMirror-separator {
|
|
|
119176
119216
|
"9:16": {
|
|
119177
119217
|
zh: "9:16 竖屏",
|
|
119178
119218
|
en: "9:16 Portrait"
|
|
119219
|
+
},
|
|
119220
|
+
"21:9": {
|
|
119221
|
+
zh: "21:9 超宽",
|
|
119222
|
+
en: "21:9 Ultrawide"
|
|
119179
119223
|
}
|
|
119180
119224
|
};
|
|
119181
119225
|
const LOCALIZED_QUALITIES = {
|
|
@@ -119184,8 +119228,32 @@ img.ProseMirror-separator {
|
|
|
119184
119228
|
en: "Standard (Recommended)"
|
|
119185
119229
|
},
|
|
119186
119230
|
auto: {
|
|
119187
|
-
zh: "
|
|
119188
|
-
en: "
|
|
119231
|
+
zh: "自动",
|
|
119232
|
+
en: "Auto"
|
|
119233
|
+
},
|
|
119234
|
+
low: {
|
|
119235
|
+
zh: "低(快速)",
|
|
119236
|
+
en: "Low (Fast)"
|
|
119237
|
+
},
|
|
119238
|
+
medium: {
|
|
119239
|
+
zh: "中",
|
|
119240
|
+
en: "Medium"
|
|
119241
|
+
},
|
|
119242
|
+
high: {
|
|
119243
|
+
zh: "高",
|
|
119244
|
+
en: "High"
|
|
119245
|
+
},
|
|
119246
|
+
xhigh: {
|
|
119247
|
+
zh: "超高",
|
|
119248
|
+
en: "Extra High"
|
|
119249
|
+
},
|
|
119250
|
+
max: {
|
|
119251
|
+
zh: "最高",
|
|
119252
|
+
en: "Max"
|
|
119253
|
+
},
|
|
119254
|
+
hd: {
|
|
119255
|
+
zh: "高清",
|
|
119256
|
+
en: "HD"
|
|
119189
119257
|
}
|
|
119190
119258
|
};
|
|
119191
119259
|
function localizeRatioOptions(options, lang) {
|
|
@@ -119200,38 +119268,6 @@ img.ProseMirror-separator {
|
|
|
119200
119268
|
label: LOCALIZED_QUALITIES[opt.value]?.[lang] ?? opt.label
|
|
119201
119269
|
}));
|
|
119202
119270
|
}
|
|
119203
|
-
function comparisonRatioOptions(lang) {
|
|
119204
|
-
return [
|
|
119205
|
-
"1:1",
|
|
119206
|
-
"3:2",
|
|
119207
|
-
"2:3",
|
|
119208
|
-
"16:9",
|
|
119209
|
-
"9:16"
|
|
119210
|
-
].map((value) => ({
|
|
119211
|
-
value,
|
|
119212
|
-
label: LOCALIZED_RATIOS[value]?.[lang] ?? value
|
|
119213
|
-
}));
|
|
119214
|
-
}
|
|
119215
|
-
function comparisonQualityOptions(lang) {
|
|
119216
|
-
return [
|
|
119217
|
-
{
|
|
119218
|
-
value: "standard",
|
|
119219
|
-
label: lang === "zh" ? "标准" : "Standard"
|
|
119220
|
-
},
|
|
119221
|
-
{
|
|
119222
|
-
value: "1K",
|
|
119223
|
-
label: "1K"
|
|
119224
|
-
},
|
|
119225
|
-
{
|
|
119226
|
-
value: "2K",
|
|
119227
|
-
label: "2K"
|
|
119228
|
-
},
|
|
119229
|
-
{
|
|
119230
|
-
value: "4K",
|
|
119231
|
-
label: "4K"
|
|
119232
|
-
}
|
|
119233
|
-
];
|
|
119234
|
-
}
|
|
119235
119271
|
const RecentItem = ({ item, active, onClick }) => {
|
|
119236
119272
|
const [setRef, inView] = useInView();
|
|
119237
119273
|
const image = useAttachmentImage(item.attachment, inView);
|
|
@@ -122037,6 +122073,19 @@ img.ProseMirror-separator {
|
|
|
122037
122073
|
}
|
|
122038
122074
|
/** Extract standard aspect ratio for precise filtering */
|
|
122039
122075
|
function getItemRatio(item) {
|
|
122076
|
+
if (item.provider === "chatgpt-sub" && item.attachment.width && item.attachment.height) {
|
|
122077
|
+
const actual = item.attachment.width / item.attachment.height;
|
|
122078
|
+
for (const [label, value] of [
|
|
122079
|
+
["1:1", 1],
|
|
122080
|
+
["16:9", 16 / 9],
|
|
122081
|
+
["9:16", 9 / 16],
|
|
122082
|
+
["4:3", 4 / 3],
|
|
122083
|
+
["3:4", 3 / 4],
|
|
122084
|
+
["3:2", 3 / 2],
|
|
122085
|
+
["2:3", 2 / 3]
|
|
122086
|
+
]) if (Math.abs(actual / value - 1) < .08) return label;
|
|
122087
|
+
return "custom";
|
|
122088
|
+
}
|
|
122040
122089
|
if (item.aspectRatio && item.aspectRatio !== "custom") return item.aspectRatio;
|
|
122041
122090
|
if (item.output) {
|
|
122042
122091
|
const ratioMatch = item.output.match(/\b(1:1|16:9|9:16|4:3|3:4|3:2|2:3)\b/);
|
|
@@ -123572,11 +123621,10 @@ img.ProseMirror-separator {
|
|
|
123572
123621
|
//#region lib/types/client/image-result-node.js
|
|
123573
123622
|
const IMAGE_RESULT_NODE_KIND = "dsh-image-result";
|
|
123574
123623
|
/**
|
|
123575
|
-
*
|
|
123576
|
-
*
|
|
123577
|
-
* Turn closes (only needed under the folding Compact transcript view).
|
|
123624
|
+
* Give each image Tool result its own Chat row at the event that produced it.
|
|
123625
|
+
* PTC (run_code) sub-calls already have their own stable sub-call identity.
|
|
123578
123626
|
*/
|
|
123579
|
-
function createImageResultDefinition(
|
|
123627
|
+
function createImageResultDefinition() {
|
|
123580
123628
|
return {
|
|
123581
123629
|
kind: IMAGE_RESULT_NODE_KIND,
|
|
123582
123630
|
target: "chat",
|
|
@@ -123584,77 +123632,52 @@ img.ProseMirror-separator {
|
|
|
123584
123632
|
if (event.type === "tool/ptc-dispatch") {
|
|
123585
123633
|
const subCallId = event.data.subCallId;
|
|
123586
123634
|
if (typeof subCallId !== "string" || subCallId === "") return null;
|
|
123587
|
-
return
|
|
123635
|
+
return imageResultsFromPtcDispatch(event).length === 0 ? null : {
|
|
123588
123636
|
id: `ptc:${subCallId}`,
|
|
123589
123637
|
role: "start"
|
|
123590
123638
|
};
|
|
123591
123639
|
}
|
|
123592
|
-
|
|
123593
|
-
|
|
123594
|
-
if (event.type === "turn/start") return {
|
|
123595
|
-
id: String(turn),
|
|
123640
|
+
if (event.type === "tool/result" && eventTurn(event) !== void 0 && imageResultsFromMeta(event.data.meta).length > 0) return {
|
|
123641
|
+
id: `result:${event.seq}`,
|
|
123596
123642
|
role: "start"
|
|
123597
123643
|
};
|
|
123598
|
-
if (event.type === "turn/end") return {
|
|
123599
|
-
id: String(turn),
|
|
123600
|
-
role: "update"
|
|
123601
|
-
};
|
|
123602
|
-
if (event.type === "assistant/message") return {
|
|
123603
|
-
id: String(turn),
|
|
123604
|
-
role: "update"
|
|
123605
|
-
};
|
|
123606
|
-
if (event.type === "tool/result" && imageResultFromMeta(event.data.meta) !== void 0) return {
|
|
123607
|
-
id: String(turn),
|
|
123608
|
-
role: "update"
|
|
123609
|
-
};
|
|
123610
123644
|
return null;
|
|
123611
123645
|
},
|
|
123612
123646
|
start: (_context, match) => {
|
|
123613
123647
|
if (match.event.type === "tool/ptc-dispatch") {
|
|
123614
|
-
const
|
|
123615
|
-
if (
|
|
123616
|
-
return { results:
|
|
123648
|
+
const results = imageResultsFromPtcDispatch(match.event);
|
|
123649
|
+
if (results.length === 0) throw new Error("dsh-image-result start requires a plugin image dispatch");
|
|
123650
|
+
return { results: results.map((result) => ({
|
|
123617
123651
|
...result,
|
|
123618
123652
|
seq: match.event.seq
|
|
123619
|
-
}
|
|
123653
|
+
})) };
|
|
123620
123654
|
}
|
|
123621
123655
|
const turn = eventTurn(match.event);
|
|
123622
|
-
|
|
123656
|
+
const results = match.event.type === "tool/result" ? imageResultsFromMeta(match.event.data.meta) : [];
|
|
123657
|
+
if (turn === void 0 || results.length === 0) throw new Error("dsh-image-result start requires an image Tool result");
|
|
123623
123658
|
return {
|
|
123624
123659
|
turn,
|
|
123625
|
-
results:
|
|
123660
|
+
results: results.map((result) => ({
|
|
123661
|
+
...result,
|
|
123662
|
+
seq: match.event.seq
|
|
123663
|
+
}))
|
|
123626
123664
|
};
|
|
123627
123665
|
},
|
|
123628
123666
|
update: (context, match) => {
|
|
123629
|
-
if (match.event.type
|
|
123630
|
-
|
|
123631
|
-
endSeq: match.event.seq
|
|
123632
|
-
};
|
|
123633
|
-
if (match.event.type === "assistant/message") return {
|
|
123634
|
-
...context.state,
|
|
123635
|
-
answerSeq: match.event.seq
|
|
123636
|
-
};
|
|
123637
|
-
if (match.event.type === "tool/ptc-dispatch") {
|
|
123638
|
-
const result = imageResultFromPtcDispatch(match.event);
|
|
123639
|
-
return result === void 0 ? context.state : appendResult(context.state, result, match.event.seq);
|
|
123640
|
-
}
|
|
123641
|
-
if (match.event.type !== "tool/result") return context.state;
|
|
123642
|
-
const result = imageResultFromMeta(match.event.data.meta);
|
|
123643
|
-
if (result === void 0) return context.state;
|
|
123644
|
-
return appendResult(context.state, result, match.event.seq);
|
|
123667
|
+
if (match.event.type !== "tool/ptc-dispatch") return context.state;
|
|
123668
|
+
return imageResultsFromPtcDispatch(match.event).reduce((state, result) => appendResult(state, result, match.event.seq), context.state);
|
|
123645
123669
|
},
|
|
123646
123670
|
buildViewNode: (context) => {
|
|
123647
123671
|
const state = context.state;
|
|
123648
|
-
const
|
|
123649
|
-
if (state === void 0 ||
|
|
123650
|
-
const location = context.matches.at(-1)?.location ?? context.start?.location ?? { kind: "unresolved" };
|
|
123672
|
+
const first = state?.results[0];
|
|
123673
|
+
if (state === void 0 || first === void 0) return null;
|
|
123651
123674
|
return {
|
|
123652
123675
|
key: context.key,
|
|
123653
123676
|
kind: IMAGE_RESULT_NODE_KIND,
|
|
123654
123677
|
id: context.id,
|
|
123655
123678
|
target: "chat",
|
|
123656
|
-
anchorSeq:
|
|
123657
|
-
location,
|
|
123679
|
+
anchorSeq: first.seq,
|
|
123680
|
+
location: { kind: "session" },
|
|
123658
123681
|
visibility: "visible",
|
|
123659
123682
|
data: {
|
|
123660
123683
|
...state.turn !== void 0 ? { turn: state.turn } : {},
|
|
@@ -123675,13 +123698,6 @@ img.ProseMirror-separator {
|
|
|
123675
123698
|
}]
|
|
123676
123699
|
};
|
|
123677
123700
|
}
|
|
123678
|
-
function compactTranscript(options) {
|
|
123679
|
-
try {
|
|
123680
|
-
return options.isCompactTranscript?.() ?? true;
|
|
123681
|
-
} catch {
|
|
123682
|
-
return true;
|
|
123683
|
-
}
|
|
123684
|
-
}
|
|
123685
123701
|
/** Parse the plugin-owned durable presentation metadata from a Tool result event. */
|
|
123686
123702
|
function imageResultFromMeta(value) {
|
|
123687
123703
|
const meta = record(value);
|
|
@@ -123698,12 +123714,26 @@ img.ProseMirror-separator {
|
|
|
123698
123714
|
...typeof meta.seed === "number" ? { seed: meta.seed } : {}
|
|
123699
123715
|
};
|
|
123700
123716
|
}
|
|
123717
|
+
/** Parse all successful images from either a single or batch Tool result. */
|
|
123718
|
+
function imageResultsFromMeta(value) {
|
|
123719
|
+
const meta = record(value);
|
|
123720
|
+
if (meta?.kind === "dsh-image-gen-batch" && Array.isArray(meta.images)) return meta.images.flatMap((image) => {
|
|
123721
|
+
const result = imageResultFromMeta(image);
|
|
123722
|
+
return result === void 0 ? [] : [result];
|
|
123723
|
+
});
|
|
123724
|
+
const result = imageResultFromMeta(value);
|
|
123725
|
+
return result === void 0 ? [] : [result];
|
|
123726
|
+
}
|
|
123701
123727
|
function eventTurn(event) {
|
|
123702
123728
|
const turn = event.data.turn;
|
|
123703
123729
|
return typeof turn === "number" && Number.isSafeInteger(turn) && turn >= 0 ? turn : void 0;
|
|
123704
123730
|
}
|
|
123705
123731
|
/** Plugin tools whose PTC (run_code) dispatch results are image results. */
|
|
123706
|
-
const PTC_IMAGE_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
123732
|
+
const PTC_IMAGE_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
123733
|
+
"generate_image",
|
|
123734
|
+
"generate_images",
|
|
123735
|
+
"edit_image"
|
|
123736
|
+
]);
|
|
123707
123737
|
/**
|
|
123708
123738
|
* Fixed summary text rendered by the tools' imageOutput(). PTC dispatch events
|
|
123709
123739
|
* carry no presentationMeta, so provider/model/output are recovered from this
|
|
@@ -123711,42 +123741,41 @@ img.ProseMirror-separator {
|
|
|
123711
123741
|
*/
|
|
123712
123742
|
const PTC_SUMMARY_PATTERN = /^(?:Generated|Edited) one image with ([^/\s]+)\/(\S+) \((.+)\)\. Attachment ID: /;
|
|
123713
123743
|
const PTC_SAVED_TO_PATTERN = / It was also saved to the workspace as (.+)\. (?:(?:Saving it to the workspace failed)|(?:It has no local file path)|(?:Respond to the user))/;
|
|
123714
|
-
/**
|
|
123715
|
-
|
|
123716
|
-
|
|
123717
|
-
* is rebuilt from the dispatch payload itself: the image content block for the
|
|
123718
|
-
* attachment, arguments for the prompt (and edit source ids), and the tool's
|
|
123719
|
-
* fixed-format summary text for provider/model/output. Returns undefined for
|
|
123720
|
-
* anything that is not a successful image result from our own image tools.
|
|
123721
|
-
*/
|
|
123722
|
-
function imageResultFromPtcDispatch(event) {
|
|
123723
|
-
if (event.type !== "tool/ptc-dispatch") return void 0;
|
|
123744
|
+
/** Pair each rendered image with its own summary, including batches with failed items. */
|
|
123745
|
+
function imageResultsFromPtcDispatch(event) {
|
|
123746
|
+
if (event.type !== "tool/ptc-dispatch") return [];
|
|
123724
123747
|
const data = event.data;
|
|
123725
|
-
if (data.isError === true) return
|
|
123726
|
-
if (typeof data.name !== "string" || !PTC_IMAGE_TOOL_NAMES.has(data.name)) return
|
|
123748
|
+
if (data.isError === true) return [];
|
|
123749
|
+
if (typeof data.name !== "string" || !PTC_IMAGE_TOOL_NAMES.has(data.name)) return [];
|
|
123727
123750
|
const content = Array.isArray(data.content) ? data.content : [];
|
|
123728
|
-
|
|
123751
|
+
const results = [];
|
|
123729
123752
|
let summaryText = "";
|
|
123753
|
+
const args = record(data.arguments);
|
|
123754
|
+
const sourceIds = sourceAttachmentIds(args);
|
|
123730
123755
|
for (const block of content) {
|
|
123731
123756
|
const candidate = record(block);
|
|
123732
123757
|
if (candidate === void 0) continue;
|
|
123733
|
-
if (candidate.type === "
|
|
123734
|
-
|
|
123758
|
+
if (candidate.type === "text" && typeof candidate.text === "string") {
|
|
123759
|
+
summaryText = candidate.text;
|
|
123760
|
+
continue;
|
|
123761
|
+
}
|
|
123762
|
+
if (candidate.type !== "image") continue;
|
|
123763
|
+
const attachment = imageAttachment(candidate.attachment);
|
|
123764
|
+
if (attachment === void 0) continue;
|
|
123765
|
+
const summary = PTC_SUMMARY_PATTERN.exec(summaryText);
|
|
123766
|
+
const savedTo = PTC_SAVED_TO_PATTERN.exec(summaryText)?.[1];
|
|
123767
|
+
const promptAt = data.name === "generate_images" ? summaryText.indexOf("\nImage prompt: ") : -1;
|
|
123768
|
+
results.push({
|
|
123769
|
+
attachment,
|
|
123770
|
+
prompt: promptAt < 0 ? stringValue(args?.prompt, "Generated Image") : summaryText.slice(promptAt + 15),
|
|
123771
|
+
provider: summary?.[1] ?? "",
|
|
123772
|
+
model: summary?.[2] ?? "",
|
|
123773
|
+
output: summary?.[3] ?? "",
|
|
123774
|
+
...savedTo !== void 0 ? { savedTo } : {},
|
|
123775
|
+
...sourceIds !== void 0 ? { sourceAttachmentIds: sourceIds } : {}
|
|
123776
|
+
});
|
|
123735
123777
|
}
|
|
123736
|
-
|
|
123737
|
-
const summary = PTC_SUMMARY_PATTERN.exec(summaryText);
|
|
123738
|
-
const savedTo = PTC_SAVED_TO_PATTERN.exec(summaryText)?.[1];
|
|
123739
|
-
const args = record(data.arguments);
|
|
123740
|
-
const sourceIds = sourceAttachmentIds(args);
|
|
123741
|
-
return {
|
|
123742
|
-
attachment,
|
|
123743
|
-
prompt: stringValue(args?.prompt, "Generated Image"),
|
|
123744
|
-
provider: summary?.[1] ?? "",
|
|
123745
|
-
model: summary?.[2] ?? "",
|
|
123746
|
-
output: summary?.[3] ?? "",
|
|
123747
|
-
...savedTo !== void 0 ? { savedTo } : {},
|
|
123748
|
-
...sourceIds !== void 0 ? { sourceAttachmentIds: sourceIds } : {}
|
|
123749
|
-
};
|
|
123778
|
+
return results;
|
|
123750
123779
|
}
|
|
123751
123780
|
/** Collect edit_image source attachment ids (single or list form) from dispatch arguments. */
|
|
123752
123781
|
function sourceAttachmentIds(args) {
|
|
@@ -123808,16 +123837,16 @@ img.ProseMirror-separator {
|
|
|
123808
123837
|
const isNew = event.seq > lastSeq;
|
|
123809
123838
|
lastSeq = Math.max(lastSeq, event.seq);
|
|
123810
123839
|
if (change.kind !== "append" || !isNew) continue;
|
|
123811
|
-
const
|
|
123812
|
-
if (
|
|
123813
|
-
pushTlLandingsLive(
|
|
123840
|
+
const results = event.type === "tool/result" ? imageResultsFromMeta(event.data.meta) : imageResultsFromPtcDispatch(event);
|
|
123841
|
+
if (results.length === 0) continue;
|
|
123842
|
+
pushTlLandingsLive(results.map((result) => ({
|
|
123814
123843
|
galleryId: String(result.attachment.attachmentId),
|
|
123815
123844
|
attachment: result.attachment,
|
|
123816
123845
|
fromConversation: true,
|
|
123817
123846
|
prompt: result.prompt,
|
|
123818
123847
|
provider: result.provider,
|
|
123819
123848
|
model: result.model
|
|
123820
|
-
}
|
|
123849
|
+
})));
|
|
123821
123850
|
}
|
|
123822
123851
|
});
|
|
123823
123852
|
};
|
|
@@ -124754,7 +124783,7 @@ body[data-ds-dark-theme] .dsh-ig-workbench{--ig-danger:#f08c8c;--ig-warn:#e5b76a
|
|
|
124754
124783
|
`;
|
|
124755
124784
|
//#endregion
|
|
124756
124785
|
//#region lib/types/client/index.js
|
|
124757
|
-
console.info(`[dsh-image-gen] canvas bundle 2026-09-
|
|
124786
|
+
console.info(`[dsh-image-gen] canvas bundle 2026-09-30T06:41:54.565Z`);
|
|
124758
124787
|
/** Right-sidebar tab-type registration id (DSH 0.1.5 `sidebarRightTabs`). */
|
|
124759
124788
|
const SIDEBAR_STUDIO_TAB_ID = "dsh-image-gen/studio";
|
|
124760
124789
|
/** The tab kind: a page type opened by kind, recognizing no resource address. */
|
|
@@ -124782,6 +124811,7 @@ body[data-ds-dark-theme] .dsh-ig-workbench{--ig-danger:#f08c8c;--ig-warn:#e5b76a
|
|
|
124782
124811
|
subBadgeUnknown: "状态未知",
|
|
124783
124812
|
subSectionTitle: "订阅生图",
|
|
124784
124813
|
subHint: "通过已登录的订阅账号生图,无需 API Key。登录在你的授权下进行,不会修改任何 API Key 或默认 Provider。",
|
|
124814
|
+
subProxyHint: "需要代理时,请在登录前开启代理软件的 TUN(虚拟网卡)模式。普通系统代理可能无法覆盖 DSH 后端请求,导致网页授权后登录失败。",
|
|
124785
124815
|
subAccountLabel: "账号",
|
|
124786
124816
|
subAccountEmail: "已登录:{email}",
|
|
124787
124817
|
subAccountNone: "未登录",
|
|
@@ -124816,6 +124846,9 @@ body[data-ds-dark-theme] .dsh-ig-workbench{--ig-danger:#f08c8c;--ig-warn:#e5b76a
|
|
|
124816
124846
|
clearKeyFailed: "清除 Key 失败",
|
|
124817
124847
|
saveKeyFailed: "保存 Key 失败",
|
|
124818
124848
|
saveKeyFirst: "请先保存 API Key,再拉取模型或测试连接。",
|
|
124849
|
+
saveEndpointFirst: "接口地址尚未保存,请先点击保存,再拉取模型或测试连接。",
|
|
124850
|
+
endpointRequired: "请填写接口地址并保存,再拉取模型或测试连接。",
|
|
124851
|
+
savedEndpointMissing: "未读取到已保存的接口地址,请保存后重试。",
|
|
124819
124852
|
clearKeyUnsupported: "当前版本 DSH 不支持在此清除 Key,请到凭据管理中删除。",
|
|
124820
124853
|
endpoint: "接口地址",
|
|
124821
124854
|
reset: "重置",
|
|
@@ -124927,6 +124960,7 @@ body[data-ds-dark-theme] .dsh-ig-workbench{--ig-danger:#f08c8c;--ig-warn:#e5b76a
|
|
|
124927
124960
|
subBadgeUnknown: "Unknown",
|
|
124928
124961
|
subSectionTitle: "Subscription generation",
|
|
124929
124962
|
subHint: "Generates through a logged-in subscription account; no API key needed. Signing in never changes any API key or the default provider.",
|
|
124963
|
+
subProxyHint: "If you need a proxy, enable TUN (virtual network adapter) mode before signing in. A system proxy alone may not cover DSH backend requests, causing sign-in to fail after browser authorization.",
|
|
124930
124964
|
subAccountLabel: "Account",
|
|
124931
124965
|
subAccountEmail: "Signed in: {email}",
|
|
124932
124966
|
subAccountNone: "Not signed in",
|
|
@@ -124961,6 +124995,9 @@ body[data-ds-dark-theme] .dsh-ig-workbench{--ig-danger:#f08c8c;--ig-warn:#e5b76a
|
|
|
124961
124995
|
clearKeyFailed: "Failed to clear key",
|
|
124962
124996
|
saveKeyFailed: "Failed to save the key",
|
|
124963
124997
|
saveKeyFirst: "Save the API key first, then fetch models or test the connection.",
|
|
124998
|
+
saveEndpointFirst: "The endpoint address has not been saved. Click Save before fetching models or testing the connection.",
|
|
124999
|
+
endpointRequired: "Enter and save an endpoint address before fetching models or testing the connection.",
|
|
125000
|
+
savedEndpointMissing: "No saved endpoint address was found. Save it and try again.",
|
|
124964
125001
|
clearKeyUnsupported: "This DSH build cannot clear keys here; remove it from credential management instead.",
|
|
124965
125002
|
endpoint: "Endpoint / Base URL",
|
|
124966
125003
|
reset: "Reset",
|
|
@@ -125371,11 +125408,6 @@ body[data-ds-dark-theme] .dsh-ig-workbench{--ig-danger:#f08c8c;--ig-warn:#e5b76a
|
|
|
125371
125408
|
const configForms = ctx.get("configForms");
|
|
125372
125409
|
const settingsScopeApi = configForms === void 0 ? ctx.get("settingsScope") : void 0;
|
|
125373
125410
|
const scope = configForms?.get("image-gen") ?? settingsScopeApi?.bind({ namespace: "image-generation" }) ?? degradedScope();
|
|
125374
|
-
const chatScope = configForms?.get("ui-chat") ?? settingsScopeApi?.bind({ namespace: "ui-chat" }) ?? degradedScope();
|
|
125375
|
-
const isCompactTranscript = () => {
|
|
125376
|
-
const mode = chatScope.getSnapshot().value?.transcriptView;
|
|
125377
|
-
return configForms === void 0 ? mode !== "normal" : mode !== "standard" && mode !== "detailed" && mode !== "verbose";
|
|
125378
|
-
};
|
|
125379
125411
|
const locale = ctx.get("locale");
|
|
125380
125412
|
const promotion = { enabled: false };
|
|
125381
125413
|
ctx.inject(["sessions"], (owner) => {
|
|
@@ -125403,7 +125435,7 @@ body[data-ds-dark-theme] .dsh-ig-workbench{--ig-danger:#f08c8c;--ig-warn:#e5b76a
|
|
|
125403
125435
|
if (uiConversation === void 0) throw new Error("dsh-image-gen: uiConversation has an incompatible interface");
|
|
125404
125436
|
promotion.enabled = true;
|
|
125405
125437
|
const ownerRegister = owner.slots.register.bind(owner.slots);
|
|
125406
|
-
owner.effect(() => uiConversation.events.register(createImageResultDefinition(
|
|
125438
|
+
owner.effect(() => uiConversation.events.register(createImageResultDefinition()), "dsh-image-gen: promoted image result node");
|
|
125407
125439
|
owner.slots.inject("conversation.chat.node", () => ownerRegister({
|
|
125408
125440
|
name: "conversation.chat.node",
|
|
125409
125441
|
key: IMAGE_RESULT_NODE_KIND,
|
|
@@ -125502,6 +125534,14 @@ body[data-ds-dark-theme] .dsh-ig-workbench{--ig-danger:#f08c8c;--ig-warn:#e5b76a
|
|
|
125502
125534
|
promoted: promotion.enabled
|
|
125503
125535
|
})
|
|
125504
125536
|
}, GeneratedImageCard));
|
|
125537
|
+
ctx.slots.inject("tool.call.toolview", () => register({
|
|
125538
|
+
name: "tool.call.toolview",
|
|
125539
|
+
key: "generate_images",
|
|
125540
|
+
inject: () => ({
|
|
125541
|
+
locale,
|
|
125542
|
+
promoted: promotion.enabled
|
|
125543
|
+
})
|
|
125544
|
+
}, GeneratedImagesCard));
|
|
125505
125545
|
ctx.slots.inject("tool.call.toolview", () => register({
|
|
125506
125546
|
name: "tool.call.toolview",
|
|
125507
125547
|
key: "edit_image",
|
|
@@ -126071,11 +126111,23 @@ body[data-ds-dark-theme] .dsh-ig-workbench{--ig-danger:#f08c8c;--ig-warn:#e5b76a
|
|
|
126071
126111
|
updateRow(provider, { saving: false });
|
|
126072
126112
|
}
|
|
126073
126113
|
};
|
|
126114
|
+
/** These actions use host settings, so drafts must be saved before making a request. */
|
|
126115
|
+
const providerActionBlockMessage = (provider) => {
|
|
126116
|
+
const row = rows[provider];
|
|
126117
|
+
if (row.keyInput.trim().length > 0) return t("saveKeyFirst");
|
|
126118
|
+
if (isSubscriptionProvider(provider)) return void 0;
|
|
126119
|
+
const address = row.baseURL.trim();
|
|
126120
|
+
if (address.length === 0) return t("endpointRequired");
|
|
126121
|
+
if (address !== baseURLOf(provider, props.scope.getSnapshot().value).trim()) return t("saveEndpointFirst");
|
|
126122
|
+
};
|
|
126123
|
+
/** Localize the host's missing-address error while preserving upstream details. */
|
|
126124
|
+
const providerErrorMessage = (message) => message === "Base URL is not configured" ? t("savedEndpointMissing") : message ?? t("testFailed");
|
|
126074
126125
|
/** Probe through the host route so the browser side never touches credential values. */
|
|
126075
126126
|
const testConnection = async (provider) => {
|
|
126076
|
-
|
|
126127
|
+
const blocked = providerActionBlockMessage(provider);
|
|
126128
|
+
if (blocked !== void 0) {
|
|
126077
126129
|
updateRow(provider, {
|
|
126078
|
-
message:
|
|
126130
|
+
message: blocked,
|
|
126079
126131
|
messageIsError: false,
|
|
126080
126132
|
testResult: void 0
|
|
126081
126133
|
});
|
|
@@ -126107,9 +126159,10 @@ body[data-ds-dark-theme] .dsh-ig-workbench{--ig-danger:#f08c8c;--ig-warn:#e5b76a
|
|
|
126107
126159
|
};
|
|
126108
126160
|
/** Pull the provider's image-capable model ids through the host route (Google and the OpenAI family). */
|
|
126109
126161
|
const fetchProviderModels = async (provider) => {
|
|
126110
|
-
|
|
126162
|
+
const blocked = providerActionBlockMessage(provider);
|
|
126163
|
+
if (blocked !== void 0) {
|
|
126111
126164
|
updateRow(provider, {
|
|
126112
|
-
modelFetchMessage:
|
|
126165
|
+
modelFetchMessage: blocked,
|
|
126113
126166
|
modelFetchIsError: false
|
|
126114
126167
|
});
|
|
126115
126168
|
return;
|
|
@@ -126146,7 +126199,7 @@ body[data-ds-dark-theme] .dsh-ig-workbench{--ig-danger:#f08c8c;--ig-warn:#e5b76a
|
|
|
126146
126199
|
modelFetchIsError: true
|
|
126147
126200
|
});
|
|
126148
126201
|
else updateRow(provider, {
|
|
126149
|
-
modelFetchMessage: payload.message
|
|
126202
|
+
modelFetchMessage: providerErrorMessage(payload.message),
|
|
126150
126203
|
modelFetchIsError: true
|
|
126151
126204
|
});
|
|
126152
126205
|
} catch (cause) {
|
|
@@ -126197,7 +126250,7 @@ body[data-ds-dark-theme] .dsh-ig-workbench{--ig-danger:#f08c8c;--ig-warn:#e5b76a
|
|
|
126197
126250
|
if (result.ok) return t("testOk");
|
|
126198
126251
|
if (result.reason === "missing-key") return t("badgeMissing");
|
|
126199
126252
|
if (result.reason === "unauthorized") return t("testUnauthorized");
|
|
126200
|
-
return `${t("testFailed")}${result.message !== void 0 && result.message.length > 0 ? `: ${result.message}` : ""}`;
|
|
126253
|
+
return `${t("testFailed")}${result.message !== void 0 && result.message.length > 0 ? `: ${providerErrorMessage(result.message)}` : ""}`;
|
|
126201
126254
|
};
|
|
126202
126255
|
const badgeOf = (provider) => {
|
|
126203
126256
|
if (provider === "comfyui") return {
|
|
@@ -126864,13 +126917,21 @@ body[data-ds-dark-theme] .dsh-ig-workbench{--ig-danger:#f08c8c;--ig-warn:#e5b76a
|
|
|
126864
126917
|
children: [
|
|
126865
126918
|
(0, react_jsx_runtime.jsxs)("div", {
|
|
126866
126919
|
className: "dsh-ig-field",
|
|
126867
|
-
children: [
|
|
126868
|
-
|
|
126869
|
-
|
|
126870
|
-
|
|
126871
|
-
|
|
126872
|
-
|
|
126873
|
-
|
|
126920
|
+
children: [
|
|
126921
|
+
(0, react_jsx_runtime.jsx)("span", {
|
|
126922
|
+
className: "dsh-ig-label",
|
|
126923
|
+
children: t("subSectionTitle")
|
|
126924
|
+
}),
|
|
126925
|
+
(0, react_jsx_runtime.jsx)("p", {
|
|
126926
|
+
className: "dsh-ig-hint",
|
|
126927
|
+
children: t("subHint")
|
|
126928
|
+
}),
|
|
126929
|
+
(0, react_jsx_runtime.jsx)("p", {
|
|
126930
|
+
className: "dsh-ig-hint",
|
|
126931
|
+
role: "note",
|
|
126932
|
+
children: t("subProxyHint")
|
|
126933
|
+
})
|
|
126934
|
+
]
|
|
126874
126935
|
}),
|
|
126875
126936
|
(0, react_jsx_runtime.jsxs)("div", {
|
|
126876
126937
|
className: "dsh-ig-field",
|
|
@@ -127196,15 +127257,41 @@ body[data-ds-dark-theme] .dsh-ig-workbench{--ig-danger:#f08c8c;--ig-warn:#e5b76a
|
|
|
127196
127257
|
sessionId: props.sessionId
|
|
127197
127258
|
});
|
|
127198
127259
|
}
|
|
127260
|
+
/** Suppress the folded duplicate on modern hosts; render every image on legacy hosts. */
|
|
127261
|
+
function GeneratedImagesCard(props) {
|
|
127262
|
+
const block = props.block;
|
|
127263
|
+
let results = imageResultsFromMeta(block.meta ?? block.resultView?.meta);
|
|
127264
|
+
if (results.length === 0 && "kind" in block) results = ((block.resultView?.card === "generic" ? block.resultView.content : block.content) ?? []).flatMap((item) => item.type === "image" && item.attachment !== void 0 ? [{
|
|
127265
|
+
attachment: item.attachment,
|
|
127266
|
+
prompt: "Generated Image",
|
|
127267
|
+
provider: "",
|
|
127268
|
+
model: "",
|
|
127269
|
+
output: ""
|
|
127270
|
+
}] : []);
|
|
127271
|
+
if (props.promoted && results.length > 0) return (0, react_jsx_runtime.jsx)(PromotedResultNotice, { locale: props.locale });
|
|
127272
|
+
if (results.length === 0) {
|
|
127273
|
+
if (!("kind" in block)) return (0, react_jsx_runtime.jsx)(ImageResultCard, { locale: props.locale });
|
|
127274
|
+
const content = block.content ?? block.resultView?.content ?? [];
|
|
127275
|
+
return (0, react_jsx_runtime.jsx)("div", { children: content.filter((item) => item.type === "text").map((item, index) => (0, react_jsx_runtime.jsx)("p", { children: item.text }, index)) });
|
|
127276
|
+
}
|
|
127277
|
+
return (0, react_jsx_runtime.jsx)("div", {
|
|
127278
|
+
className: "dsh-ig-promoted-results",
|
|
127279
|
+
children: results.map((result, index) => (0, react_jsx_runtime.jsx)(ImageResultCard, {
|
|
127280
|
+
result,
|
|
127281
|
+
locale: props.locale,
|
|
127282
|
+
sessionId: props.sessionId
|
|
127283
|
+
}, `${result.attachment.attachmentId}:${index}`))
|
|
127284
|
+
});
|
|
127285
|
+
}
|
|
127199
127286
|
/** Render modern image artifacts as final conversation output instead of Tool process content. */
|
|
127200
127287
|
function PromotedImageResultNode(props) {
|
|
127201
127288
|
return (0, react_jsx_runtime.jsx)("div", {
|
|
127202
127289
|
className: "dsh-ig-promoted-results",
|
|
127203
|
-
children: props.node.data.results.map((result) => (0, react_jsx_runtime.jsx)(ImageResultCard, {
|
|
127290
|
+
children: props.node.data.results.map((result, index) => (0, react_jsx_runtime.jsx)(ImageResultCard, {
|
|
127204
127291
|
result,
|
|
127205
127292
|
locale: props.locale,
|
|
127206
127293
|
sessionId: props.sessionId
|
|
127207
|
-
}, result.attachment.attachmentId))
|
|
127294
|
+
}, `${result.attachment.attachmentId}:${index}`))
|
|
127208
127295
|
});
|
|
127209
127296
|
}
|
|
127210
127297
|
function PromotedResultNotice({ locale }) {
|
|
@@ -127742,6 +127829,7 @@ body[data-ds-dark-theme] .dsh-ig-workbench{--ig-danger:#f08c8c;--ig-warn:#e5b76a
|
|
|
127742
127829
|
}
|
|
127743
127830
|
//#endregion
|
|
127744
127831
|
exports.GeneratedImageCard = GeneratedImageCard;
|
|
127832
|
+
exports.GeneratedImagesCard = GeneratedImagesCard;
|
|
127745
127833
|
exports.ImageGenerationSettingsCard = ImageGenerationSettingsCard;
|
|
127746
127834
|
exports.PromotedImageResultNode = PromotedImageResultNode;
|
|
127747
127835
|
exports.apply = apply;
|