ibc-ai-web-sdk 2.0.5 → 2.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.
@@ -0,0 +1,56 @@
1
+ export declare class AIChatClient {
2
+ config: any;
3
+ conversationId: string | null;
4
+ currentRequestId: string | null;
5
+ abortController: AbortController | null;
6
+ refreshTokenPromise: Promise<any> | null;
7
+ _backgroundTimer: any;
8
+ _visibilityHandler: any;
9
+ constructor(config?: any);
10
+ buildUrl(path: any): any;
11
+ buildHeaders(extra?: any): any;
12
+ createError(code: any, message: any, extra?: any): any;
13
+ getAuthCodes(): Set<any>;
14
+ isAuthErrorCode(code: any): boolean;
15
+ isTokenExpiring(): boolean;
16
+ applyTokenResult(result: any): any;
17
+ refreshToken(reason?: string, { silent }?: any): Promise<any>;
18
+ _shouldStartBackgroundRefresh(): boolean;
19
+ startBackgroundRefresh(): void;
20
+ stopBackgroundRefresh(): void;
21
+ dispose(): void;
22
+ ensureFreshToken(): Promise<void>;
23
+ runAuthFn(): Promise<void>;
24
+ parseResponse(raw: any): {
25
+ success: boolean;
26
+ code: any;
27
+ message: any;
28
+ data: any;
29
+ requestId: any;
30
+ };
31
+ requestJson(path: any, payload?: {}, options?: any): Promise<any>;
32
+ buildAppPayload(prompt: any, options?: any): any;
33
+ normalizeAttachmentIds(attachments: any): any[];
34
+ sendMessage(prompt: any, token: any, options?: any): Promise<any>;
35
+ isRetryableError(error: any): boolean;
36
+ sendMessageStream(prompt: any, handlers?: any, options?: any): Promise<any>;
37
+ executeMessageStream(prompt: any, handlers: any, options: any, retriedAfterRefresh: any): any;
38
+ handleSseEvent(event: any, data: any, handlers: any, setFinalText: any, markDone: any): void;
39
+ isEventLike(text: any): boolean;
40
+ stopCompletion(requestId?: string): Promise<any>;
41
+ uploadAttachment(file: any, options?: any): Promise<any>;
42
+ queryConversation(options?: any): Promise<any>;
43
+ deleteConversation(conversationId?: string, options?: any): Promise<any>;
44
+ asyncCompletion(prompt: any, options?: any): Promise<any>;
45
+ getTaskStatus(taskId: any, options?: any): Promise<any>;
46
+ getAppDetail(appId?: any, options?: any): Promise<any>;
47
+ listApplications(options?: any): Promise<any>;
48
+ replyPermission(request: any): Promise<any>;
49
+ replyQuestion(request: any): Promise<any>;
50
+ rejectQuestion(request: any): Promise<any>;
51
+ setConversationId(conversationId: any): void;
52
+ clearConversation(): void;
53
+ cancelCurrentRequest(): void;
54
+ updateConfig(newConfig: any): void;
55
+ }
56
+ export default AIChatClient;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * IBC AI Web SDK - 纯JavaScript版本
3
+ * 支持任意前端框架:Vue, React, Angular, 原生HTML等
4
+ *
5
+ * @author IBC AI Team
6
+ * @version 2.1.0
7
+ */
8
+ import { AIChatDialog } from './AIChatDialog.js';
9
+ import { AIChatClient } from './core/AIChatClient.js';
10
+ export { AIChatDialog } from './AIChatDialog.js';
11
+ export { default as AIChatDialogDefault } from './AIChatDialog.js';
12
+ export { AIChatClient } from './core/AIChatClient.js';
13
+ export { default as AIChatClientDefault } from './core/AIChatClient.js';
14
+ export declare function createAIChatDialog(options?: any): HTMLElement;
15
+ export declare function installVuePlugin(Vue: any): void;
16
+ export declare function useAIChat(options?: any): {
17
+ open: () => void;
18
+ close: () => void;
19
+ isVisible: boolean;
20
+ messages: any[];
21
+ isLoading: boolean;
22
+ toggle?: undefined;
23
+ sendMessage?: undefined;
24
+ clearMessages?: undefined;
25
+ ref?: undefined;
26
+ } | {
27
+ open: () => void;
28
+ close: () => void;
29
+ toggle: () => void;
30
+ sendMessage: (content: any) => void;
31
+ clearMessages: () => void;
32
+ isVisible: any;
33
+ messages: any;
34
+ isLoading: any;
35
+ ref: any;
36
+ };
37
+ declare const _default: {
38
+ AIChatDialog: typeof AIChatDialog;
39
+ AIChatClient: typeof AIChatClient;
40
+ createAIChatDialog: typeof createAIChatDialog;
41
+ installVuePlugin: typeof installVuePlugin;
42
+ useAIChat: typeof useAIChat;
43
+ version: string;
44
+ };
45
+ export default _default;
@@ -0,0 +1,456 @@
1
+ /**
2
+ * IBC AI Web SDK - TypeScript 类型定义
3
+ * 统一定义所有类型和接口,提供完整的类型提示
4
+ */
5
+ /**
6
+ * AI 聊天配置接口
7
+ */
8
+ export interface AIChatConfig {
9
+ /** API 接口地址 */
10
+ apiEndpoint: string;
11
+ /** API 基础地址,默认空字符串 */
12
+ apiBaseUrl?: string;
13
+ /** 流式接口地址,默认 /v1/app/completion/stream */
14
+ streamEndpoint?: string;
15
+ /** 停止生成接口地址,默认 /v1/app/completion/stop */
16
+ stopEndpoint?: string;
17
+ /** 附件上传接口地址,默认 /v1/app/attachment/upload */
18
+ attachmentUploadEndpoint?: string;
19
+ /** 应用详情接口地址,默认 /v1/app/{appId} */
20
+ appDetailEndpoint?: string;
21
+ /** 异步任务提交接口地址,默认 /v1/app/completion/async */
22
+ asyncEndpoint?: string;
23
+ /** 任务状态查询接口地址,默认 /v1/app/task/{taskId} */
24
+ taskStatusEndpoint?: string;
25
+ /** 会话查询接口地址,默认 /v1/app/conversation/query */
26
+ conversationQueryEndpoint?: string;
27
+ /** 会话删除接口地址,默认 /v1/app/conversation/delete */
28
+ conversationDeleteEndpoint?: string;
29
+ /** 应用列表接口地址,默认 /v1/app/list */
30
+ appListEndpoint?: string;
31
+ /** 权限确认回复接口地址,默认 /v1/app/runtime/permission/reply */
32
+ runtimePermissionReplyEndpoint?: string;
33
+ /** 问题回复接口地址,默认 /v1/app/runtime/question/reply */
34
+ runtimeQuestionReplyEndpoint?: string;
35
+ /** 问题拒绝接口地址,默认 /v1/app/runtime/question/reject */
36
+ runtimeQuestionRejectEndpoint?: string;
37
+ /** 应用 ID */
38
+ appId: string;
39
+ /** @deprecated 请使用 appId */
40
+ agentAppId?: string;
41
+ /** 用户 ID */
42
+ userId: string;
43
+ /** 业务类型标识 */
44
+ bizType: string;
45
+ /** 认证 Token */
46
+ token?: string;
47
+ /** 刷新 Token,可由 refreshTokenFn 使用 */
48
+ refreshToken?: string;
49
+ /** Token 过期时间戳(毫秒),配置后 SDK 会在过期前自动刷新 */
50
+ tokenExpiresAt?: number;
51
+ /** Token 过期前多久主动刷新,默认 60000ms */
52
+ tokenRefreshBufferMs?: number;
53
+ /**
54
+ * Token 刷新函数。返回字符串时视为新的 access token;
55
+ * 返回对象时支持 token/accessToken、refreshToken、expiresAt、expiresIn、headers。
56
+ */
57
+ refreshTokenFn?: (context: TokenRefreshContext) => Promise<TokenRefreshResult>;
58
+ /** Token 刷新成功回调 */
59
+ onTokenRefreshed?: (result: TokenRefreshSuccess) => void;
60
+ /** Token 刷新失败或未配置刷新函数时触发 */
61
+ onTokenExpired?: (error: Error | unknown) => void;
62
+ /** 额外业务未授权错误码,默认已包含 401/403/1005/S00001/ET0006/999990 */
63
+ authErrorCodes?: Array<string | number>;
64
+ /** 请求超时时间(毫秒),默认 60000 */
65
+ timeout?: number;
66
+ /** 自定义请求头 */
67
+ headers?: Record<string, string>;
68
+ /** 扩展信息 */
69
+ extendInfo?: Record<string, any> | null;
70
+ /** 对话框标题,默认 'AI 智能助理' */
71
+ title?: string;
72
+ /** 欢迎文本,默认 '您好!我是 AI 智能助理' */
73
+ welcomeText?: string;
74
+ /** 欢迎描述,默认 '我可以帮您解答系统使用问题' */
75
+ welcomeDesc?: string;
76
+ /** 最大消息数量,默认 50 */
77
+ maxMessages?: number;
78
+ /** 输入框最大字数,默认 500 */
79
+ maxLength?: number;
80
+ /** 历史记录查询条数,默认 20 */
81
+ historyPageSize?: number;
82
+ /** 历史记录保留天数,默认 30;0 表示不按天过滤 */
83
+ historyDays?: number;
84
+ /** 是否允许拖拽,默认 true */
85
+ enableDrag?: boolean;
86
+ /**
87
+ * 可选鉴权函数
88
+ * @param token - 当前用户的 token
89
+ * @param userId - 用户 ID
90
+ * @returns Promise<void>,resolve 表示通过,reject/throw 表示拒绝
91
+ */
92
+ authFn?: (token: string, userId: string) => Promise<void>;
93
+ /** SDK 加载完成回调 */
94
+ onLoad?: (client: AIChatClient) => void;
95
+ /** 错误回调 */
96
+ onError?: (error: Error | string) => void;
97
+ /** 主题配置 */
98
+ theme?: {
99
+ /** 主色调 */
100
+ primaryColor?: string;
101
+ /** 背景色 */
102
+ backgroundColor?: string;
103
+ /** 气泡背景色 */
104
+ bubbleColor?: string;
105
+ };
106
+ }
107
+ /**
108
+ * AI 聊天客户端接口
109
+ */
110
+ export interface AIChatClient {
111
+ /** 发送聊天消息 */
112
+ sendMessage(prompt: string, token?: string, options?: AIChatRequestOptions): Promise<AIResponse>;
113
+ /** 发送流式聊天消息 */
114
+ sendMessageStream(prompt: string, handlers?: AIStreamHandlers, options?: AIChatRequestOptions): Promise<AIResponse>;
115
+ /** 停止当前流式生成 */
116
+ stopCompletion(requestId?: string): Promise<AIResponse>;
117
+ /** 上传附件 */
118
+ uploadAttachment(file: File, options?: UploadAttachmentOptions): Promise<AIResponse<AttachmentUploadResponse>>;
119
+ /** 查询会话记录 */
120
+ queryConversation(options?: ConversationQueryOptions): Promise<AIResponse<ConversationQueryResponse>>;
121
+ /** 删除会话记录 */
122
+ deleteConversation(conversationId?: string, options?: ConversationQueryOptions): Promise<AIResponse>;
123
+ /** 异步提交任务 */
124
+ asyncCompletion(prompt: string, options?: AIChatRequestOptions): Promise<AIResponse>;
125
+ /** 查询异步任务状态 */
126
+ getTaskStatus(taskId: string): Promise<AIResponse>;
127
+ /** 查询智能体详情 */
128
+ getAppDetail(appId?: string): Promise<AIResponse>;
129
+ /** 查询可用智能体应用列表 */
130
+ listApplications(options?: AppListOptions): Promise<AIResponse<AppListResponse>>;
131
+ /** 回复权限确认请求(HITL权限交互) */
132
+ replyPermission(request: PermissionReplyRequest): Promise<AIResponse>;
133
+ /** 回复智能体问题(HITL问答交互) */
134
+ replyQuestion(request: QuestionReplyRequest): Promise<AIResponse>;
135
+ /** 拒绝智能体问题(HITL问答拒绝) */
136
+ rejectQuestion(request: QuestionRejectRequest): Promise<AIResponse>;
137
+ /** 设置会话 ID */
138
+ setConversationId(conversationId: string): void;
139
+ /** 清除会话 ID(开始新对话) */
140
+ clearConversation(): void;
141
+ /** 取消当前请求 */
142
+ cancelCurrentRequest(): void;
143
+ /** 更新配置 */
144
+ updateConfig(newConfig: Partial<AIChatConfig>): void;
145
+ }
146
+ export interface TokenRefreshContext {
147
+ token: string;
148
+ refreshToken: string;
149
+ userId: string;
150
+ reason: 'preflight' | 'response' | 'authFn' | string;
151
+ }
152
+ export type TokenRefreshResult = string | {
153
+ token?: string;
154
+ accessToken?: string;
155
+ authorization?: string;
156
+ refreshToken?: string;
157
+ expiresAt?: number;
158
+ expiresIn?: number;
159
+ headers?: Record<string, string>;
160
+ };
161
+ export interface TokenRefreshSuccess {
162
+ token: string;
163
+ refreshToken?: string;
164
+ tokenExpiresAt?: number;
165
+ raw?: TokenRefreshResult;
166
+ }
167
+ /**
168
+ * AI 响应接口
169
+ */
170
+ export interface AIResponse<TData = {
171
+ /** AI 回复内容 */
172
+ content?: string;
173
+ /** 回复文本(兼容旧格式) */
174
+ replyText?: string;
175
+ /** 会话 ID */
176
+ conversationId?: string;
177
+ /** 消息 ID */
178
+ messageId?: string;
179
+ /** 使用量统计 */
180
+ usage?: {
181
+ /** 输入 token 数 */
182
+ inputTokens: number;
183
+ /** 输出 token 数 */
184
+ outputTokens: number;
185
+ };
186
+ } | null> {
187
+ /** 是否成功 */
188
+ success: boolean;
189
+ /** 状态码 */
190
+ code: number;
191
+ /** 消息 */
192
+ message: string;
193
+ /** 响应数据 */
194
+ data: TData;
195
+ }
196
+ export interface AIChatRequestOptions {
197
+ appId?: string;
198
+ userId?: string;
199
+ bizType?: string;
200
+ conversationId?: string;
201
+ requestId?: string;
202
+ attachmentIds?: string[];
203
+ attachments?: Array<string | {
204
+ attachmentId?: string;
205
+ fileId?: string;
206
+ id?: string;
207
+ }>;
208
+ bizParams?: Record<string, any> | string;
209
+ extendInfo?: Record<string, any> | string;
210
+ timeout?: number;
211
+ retries?: number;
212
+ endpoint?: string;
213
+ }
214
+ export interface AIStreamHandlers {
215
+ onStart?: () => void;
216
+ onProgress?: (message: string) => void;
217
+ onMessage?: (chunk: string) => void;
218
+ onMeta?: (meta: Record<string, any>) => void;
219
+ onPlanningEvent?: (event: Record<string, any>) => void;
220
+ /** 思考/推理文本增量(DeepSeek-R1 / Claude thinking) */
221
+ onThinking?: (thinking: string) => void;
222
+ /** 执行进度书签事件 */
223
+ onProgressEvent?: (stage: string, message: string) => void;
224
+ /** 工具调用开始 */
225
+ onToolStart?: (toolName: string, toolCallId: string) => void;
226
+ /** 工具调用结果增量 */
227
+ onToolResult?: (toolName: string, text: string) => void;
228
+ /** 工具调用结束 */
229
+ onToolEnd?: (toolName: string, toolCallId: string) => void;
230
+ /** 工作流节点开始 */
231
+ onNodeStart?: (nodeName: string, message: string) => void;
232
+ /** 工作流节点进度 */
233
+ onNodeProgress?: (nodeName: string, message: string) => void;
234
+ /** 工作流节点完成 */
235
+ onNodeComplete?: (nodeName: string, message: string) => void;
236
+ /** 警告事件 */
237
+ onWarning?: (message: string) => void;
238
+ /** HITL 人机交互中断(权限确认/问题提问) */
239
+ onHitlInterrupt?: (hitlData: HitlInterruptData) => void;
240
+ onError?: (message: string, raw?: any) => void;
241
+ onDone?: (finalText?: string) => void;
242
+ }
243
+ /**
244
+ * HITL 交互中断数据
245
+ */
246
+ export interface HitlInterruptData {
247
+ type: 'TOOL_CONFIRMATION' | 'QUESTION';
248
+ requestId: string;
249
+ sessionId: string;
250
+ taskRunId?: string;
251
+ toolCalls?: ToolCallInfo[];
252
+ message?: string;
253
+ }
254
+ /**
255
+ * 工具调用信息
256
+ */
257
+ export interface ToolCallInfo {
258
+ id?: string;
259
+ name?: string;
260
+ input?: Record<string, any>;
261
+ }
262
+ export interface UploadAttachmentOptions {
263
+ userId?: string;
264
+ fileType?: string;
265
+ conversationId?: string;
266
+ timeout?: number;
267
+ endpoint?: string;
268
+ }
269
+ export interface AttachmentUploadResponse {
270
+ attachmentId: string;
271
+ fileName: string;
272
+ fileSize?: number;
273
+ fileType?: string;
274
+ fileUrl?: string;
275
+ filePath?: string;
276
+ mimeType?: string;
277
+ }
278
+ export interface ConversationQueryOptions {
279
+ userId?: string;
280
+ conversationId?: string;
281
+ appId?: string;
282
+ bizType?: string;
283
+ pageIndex?: number;
284
+ pageSize?: number;
285
+ requestId?: string;
286
+ }
287
+ export interface ConversationRecord {
288
+ recordId?: string | number;
289
+ requestId?: string;
290
+ conversationId?: string;
291
+ role?: string;
292
+ content?: string;
293
+ prompt?: string;
294
+ replyText?: string;
295
+ answer?: string;
296
+ createTime?: string;
297
+ attachments?: AttachmentUploadResponse[];
298
+ }
299
+ export interface ConversationQueryResponse {
300
+ conversationId: string;
301
+ appId?: string;
302
+ records: ConversationRecord[];
303
+ total?: number;
304
+ pageIndex?: number;
305
+ pageSize?: number;
306
+ }
307
+ /**
308
+ * HITL 权限回复请求
309
+ */
310
+ export interface PermissionReplyRequest {
311
+ /** 会话ID(来自[HITL]事件) */
312
+ sessionId: string;
313
+ /** 权限请求ID(来自[HITL]事件) */
314
+ requestId: string;
315
+ /** 回复动作:once-仅本次 always-始终允许 reject-拒绝 */
316
+ reply: 'once' | 'always' | 'reject';
317
+ /** 补充说明 */
318
+ message?: string;
319
+ }
320
+ /**
321
+ * HITL 问题回复请求
322
+ */
323
+ export interface QuestionReplyRequest {
324
+ /** 会话ID(来自[HITL]事件) */
325
+ sessionId: string;
326
+ /** 问题请求ID(来自[HITL]事件) */
327
+ requestId: string;
328
+ /** 答案列表(二维数组) */
329
+ answers: string[][];
330
+ }
331
+ /**
332
+ * HITL 问题拒绝请求
333
+ */
334
+ export interface QuestionRejectRequest {
335
+ /** 会话ID(来自[HITL]事件) */
336
+ sessionId: string;
337
+ /** 问题请求ID(来自[HITL]事件) */
338
+ requestId: string;
339
+ }
340
+ /**
341
+ * 应用列表查询选项
342
+ */
343
+ export interface AppListOptions {
344
+ /** 应用类型过滤:1-简易问答 3-智能助手 2-高级编排,不传则返回全部 */
345
+ applicationType?: number;
346
+ /** 页码,默认1 */
347
+ pageIndex?: number;
348
+ /** 每页大小,默认20,最大50 */
349
+ pageSize?: number;
350
+ }
351
+ /**
352
+ * 应用列表项
353
+ */
354
+ export interface AppListItem {
355
+ /** 应用ID */
356
+ appId: string;
357
+ /** 应用名称 */
358
+ name: string;
359
+ /** 应用描述 */
360
+ description?: string;
361
+ /** 应用类型 */
362
+ applicationType?: number;
363
+ /** 应用图标URL */
364
+ icon?: string;
365
+ /** 开场白/欢迎语 */
366
+ prologue?: string;
367
+ }
368
+ /**
369
+ * 应用列表响应
370
+ */
371
+ export interface AppListResponse {
372
+ /** 应用列表 */
373
+ records: AppListItem[];
374
+ /** 总数 */
375
+ total?: number;
376
+ /** 当前页码 */
377
+ currentPage?: number;
378
+ /** 每页大小 */
379
+ pageSize?: number;
380
+ /** 总页数 */
381
+ pages?: number;
382
+ /** 默认对话应用ID */
383
+ defaultChatAppId?: string;
384
+ }
385
+ /**
386
+ * 消息类型枚举
387
+ */
388
+ export declare enum MessageType {
389
+ /** 用户消息 */
390
+ USER = "user",
391
+ /** AI 消息 */
392
+ AI = "ai"
393
+ }
394
+ /**
395
+ * 消息接口
396
+ */
397
+ export interface Message {
398
+ /** 消息 ID */
399
+ id: string;
400
+ /** 消息类型 */
401
+ type: MessageType;
402
+ /** 消息内容 */
403
+ content: string;
404
+ /** 渲染后的内容(HTML) */
405
+ renderedContent: string;
406
+ /** 消息时间 */
407
+ time: string;
408
+ /** 是否失败 */
409
+ error?: boolean;
410
+ /** 是否已复制 */
411
+ copied?: boolean;
412
+ }
413
+ /**
414
+ * SDK 事件参数
415
+ */
416
+ export interface SDKEvents {
417
+ /** 用户发送消息 */
418
+ 'message-send': {
419
+ message: string;
420
+ index: number;
421
+ };
422
+ /** AI 回复消息 */
423
+ 'message-receive': {
424
+ response: AIResponse;
425
+ index: number;
426
+ };
427
+ /** Loading 状态变化 */
428
+ 'loading-change': boolean;
429
+ /** 关闭对话框 */
430
+ close: void;
431
+ /** 展开/收起 */
432
+ expand: boolean;
433
+ /** 清除对话 */
434
+ clear: void;
435
+ }
436
+ /**
437
+ * 错误码枚举
438
+ */
439
+ export declare const ERROR_CODES: {
440
+ readonly SUCCESS: 200;
441
+ readonly AGENT_NOT_FOUND: 40001;
442
+ readonly PROMPT_EMPTY: 40002;
443
+ readonly AUTH_FAILED: 40301;
444
+ readonly NETWORK_ERROR: 500;
445
+ readonly SERVER_ERROR: 50001;
446
+ readonly TIMEOUT_ERROR: 50002;
447
+ readonly REQUEST_CANCELLED: 0;
448
+ };
449
+ /**
450
+ * 导出错误码类型
451
+ */
452
+ export type ErrorCode = typeof ERROR_CODES[keyof typeof ERROR_CODES];
453
+ /**
454
+ * 默认配置
455
+ */
456
+ export declare const defaultConfig: AIChatConfig;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * 错误码常量
3
+ * 统一定义所有错误码,方便维护
4
+ */
5
+ declare const ERROR_CODES: {
6
+ SUCCESS: number;
7
+ AGENT_NOT_FOUND: number;
8
+ PROMPT_EMPTY: number;
9
+ AUTH_FAILED: number;
10
+ NETWORK_ERROR: number;
11
+ SERVER_ERROR: number;
12
+ TIMEOUT_ERROR: number;
13
+ REQUEST_CANCELLED: number;
14
+ };
15
+ export default ERROR_CODES;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * 日志脱敏工具
3
+ * 防止敏感信息(如 Token)打印到控制台
4
+ */
5
+ /**
6
+ * 脱敏对象中的敏感字段
7
+ * @param {Object} obj - 需要脱敏的对象
8
+ * @returns {Object} 脱敏后的对象
9
+ */
10
+ export declare function maskSensitiveData(obj: any): any;
11
+ /**
12
+ * 脱敏字符串中的 Token
13
+ * @param {string} str - 需要脱敏的字符串
14
+ * @returns {string} 脱敏后的字符串
15
+ */
16
+ export declare function maskToken(str: any): any;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * 唯一 ID 生成器
3
+ * 避免消息 ID 冲突问题
4
+ */
5
+ /**
6
+ * 生成唯一消息 ID
7
+ * 格式:{timestamp}-{counter}-{random}
8
+ * 例如:1713926400000-1-abc123
9
+ * @returns {string} 唯一 ID
10
+ */
11
+ declare function generateMessageId(): string;
12
+ export { generateMessageId };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ibc-ai-web-sdk",
3
- "version": "2.0.5",
3
+ "version": "2.1.0",
4
4
  "description": "IBC AI Web SDK - 纯JavaScript实现的AI对话组件,支持任意框架(Vue/React/Angular/原生HTML)",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -8,10 +8,15 @@
