@legendzd/ai-agent-vue 1.0.4 → 1.0.6
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/README.md +38 -6
- package/dist/index.cjs +54 -54
- package/dist/index.mjs +10288 -9923
- package/dist/src/api/agent.d.ts +9 -2
- package/dist/src/components/ChatMessage.vue.d.ts +4 -0
- package/dist/src/stores/chat.d.ts +65 -53
- package/dist/src/types/agent.d.ts +50 -13
- package/dist/src/views/AgentChat.vue.d.ts +3 -3
- package/dist/src/views/AgentChatFull.vue.d.ts +3 -3
- package/dist/src/views/AgentChatMobile.vue.d.ts +3 -3
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/src/api/agent.d.ts
CHANGED
|
@@ -5,14 +5,21 @@ export declare function setAgentOptions(options: AgentPluginOptions): void;
|
|
|
5
5
|
export declare function getAgentOptions(): AgentPluginOptions;
|
|
6
6
|
/**
|
|
7
7
|
* 创建会话
|
|
8
|
-
*
|
|
8
|
+
* GET ${apiUrl}/external/chat/sessions
|
|
9
|
+
* 携带 agent_id(必传)、ext_user_id
|
|
9
10
|
*/
|
|
10
11
|
export declare function createChatSession(options?: AgentPluginOptions): Promise<string>;
|
|
11
12
|
/**
|
|
12
13
|
* 获取历史会话列表
|
|
13
|
-
* GET ${apiUrl}/
|
|
14
|
+
* GET ${apiUrl}/external/chat/sessions
|
|
15
|
+
* 携带 agent_id(必传)、ext_user_id
|
|
14
16
|
*/
|
|
15
17
|
export declare function getChatSessions(options?: AgentPluginOptions): Promise<SessionInfo[]>;
|
|
18
|
+
/**
|
|
19
|
+
* 获取历史会话的消息列表
|
|
20
|
+
* GET ${apiUrl}/external/chat/sessions/{id}/messages
|
|
21
|
+
*/
|
|
22
|
+
export declare function getSessionMessages(sessionId: number | string, options?: AgentPluginOptions): Promise<any[]>;
|
|
16
23
|
/**
|
|
17
24
|
* 流式文本生成接口
|
|
18
25
|
* 使用 fetch + ReadableStream 实现 SSE 流式读取
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { ChatMessage } from '../../types/agent';
|
|
2
2
|
type __VLS_Props = {
|
|
3
3
|
message: ChatMessage;
|
|
4
|
+
/** 用户头像 URL(svg/png/jpg 等) */
|
|
5
|
+
userAvatar?: string;
|
|
6
|
+
/** AI 助手头像 URL(svg/png/jpg 等) */
|
|
7
|
+
assistantAvatar?: string;
|
|
4
8
|
};
|
|
5
9
|
declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
6
10
|
declare const _default: typeof __VLS_export;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AgentPluginOptions, ChatMessage, SessionInfo, SourceInfo } from '../../types/agent';
|
|
1
|
+
import { AgentPluginOptions, ChatMessage, ChatMessageRole, ChatMessageStatus, SessionInfo, SourceInfo } from '../../types/agent';
|
|
2
2
|
/** 聊天 store 实例类型 */
|
|
3
3
|
export type ChatStoreInstance = ReturnType<ReturnType<typeof createChatStoreDefinition>>;
|
|
4
4
|
/** 获取或创建聊天实例 */
|
|
@@ -13,19 +13,19 @@ export declare function destroyChatInstance(instanceId: string): void;
|
|
|
13
13
|
declare function createChatStoreDefinition(instanceId: string): import('pinia').StoreDefinition<`agent-chat-${string}`, Pick<{
|
|
14
14
|
sessionId: import('vue').Ref<string, string>;
|
|
15
15
|
sessions: import('vue').Ref<{
|
|
16
|
-
id: string;
|
|
16
|
+
id: number | string;
|
|
17
17
|
title: string;
|
|
18
18
|
created_at: string;
|
|
19
19
|
}[], SessionInfo[] | {
|
|
20
|
-
id: string;
|
|
20
|
+
id: number | string;
|
|
21
21
|
title: string;
|
|
22
22
|
created_at: string;
|
|
23
23
|
}[]>;
|
|
24
24
|
messages: import('vue').Ref<{
|
|
25
25
|
id: string;
|
|
26
|
-
role:
|
|
26
|
+
role: ChatMessageRole;
|
|
27
27
|
content: string;
|
|
28
|
-
status:
|
|
28
|
+
status: ChatMessageStatus;
|
|
29
29
|
createdAt: number;
|
|
30
30
|
reportId?: number | undefined;
|
|
31
31
|
title?: string | undefined;
|
|
@@ -41,9 +41,9 @@ declare function createChatStoreDefinition(instanceId: string): import('pinia').
|
|
|
41
41
|
}[] | undefined;
|
|
42
42
|
}[], ChatMessage[] | {
|
|
43
43
|
id: string;
|
|
44
|
-
role:
|
|
44
|
+
role: ChatMessageRole;
|
|
45
45
|
content: string;
|
|
46
|
-
status:
|
|
46
|
+
status: ChatMessageStatus;
|
|
47
47
|
createdAt: number;
|
|
48
48
|
reportId?: number | undefined;
|
|
49
49
|
title?: string | undefined;
|
|
@@ -62,8 +62,10 @@ declare function createChatStoreDefinition(instanceId: string): import('pinia').
|
|
|
62
62
|
isSessionLoading: import('vue').Ref<boolean, boolean>;
|
|
63
63
|
initSession: () => Promise<void>;
|
|
64
64
|
loadSessions: () => Promise<void>;
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
isVirtualSession: import('vue').ComputedRef<boolean>;
|
|
66
|
+
syncSessionFromHistory: () => Promise<void>;
|
|
67
|
+
switchSession: (id: number | string) => Promise<void>;
|
|
68
|
+
newChat: () => void;
|
|
67
69
|
addUserMessage: (content: string) => ChatMessage;
|
|
68
70
|
addAssistantPlaceholder: () => ChatMessage;
|
|
69
71
|
appendStreamContent: (content: string) => void;
|
|
@@ -78,19 +80,19 @@ declare function createChatStoreDefinition(instanceId: string): import('pinia').
|
|
|
78
80
|
}, "sessionId" | "sessions" | "messages" | "isStreaming" | "isSessionLoading">, Pick<{
|
|
79
81
|
sessionId: import('vue').Ref<string, string>;
|
|
80
82
|
sessions: import('vue').Ref<{
|
|
81
|
-
id: string;
|
|
83
|
+
id: number | string;
|
|
82
84
|
title: string;
|
|
83
85
|
created_at: string;
|
|
84
86
|
}[], SessionInfo[] | {
|
|
85
|
-
id: string;
|
|
87
|
+
id: number | string;
|
|
86
88
|
title: string;
|
|
87
89
|
created_at: string;
|
|
88
90
|
}[]>;
|
|
89
91
|
messages: import('vue').Ref<{
|
|
90
92
|
id: string;
|
|
91
|
-
role:
|
|
93
|
+
role: ChatMessageRole;
|
|
92
94
|
content: string;
|
|
93
|
-
status:
|
|
95
|
+
status: ChatMessageStatus;
|
|
94
96
|
createdAt: number;
|
|
95
97
|
reportId?: number | undefined;
|
|
96
98
|
title?: string | undefined;
|
|
@@ -106,9 +108,9 @@ declare function createChatStoreDefinition(instanceId: string): import('pinia').
|
|
|
106
108
|
}[] | undefined;
|
|
107
109
|
}[], ChatMessage[] | {
|
|
108
110
|
id: string;
|
|
109
|
-
role:
|
|
111
|
+
role: ChatMessageRole;
|
|
110
112
|
content: string;
|
|
111
|
-
status:
|
|
113
|
+
status: ChatMessageStatus;
|
|
112
114
|
createdAt: number;
|
|
113
115
|
reportId?: number | undefined;
|
|
114
116
|
title?: string | undefined;
|
|
@@ -127,8 +129,10 @@ declare function createChatStoreDefinition(instanceId: string): import('pinia').
|
|
|
127
129
|
isSessionLoading: import('vue').Ref<boolean, boolean>;
|
|
128
130
|
initSession: () => Promise<void>;
|
|
129
131
|
loadSessions: () => Promise<void>;
|
|
130
|
-
|
|
131
|
-
|
|
132
|
+
isVirtualSession: import('vue').ComputedRef<boolean>;
|
|
133
|
+
syncSessionFromHistory: () => Promise<void>;
|
|
134
|
+
switchSession: (id: number | string) => Promise<void>;
|
|
135
|
+
newChat: () => void;
|
|
132
136
|
addUserMessage: (content: string) => ChatMessage;
|
|
133
137
|
addAssistantPlaceholder: () => ChatMessage;
|
|
134
138
|
appendStreamContent: (content: string) => void;
|
|
@@ -140,22 +144,22 @@ declare function createChatStoreDefinition(instanceId: string): import('pinia').
|
|
|
140
144
|
markStreamDone: (reportId?: number, title?: string) => void;
|
|
141
145
|
markStreamError: (errorMessage: string) => void;
|
|
142
146
|
clearMessages: () => void;
|
|
143
|
-
},
|
|
147
|
+
}, "isVirtualSession">, Pick<{
|
|
144
148
|
sessionId: import('vue').Ref<string, string>;
|
|
145
149
|
sessions: import('vue').Ref<{
|
|
146
|
-
id: string;
|
|
150
|
+
id: number | string;
|
|
147
151
|
title: string;
|
|
148
152
|
created_at: string;
|
|
149
153
|
}[], SessionInfo[] | {
|
|
150
|
-
id: string;
|
|
154
|
+
id: number | string;
|
|
151
155
|
title: string;
|
|
152
156
|
created_at: string;
|
|
153
157
|
}[]>;
|
|
154
158
|
messages: import('vue').Ref<{
|
|
155
159
|
id: string;
|
|
156
|
-
role:
|
|
160
|
+
role: ChatMessageRole;
|
|
157
161
|
content: string;
|
|
158
|
-
status:
|
|
162
|
+
status: ChatMessageStatus;
|
|
159
163
|
createdAt: number;
|
|
160
164
|
reportId?: number | undefined;
|
|
161
165
|
title?: string | undefined;
|
|
@@ -171,9 +175,9 @@ declare function createChatStoreDefinition(instanceId: string): import('pinia').
|
|
|
171
175
|
}[] | undefined;
|
|
172
176
|
}[], ChatMessage[] | {
|
|
173
177
|
id: string;
|
|
174
|
-
role:
|
|
178
|
+
role: ChatMessageRole;
|
|
175
179
|
content: string;
|
|
176
|
-
status:
|
|
180
|
+
status: ChatMessageStatus;
|
|
177
181
|
createdAt: number;
|
|
178
182
|
reportId?: number | undefined;
|
|
179
183
|
title?: string | undefined;
|
|
@@ -192,8 +196,10 @@ declare function createChatStoreDefinition(instanceId: string): import('pinia').
|
|
|
192
196
|
isSessionLoading: import('vue').Ref<boolean, boolean>;
|
|
193
197
|
initSession: () => Promise<void>;
|
|
194
198
|
loadSessions: () => Promise<void>;
|
|
195
|
-
|
|
196
|
-
|
|
199
|
+
isVirtualSession: import('vue').ComputedRef<boolean>;
|
|
200
|
+
syncSessionFromHistory: () => Promise<void>;
|
|
201
|
+
switchSession: (id: number | string) => Promise<void>;
|
|
202
|
+
newChat: () => void;
|
|
197
203
|
addUserMessage: (content: string) => ChatMessage;
|
|
198
204
|
addAssistantPlaceholder: () => ChatMessage;
|
|
199
205
|
appendStreamContent: (content: string) => void;
|
|
@@ -205,24 +211,24 @@ declare function createChatStoreDefinition(instanceId: string): import('pinia').
|
|
|
205
211
|
markStreamDone: (reportId?: number, title?: string) => void;
|
|
206
212
|
markStreamError: (errorMessage: string) => void;
|
|
207
213
|
clearMessages: () => void;
|
|
208
|
-
}, "initSession" | "loadSessions" | "switchSession" | "newChat" | "addUserMessage" | "addAssistantPlaceholder" | "appendStreamContent" | "updateStatusText" | "updateSql" | "updateData" | "updateChartConfig" | "updateSources" | "markStreamDone" | "markStreamError" | "clearMessages">>;
|
|
214
|
+
}, "initSession" | "loadSessions" | "syncSessionFromHistory" | "switchSession" | "newChat" | "addUserMessage" | "addAssistantPlaceholder" | "appendStreamContent" | "updateStatusText" | "updateSql" | "updateData" | "updateChartConfig" | "updateSources" | "markStreamDone" | "markStreamError" | "clearMessages">>;
|
|
209
215
|
/** 默认聊天 store 实例(instanceId = 'default') */
|
|
210
216
|
export declare const chatStore: import('pinia').Store<`agent-chat-${string}`, Pick<{
|
|
211
217
|
sessionId: import('vue').Ref<string, string>;
|
|
212
218
|
sessions: import('vue').Ref<{
|
|
213
|
-
id: string;
|
|
219
|
+
id: number | string;
|
|
214
220
|
title: string;
|
|
215
221
|
created_at: string;
|
|
216
222
|
}[], SessionInfo[] | {
|
|
217
|
-
id: string;
|
|
223
|
+
id: number | string;
|
|
218
224
|
title: string;
|
|
219
225
|
created_at: string;
|
|
220
226
|
}[]>;
|
|
221
227
|
messages: import('vue').Ref<{
|
|
222
228
|
id: string;
|
|
223
|
-
role:
|
|
229
|
+
role: ChatMessageRole;
|
|
224
230
|
content: string;
|
|
225
|
-
status:
|
|
231
|
+
status: ChatMessageStatus;
|
|
226
232
|
createdAt: number;
|
|
227
233
|
reportId?: number | undefined;
|
|
228
234
|
title?: string | undefined;
|
|
@@ -238,9 +244,9 @@ export declare const chatStore: import('pinia').Store<`agent-chat-${string}`, Pi
|
|
|
238
244
|
}[] | undefined;
|
|
239
245
|
}[], ChatMessage[] | {
|
|
240
246
|
id: string;
|
|
241
|
-
role:
|
|
247
|
+
role: ChatMessageRole;
|
|
242
248
|
content: string;
|
|
243
|
-
status:
|
|
249
|
+
status: ChatMessageStatus;
|
|
244
250
|
createdAt: number;
|
|
245
251
|
reportId?: number | undefined;
|
|
246
252
|
title?: string | undefined;
|
|
@@ -259,8 +265,10 @@ export declare const chatStore: import('pinia').Store<`agent-chat-${string}`, Pi
|
|
|
259
265
|
isSessionLoading: import('vue').Ref<boolean, boolean>;
|
|
260
266
|
initSession: () => Promise<void>;
|
|
261
267
|
loadSessions: () => Promise<void>;
|
|
262
|
-
|
|
263
|
-
|
|
268
|
+
isVirtualSession: import('vue').ComputedRef<boolean>;
|
|
269
|
+
syncSessionFromHistory: () => Promise<void>;
|
|
270
|
+
switchSession: (id: number | string) => Promise<void>;
|
|
271
|
+
newChat: () => void;
|
|
264
272
|
addUserMessage: (content: string) => ChatMessage;
|
|
265
273
|
addAssistantPlaceholder: () => ChatMessage;
|
|
266
274
|
appendStreamContent: (content: string) => void;
|
|
@@ -275,19 +283,19 @@ export declare const chatStore: import('pinia').Store<`agent-chat-${string}`, Pi
|
|
|
275
283
|
}, "sessionId" | "sessions" | "messages" | "isStreaming" | "isSessionLoading">, Pick<{
|
|
276
284
|
sessionId: import('vue').Ref<string, string>;
|
|
277
285
|
sessions: import('vue').Ref<{
|
|
278
|
-
id: string;
|
|
286
|
+
id: number | string;
|
|
279
287
|
title: string;
|
|
280
288
|
created_at: string;
|
|
281
289
|
}[], SessionInfo[] | {
|
|
282
|
-
id: string;
|
|
290
|
+
id: number | string;
|
|
283
291
|
title: string;
|
|
284
292
|
created_at: string;
|
|
285
293
|
}[]>;
|
|
286
294
|
messages: import('vue').Ref<{
|
|
287
295
|
id: string;
|
|
288
|
-
role:
|
|
296
|
+
role: ChatMessageRole;
|
|
289
297
|
content: string;
|
|
290
|
-
status:
|
|
298
|
+
status: ChatMessageStatus;
|
|
291
299
|
createdAt: number;
|
|
292
300
|
reportId?: number | undefined;
|
|
293
301
|
title?: string | undefined;
|
|
@@ -303,9 +311,9 @@ export declare const chatStore: import('pinia').Store<`agent-chat-${string}`, Pi
|
|
|
303
311
|
}[] | undefined;
|
|
304
312
|
}[], ChatMessage[] | {
|
|
305
313
|
id: string;
|
|
306
|
-
role:
|
|
314
|
+
role: ChatMessageRole;
|
|
307
315
|
content: string;
|
|
308
|
-
status:
|
|
316
|
+
status: ChatMessageStatus;
|
|
309
317
|
createdAt: number;
|
|
310
318
|
reportId?: number | undefined;
|
|
311
319
|
title?: string | undefined;
|
|
@@ -324,8 +332,10 @@ export declare const chatStore: import('pinia').Store<`agent-chat-${string}`, Pi
|
|
|
324
332
|
isSessionLoading: import('vue').Ref<boolean, boolean>;
|
|
325
333
|
initSession: () => Promise<void>;
|
|
326
334
|
loadSessions: () => Promise<void>;
|
|
327
|
-
|
|
328
|
-
|
|
335
|
+
isVirtualSession: import('vue').ComputedRef<boolean>;
|
|
336
|
+
syncSessionFromHistory: () => Promise<void>;
|
|
337
|
+
switchSession: (id: number | string) => Promise<void>;
|
|
338
|
+
newChat: () => void;
|
|
329
339
|
addUserMessage: (content: string) => ChatMessage;
|
|
330
340
|
addAssistantPlaceholder: () => ChatMessage;
|
|
331
341
|
appendStreamContent: (content: string) => void;
|
|
@@ -337,22 +347,22 @@ export declare const chatStore: import('pinia').Store<`agent-chat-${string}`, Pi
|
|
|
337
347
|
markStreamDone: (reportId?: number, title?: string) => void;
|
|
338
348
|
markStreamError: (errorMessage: string) => void;
|
|
339
349
|
clearMessages: () => void;
|
|
340
|
-
},
|
|
350
|
+
}, "isVirtualSession">, Pick<{
|
|
341
351
|
sessionId: import('vue').Ref<string, string>;
|
|
342
352
|
sessions: import('vue').Ref<{
|
|
343
|
-
id: string;
|
|
353
|
+
id: number | string;
|
|
344
354
|
title: string;
|
|
345
355
|
created_at: string;
|
|
346
356
|
}[], SessionInfo[] | {
|
|
347
|
-
id: string;
|
|
357
|
+
id: number | string;
|
|
348
358
|
title: string;
|
|
349
359
|
created_at: string;
|
|
350
360
|
}[]>;
|
|
351
361
|
messages: import('vue').Ref<{
|
|
352
362
|
id: string;
|
|
353
|
-
role:
|
|
363
|
+
role: ChatMessageRole;
|
|
354
364
|
content: string;
|
|
355
|
-
status:
|
|
365
|
+
status: ChatMessageStatus;
|
|
356
366
|
createdAt: number;
|
|
357
367
|
reportId?: number | undefined;
|
|
358
368
|
title?: string | undefined;
|
|
@@ -368,9 +378,9 @@ export declare const chatStore: import('pinia').Store<`agent-chat-${string}`, Pi
|
|
|
368
378
|
}[] | undefined;
|
|
369
379
|
}[], ChatMessage[] | {
|
|
370
380
|
id: string;
|
|
371
|
-
role:
|
|
381
|
+
role: ChatMessageRole;
|
|
372
382
|
content: string;
|
|
373
|
-
status:
|
|
383
|
+
status: ChatMessageStatus;
|
|
374
384
|
createdAt: number;
|
|
375
385
|
reportId?: number | undefined;
|
|
376
386
|
title?: string | undefined;
|
|
@@ -389,8 +399,10 @@ export declare const chatStore: import('pinia').Store<`agent-chat-${string}`, Pi
|
|
|
389
399
|
isSessionLoading: import('vue').Ref<boolean, boolean>;
|
|
390
400
|
initSession: () => Promise<void>;
|
|
391
401
|
loadSessions: () => Promise<void>;
|
|
392
|
-
|
|
393
|
-
|
|
402
|
+
isVirtualSession: import('vue').ComputedRef<boolean>;
|
|
403
|
+
syncSessionFromHistory: () => Promise<void>;
|
|
404
|
+
switchSession: (id: number | string) => Promise<void>;
|
|
405
|
+
newChat: () => void;
|
|
394
406
|
addUserMessage: (content: string) => ChatMessage;
|
|
395
407
|
addAssistantPlaceholder: () => ChatMessage;
|
|
396
408
|
appendStreamContent: (content: string) => void;
|
|
@@ -402,5 +414,5 @@ export declare const chatStore: import('pinia').Store<`agent-chat-${string}`, Pi
|
|
|
402
414
|
markStreamDone: (reportId?: number, title?: string) => void;
|
|
403
415
|
markStreamError: (errorMessage: string) => void;
|
|
404
416
|
clearMessages: () => void;
|
|
405
|
-
}, "initSession" | "loadSessions" | "switchSession" | "newChat" | "addUserMessage" | "addAssistantPlaceholder" | "appendStreamContent" | "updateStatusText" | "updateSql" | "updateData" | "updateChartConfig" | "updateSources" | "markStreamDone" | "markStreamError" | "clearMessages">>;
|
|
417
|
+
}, "initSession" | "loadSessions" | "syncSessionFromHistory" | "switchSession" | "newChat" | "addUserMessage" | "addAssistantPlaceholder" | "appendStreamContent" | "updateStatusText" | "updateSql" | "updateData" | "updateChartConfig" | "updateSources" | "markStreamDone" | "markStreamError" | "clearMessages">>;
|
|
406
418
|
export {};
|
|
@@ -3,8 +3,28 @@ import { ComputedRef, InjectionKey } from 'vue';
|
|
|
3
3
|
export type AgentThemeMode = 'dark' | 'light';
|
|
4
4
|
/** 主题变量覆盖:键为 CSS 变量名(含 --agent- 前缀),值为 CSS 值 */
|
|
5
5
|
export type AgentThemeOverrides = Record<string, string>;
|
|
6
|
+
/** 自定义请求参数 key 名称,用于适配不同后端接口的参数命名 */
|
|
7
|
+
export interface ParamKeys {
|
|
8
|
+
/** 智能体 ID 参数名,默认 'agent_id' */
|
|
9
|
+
agent_id?: string;
|
|
10
|
+
/** 查询内容参数名,默认 'query' */
|
|
11
|
+
query?: string;
|
|
12
|
+
/** 会话 ID 参数名,默认 'session_id' */
|
|
13
|
+
session_id?: string;
|
|
14
|
+
/** 外部用户 ID 参数名,默认 'ext_user_id' */
|
|
15
|
+
ext_user_id?: string;
|
|
16
|
+
}
|
|
17
|
+
/** 解析后的参数 key 名称(合并默认值后所有字段必填) */
|
|
18
|
+
export interface ResolvedParamKeys {
|
|
19
|
+
agent_id: string;
|
|
20
|
+
query: string;
|
|
21
|
+
session_id: string;
|
|
22
|
+
ext_user_id: string;
|
|
23
|
+
}
|
|
6
24
|
/** 拖拽约束模式 */
|
|
7
25
|
export type DragConstrainMode = 'viewport' | 'none';
|
|
26
|
+
/** 弹窗方位(9 个方向,类似 ElPopover/ElTooltip 的 placement) */
|
|
27
|
+
export type AgentWindowPlacement = 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'right' | 'auto';
|
|
8
28
|
/** 智能体插件配置(所有字段均可选,由组件 props 或 install 时传入) */
|
|
9
29
|
export interface AgentPluginOptions {
|
|
10
30
|
/** API 基础地址(如 http://host:port/api/v2) */
|
|
@@ -13,16 +33,22 @@ export interface AgentPluginOptions {
|
|
|
13
33
|
getAccessToken?: () => string;
|
|
14
34
|
/** 认证 session 获取函数 */
|
|
15
35
|
getSession?: () => string;
|
|
16
|
-
/**
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
|
|
36
|
+
/** 智能体 ID 获取函数(动态场景优先使用,agent_id 为必传值) */
|
|
37
|
+
getAgentId?: () => string;
|
|
38
|
+
/** 智能体 ID 静态值(必传,getAgentId 优先) */
|
|
39
|
+
agentId?: string;
|
|
40
|
+
/** 外部用户 ID 获取函数,用于创建/查询会话(动态场景优先使用) */
|
|
41
|
+
getExtUserId?: () => string;
|
|
42
|
+
/** 外部用户 ID 静态值(简化用法,getExtUserId 优先) */
|
|
43
|
+
extUserId?: string;
|
|
44
|
+
/** 自定义请求参数 key 名称,默认 { agent_id, query, session_id, ext_user_id } */
|
|
45
|
+
paramKeys?: ParamKeys;
|
|
46
|
+
/** 应用 Key,用于自动生成 X-App-Key 等安全签名头(与 appSecret 配合使用) */
|
|
47
|
+
appKey?: string;
|
|
48
|
+
/** 应用密钥,用于 HMAC-SHA256 签名(与 appKey 配合使用) */
|
|
49
|
+
appSecret?: string;
|
|
50
|
+
/** 安全请求头获取函数,优先级高于 appKey/appSecret 自动签名,用于完全自定义签名逻辑 */
|
|
51
|
+
getSecurityHeaders?: () => Record<string, string>;
|
|
26
52
|
/** 窗口标题文本 */
|
|
27
53
|
headerTitle?: string;
|
|
28
54
|
/** 空状态提示文本 */
|
|
@@ -43,6 +69,16 @@ export interface AgentPluginOptions {
|
|
|
43
69
|
draggable?: boolean;
|
|
44
70
|
/** 拖拽约束模式:'viewport' 限制在视口内,'none' 不限制(但仍不超出可见区域),默认 'viewport' */
|
|
45
71
|
dragConstrain?: DragConstrainMode;
|
|
72
|
+
/** 弹窗相对按钮的方位,默认 'top-end'(按钮上方右对齐) */
|
|
73
|
+
placement?: AgentWindowPlacement;
|
|
74
|
+
/** 用户头像 URL(支持 svg/png/jpg 等图片格式,不传则使用默认图标) */
|
|
75
|
+
userAvatar?: string;
|
|
76
|
+
/** AI 助手头像 URL(支持 svg/png/jpg 等图片格式,不传则使用默认图标) */
|
|
77
|
+
assistantAvatar?: string;
|
|
78
|
+
/** 是否显示欢迎气泡,默认 true */
|
|
79
|
+
showWelcome?: boolean;
|
|
80
|
+
/** 欢迎词文本,默认 '请问有什么可以帮你?' */
|
|
81
|
+
welcomeMessage?: string;
|
|
46
82
|
}
|
|
47
83
|
/** provide/inject key */
|
|
48
84
|
export declare const AGENT_CONFIG_KEY: InjectionKey<ComputedRef<AgentPluginOptions>>;
|
|
@@ -90,15 +126,16 @@ export interface ChatMessage {
|
|
|
90
126
|
}
|
|
91
127
|
/** 会话信息 */
|
|
92
128
|
export interface SessionInfo {
|
|
93
|
-
id: string;
|
|
129
|
+
id: number | string;
|
|
94
130
|
title: string;
|
|
95
131
|
created_at: string;
|
|
96
132
|
}
|
|
97
133
|
/** 流式请求参数 */
|
|
98
134
|
export interface StreamRequestData {
|
|
99
|
-
|
|
135
|
+
/** 会话 ID(可选,选择历史记录后传入对应 session_id) */
|
|
136
|
+
sessionId?: string;
|
|
137
|
+
/** 用户查询内容 */
|
|
100
138
|
query: string;
|
|
101
|
-
userId?: string;
|
|
102
139
|
}
|
|
103
140
|
/** 流式事件类型 */
|
|
104
141
|
export type StreamEventType = 'status' | 'sql' | 'data' | 'chart_config' | 'sources' | 'analysis_chunk' | 'delta' | 'done' | 'error';
|
|
@@ -9,7 +9,7 @@ declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {
|
|
|
9
9
|
sessionId: string;
|
|
10
10
|
/** 历史会话列表 */
|
|
11
11
|
sessions: {
|
|
12
|
-
id: string;
|
|
12
|
+
id: number | string;
|
|
13
13
|
title: string;
|
|
14
14
|
created_at: string;
|
|
15
15
|
}[];
|
|
@@ -42,9 +42,9 @@ declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {
|
|
|
42
42
|
/** 加载历史会话列表 */
|
|
43
43
|
loadSessions: () => Promise<void>;
|
|
44
44
|
/** 切换到指定会话 */
|
|
45
|
-
switchSession: (id: string) => void
|
|
45
|
+
switchSession: (id: number | string) => Promise<void>;
|
|
46
46
|
/** 新建聊天 */
|
|
47
|
-
newChat: () =>
|
|
47
|
+
newChat: () => void;
|
|
48
48
|
/** 清空对话消息 */
|
|
49
49
|
clearMessages: () => void;
|
|
50
50
|
/** 切换窗口显示 */
|
|
@@ -7,7 +7,7 @@ declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {
|
|
|
7
7
|
sessionId: string;
|
|
8
8
|
/** 历史会话列表 */
|
|
9
9
|
sessions: {
|
|
10
|
-
id: string;
|
|
10
|
+
id: number | string;
|
|
11
11
|
title: string;
|
|
12
12
|
created_at: string;
|
|
13
13
|
}[];
|
|
@@ -40,9 +40,9 @@ declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {
|
|
|
40
40
|
/** 加载历史会话列表 */
|
|
41
41
|
loadSessions: () => Promise<void>;
|
|
42
42
|
/** 切换到指定会话 */
|
|
43
|
-
switchSession: (id: string) => void
|
|
43
|
+
switchSession: (id: number | string) => Promise<void>;
|
|
44
44
|
/** 新建聊天 */
|
|
45
|
-
newChat: () =>
|
|
45
|
+
newChat: () => void;
|
|
46
46
|
/** 清空对话消息 */
|
|
47
47
|
clearMessages: () => void;
|
|
48
48
|
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
@@ -9,7 +9,7 @@ declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {
|
|
|
9
9
|
sessionId: string;
|
|
10
10
|
/** 历史会话列表 */
|
|
11
11
|
sessions: {
|
|
12
|
-
id: string;
|
|
12
|
+
id: number | string;
|
|
13
13
|
title: string;
|
|
14
14
|
created_at: string;
|
|
15
15
|
}[];
|
|
@@ -42,9 +42,9 @@ declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {
|
|
|
42
42
|
/** 加载历史会话列表 */
|
|
43
43
|
loadSessions: () => Promise<void>;
|
|
44
44
|
/** 切换到指定会话 */
|
|
45
|
-
switchSession: (id: string) => void
|
|
45
|
+
switchSession: (id: number | string) => Promise<void>;
|
|
46
46
|
/** 新建聊天 */
|
|
47
|
-
newChat: () =>
|
|
47
|
+
newChat: () => void;
|
|
48
48
|
/** 清空对话消息 */
|
|
49
49
|
clearMessages: () => void;
|
|
50
50
|
/** 历史抽屉可见 */
|