koishi-plugin-aka-ai-generator 0.5.5 → 0.6.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.
@@ -19,6 +19,5 @@ export interface ProviderFactoryConfig {
19
19
  */
20
20
  export declare function createImageProvider(config: ProviderFactoryConfig): ImageProvider;
21
21
  export { ImageProvider } from './types';
22
- export { YunwuProvider } from './yunwu';
23
22
  export { GptGodProvider } from './gptgod';
24
23
  export { GeminiProvider } from './gemini';
@@ -14,11 +14,4 @@ export interface ProviderConfig {
14
14
  logger: any;
15
15
  ctx: any;
16
16
  }
17
- /**
18
- * 清理对象中的敏感信息(API KEY、密钥等)
19
- */
20
- export declare function sanitizeError(error: any): any;
21
- /**
22
- * 清理字符串中的 API KEY 模式
23
- */
24
- export declare function sanitizeString(str: string): string;
17
+ export { sanitizeError, sanitizeString } from './utils';
@@ -0,0 +1,17 @@
1
+ import { Context } from 'koishi';
2
+ /**
3
+ * 清理对象中的敏感信息(API KEY、密钥等)
4
+ */
5
+ export declare function sanitizeError(error: any): any;
6
+ /**
7
+ * 清理字符串中的 API KEY 模式
8
+ */
9
+ export declare function sanitizeString(str: string): string;
10
+ /**
11
+ * 下载图片并转换为 Base64
12
+ * 包含 MIME 类型检测和大小限制
13
+ */
14
+ export declare function downloadImageAsBase64(ctx: Context, url: string, timeout: number, logger: any, maxSize?: number): Promise<{
15
+ data: string;
16
+ mimeType: string;
17
+ }>;
@@ -0,0 +1,88 @@
1
+ import { Config } from '../index';
2
+ export interface UserData {
3
+ userId: string;
4
+ userName: string;
5
+ totalUsageCount: number;
6
+ dailyUsageCount: number;
7
+ lastDailyReset: string;
8
+ purchasedCount: number;
9
+ remainingPurchasedCount: number;
10
+ donationCount: number;
11
+ donationAmount: number;
12
+ lastUsed: string;
13
+ createdAt: string;
14
+ }
15
+ export interface UsersData {
16
+ [userId: string]: UserData;
17
+ }
18
+ export interface RechargeRecord {
19
+ id: string;
20
+ timestamp: string;
21
+ type: 'single' | 'batch' | 'all';
22
+ operator: {
23
+ userId: string;
24
+ userName: string;
25
+ };
26
+ targets: Array<{
27
+ userId: string;
28
+ userName: string;
29
+ amount: number;
30
+ beforeBalance: number;
31
+ afterBalance: number;
32
+ }>;
33
+ totalAmount: number;
34
+ note: string;
35
+ metadata: Record<string, any>;
36
+ }
37
+ export interface RechargeHistory {
38
+ version: string;
39
+ lastUpdate: string;
40
+ records: RechargeRecord[];
41
+ }
42
+ export declare class UserManager {
43
+ private dataDir;
44
+ private dataFile;
45
+ private backupFile;
46
+ private rechargeHistoryFile;
47
+ private logger;
48
+ private dataLock;
49
+ private historyLock;
50
+ private usersCache;
51
+ private activeTasks;
52
+ private rateLimitMap;
53
+ private securityBlockMap;
54
+ private securityWarningMap;
55
+ constructor(baseDir: string, logger: any);
56
+ startTask(userId: string): boolean;
57
+ endTask(userId: string): void;
58
+ isTaskActive(userId: string): boolean;
59
+ isAdmin(userId: string, config: Config): boolean;
60
+ private loadUsersData;
61
+ private saveUsersDataInternal;
62
+ getUserData(userId: string, userName: string): Promise<UserData>;
63
+ getAllUsers(): Promise<UsersData>;
64
+ updateUsersBatch(updates: (data: UsersData) => void): Promise<void>;
65
+ loadRechargeHistory(): Promise<RechargeHistory>;
66
+ addRechargeRecord(record: RechargeRecord): Promise<void>;
67
+ checkRateLimit(userId: string, config: Config): {
68
+ allowed: boolean;
69
+ message?: string;
70
+ };
71
+ updateRateLimit(userId: string): void;
72
+ checkDailyLimit(userId: string, config: Config, numImages?: number): Promise<{
73
+ allowed: boolean;
74
+ message?: string;
75
+ isAdmin?: boolean;
76
+ }>;
77
+ consumeQuota(userId: string, userName: string, commandName: string, numImages: number, config: Config): Promise<{
78
+ userData: UserData;
79
+ consumptionType: 'free' | 'purchased' | 'mixed';
80
+ freeUsed: number;
81
+ purchasedUsed: number;
82
+ }>;
83
+ recordSecurityBlock(userId: string, config: Config): Promise<{
84
+ shouldWarn: boolean;
85
+ shouldDeduct: boolean;
86
+ blockCount: number;
87
+ }>;
88
+ }
@@ -0,0 +1,20 @@
1
+ import { Argv } from 'koishi';
2
+ import { ModelMappingConfig } from '../index';
3
+ interface StyleCommandModifiers {
4
+ modelMapping?: ModelMappingConfig;
5
+ customPromptSuffix?: string;
6
+ customAdditions?: string[];
7
+ }
8
+ /**
9
+ * 规范化后缀名称
10
+ */
11
+ export declare function normalizeSuffix(value?: string): string;
12
+ /**
13
+ * 构建模型映射索引
14
+ */
15
+ export declare function buildModelMappingIndex(mappings?: ModelMappingConfig[]): Map<string, ModelMappingConfig>;
16
+ /**
17
+ * 解析风格命令修饰符
18
+ */
19
+ export declare function parseStyleCommandModifiers(argv: Argv, imgParam: any, modelMappingIndex: Map<string, ModelMappingConfig>): StyleCommandModifiers;
20
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-aka-ai-generator",
3
3
  "description": "自用AI生成插件(GPTGod & Yunwu)",
4
- "version": "0.5.5",
4
+ "version": "0.6.1",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [