koishi-plugin-imgdraw-selfuse 0.1.0 → 0.1.1

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.
Files changed (3) hide show
  1. package/lib/index.d.ts +200 -26
  2. package/lib/index.js +20 -10
  3. package/package.json +1 -1
package/lib/index.d.ts CHANGED
@@ -16,7 +16,7 @@ interface BlacklistEntry {
16
16
  id: string;
17
17
  createdAt: Date;
18
18
  }
19
- export declare const Config: Schema<Schemastery.ObjectS<{
19
+ export declare const BaseConfig: Schema<Schemastery.ObjectS<{
20
20
  debug: Schema<boolean, boolean>;
21
21
  apiStrategy: Schema<"sequence" | "roundrobin", "sequence" | "roundrobin">;
22
22
  timeout: Schema<number, number>;
@@ -32,20 +32,40 @@ export declare const Config: Schema<Schemastery.ObjectS<{
32
32
  imgQuality: Schema<number, number>;
33
33
  imgMaxFileSize: Schema<number, number>;
34
34
  enableImg2ImgBase64: Schema<boolean, boolean>;
35
- enablePresets: Schema<boolean, boolean>;
36
- presets: Schema<Schemastery.ObjectS<{
35
+ apiList: Schema<Schemastery.ObjectS<{
37
36
  enable: Schema<boolean, boolean>;
38
- text: Schema<string, string>;
39
- command: Schema<string, string>;
40
- keyword: Schema<string, string>;
41
- enableKeywordMatch: Schema<boolean, boolean>;
37
+ apiKey: Schema<string, string>;
38
+ baseUrl: Schema<string, string>;
42
39
  }>[], Schemastery.ObjectT<{
43
40
  enable: Schema<boolean, boolean>;
44
- text: Schema<string, string>;
45
- command: Schema<string, string>;
46
- keyword: Schema<string, string>;
47
- enableKeywordMatch: Schema<boolean, boolean>;
41
+ apiKey: Schema<string, string>;
42
+ baseUrl: Schema<string, string>;
48
43
  }>[]>;
44
+ enableTxt2Img: Schema<boolean, boolean>;
45
+ enableImg2Img: Schema<boolean, boolean>;
46
+ command: Schema<string, string>;
47
+ aliases: Schema<string[], string[]>;
48
+ img2imgCommand: Schema<string, string>;
49
+ img2imgAliases: Schema<string[], string[]>;
50
+ txt2imgPrompt: Schema<string, string>;
51
+ img2imgPrompt: Schema<string, string>;
52
+ blacklistAdmins: Schema<string[], string[]>;
53
+ }>, Schemastery.ObjectT<{
54
+ debug: Schema<boolean, boolean>;
55
+ apiStrategy: Schema<"sequence" | "roundrobin", "sequence" | "roundrobin">;
56
+ timeout: Schema<number, number>;
57
+ rateLimit: Schema<number, number>;
58
+ imgWaitTime: Schema<number, number>;
59
+ model: Schema<string, string>;
60
+ txt2imgModel: Schema<string, string>;
61
+ img2imgModel: Schema<string, string>;
62
+ maxImages: Schema<number, number>;
63
+ enableImgCompress: Schema<boolean, boolean>;
64
+ imgMaxWidth: Schema<number, number>;
65
+ imgMaxHeight: Schema<number, number>;
66
+ imgQuality: Schema<number, number>;
67
+ imgMaxFileSize: Schema<number, number>;
68
+ enableImg2ImgBase64: Schema<boolean, boolean>;
49
69
  apiList: Schema<Schemastery.ObjectS<{
50
70
  enable: Schema<boolean, boolean>;
51
71
  apiKey: Schema<string, string>;
@@ -64,6 +84,39 @@ export declare const Config: Schema<Schemastery.ObjectS<{
64
84
  txt2imgPrompt: Schema<string, string>;
65
85
  img2imgPrompt: Schema<string, string>;
66
86
  blacklistAdmins: Schema<string[], string[]>;
87
+ }>>;
88
+ export declare const PresetConfig: Schema<Schemastery.ObjectS<{
89
+ enablePresets: Schema<boolean, boolean>;
90
+ presets: Schema<Schemastery.ObjectS<{
91
+ enable: Schema<boolean, boolean>;
92
+ text: Schema<string, string>;
93
+ command: Schema<string, string>;
94
+ keyword: Schema<string, string>;
95
+ enableKeywordMatch: Schema<boolean, boolean>;
96
+ }>[], Schemastery.ObjectT<{
97
+ enable: Schema<boolean, boolean>;
98
+ text: Schema<string, string>;
99
+ command: Schema<string, string>;
100
+ keyword: Schema<string, string>;
101
+ enableKeywordMatch: Schema<boolean, boolean>;
102
+ }>[]>;
103
+ }>, Schemastery.ObjectT<{
104
+ enablePresets: Schema<boolean, boolean>;
105
+ presets: Schema<Schemastery.ObjectS<{
106
+ enable: Schema<boolean, boolean>;
107
+ text: Schema<string, string>;
108
+ command: Schema<string, string>;
109
+ keyword: Schema<string, string>;
110
+ enableKeywordMatch: Schema<boolean, boolean>;
111
+ }>[], Schemastery.ObjectT<{
112
+ enable: Schema<boolean, boolean>;
113
+ text: Schema<string, string>;
114
+ command: Schema<string, string>;
115
+ keyword: Schema<string, string>;
116
+ enableKeywordMatch: Schema<boolean, boolean>;
117
+ }>[]>;
118
+ }>>;
119
+ export declare const MessageConfig: Schema<Schemastery.ObjectS<{
67
120
  messages: Schema<Schemastery.ObjectS<{
68
121
  generating: Schema<string, string>;
69
122
  waitImage: Schema<string, string>;
@@ -116,6 +169,59 @@ export declare const Config: Schema<Schemastery.ObjectS<{
116
169
  blacklistListTitle: Schema<string, string>;
117
170
  }>>;
118
171
  }>, Schemastery.ObjectT<{
172
+ messages: Schema<Schemastery.ObjectS<{
173
+ generating: Schema<string, string>;
174
+ waitImage: Schema<string, string>;
175
+ timeout: Schema<string, string>;
176
+ empty: Schema<string, string>;
177
+ noApi: Schema<string, string>;
178
+ fail: Schema<string, string>;
179
+ modelTextOnly: Schema<string, string>;
180
+ needAssets: Schema<string, string>;
181
+ txt2imgDisabled: Schema<string, string>;
182
+ img2imgDisabled: Schema<string, string>;
183
+ rateLimit: Schema<string, string>;
184
+ alreadyWaiting: Schema<string, string>;
185
+ multiImageReceived: Schema<string, string>;
186
+ multiImageLimit: Schema<string, string>;
187
+ noImageReceived: Schema<string, string>;
188
+ blacklisted: Schema<string, string>;
189
+ noPermission: Schema<string, string>;
190
+ blacklistAddSuccess: Schema<string, string>;
191
+ blacklistRemoveSuccess: Schema<string, string>;
192
+ blacklistAddFail: Schema<string, string>;
193
+ blacklistRemoveFail: Schema<string, string>;
194
+ invalidUserId: Schema<string, string>;
195
+ blacklistListEmpty: Schema<string, string>;
196
+ blacklistListTitle: Schema<string, string>;
197
+ }>, Schemastery.ObjectT<{
198
+ generating: Schema<string, string>;
199
+ waitImage: Schema<string, string>;
200
+ timeout: Schema<string, string>;
201
+ empty: Schema<string, string>;
202
+ noApi: Schema<string, string>;
203
+ fail: Schema<string, string>;
204
+ modelTextOnly: Schema<string, string>;
205
+ needAssets: Schema<string, string>;
206
+ txt2imgDisabled: Schema<string, string>;
207
+ img2imgDisabled: Schema<string, string>;
208
+ rateLimit: Schema<string, string>;
209
+ alreadyWaiting: Schema<string, string>;
210
+ multiImageReceived: Schema<string, string>;
211
+ multiImageLimit: Schema<string, string>;
212
+ noImageReceived: Schema<string, string>;
213
+ blacklisted: Schema<string, string>;
214
+ noPermission: Schema<string, string>;
215
+ blacklistAddSuccess: Schema<string, string>;
216
+ blacklistRemoveSuccess: Schema<string, string>;
217
+ blacklistAddFail: Schema<string, string>;
218
+ blacklistRemoveFail: Schema<string, string>;
219
+ invalidUserId: Schema<string, string>;
220
+ blacklistListEmpty: Schema<string, string>;
221
+ blacklistListTitle: Schema<string, string>;
222
+ }>>;
223
+ }>>;
224
+ export declare const Config: Schema<Schemastery.ObjectS<{
119
225
  debug: Schema<boolean, boolean>;
120
226
  apiStrategy: Schema<"sequence" | "roundrobin", "sequence" | "roundrobin">;
121
227
  timeout: Schema<number, number>;
@@ -131,20 +237,6 @@ export declare const Config: Schema<Schemastery.ObjectS<{
131
237
  imgQuality: Schema<number, number>;
132
238
  imgMaxFileSize: Schema<number, number>;
133
239
  enableImg2ImgBase64: Schema<boolean, boolean>;
134
- enablePresets: Schema<boolean, boolean>;
135
- presets: Schema<Schemastery.ObjectS<{
136
- enable: Schema<boolean, boolean>;
137
- text: Schema<string, string>;
138
- command: Schema<string, string>;
139
- keyword: Schema<string, string>;
140
- enableKeywordMatch: Schema<boolean, boolean>;
141
- }>[], Schemastery.ObjectT<{
142
- enable: Schema<boolean, boolean>;
143
- text: Schema<string, string>;
144
- command: Schema<string, string>;
145
- keyword: Schema<string, string>;
146
- enableKeywordMatch: Schema<boolean, boolean>;
147
- }>[]>;
148
240
  apiList: Schema<Schemastery.ObjectS<{
149
241
  enable: Schema<boolean, boolean>;
150
242
  apiKey: Schema<string, string>;
@@ -163,6 +255,22 @@ export declare const Config: Schema<Schemastery.ObjectS<{
163
255
  txt2imgPrompt: Schema<string, string>;
164
256
  img2imgPrompt: Schema<string, string>;
165
257
  blacklistAdmins: Schema<string[], string[]>;
258
+ }> | Schemastery.ObjectS<{
259
+ enablePresets: Schema<boolean, boolean>;
260
+ presets: Schema<Schemastery.ObjectS<{
261
+ enable: Schema<boolean, boolean>;
262
+ text: Schema<string, string>;
263
+ command: Schema<string, string>;
264
+ keyword: Schema<string, string>;
265
+ enableKeywordMatch: Schema<boolean, boolean>;
266
+ }>[], Schemastery.ObjectT<{
267
+ enable: Schema<boolean, boolean>;
268
+ text: Schema<string, string>;
269
+ command: Schema<string, string>;
270
+ keyword: Schema<string, string>;
271
+ enableKeywordMatch: Schema<boolean, boolean>;
272
+ }>[]>;
273
+ }> | Schemastery.ObjectS<{
166
274
  messages: Schema<Schemastery.ObjectS<{
167
275
  generating: Schema<string, string>;
168
276
  waitImage: Schema<string, string>;
@@ -214,7 +322,73 @@ export declare const Config: Schema<Schemastery.ObjectS<{
214
322
  blacklistListEmpty: Schema<string, string>;
215
323
  blacklistListTitle: Schema<string, string>;
216
324
  }>>;
217
- }>>;
325
+ }>, {
326
+ debug: boolean;
327
+ apiStrategy: "sequence" | "roundrobin";
328
+ timeout: number;
329
+ rateLimit: number;
330
+ imgWaitTime: number;
331
+ model: string;
332
+ txt2imgModel: string;
333
+ img2imgModel: string;
334
+ maxImages: number;
335
+ enableImgCompress: boolean;
336
+ imgMaxWidth: number;
337
+ imgMaxHeight: number;
338
+ imgQuality: number;
339
+ imgMaxFileSize: number;
340
+ enableImg2ImgBase64: boolean;
341
+ apiList: Schemastery.ObjectT<{
342
+ enable: Schema<boolean, boolean>;
343
+ apiKey: Schema<string, string>;
344
+ baseUrl: Schema<string, string>;
345
+ }>[];
346
+ enableTxt2Img: boolean;
347
+ enableImg2Img: boolean;
348
+ command: string;
349
+ aliases: string[];
350
+ img2imgCommand: string;
351
+ img2imgAliases: string[];
352
+ txt2imgPrompt: string;
353
+ img2imgPrompt: string;
354
+ blacklistAdmins: string[];
355
+ } & import("cosmokit", { with: { "resolution-mode": "import" } }).Dict & {
356
+ enablePresets: boolean;
357
+ presets: Schemastery.ObjectT<{
358
+ enable: Schema<boolean, boolean>;
359
+ text: Schema<string, string>;
360
+ command: Schema<string, string>;
361
+ keyword: Schema<string, string>;
362
+ enableKeywordMatch: Schema<boolean, boolean>;
363
+ }>[];
364
+ } & {
365
+ messages: Schemastery.ObjectT<{
366
+ generating: Schema<string, string>;
367
+ waitImage: Schema<string, string>;
368
+ timeout: Schema<string, string>;
369
+ empty: Schema<string, string>;
370
+ noApi: Schema<string, string>;
371
+ fail: Schema<string, string>;
372
+ modelTextOnly: Schema<string, string>;
373
+ needAssets: Schema<string, string>;
374
+ txt2imgDisabled: Schema<string, string>;
375
+ img2imgDisabled: Schema<string, string>;
376
+ rateLimit: Schema<string, string>;
377
+ alreadyWaiting: Schema<string, string>;
378
+ multiImageReceived: Schema<string, string>;
379
+ multiImageLimit: Schema<string, string>;
380
+ noImageReceived: Schema<string, string>;
381
+ blacklisted: Schema<string, string>;
382
+ noPermission: Schema<string, string>;
383
+ blacklistAddSuccess: Schema<string, string>;
384
+ blacklistRemoveSuccess: Schema<string, string>;
385
+ blacklistAddFail: Schema<string, string>;
386
+ blacklistRemoveFail: Schema<string, string>;
387
+ invalidUserId: Schema<string, string>;
388
+ blacklistListEmpty: Schema<string, string>;
389
+ blacklistListTitle: Schema<string, string>;
390
+ }>;
391
+ }>;
218
392
  export type Config = any;
219
393
  export declare function apply(ctx: Context, cfg: any): Promise<void>;
220
394
  export {};
package/lib/index.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Config = exports.inject = exports.name = void 0;
6
+ exports.Config = exports.MessageConfig = exports.PresetConfig = exports.BaseConfig = exports.inject = exports.name = void 0;
7
7
  exports.apply = apply;
8
8
  const koishi_1 = require("koishi");
9
9
  const axios_1 = __importDefault(require("axios"));
@@ -24,8 +24,7 @@ exports.inject = {
24
24
  optional: ['assets'],
25
25
  };
26
26
  const logger = new koishi_1.Logger('ai-image');
27
- // ==================== 配置 Schema ====================
28
- // 预置提示词单项配置
27
+ // ==================== 预置提示词单项配置 ====================
29
28
  const PresetItem = koishi_1.Schema.object({
30
29
  enable: koishi_1.Schema.boolean().default(true).description('启用此预置提示词'),
31
30
  text: koishi_1.Schema.string().default('').description('预置提示词文本(将自动添加到 prompt 前)'),
@@ -33,7 +32,8 @@ const PresetItem = koishi_1.Schema.object({
33
32
  keyword: koishi_1.Schema.string().default('').description('匹配关键词(如 猫娘,留空则不启用关键词匹配)'),
34
33
  enableKeywordMatch: koishi_1.Schema.boolean().default(false).description('启用关键词匹配(用户 prompt 包含关键词时自动添加)'),
35
34
  }).description('预置提示词配置项');
36
- exports.Config = koishi_1.Schema.object({
35
+ // ==================== 独立大类 1:AI 绘图插件配置 ====================
36
+ exports.BaseConfig = koishi_1.Schema.object({
37
37
  debug: koishi_1.Schema.boolean().default(false).description('开启调试模式,输出完整请求日志'),
38
38
  apiStrategy: koishi_1.Schema.union([
39
39
  koishi_1.Schema.const('sequence').description('顺序模式'),
@@ -53,13 +53,9 @@ exports.Config = koishi_1.Schema.object({
53
53
  imgQuality: koishi_1.Schema.number().default(85).description('JPEG 压缩质量 1-100(越高越清晰,建议 80-90)'),
54
54
  imgMaxFileSize: koishi_1.Schema.number().default(3).description('图片最大体积(MB),超过会进一步压缩'),
55
55
  // ==========================================================
56
- // ==================== 新增:图生图 base64 转换开关 ====================
56
+ // ==================== 图生图 base64 转换开关 ====================
57
57
  enableImg2ImgBase64: koishi_1.Schema.boolean().default(true).description('图生图将图片转换为 base64(关闭则直接传 URL,部分 API 不需要 base64)'),
58
58
  // ==========================================================
59
- // ==================== 预置提示词配置 ====================
60
- enablePresets: koishi_1.Schema.boolean().default(false).description('启用预置提示词功能(仅用于文生图)'),
61
- presets: koishi_1.Schema.array(PresetItem).default([]).description('预置提示词列表(可添加多个,支持指令触发和关键词匹配)'),
62
- // ==========================================================
63
59
  apiList: koishi_1.Schema.array(koishi_1.Schema.object({
64
60
  enable: koishi_1.Schema.boolean().default(true).description('启用此 API'),
65
61
  apiKey: koishi_1.Schema.string().description('API Key'),
@@ -74,6 +70,14 @@ exports.Config = koishi_1.Schema.object({
74
70
  txt2imgPrompt: koishi_1.Schema.string().default('请严格遵循我的要求生成一张图片,不要询问或添加额外说明,直接输出图片。你可以使用联网功能获取最新的数据或信息。要求:{prompt}').description('文生图提示词模板'),
75
71
  img2imgPrompt: koishi_1.Schema.string().default('图片链接:{url} 请严格根据以下指令对提供的图片进行编辑或重绘,不要询问,直接输出结果。你可以使用联网功能获取最新的数据或信息。\n指令:{prompt}').description('图生图提示词模板'),
76
72
  blacklistAdmins: koishi_1.Schema.array(String).default([]).description('允许管理黑名单的 QQ 号列表'),
73
+ }).description('AI 绘图插件配置');
74
+ // ==================== 独立大类 2:预置提示词配置 ====================
75
+ exports.PresetConfig = koishi_1.Schema.object({
76
+ enablePresets: koishi_1.Schema.boolean().default(false).description('启用预置提示词功能(仅用于文生图)'),
77
+ presets: koishi_1.Schema.array(PresetItem).default([]).description('预置提示词列表(可添加多个,支持指令触发和关键词匹配)'),
78
+ }).description('预置提示词配置');
79
+ // ==================== 独立大类 3:提示文案配置 ====================
80
+ exports.MessageConfig = koishi_1.Schema.object({
77
81
  messages: koishi_1.Schema.object({
78
82
  generating: koishi_1.Schema.string().default('⏳ 生成中...'),
79
83
  waitImage: koishi_1.Schema.string().default('请在60秒内发送需要编辑的图片'),
@@ -100,7 +104,13 @@ exports.Config = koishi_1.Schema.object({
100
104
  blacklistListEmpty: koishi_1.Schema.string().default('✅ 当前黑名单为空'),
101
105
  blacklistListTitle: koishi_1.Schema.string().default('📋 当前黑名单:'),
102
106
  }).description('提示文案配置'),
103
- }).description('AI 绘图插件配置');
107
+ }).description('提示文案配置');
108
+ // ==================== 组合配置(三个并列大类)====================
109
+ exports.Config = koishi_1.Schema.intersect([
110
+ exports.BaseConfig,
111
+ exports.PresetConfig,
112
+ exports.MessageConfig,
113
+ ]);
104
114
  // ==================== 主函数 ====================
105
115
  async function apply(ctx, cfg) {
106
116
  const debug = cfg.debug;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-imgdraw-selfuse",
3
3
  "description": "修改自ai-image的画图插件,支持openai兼容api,增加base64转换自由开启,增加图文合并消息图生图,增加预置提示词",
4
- "version": "0.1.0",
4
+ "version": "0.1.1",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [