@dsh-plus/image-studio 0.1.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/LICENSE +21 -0
- package/lib/client.js +129 -0
- package/lib/index.d.ts +321 -0
- package/lib/index.js +1304 -0
- package/package.json +60 -0
- package/src/api.ts +213 -0
- package/src/client/api.ts +89 -0
- package/src/client/card.tsx +14 -0
- package/src/client/client.ts +75 -0
- package/src/client/i18n.ts +20 -0
- package/src/client/section.tsx +14 -0
- package/src/client/styles.ts +33 -0
- package/src/config.ts +90 -0
- package/src/credentials.ts +22 -0
- package/src/dto.ts +87 -0
- package/src/errors.ts +47 -0
- package/src/gallery/store.ts +172 -0
- package/src/index.ts +44 -0
- package/src/ns.ts +7 -0
- package/src/params/catalog.ts +184 -0
- package/src/params/spec.ts +109 -0
- package/src/provider/openai-images.ts +266 -0
- package/src/provider/registry.ts +54 -0
- package/src/provider/types.ts +86 -0
- package/src/service.ts +458 -0
- package/src/task/runner.ts +200 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 agguy
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/lib/client.js
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: "@dsh-plus/image-studio",
|
|
3
|
+
factory: (require) => {
|
|
4
|
+
var module = { exports: {} };
|
|
5
|
+
var exports = module.exports;
|
|
6
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
7
|
+
//#region src/client/card.tsx
|
|
8
|
+
/**
|
|
9
|
+
* 配置卡片占位组件:本次交付为空壳(不做前端设计与编码)。
|
|
10
|
+
* 后续版本在此渲染三组预设编辑与凭据管理;keyed 槽位契约已声明。
|
|
11
|
+
* @module image-studio/client/card
|
|
12
|
+
*/
|
|
13
|
+
/** 占位组件。 */
|
|
14
|
+
function StudioConfigCard(props) {
|
|
15
|
+
const t = props.t ?? ((key) => key);
|
|
16
|
+
const el = document.createElement("div");
|
|
17
|
+
el.className = "dsh-plus-image-studio-card-placeholder";
|
|
18
|
+
el.textContent = t("cardPlaceholder");
|
|
19
|
+
return {
|
|
20
|
+
type: el,
|
|
21
|
+
props: {}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/client/i18n.ts
|
|
26
|
+
/**
|
|
27
|
+
* i18n 字典(zh 为主,en 兜底);NS 与 settings 命名空间分离,
|
|
28
|
+
* 仅承载前端文案 key。本次只含占位文案。
|
|
29
|
+
* @module image-studio/client/i18n
|
|
30
|
+
*/
|
|
31
|
+
/** locale 命名空间。 */
|
|
32
|
+
const NS = "dsh-plus-image-studio";
|
|
33
|
+
const zh = {
|
|
34
|
+
nav: "图像工作室",
|
|
35
|
+
placeholder: "生图工作台与画廊将在后续版本提供",
|
|
36
|
+
cardPlaceholder: "图像工作室配置(预设/凭据管理将在后续版本提供)"
|
|
37
|
+
};
|
|
38
|
+
const en = {
|
|
39
|
+
nav: "Image Studio",
|
|
40
|
+
placeholder: "Image workspace and gallery arrive in a later release",
|
|
41
|
+
cardPlaceholder: "Image Studio settings (preset/credential management arrives later)"
|
|
42
|
+
};
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/client/section.tsx
|
|
45
|
+
/**
|
|
46
|
+
* 独立设置页占位组件:本次交付为空壳(不做前端设计与编码)。
|
|
47
|
+
* 后续版本在此渲染生图工作台与画廊;插槽契约已按官方 settings.section 形态声明。
|
|
48
|
+
* @module image-studio/client/section
|
|
49
|
+
*/
|
|
50
|
+
/** 占位组件(props 形态对齐 settings.section 四 share 注入)。 */
|
|
51
|
+
function StudioSection(props) {
|
|
52
|
+
const t = props.t ?? ((key) => key);
|
|
53
|
+
const el = document.createElement("div");
|
|
54
|
+
el.className = "dsh-plus-image-studio-section-placeholder";
|
|
55
|
+
el.textContent = t("placeholder");
|
|
56
|
+
return {
|
|
57
|
+
type: el,
|
|
58
|
+
props: {}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region src/client/styles.ts
|
|
63
|
+
/**
|
|
64
|
+
* 画廊/生图占位样式:本次交付仅注入极简占位类名(无视觉设计)。
|
|
65
|
+
* 沿用官方约定 <style data-plugin data-plugin-css>,HMR 按此卸载。
|
|
66
|
+
* @module image-studio/client/styles
|
|
67
|
+
*/
|
|
68
|
+
const PKG = "@dsh-plus/image-studio";
|
|
69
|
+
/** 注入设置页占位样式。 */
|
|
70
|
+
function injectSectionStyle() {
|
|
71
|
+
return inject$1("dsh-plus-image-studio-section", ".dsh-plus-image-studio-section-placeholder{padding:16px;opacity:.6}");
|
|
72
|
+
}
|
|
73
|
+
/** 注入配置卡片占位样式。 */
|
|
74
|
+
function injectCardStyles() {
|
|
75
|
+
return inject$1("dsh-plus-image-studio-card", ".dsh-plus-image-studio-card-placeholder{padding:8px;opacity:.6}");
|
|
76
|
+
}
|
|
77
|
+
function inject$1(id, css) {
|
|
78
|
+
if (typeof document === "undefined") return null;
|
|
79
|
+
const tag = document.createElement("style");
|
|
80
|
+
tag.dataset.plugin = PKG;
|
|
81
|
+
tag.dataset.pluginCss = `${PKG}/${id}`;
|
|
82
|
+
tag.textContent = css;
|
|
83
|
+
document.head.appendChild(tag);
|
|
84
|
+
return tag;
|
|
85
|
+
}
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region src/client/client.ts
|
|
88
|
+
const name = "dsh-plus-image-studio";
|
|
89
|
+
/** 浏览器半需要的 cordis 服务 key(loader 据此注入)。 */
|
|
90
|
+
const inject = [
|
|
91
|
+
"slots",
|
|
92
|
+
"locale",
|
|
93
|
+
"remote",
|
|
94
|
+
"remote.settings"
|
|
95
|
+
];
|
|
96
|
+
function apply(ctx) {
|
|
97
|
+
const c = ctx;
|
|
98
|
+
const sectionTag = injectSectionStyle();
|
|
99
|
+
const cardTag = injectCardStyles();
|
|
100
|
+
c.effect(() => () => {
|
|
101
|
+
sectionTag?.remove();
|
|
102
|
+
cardTag?.remove();
|
|
103
|
+
}, "image-studio: style");
|
|
104
|
+
c.effect(() => c.locale.register(NS, {
|
|
105
|
+
zh,
|
|
106
|
+
en
|
|
107
|
+
}), "image-studio: locale");
|
|
108
|
+
const t = c.locale.bind(NS);
|
|
109
|
+
c.slots.inject("settings.section", () => c.slots.register({
|
|
110
|
+
name: "settings.section",
|
|
111
|
+
id: "dsh-plus-image-studio",
|
|
112
|
+
order: 16,
|
|
113
|
+
label: () => t("nav"),
|
|
114
|
+
inject: () => ({ t })
|
|
115
|
+
}, StudioSection));
|
|
116
|
+
c.slots.inject("settings.plugin.item", () => c.slots.register({
|
|
117
|
+
name: "settings.plugin.item",
|
|
118
|
+
key: "dsh-plus-image-studio",
|
|
119
|
+
locale: NS,
|
|
120
|
+
inject: () => ({ t })
|
|
121
|
+
}, StudioConfigCard));
|
|
122
|
+
}
|
|
123
|
+
//#endregion
|
|
124
|
+
exports.apply = apply;
|
|
125
|
+
exports.inject = inject;
|
|
126
|
+
exports.name = name;
|
|
127
|
+
return module.exports;
|
|
128
|
+
}
|
|
129
|
+
});
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import z from "@deepseek-ai/schemastery";
|
|
2
|
+
import { Context, Service } from "@deepseek-ai/cordis";
|
|
3
|
+
//#region src/config.d.ts
|
|
4
|
+
declare const Config: z<Schemastery.ObjectS<{
|
|
5
|
+
promptPresets: z<unknown[], any[]>;
|
|
6
|
+
paramPresets: z<unknown[], any[]>;
|
|
7
|
+
providerPresets: z<unknown[], any[]>;
|
|
8
|
+
maxConcurrent: z<number, number>;
|
|
9
|
+
requestTimeoutMs: z<number, number>;
|
|
10
|
+
proxy: z<string, string>;
|
|
11
|
+
galleryMaxItems: z<number, number>;
|
|
12
|
+
}>, Schemastery.ObjectT<{
|
|
13
|
+
promptPresets: z<unknown[], any[]>;
|
|
14
|
+
paramPresets: z<unknown[], any[]>;
|
|
15
|
+
providerPresets: z<unknown[], any[]>;
|
|
16
|
+
maxConcurrent: z<number, number>;
|
|
17
|
+
requestTimeoutMs: z<number, number>;
|
|
18
|
+
proxy: z<string, string>;
|
|
19
|
+
galleryMaxItems: z<number, number>;
|
|
20
|
+
}>>;
|
|
21
|
+
type ImageStudioConfig = Schemastery.TypeT<typeof Config>;
|
|
22
|
+
/** 提示词预设(解析后视图)。 */
|
|
23
|
+
interface PromptPresetEntry {
|
|
24
|
+
id: string;
|
|
25
|
+
name: string;
|
|
26
|
+
text: string;
|
|
27
|
+
}
|
|
28
|
+
/** 参数预设(解析后视图)。 */
|
|
29
|
+
interface ParamPresetEntry {
|
|
30
|
+
id: string;
|
|
31
|
+
name: string;
|
|
32
|
+
endpoint: 'generation' | 'edit';
|
|
33
|
+
paramSpecs: unknown;
|
|
34
|
+
}
|
|
35
|
+
/** 提供商预设(解析后视图)。 */
|
|
36
|
+
interface ProviderPresetEntry {
|
|
37
|
+
id: string;
|
|
38
|
+
name: string;
|
|
39
|
+
protocol: string;
|
|
40
|
+
baseUrl: string;
|
|
41
|
+
model: string;
|
|
42
|
+
credentialRef: string;
|
|
43
|
+
extraHeaders: Record<string, string>;
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/provider/types.d.ts
|
|
47
|
+
/**
|
|
48
|
+
* 图像生成 provider 抽象:协议无关的请求/结果模型 + 适配器契约。
|
|
49
|
+
* 首批实现 openai-images;后续协议经 ImageProviderRegistry 挂载,不改核心。
|
|
50
|
+
* @module image-studio/provider/types
|
|
51
|
+
*/
|
|
52
|
+
/** 生图端点(官方 Images API 两类;新增协议可扩展联合)。 */
|
|
53
|
+
type ImageEndpoint = 'generation' | 'edit';
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/gallery/store.d.ts
|
|
56
|
+
/** 画廊条目元数据(DTO 主体,端点原样投影)。 */
|
|
57
|
+
interface GalleryItem {
|
|
58
|
+
id: string;
|
|
59
|
+
createdAt: string;
|
|
60
|
+
/** 提供商预设 id(inline 请求时为 null)。 */
|
|
61
|
+
providerPresetId: string | null;
|
|
62
|
+
protocol: string;
|
|
63
|
+
endpoint: ImageEndpoint;
|
|
64
|
+
model: string;
|
|
65
|
+
/** 用户输入提示词(原样,非 revised)。 */
|
|
66
|
+
prompt: string;
|
|
67
|
+
/** 全部启用的请求参数(请求体快照,含 response_format 等)。 */
|
|
68
|
+
params: Record<string, unknown>;
|
|
69
|
+
/** 结果图 id 列表(images/<imageId>.<ext>)。 */
|
|
70
|
+
imageIds: string[];
|
|
71
|
+
/** 每张图的 revised_prompt(与 imageIds 对齐,可为 null)。 */
|
|
72
|
+
revisedPrompts: Array<string | null>;
|
|
73
|
+
/** 图生图源图(本画廊内的 imageId);文生图为空。 */
|
|
74
|
+
sourceIds: string[];
|
|
75
|
+
}
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/task/runner.d.ts
|
|
78
|
+
/**
|
|
79
|
+
* 生图任务并发执行器:FIFO 队列 + 可配置并发上限(0 = 不限)。
|
|
80
|
+
* 与业务解耦:任务体是注入的异步函数,本模块只管调度与状态;
|
|
81
|
+
* 纯调度逻辑可单测(不触网)。
|
|
82
|
+
* @module image-studio/task/runner
|
|
83
|
+
*/
|
|
84
|
+
/** 任务状态。 */
|
|
85
|
+
type TaskState = 'queued' | 'running' | 'succeeded' | 'failed' | 'cancelled';
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region src/dto.d.ts
|
|
88
|
+
/** 任务提交请求体。 */
|
|
89
|
+
interface GenerateRequest {
|
|
90
|
+
/** 提供商预设 id 与 inline 二选一(都传时 inline 优先)。 */
|
|
91
|
+
providerPresetId?: string;
|
|
92
|
+
/** inline 提供商(无预设直发;apiKey 走同 preset 凭据通道)。 */
|
|
93
|
+
inlineProvider?: {
|
|
94
|
+
protocol: string;
|
|
95
|
+
baseUrl: string;
|
|
96
|
+
model: string;
|
|
97
|
+
};
|
|
98
|
+
endpoint: ImageEndpoint;
|
|
99
|
+
prompt: string;
|
|
100
|
+
/** 参数预设 id(先应用,再被 paramSpecs 覆盖)。 */
|
|
101
|
+
paramPresetId?: string;
|
|
102
|
+
/** 参数覆盖表(同 ParamSpecMap 形态)。 */
|
|
103
|
+
paramSpecs?: Record<string, {
|
|
104
|
+
enabled: boolean;
|
|
105
|
+
value?: unknown;
|
|
106
|
+
}>;
|
|
107
|
+
/** 图生图源图(本画廊 imageId;edit 必填 ≥1)。 */
|
|
108
|
+
sourceIds?: string[];
|
|
109
|
+
/** 可选 PNG mask(本画廊 imageId)。 */
|
|
110
|
+
maskId?: string;
|
|
111
|
+
}
|
|
112
|
+
/** 任务记录 wire 视图。 */
|
|
113
|
+
interface TaskWire {
|
|
114
|
+
id: string;
|
|
115
|
+
state: TaskState;
|
|
116
|
+
endpoint: ImageEndpoint;
|
|
117
|
+
model: string;
|
|
118
|
+
promptPreview: string;
|
|
119
|
+
createdAt: string;
|
|
120
|
+
startedAt: string | null;
|
|
121
|
+
finishedAt: string | null;
|
|
122
|
+
error: string | null;
|
|
123
|
+
/** 成功时指向画廊条目 id。 */
|
|
124
|
+
galleryItemId: string | null;
|
|
125
|
+
}
|
|
126
|
+
/** 画廊删除/查询应答。 */
|
|
127
|
+
interface GalleryListWire {
|
|
128
|
+
items: GalleryItem[];
|
|
129
|
+
total: number;
|
|
130
|
+
}
|
|
131
|
+
/** 凭据状态(describe 投影,永不回传值)。 */
|
|
132
|
+
interface CredentialStatusWire {
|
|
133
|
+
credentialRef: string;
|
|
134
|
+
configured: boolean;
|
|
135
|
+
}
|
|
136
|
+
/** providers 端点应答:协议 registry + 参数目录(前端表单依据)。 */
|
|
137
|
+
interface ProvidersWire {
|
|
138
|
+
protocols: Array<{
|
|
139
|
+
id: string;
|
|
140
|
+
label: string;
|
|
141
|
+
endpoints: ImageEndpoint[];
|
|
142
|
+
}>;
|
|
143
|
+
params: Array<{
|
|
144
|
+
key: string;
|
|
145
|
+
kind: string;
|
|
146
|
+
values?: readonly string[];
|
|
147
|
+
min?: number;
|
|
148
|
+
max?: number;
|
|
149
|
+
applies: ImageEndpoint[];
|
|
150
|
+
generation: string;
|
|
151
|
+
advanced: boolean;
|
|
152
|
+
description: string;
|
|
153
|
+
}>;
|
|
154
|
+
}
|
|
155
|
+
/** 预设三组(settings 快照投影)。 */
|
|
156
|
+
interface PresetsWire {
|
|
157
|
+
promptPresets: PromptPresetEntry[];
|
|
158
|
+
paramPresets: ParamPresetEntry[];
|
|
159
|
+
providerPresets: ProviderPresetEntry[];
|
|
160
|
+
}
|
|
161
|
+
//#endregion
|
|
162
|
+
//#region src/service.d.ts
|
|
163
|
+
declare class ImageStudioService extends Service {
|
|
164
|
+
private current;
|
|
165
|
+
private readonly runner;
|
|
166
|
+
private readonly log;
|
|
167
|
+
constructor(ctx: Context, config: ImageStudioConfig);
|
|
168
|
+
/** 配置热更:并发上限即时生效(进行中任务不受影响)。 */
|
|
169
|
+
private applyConfig;
|
|
170
|
+
private promptPresets;
|
|
171
|
+
private paramPresets;
|
|
172
|
+
private providerPresets;
|
|
173
|
+
/** 预设快照(端点投影)。 */
|
|
174
|
+
presets(): {
|
|
175
|
+
promptPresets: PromptPresetEntry[];
|
|
176
|
+
paramPresets: ParamPresetEntry[];
|
|
177
|
+
providerPresets: ProviderPresetEntry[];
|
|
178
|
+
};
|
|
179
|
+
/** describe 单个提供商预设凭据(不回传值)。 */
|
|
180
|
+
credentialStatus(presetId: string): Promise<{
|
|
181
|
+
credentialRef: string;
|
|
182
|
+
configured: boolean;
|
|
183
|
+
}>;
|
|
184
|
+
/** set/unset 凭据(端点写通道)。 */
|
|
185
|
+
setCredential(presetId: string, value: string): Promise<void>;
|
|
186
|
+
unsetCredential(presetId: string): Promise<void>;
|
|
187
|
+
/** credentials seam 可选探测(缺席返回 null)。 */
|
|
188
|
+
private credentialsSeam;
|
|
189
|
+
private requireCredentials;
|
|
190
|
+
/** 提交生图任务:校验 → 入队 → 返回 taskId。 */
|
|
191
|
+
submitGenerate(request: GenerateRequest): Promise<string>;
|
|
192
|
+
/** 单任务查询(wire 投影)。 */
|
|
193
|
+
taskWire(id: string): TaskWire | null;
|
|
194
|
+
/** 任务列表(最新在前)。 */
|
|
195
|
+
taskWires(): TaskWire[];
|
|
196
|
+
/** 取消任务。 */
|
|
197
|
+
cancelTask(id: string): boolean;
|
|
198
|
+
private toTaskWire;
|
|
199
|
+
/**
|
|
200
|
+
* 任务准备(边界校验集中地):提供商预设/inline → target;
|
|
201
|
+
* 参数预设 + 覆盖 → 归一化参数表;sourceIds → 输入图字节。
|
|
202
|
+
*/
|
|
203
|
+
private prepareTask;
|
|
204
|
+
/** 提供商预设 / inline → ProviderTarget(凭据即时 resolve)。 */
|
|
205
|
+
private resolveTarget;
|
|
206
|
+
/** 凭据解析(每次操作即时 resolve,不缓存)。 */
|
|
207
|
+
private resolveApiKey;
|
|
208
|
+
/** 参数预设 + 覆盖合并 → 端点归一化(model 由 target 承载)。 */
|
|
209
|
+
private resolveParams;
|
|
210
|
+
/** 模型优先级:inline > 提供商预设(参数表中的 model 仅为展示,不参与)。 */
|
|
211
|
+
private modelOf;
|
|
212
|
+
private providerModelOf;
|
|
213
|
+
/** 源图字节加载(edit ≥1 张;单图上限 50MB 对齐官方)。 */
|
|
214
|
+
private loadSourceImages;
|
|
215
|
+
private loadMask;
|
|
216
|
+
private loadOneImage;
|
|
217
|
+
/** 任务体:调协议适配器 → 成功入画廊。失败向上抛给 TaskRunner 记录。 */
|
|
218
|
+
private executeTask;
|
|
219
|
+
/** 提交时上下文里的预设 id(executeTask 无原请求,经 target 旁路携带)。 */
|
|
220
|
+
private presetIdOf;
|
|
221
|
+
/** 画廊列表(全量;分页/过滤由端点层做)。 */
|
|
222
|
+
gallery(): Promise<GalleryItem[]>;
|
|
223
|
+
/** 删除画廊条目(图片 + 元数据)。 */
|
|
224
|
+
deleteGalleryItem(itemId: string): Promise<boolean>;
|
|
225
|
+
/** 读取图片字节(端点直投流)。 */
|
|
226
|
+
imageBytes(imageId: string): Promise<{
|
|
227
|
+
data: Uint8Array;
|
|
228
|
+
ext: string;
|
|
229
|
+
} | null>;
|
|
230
|
+
dispose(): void;
|
|
231
|
+
}
|
|
232
|
+
//#endregion
|
|
233
|
+
//#region src/credentials.d.ts
|
|
234
|
+
/**
|
|
235
|
+
* 凭据引用名派生与校验:提供商预设 id → IMAGE_STUDIO_PRESET_<ID>。
|
|
236
|
+
* 规则对齐《插件存储规范》:大写下划线、全大写、前缀属主。
|
|
237
|
+
* 纯函数,零依赖。
|
|
238
|
+
* @module image-studio/credentials
|
|
239
|
+
*/
|
|
240
|
+
/** 预设 id 是否合法(kebab-case,用于引用名派生)。 */
|
|
241
|
+
declare function isValidPresetId(id: string): boolean;
|
|
242
|
+
/** 预设 id → 凭据引用名(kebab → SNAKE 大写)。 */
|
|
243
|
+
declare function credentialRefNameOf(presetId: string): string;
|
|
244
|
+
//#endregion
|
|
245
|
+
//#region src/errors.d.ts
|
|
246
|
+
/**
|
|
247
|
+
* 插件内可识别错误:消息即结构化错误码,端点与任务层按码映射 HTTP 状态。
|
|
248
|
+
* @module image-studio/errors
|
|
249
|
+
*/
|
|
250
|
+
/** 全部错误码(封闭集合,新增协议/端点行为时按需扩充)。 */
|
|
251
|
+
declare const ERROR_CODES: readonly ["unknown-protocol", "unknown-endpoint", "invalid-request", "unknown-source", "unknown-task", "task-not-runnable", "credential-unavailable", "settings-unavailable", "provider-error"];
|
|
252
|
+
type ErrorCode = (typeof ERROR_CODES)[number];
|
|
253
|
+
declare class ImageStudioError extends Error {
|
|
254
|
+
readonly code: ErrorCode;
|
|
255
|
+
constructor(code: ErrorCode, message?: string);
|
|
256
|
+
}
|
|
257
|
+
//#endregion
|
|
258
|
+
//#region src/params/catalog.d.ts
|
|
259
|
+
/** 参数值类型(校验与前端控件形态的依据)。 */
|
|
260
|
+
type ParamKind = 'string' | 'integer' | 'enum' | 'boolean';
|
|
261
|
+
/** 单个参数的目录条目。 */
|
|
262
|
+
interface ParamEntry {
|
|
263
|
+
/** 请求体字段名(官方 API 参数名)。 */
|
|
264
|
+
key: string;
|
|
265
|
+
/** 值类型。 */
|
|
266
|
+
kind: ParamKind;
|
|
267
|
+
/** enum 类型时的合法取值。 */
|
|
268
|
+
values?: readonly string[];
|
|
269
|
+
/** integer 时的下界(含)。 */
|
|
270
|
+
min?: number;
|
|
271
|
+
/** integer 时的上界(含)。 */
|
|
272
|
+
max?: number;
|
|
273
|
+
/** 适用端点(new-array 是目录实现细节,不外泄)。 */
|
|
274
|
+
applies: readonly ImageEndpoint[];
|
|
275
|
+
/** 适用模型代际:current(GPT Image)| dall-e-3 | dall-e-2 | all。 */
|
|
276
|
+
generation: 'current' | 'dall-e-3' | 'dall-e-2' | 'all';
|
|
277
|
+
/** 默认关闭(中转不兼容或旧代际专用,显式启用才发送)。 */
|
|
278
|
+
advanced: boolean;
|
|
279
|
+
/** 中文说明(面向用户的简述)。 */
|
|
280
|
+
description: string;
|
|
281
|
+
}
|
|
282
|
+
/** 只读目录(冻结防运行期篡改)。 */
|
|
283
|
+
declare const PARAM_CATALOG: readonly ParamEntry[];
|
|
284
|
+
/** 按字段名查目录条目。 */
|
|
285
|
+
declare function paramEntryOf(key: string): ParamEntry | null;
|
|
286
|
+
/** 某端点下可用的参数键集合(含 advanced)。 */
|
|
287
|
+
declare function paramKeysFor(endpoint: ImageEndpoint): readonly string[];
|
|
288
|
+
//#endregion
|
|
289
|
+
//#region src/params/spec.d.ts
|
|
290
|
+
/** 单参数的开关 + 自定义值。 */
|
|
291
|
+
interface ParamSpec {
|
|
292
|
+
enabled: boolean;
|
|
293
|
+
value?: unknown;
|
|
294
|
+
}
|
|
295
|
+
/** 端点 → 该端点参数表。 */
|
|
296
|
+
type ParamSpecMap = Record<string, ParamSpec>;
|
|
297
|
+
/** 归一化失败原因(边界校验用,端点转 invalid-request)。 */
|
|
298
|
+
declare class ParamValidationError extends Error {
|
|
299
|
+
readonly key: string;
|
|
300
|
+
constructor(key: string, message: string);
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* 校验并归一化一份参数表:仅保留启用且适用于该端点的参数;
|
|
304
|
+
* model 是请求基础(提供商预设承载),不计入协议参数表。
|
|
305
|
+
* 任何禁用/未知/越界项直接抛 ParamValidationError(边界 fail-loud)。
|
|
306
|
+
*/
|
|
307
|
+
declare function normalizeParamSpecs(specs: ParamSpecMap, endpoint: ImageEndpoint): Record<string, unknown>;
|
|
308
|
+
/** 校验预设里的参数表(结构合法但可跨端点;应用时再按端点归一化)。 */
|
|
309
|
+
declare function validateParamSpecs(specs: unknown): ParamSpecMap;
|
|
310
|
+
//#endregion
|
|
311
|
+
//#region src/index.d.ts
|
|
312
|
+
declare const name = "dsh-plus-image-studio";
|
|
313
|
+
declare const inject: readonly ["credentials"];
|
|
314
|
+
declare module '@deepseek-ai/cordis' {
|
|
315
|
+
interface Context {
|
|
316
|
+
imageStudio: ImageStudioService;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
declare function apply(ctx: Context, config: ImageStudioConfig): void;
|
|
320
|
+
//#endregion
|
|
321
|
+
export { Config, type CredentialStatusWire, type ErrorCode, type GalleryItem, type GalleryListWire, type GenerateRequest, ImageStudioError, ImageStudioService, PARAM_CATALOG, type ParamEntry, type ParamSpec, type ParamSpecMap, ParamValidationError, type PresetsWire, type ProvidersWire, type TaskWire, apply, credentialRefNameOf, inject, isValidPresetId, name, normalizeParamSpecs, paramEntryOf, paramKeysFor, validateParamSpecs };
|