ai-world-sdk 1.2.7 → 1.3.2

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.
@@ -0,0 +1,186 @@
1
+ "use strict";
2
+ /**
3
+ * Agent Skill Client
4
+ * Agent Skills 管理客户端
5
+ * 通过后端 /api/agent-skills 上传、下载、删除、列出 Skills
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.AgentSkillClient = void 0;
9
+ const config_1 = require("./config");
10
+ const log_1 = require("./log");
11
+ // ==================== AgentSkillClient ====================
12
+ /**
13
+ * Agent Skill Client
14
+ * Agent Skills 管理客户端类
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * import { AgentSkillClient } from 'ai-world-sdk';
19
+ *
20
+ * const skills = new AgentSkillClient();
21
+ *
22
+ * // 列出所有 skills
23
+ * const list = await skills.list({ page: 1, pageSize: 20 });
24
+ *
25
+ * // 获取 skill 详情
26
+ * const detail = await skills.get('web-search');
27
+ *
28
+ * // 上传 skill(需要 File 或 Blob)
29
+ * const zipFile = new File([zipContent], 'web-search.zip');
30
+ * await skills.upload('web-search', zipFile);
31
+ *
32
+ * // 下载 skill
33
+ * const blob = await skills.download('web-search');
34
+ *
35
+ * // 删除 skill
36
+ * await skills.delete('web-search');
37
+ * ```
38
+ */
39
+ class AgentSkillClient {
40
+ constructor(config = {}) {
41
+ this.baseUrl =
42
+ config.baseUrl ||
43
+ config_1.sdkConfig.getServerUrl() ||
44
+ (typeof window !== "undefined" ? window.location.origin : "");
45
+ const globalHeaders = config_1.sdkConfig.getHeaders();
46
+ const globalToken = config.token || config_1.sdkConfig.getToken();
47
+ this.headers = {
48
+ "Content-Type": "application/json",
49
+ ...globalHeaders,
50
+ ...config.headers,
51
+ };
52
+ if (globalToken) {
53
+ this.headers["Authorization"] = `Bearer ${globalToken}`;
54
+ }
55
+ }
56
+ async handleErrorResponse(response) {
57
+ let errorMessage = `Request failed: ${response.status} ${response.statusText}`;
58
+ try {
59
+ const errorText = await response.text();
60
+ const errorJson = JSON.parse(errorText);
61
+ errorMessage = errorJson.detail || errorMessage;
62
+ }
63
+ catch {
64
+ // ignore parse error
65
+ }
66
+ throw new Error(errorMessage);
67
+ }
68
+ /**
69
+ * List agent skills
70
+ * 列出 Agent Skills
71
+ */
72
+ async list(options = {}) {
73
+ config_1.sdkConfig.ensureVersionCompatible();
74
+ const params = new URLSearchParams();
75
+ if (options.name)
76
+ params.append("name", options.name);
77
+ if (options.page)
78
+ params.append("page", String(options.page));
79
+ if (options.pageSize)
80
+ params.append("page_size", String(options.pageSize));
81
+ const apiUrl = `${this.baseUrl}/api/agent-skills/?${params.toString()}`;
82
+ (0, log_1.debugLog)("List agent skills:", options);
83
+ (0, log_1.logRequest)("GET", apiUrl, this.headers);
84
+ const response = await fetch(apiUrl, {
85
+ method: "GET",
86
+ headers: this.headers,
87
+ });
88
+ if (!response.ok) {
89
+ await this.handleErrorResponse(response);
90
+ }
91
+ const result = (await response.json());
92
+ (0, log_1.logResponse)(response.status, response.statusText, response.headers, result);
93
+ return result;
94
+ }
95
+ /**
96
+ * Get skill detail
97
+ * 获取 Skill 详情
98
+ */
99
+ async get(skillName) {
100
+ config_1.sdkConfig.ensureVersionCompatible();
101
+ const apiUrl = `${this.baseUrl}/api/agent-skills/${skillName}`;
102
+ (0, log_1.debugLog)("Get agent skill:", { skillName });
103
+ (0, log_1.logRequest)("GET", apiUrl, this.headers);
104
+ const response = await fetch(apiUrl, {
105
+ method: "GET",
106
+ headers: this.headers,
107
+ });
108
+ if (!response.ok) {
109
+ await this.handleErrorResponse(response);
110
+ }
111
+ const result = (await response.json());
112
+ (0, log_1.logResponse)(response.status, response.statusText, response.headers, result);
113
+ return result;
114
+ }
115
+ /**
116
+ * Upload a skill (zip file)
117
+ * 上传 Skill
118
+ * @param skillName - Skill 名称
119
+ * @param file - zip 文件
120
+ * @param description - 自定义显示描述(不填则使用 SKILL.md 中的描述)
121
+ */
122
+ async upload(skillName, file, description) {
123
+ config_1.sdkConfig.ensureVersionCompatible();
124
+ const formData = new FormData();
125
+ formData.append("skill_name", skillName);
126
+ formData.append("skill_zip", file);
127
+ if (description?.trim()) {
128
+ formData.append("description", description.trim());
129
+ }
130
+ const apiUrl = `${this.baseUrl}/api/agent-skills/upload`;
131
+ (0, log_1.debugLog)("Upload agent skill:", { skillName });
132
+ const uploadHeaders = { ...this.headers };
133
+ delete uploadHeaders["Content-Type"];
134
+ (0, log_1.logRequest)("POST", apiUrl, uploadHeaders, { skillName });
135
+ const response = await fetch(apiUrl, {
136
+ method: "POST",
137
+ headers: uploadHeaders,
138
+ body: formData,
139
+ });
140
+ if (!response.ok) {
141
+ await this.handleErrorResponse(response);
142
+ }
143
+ const result = (await response.json());
144
+ (0, log_1.logResponse)(response.status, response.statusText, response.headers, result);
145
+ return result;
146
+ }
147
+ /**
148
+ * Download a skill as zip blob
149
+ * 下载 Skill(返回 Blob)
150
+ */
151
+ async download(skillName) {
152
+ config_1.sdkConfig.ensureVersionCompatible();
153
+ const apiUrl = `${this.baseUrl}/api/agent-skills/${skillName}/download`;
154
+ (0, log_1.debugLog)("Download agent skill:", { skillName });
155
+ (0, log_1.logRequest)("GET", apiUrl, this.headers);
156
+ const response = await fetch(apiUrl, {
157
+ method: "GET",
158
+ headers: this.headers,
159
+ });
160
+ if (!response.ok) {
161
+ await this.handleErrorResponse(response);
162
+ }
163
+ return await response.blob();
164
+ }
165
+ /**
166
+ * Delete a skill
167
+ * 删除 Skill
168
+ */
169
+ async delete(skillName) {
170
+ config_1.sdkConfig.ensureVersionCompatible();
171
+ const apiUrl = `${this.baseUrl}/api/agent-skills/${skillName}`;
172
+ (0, log_1.debugLog)("Delete agent skill:", { skillName });
173
+ (0, log_1.logRequest)("DELETE", apiUrl, this.headers);
174
+ const response = await fetch(apiUrl, {
175
+ method: "DELETE",
176
+ headers: this.headers,
177
+ });
178
+ if (!response.ok) {
179
+ await this.handleErrorResponse(response);
180
+ }
181
+ const result = (await response.json());
182
+ (0, log_1.logResponse)(response.status, response.statusText, response.headers, result);
183
+ return result;
184
+ }
185
+ }
186
+ exports.AgentSkillClient = AgentSkillClient;
package/dist/config.d.ts CHANGED
@@ -9,7 +9,7 @@
9
9
  *