8
8
  "unpkg": "dist/index.umd.min.js",
9
9
  "jsdelivr": "dist/index.umd.min.js",
10
10
  "types": "./index.d.ts",
11
- "sideEffects": ["./src/index.js", "./dist/index.esm.js", "./src/AIChatDialog.js", "./src/core/AIChatClient.js"],
11
+ "sideEffects": [
12
+ "./src/index.js",
13
+ "./dist/index.esm.js",
14
+ "./src/AIChatDialog.js",
15
+ "./src/core/AIChatClient.js"
16
+ ],
12
17
  "exports": {
13
18
  ".": {
14
- "types": "./index.d.ts",
19
+ "types": "./dist-ts/index.d.ts",
15
20
  "import": "./dist/index.esm.js",
16
21
  "require": "./dist/index.cjs.js",
17
22
  "default": "./dist/index.umd.min.js"
@@ -21,17 +26,18 @@
21
26
  "./package.json": "./package.json"
22
27
  },
23
28
  "files": [
24
- "dist",
29
+ "dist/*.js",
30
+ "dist-ts/*.d.ts",
31
+ "dist-ts/**/*.d.ts",
25
32
  "miniprogram",
26
- "index.d.ts",
27
- "src/types.ts",
28
33
  "README.md"
29
34
  ],
30
35
  "scripts": {
31
36
  "dev": "rollup -c rollup.config.js --watch",
32
- "build": "rollup -c rollup.config.js",
37
+ "build": "tsc && rollup -c rollup.config.js",
38
+ "typecheck": "tsc --noEmit",
33
39
  "prepublishOnly": "npm run build",
34
- "lint": "eslint src/**/*.js",
40
+ "lint": "eslint src/**/*.ts",
35
41
  "test": "jest"
36
42
  },
37
43
  "keywords": [
@@ -60,7 +66,9 @@
60
66
  "@rollup/plugin-node-resolve": "^15.2.0",
61
67
  "@rollup/plugin-terser": "^0.4.0",
62
68
  "@types/dompurify": "^3.0.5",
63
- "rollup": "^4.6.0"
69
+ "rollup": "^4.6.0",
70
+ "tslib": "^2.8.1",
71
+ "typescript": "^6.0.3"
64
72
  },
65
73
  "engines": {
66
74
  "node": ">=14.0.0"