10
10
  * 注意: {VERSION} 占位符会在构建时被替换为实际版本号
11
11
  */
12
- export declare const SDK_SIGNATURE = "AI_WORLD_SDK_V:1.2.7";
12
+ export declare const SDK_SIGNATURE = "AI_WORLD_SDK_V:1.3.2";
13
13
  /**
14
14
  * 版本兼容性错误
15
15
  */
@@ -34,8 +34,8 @@ declare class SDKConfig {
34
34
  private _authenticated;
35
35
  private _authCheckPromise;
36
36
  private _currentUser;
37
- readonly sdkSignature = "AI_WORLD_SDK_V:1.2.7";
38
- readonly sdkVersion = "1.2.7";
37
+ readonly sdkSignature = "AI_WORLD_SDK_V:1.3.2";
38
+ readonly sdkVersion = "1.3.2";
39
39
  constructor();
40
40
  /**
41
41
  * Set global base URL
package/dist/config.js CHANGED
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.sdkConfig = exports.VersionCompatibilityError = exports.SDK_SIGNATURE = void 0;
8
8
  // SDK 版本号(构建时自动从 package.json 更新)
9
9
  // 此版本号会在运行 npm run build 时自动从 package.json 读取并更新
10
- const SDK_VERSION = "1.2.7";
10
+ const SDK_VERSION = "1.3.2";
11
11
  /**
12
12
  * SDK 特征码 - 用于在构建后的 JS 文件中识别 SDK 版本
13
13
  * 格式: AI_WORLD_SDK_V:版本号
@@ -15,7 +15,7 @@ const SDK_VERSION = "1.2.7";
15
15
  *
16
16
  * 注意: {VERSION} 占位符会在构建时被替换为实际版本号
17
17
  */
18
- exports.SDK_SIGNATURE = "AI_WORLD_SDK_V:1.2.7";
18
+ exports.SDK_SIGNATURE = "AI_WORLD_SDK_V:1.3.2";
19
19
  /**
20
20
  * 版本兼容性错误
21
21
  */
@@ -0,0 +1,151 @@
1
+ /**
2
+ * Database Request Client
3
+ * 数据库请求客户端
4
+ * 通过后端 /api/database 提交建表/迁移请求,查看请求列表和详情
5
+ * 所有登录用户可提交请求,管理员可审核
6
+ */
7
+ export interface DatabaseRequestClientConfig {
8
+ baseUrl?: string;
9
+ token?: string;
10
+ headers?: Record<string, string>;
11
+ }
12
+ export type RequestType = "create" | "migrate";
13
+ export type RequestStatus = "pending" | "approved" | "rejected";
14
+ export interface ColumnDefinition {
15
+ name: string;
16
+ type: string;
17
+ primary_key?: boolean;
18
+ auto_increment?: boolean;
19
+ nullable?: boolean;
20
+ default?: unknown;
21
+ length?: number;
22
+ precision?: number;
23
+ scale?: number;
24
+ }
25
+ export interface IndexDefinition {
26
+ name: string;
27
+ columns: string[];
28
+ unique?: boolean;
29
+ }
30
+ export interface ForeignKeyDefinition {
31
+ column: string;
32
+ references_table: string;
33
+ references_column: string;
34
+ on_delete?: string;
35
+ }
36
+ export interface SchemaDefinition {
37
+ columns: ColumnDefinition[];
38
+ indexes?: IndexDefinition[];
39
+ foreign_keys?: ForeignKeyDefinition[];
40
+ }
41
+ export interface SubmitCreateRequestOptions {
42
+ tableName: string;
43
+ schemaDefinition: SchemaDefinition;
44
+ description?: string;
45
+ }
46
+ export interface SubmitMigrateRequestOptions {
47
+ tableName: string;
48
+ migrationSql: string;
49
+ description?: string;
50
+ }
51
+ export interface DatabaseRequestInfo {
52
+ id: number;
53
+ requester_id: number;
54
+ plugin_id: string;
55
+ table_name: string;
56
+ request_type: RequestType;
57
+ schema_definition: SchemaDefinition | null;
58
+ migration_sql: string | null;
59
+ description: string | null;
60
+ status: RequestStatus;
61
+ reviewer_id: number | null;
62
+ review_comment: string | null;
63
+ created_at: string;
64
+ reviewed_at: string | null;
65
+ }
66
+ export interface ListRequestsOptions {
67
+ status?: RequestStatus;
68
+ page?: number;
69
+ pageSize?: number;
70
+ }
71
+ /**
72
+ * Database Request Client
73
+ * 数据库请求客户端类
74
+ *
75
+ * @example
76
+ * ```typescript
77
+ * import { DatabaseRequestClient, sdkConfig } from 'ai-world-sdk';
78
+ *
79
+ * sdkConfig.setPluginId('my-plugin');
80
+ * const dbRequests = new DatabaseRequestClient();
81
+ *
82
+ * // 提交建表请求
83
+ * const req = await dbRequests.submitCreateRequest({
84
+ * tableName: 'user_scores',
85
+ * schemaDefinition: {
86
+ * columns: [
87
+ * { name: 'id', type: 'integer', primary_key: true, auto_increment: true, nullable: false },
88
+ * { name: 'user_id', type: 'integer', nullable: false },
89
+ * { name: 'score', type: 'float', nullable: false },
90
+ * ],
91
+ * indexes: [{ name: 'idx_user_id', columns: ['user_id'] }],
92
+ * },
93
+ * description: '用户评分表',
94
+ * });
95
+ *
96
+ * // 提交迁移请求
97
+ * const migrateReq = await dbRequests.submitMigrateRequest({
98
+ * tableName: 'user_scores',
99
+ * migrationSql: 'ALTER TABLE my_plugin_user_scores ADD COLUMN level INTEGER DEFAULT 0;',
100
+ * description: '添加 level 字段',
101
+ * });
102
+ *
103
+ * // 列出我的请求
104
+ * const list = await dbRequests.listRequests({ status: 'pending' });
105
+ *
106
+ * // 获取请求详情
107
+ * const detail = await dbRequests.getRequest(req.id);
108
+ *
109
+ * // 获取请求总数
110
+ * const total = await dbRequests.getRequestCount({ status: 'pending' });
111
+ * ```
112
+ */
113
+ export declare class DatabaseRequestClient {
114
+ private baseUrl;
115
+ private headers;
116
+ constructor(config?: DatabaseRequestClientConfig);
117
+ private getPluginId;
118
+ private handleErrorResponse;
119
+ /**
120
+ * Submit a table creation request
121
+ * 提交建表请求
122
+ */
123
+ submitCreateRequest(options: SubmitCreateRequestOptions): Promise<DatabaseRequestInfo>;
124
+ /**
125
+ * Submit a migration request
126
+ * 提交迁移请求
127
+ */
128
+ submitMigrateRequest(options: SubmitMigrateRequestOptions): Promise<DatabaseRequestInfo>;
129
+ /**
130
+ * List requests (admin sees all, regular users see own)
131
+ * 列出请求列表(管理员看全部,普通用户看自己的)
132
+ */
133
+ listRequests(options?: ListRequestsOptions): Promise<DatabaseRequestInfo[]>;
134
+ /**
135
+ * Get request count
136
+ * 获取请求总数
137
+ */
138
+ getRequestCount(options?: {
139
+ status?: RequestStatus;
140
+ }): Promise<number>;
141
+ /**
142
+ * Get request detail by ID
143
+ * 获取请求详情
144
+ */
145
+ getRequest(requestId: number): Promise<DatabaseRequestInfo>;
146
+ /**
147
+ * Review a request (approve/reject) - requires can_manage_database permission
148
+ * 审核请求(通过/拒绝)- 需要 can_manage_database 权限
149
+ */
150
+ reviewRequest(requestId: number, action: "approve" | "reject", comment?: string): Promise<DatabaseRequestInfo>;
151
+ }
@@ -0,0 +1,242 @@
1
+ "use strict";
2
+ /**
3
+ * Database Request Client
4
+ * 数据库请求客户端
5
+ * 通过后端 /api/database 提交建表/迁移请求,查看请求列表和详情
6
+ * 所有登录用户可提交请求,管理员可审核
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.DatabaseRequestClient = void 0;
10
+ const config_1 = require("./config");
11
+ const log_1 = require("./log");
12
+ // ==================== DatabaseRequestClient ====================
13
+ /**
14
+ * Database Request Client
15
+ * 数据库请求客户端类
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * import { DatabaseRequestClient, sdkConfig } from 'ai-world-sdk';
20
+ *
21
+ * sdkConfig.setPluginId('my-plugin');
22
+ * const dbRequests = new DatabaseRequestClient();
23
+ *
24
+ * // 提交建表请求
25
+ * const req = await dbRequests.submitCreateRequest({
26
+ * tableName: 'user_scores',
27
+ * schemaDefinition: {
28
+ * columns: [
29
+ * { name: 'id', type: 'integer', primary_key: true, auto_increment: true, nullable: false },
30
+ * { name: 'user_id', type: 'integer', nullable: false },
31
+ * { name: 'score', type: 'float', nullable: false },
32
+ * ],
33
+ * indexes: [{ name: 'idx_user_id', columns: ['user_id'] }],
34
+ * },
35
+ * description: '用户评分表',
36
+ * });
37
+ *
38
+ * // 提交迁移请求
39
+ * const migrateReq = await dbRequests.submitMigrateRequest({
40
+ * tableName: 'user_scores',
41
+ * migrationSql: 'ALTER TABLE my_plugin_user_scores ADD COLUMN level INTEGER DEFAULT 0;',
42
+ * description: '添加 level 字段',
43
+ * });
44
+ *
45
+ * // 列出我的请求
46
+ * const list = await dbRequests.listRequests({ status: 'pending' });
47
+ *
48
+ * // 获取请求详情
49
+ * const detail = await dbRequests.getRequest(req.id);
50
+ *
51
+ * // 获取请求总数
52
+ * const total = await dbRequests.getRequestCount({ status: 'pending' });
53
+ * ```
54
+ */
55
+ class DatabaseRequestClient {
56
+ constructor(config = {}) {
57
+ this.baseUrl =
58
+ config.baseUrl ||
59
+ config_1.sdkConfig.getServerUrl() ||
60
+ (typeof window !== "undefined" ? window.location.origin : "");
61
+ const globalHeaders = config_1.sdkConfig.getHeaders();
62
+ const globalToken = config.token || config_1.sdkConfig.getToken();
63
+ this.headers = {
64
+ "Content-Type": "application/json",
65
+ ...globalHeaders,
66
+ ...config.headers,
67
+ };
68
+ if (globalToken) {
69
+ this.headers["Authorization"] = `Bearer ${globalToken}`;
70
+ }
71
+ }
72
+ getPluginId() {
73
+ const pluginId = this.headers["X-Plugin-Id"] || config_1.sdkConfig.getPluginId();
74
+ if (!pluginId) {
75
+ throw new Error("Plugin ID is required. Set it via sdkConfig.setPluginId() or pass pluginId in headers.");
76
+ }
77
+ return pluginId;
78
+ }
79
+ async handleErrorResponse(response) {
80
+ let errorMessage = `Request failed: ${response.status} ${response.statusText}`;
81
+ try {
82
+ const errorText = await response.text();
83
+ const errorJson = JSON.parse(errorText);
84
+ errorMessage = errorJson.detail || errorMessage;
85
+ }
86
+ catch {
87
+ // ignore parse error
88
+ }
89
+ throw new Error(errorMessage);
90
+ }
91
+ /**
92
+ * Submit a table creation request
93
+ * 提交建表请求
94
+ */
95
+ async submitCreateRequest(options) {
96
+ config_1.sdkConfig.ensureVersionCompatible();
97
+ const pluginId = this.getPluginId();
98
+ const body = {
99
+ plugin_id: pluginId,
100
+ table_name: options.tableName,
101
+ request_type: "create",
102
+ schema_definition: options.schemaDefinition,
103
+ description: options.description,
104
+ };
105
+ const apiUrl = `${this.baseUrl}/api/database/table-requests`;
106
+ (0, log_1.debugLog)("Submit create request:", body);
107
+ (0, log_1.logRequest)("POST", apiUrl, this.headers, body);
108
+ const response = await fetch(apiUrl, {
109
+ method: "POST",
110
+ headers: this.headers,
111
+ body: JSON.stringify(body),
112
+ });
113
+ if (!response.ok) {
114
+ await this.handleErrorResponse(response);
115
+ }
116
+ const result = (await response.json());
117
+ (0, log_1.logResponse)(response.status, response.statusText, response.headers, result);
118
+ return result;
119
+ }
120
+ /**
121
+ * Submit a migration request
122
+ * 提交迁移请求
123
+ */
124
+ async submitMigrateRequest(options) {
125
+ config_1.sdkConfig.ensureVersionCompatible();
126
+ const pluginId = this.getPluginId();
127
+ const body = {
128
+ plugin_id: pluginId,
129
+ table_name: options.tableName,
130
+ request_type: "migrate",
131
+ migration_sql: options.migrationSql,
132
+ description: options.description,
133
+ };
134
+ const apiUrl = `${this.baseUrl}/api/database/table-requests`;
135
+ (0, log_1.debugLog)("Submit migrate request:", body);
136
+ (0, log_1.logRequest)("POST", apiUrl, this.headers, body);
137
+ const response = await fetch(apiUrl, {
138
+ method: "POST",
139
+ headers: this.headers,
140
+ body: JSON.stringify(body),
141
+ });
142
+ if (!response.ok) {
143
+ await this.handleErrorResponse(response);
144
+ }
145
+ const result = (await response.json());
146
+ (0, log_1.logResponse)(response.status, response.statusText, response.headers, result);
147
+ return result;
148
+ }
149
+ /**
150
+ * List requests (admin sees all, regular users see own)
151
+ * 列出请求列表(管理员看全部,普通用户看自己的)
152
+ */
153
+ async listRequests(options = {}) {
154
+ config_1.sdkConfig.ensureVersionCompatible();
155
+ const params = new URLSearchParams();
156
+ if (options.status)
157
+ params.append("status", options.status);
158
+ if (options.page)
159
+ params.append("page", String(options.page));
160
+ if (options.pageSize)
161
+ params.append("page_size", String(options.pageSize));
162
+ const apiUrl = `${this.baseUrl}/api/database/table-requests?${params.toString()}`;
163
+ (0, log_1.debugLog)("List requests:", options);
164
+ (0, log_1.logRequest)("GET", apiUrl, this.headers);
165
+ const response = await fetch(apiUrl, {
166
+ method: "GET",
167
+ headers: this.headers,
168
+ });
169
+ if (!response.ok) {
170
+ await this.handleErrorResponse(response);
171
+ }
172
+ const result = (await response.json());
173
+ (0, log_1.logResponse)(response.status, response.statusText, response.headers, result);
174
+ return result;
175
+ }
176
+ /**
177
+ * Get request count
178
+ * 获取请求总数
179
+ */
180
+ async getRequestCount(options = {}) {
181
+ config_1.sdkConfig.ensureVersionCompatible();
182
+ const params = new URLSearchParams();
183
+ if (options.status)
184
+ params.append("status", options.status);
185
+ const apiUrl = `${this.baseUrl}/api/database/table-requests/count?${params.toString()}`;
186
+ (0, log_1.debugLog)("Get request count:", options);
187
+ (0, log_1.logRequest)("GET", apiUrl, this.headers);
188
+ const response = await fetch(apiUrl, {
189
+ method: "GET",
190
+ headers: this.headers,
191
+ });
192
+ if (!response.ok) {
193
+ await this.handleErrorResponse(response);
194
+ }
195
+ const result = (await response.json());
196
+ (0, log_1.logResponse)(response.status, response.statusText, response.headers, result);
197
+ return result.total;
198
+ }
199
+ /**
200
+ * Get request detail by ID
201
+ * 获取请求详情
202
+ */
203
+ async getRequest(requestId) {
204
+ config_1.sdkConfig.ensureVersionCompatible();
205
+ const apiUrl = `${this.baseUrl}/api/database/table-requests/${requestId}`;
206
+ (0, log_1.debugLog)("Get request detail:", { requestId });
207
+ (0, log_1.logRequest)("GET", apiUrl, this.headers);
208
+ const response = await fetch(apiUrl, {
209
+ method: "GET",
210
+ headers: this.headers,
211
+ });
212
+ if (!response.ok) {
213
+ await this.handleErrorResponse(response);
214
+ }
215
+ const result = (await response.json());
216
+ (0, log_1.logResponse)(response.status, response.statusText, response.headers, result);
217
+ return result;
218
+ }
219
+ /**
220
+ * Review a request (approve/reject) - requires can_manage_database permission
221
+ * 审核请求(通过/拒绝)- 需要 can_manage_database 权限
222
+ */
223
+ async reviewRequest(requestId, action, comment) {
224
+ config_1.sdkConfig.ensureVersionCompatible();
225
+ const body = { action, comment };
226
+ const apiUrl = `${this.baseUrl}/api/database/table-requests/${requestId}`;
227
+ (0, log_1.debugLog)("Review request:", { requestId, ...body });
228
+ (0, log_1.logRequest)("PATCH", apiUrl, this.headers, body);
229
+ const response = await fetch(apiUrl, {
230
+ method: "PATCH",
231
+ headers: this.headers,
232
+ body: JSON.stringify(body),
233
+ });
234
+ if (!response.ok) {
235
+ await this.handleErrorResponse(response);
236
+ }
237
+ const result = (await response.json());
238
+ (0, log_1.logResponse)(response.status, response.statusText, response.headers, result);
239
+ return result;
240
+ }
241
+ }
242
+ exports.DatabaseRequestClient = DatabaseRequestClient;
package/dist/index.d.ts CHANGED
@@ -29,6 +29,8 @@ export { OpenAIVideoGenerationClient, type OpenAIVideoGenerationConfig, type Ope
29
29
  export { DownloadClient, type DownloadConfig, type DownloadOptions, type StreamDownloadOptions, };
30
30
  export { MinioStorageClient, type MinioStorageConfig, type UploadResponse, type ObjectInfo, type PresignedUrlResponse, type UploadOptions, type ListOptions, } from "./minio";
31
31
  export { ResourceClient, type ResourceClientConfig, type ResourceInfo, type AccessLevel, type UploadResourceOptions, type ListResourceOptions, } from "./resource";
32
+ export { DatabaseRequestClient, type DatabaseRequestClientConfig, type DatabaseRequestInfo, type RequestType, type RequestStatus, type ColumnDefinition, type IndexDefinition, type ForeignKeyDefinition, type SchemaDefinition, type SubmitCreateRequestOptions, type SubmitMigrateRequestOptions, type ListRequestsOptions, } from "./database-requests";
33
+ export { AgentSkillClient, type AgentSkillClientConfig, type AgentSkillInfo, type AgentSkillListResponse, type ListSkillsOptions, } from "./agent-skills";
32
34
  export { AuthClient, getCurrentUserInfo, type AuthConfig, type UserInfo, };
33
35
  export { sdkConfig, VersionCompatibilityError, SDK_SIGNATURE, type AuthenticatedUser } from "./config";
34
36
  /**
package/dist/index.js CHANGED
@@ -20,7 +20,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
20
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.SDK_SIGNATURE = exports.VersionCompatibilityError = exports.sdkConfig = exports.getCurrentUserInfo = exports.AuthClient = exports.ResourceClient = exports.MinioStorageClient = exports.DownloadClient = exports.OpenAIVideoGenerationClient = exports.VideoGenerationClient = exports.GeminiImageGenerationClient = exports.DoubaoImageGenerationClient = exports.ChatAnthropic = exports.ChatGoogleGenerativeAI = exports.ChatOpenAI = exports.BaseChatModel = exports.AIMessageChunk = exports.SystemMessage = exports.AIMessage = exports.HumanMessage = void 0;
23
+ exports.SDK_SIGNATURE = exports.VersionCompatibilityError = exports.sdkConfig = exports.getCurrentUserInfo = exports.AuthClient = exports.AgentSkillClient = exports.DatabaseRequestClient = exports.ResourceClient = exports.MinioStorageClient = exports.DownloadClient = exports.OpenAIVideoGenerationClient = exports.VideoGenerationClient = exports.GeminiImageGenerationClient = exports.DoubaoImageGenerationClient = exports.ChatAnthropic = exports.ChatGoogleGenerativeAI = exports.ChatOpenAI = exports.BaseChatModel = exports.AIMessageChunk = exports.SystemMessage = exports.AIMessage = exports.HumanMessage = void 0;
24
24
  exports.createChatModel = createChatModel;
25
25
  const openai_1 = require("./chat_models/openai");
26
26
  const google_1 = require("./chat_models/google");
@@ -59,6 +59,12 @@ Object.defineProperty(exports, "MinioStorageClient", { enumerable: true, get: fu
59
59
  // Export resource management client
60
60
  var resource_1 = require("./resource");
61
61
  Object.defineProperty(exports, "ResourceClient", { enumerable: true, get: function () { return resource_1.ResourceClient; } });
62
+ // Export database request client
63
+ var database_requests_1 = require("./database-requests");
64
+ Object.defineProperty(exports, "DatabaseRequestClient", { enumerable: true, get: function () { return database_requests_1.DatabaseRequestClient; } });
65
+ // Export agent skill client
66
+ var agent_skills_1 = require("./agent-skills");
67
+ Object.defineProperty(exports, "AgentSkillClient", { enumerable: true, get: function () { return agent_skills_1.AgentSkillClient; } });
62
68
  // Export global configuration
63
69
  var config_2 = require("./config");
64
70
  Object.defineProperty(exports, "sdkConfig", { enumerable: true, get: function () { return config_2.sdkConfig; } });
package/dist/llm.js CHANGED
@@ -7,6 +7,7 @@ const google_1 = require("@ai-sdk/google");
7
7
  const openai_1 = require("@ai-sdk/openai");
8
8
  const config_1 = require("./config");
9
9
  const ai_1 = require("ai");
10
+ const ai_sdk_provider_1 = require("@openrouter/ai-sdk-provider");
10
11
  /**
11
12
  * 根据端点类型创建 ai-sdk ProviderV3
12
13
  * 所有请求会通过后端代理(/api/llm/{endpointType})转发到实际 API
@@ -27,6 +28,10 @@ function createProvider(provider, endpointType, pluginId) {
27
28
  Authorization: `Bearer ${config_1.sdkConfig.getToken()}`,
28
29
  },
29
30
  };
31
+ if (provider === "openrouter") {
32
+ settings.baseURL = `${serverUrl}/api/llm/openrouter`;
33
+ return (0, ai_sdk_provider_1.createOpenRouter)(settings);
34
+ }
30
35
  switch (endpointType) {
31
36
  case "openai":
32
37
  return (0, openai_1.createOpenAI)(settings);
package/dist/login.d.ts CHANGED
@@ -19,6 +19,12 @@ export interface LoginResult {
19
19
  * 使用 https/http 模块替代 fetch,以支持自签名证书(rejectUnauthorized: false)
20
20
  */
21
21
  export declare function validateToken(baseUrl: string, token: string): Promise<boolean>;
22
+ /**
23
+ * 强制确保端口可用:如果被占用则 kill 占用进程
24
+ * - Unix: lsof -ti:PORT → kill -9 PID; sleep 0.3
25
+ * - Windows: netstat -ano | findstr :PORT → taskkill /F /PID PID; timeout /t 1 /nobreak >nul
26
+ */
27
+ export declare function ensurePort(port: number): void;
22
28
  /**
23
29
  * 读取 .env.local 中的环境变量
24
30
  */