@legendzd/ai-agent-vue 1.0.4 → 1.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.
@@ -5,14 +5,21 @@ export declare function setAgentOptions(options: AgentPluginOptions): void;
5
5
  export declare function getAgentOptions(): AgentPluginOptions;
6
6
  /**
7
7
  * 创建会话
8
- * POST ${apiUrl}/agent/chat/session
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}/agent/chat/sessions?userId=xxx
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,7 +1,28 @@
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;
8
+ /** 是否显示 SQL 区域,默认 false */
9
+ showSql?: boolean;
10
+ /** 是否显示数据表格区域,默认 false */
11
+ showData?: boolean;
12
+ /** 是否显示执行计划,默认 true */
13
+ showRunPlan?: boolean;
14
+ /** 执行计划默认是否展开,默认 false */
15
+ defaultRunPlanExpanded?: boolean;
4
16
  };
5
- 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>;
17
+ declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
18
+ reask: (content: string) => any;
19
+ }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
20
+ onReask?: ((content: string) => any) | undefined;
21
+ }>, {
22
+ showSql: boolean;
23
+ showData: boolean;
24
+ showRunPlan: boolean;
25
+ defaultRunPlanExpanded: boolean;
26
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
6
27
  declare const _default: typeof __VLS_export;
7
28
  export default _default;
@@ -24,6 +24,7 @@ export type {
24
24
  ChatMessage as ChatMessageType,
25
25
  ChatMessageRole,
26
26
  ChatMessageStatus,
27
+ MessageStructuredData,
27
28
  SessionInfo,
28
29
  SourceInfo,
29
30
  StreamCallbacks,
@@ -1,4 +1,4 @@
1
- import { AgentPluginOptions, ChatMessage, SessionInfo, SourceInfo } from '../../types/agent';
1
+ import { AgentPluginOptions, ChatMessage, ChatMessageRole, ChatMessageStatus, MessageStructuredData, 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: import('../../types/agent').ChatMessageRole;
26
+ role: ChatMessageRole;
27
27
  content: string;
28
- status: import('../../types/agent').ChatMessageStatus;
28
+ status: ChatMessageStatus;
29
29
  createdAt: number;
30
30
  reportId?: number | undefined;
31
31
  title?: string | undefined;
@@ -39,11 +39,13 @@ declare function createChatStoreDefinition(instanceId: string): import('pinia').
39
39
  id: string;
40
40
  title: string;
41
41
  }[] | undefined;
42
+ runPlan?: string | undefined;
43
+ runPlanExpanded?: boolean | undefined;
42
44
  }[], ChatMessage[] | {
43
45
  id: string;
44
- role: import('../../types/agent').ChatMessageRole;
46
+ role: ChatMessageRole;
45
47
  content: string;
46
- status: import('../../types/agent').ChatMessageStatus;
48
+ status: ChatMessageStatus;
47
49
  createdAt: number;
48
50
  reportId?: number | undefined;
49
51
  title?: string | undefined;
@@ -57,13 +59,19 @@ declare function createChatStoreDefinition(instanceId: string): import('pinia').
57
59
  id: string;
58
60
  title: string;
59
61
  }[] | undefined;
62
+ runPlan?: string | undefined;
63
+ runPlanExpanded?: boolean | undefined;
60
64
  }[]>;
61
65
  isStreaming: import('vue').Ref<boolean, boolean>;
62
66
  isSessionLoading: import('vue').Ref<boolean, boolean>;
67
+ runPlanVisible: import('vue').Ref<boolean, boolean>;
63
68
  initSession: () => Promise<void>;
64
69
  loadSessions: () => Promise<void>;
65
- switchSession: (id: string) => void;
66
- newChat: () => Promise<void>;
70
+ isVirtualSession: import('vue').ComputedRef<boolean>;
71
+ syncSessionFromHistory: () => Promise<void>;
72
+ syncSessionId: (id: string) => void;
73
+ switchSession: (id: number | string) => Promise<void>;
74
+ newChat: () => void;
67
75
  addUserMessage: (content: string) => ChatMessage;
68
76
  addAssistantPlaceholder: () => ChatMessage;
69
77
  appendStreamContent: (content: string) => void;
@@ -72,25 +80,27 @@ declare function createChatStoreDefinition(instanceId: string): import('pinia').
72
80
  updateData: (data: any[]) => void;
73
81
  updateChartConfig: (config: any) => void;
74
82
  updateSources: (sources: SourceInfo[]) => void;
83
+ updateRunPlan: (text: string) => void;
84
+ getMessageData: (messageId: string) => MessageStructuredData | undefined;
75
85
  markStreamDone: (reportId?: number, title?: string) => void;
76
86
  markStreamError: (errorMessage: string) => void;
77
87
  clearMessages: () => void;
78
- }, "sessionId" | "sessions" | "messages" | "isStreaming" | "isSessionLoading">, Pick<{
88
+ }, "sessionId" | "sessions" | "messages" | "runPlanVisible" | "isStreaming" | "isSessionLoading">, Pick<{
79
89
  sessionId: import('vue').Ref<string, string>;
80
90
  sessions: import('vue').Ref<{
81
- id: string;
91
+ id: number | string;
82
92
  title: string;
83
93
  created_at: string;
84
94
  }[], SessionInfo[] | {
85
- id: string;
95
+ id: number | string;
86
96
  title: string;
87
97
  created_at: string;
88
98
  }[]>;
89
99
  messages: import('vue').Ref<{
90
100
  id: string;
91
- role: import('../../types/agent').ChatMessageRole;
101
+ role: ChatMessageRole;
92
102
  content: string;
93
- status: import('../../types/agent').ChatMessageStatus;
103
+ status: ChatMessageStatus;
94
104
  createdAt: number;
95
105
  reportId?: number | undefined;
96
106
  title?: string | undefined;
@@ -104,11 +114,13 @@ declare function createChatStoreDefinition(instanceId: string): import('pinia').
104
114
  id: string;
105
115
  title: string;
106
116
  }[] | undefined;
117
+ runPlan?: string | undefined;
118
+ runPlanExpanded?: boolean | undefined;
107
119
  }[], ChatMessage[] | {
108
120
  id: string;
109
- role: import('../../types/agent').ChatMessageRole;
121
+ role: ChatMessageRole;
110
122
  content: string;
111
- status: import('../../types/agent').ChatMessageStatus;
123
+ status: ChatMessageStatus;
112
124
  createdAt: number;
113
125
  reportId?: number | undefined;
114
126
  title?: string | undefined;
@@ -122,13 +134,19 @@ declare function createChatStoreDefinition(instanceId: string): import('pinia').
122
134
  id: string;
123
135
  title: string;
124
136
  }[] | undefined;
137
+ runPlan?: string | undefined;
138
+ runPlanExpanded?: boolean | undefined;
125
139
  }[]>;
126
140
  isStreaming: import('vue').Ref<boolean, boolean>;
127
141
  isSessionLoading: import('vue').Ref<boolean, boolean>;
142
+ runPlanVisible: import('vue').Ref<boolean, boolean>;
128
143
  initSession: () => Promise<void>;
129
144
  loadSessions: () => Promise<void>;
130
- switchSession: (id: string) => void;
131
- newChat: () => Promise<void>;
145
+ isVirtualSession: import('vue').ComputedRef<boolean>;
146
+ syncSessionFromHistory: () => Promise<void>;
147
+ syncSessionId: (id: string) => void;
148
+ switchSession: (id: number | string) => Promise<void>;
149
+ newChat: () => void;
132
150
  addUserMessage: (content: string) => ChatMessage;
133
151
  addAssistantPlaceholder: () => ChatMessage;
134
152
  appendStreamContent: (content: string) => void;
@@ -137,25 +155,27 @@ declare function createChatStoreDefinition(instanceId: string): import('pinia').
137
155
  updateData: (data: any[]) => void;
138
156
  updateChartConfig: (config: any) => void;
139
157
  updateSources: (sources: SourceInfo[]) => void;
158
+ updateRunPlan: (text: string) => void;
159
+ getMessageData: (messageId: string) => MessageStructuredData | undefined;
140
160
  markStreamDone: (reportId?: number, title?: string) => void;
141
161
  markStreamError: (errorMessage: string) => void;
142
162
  clearMessages: () => void;
143
- }, never>, Pick<{
163
+ }, "isVirtualSession">, Pick<{
144
164
  sessionId: import('vue').Ref<string, string>;
145
165
  sessions: import('vue').Ref<{
146
- id: string;
166
+ id: number | string;
147
167
  title: string;
148
168
  created_at: string;
149
169
  }[], SessionInfo[] | {
150
- id: string;
170
+ id: number | string;
151
171
  title: string;
152
172
  created_at: string;
153
173
  }[]>;
154
174
  messages: import('vue').Ref<{
155
175
  id: string;
156
- role: import('../../types/agent').ChatMessageRole;
176
+ role: ChatMessageRole;
157
177
  content: string;
158
- status: import('../../types/agent').ChatMessageStatus;
178
+ status: ChatMessageStatus;
159
179
  createdAt: number;
160
180
  reportId?: number | undefined;
161
181
  title?: string | undefined;
@@ -169,11 +189,13 @@ declare function createChatStoreDefinition(instanceId: string): import('pinia').
169
189
  id: string;
170
190
  title: string;
171
191
  }[] | undefined;
192
+ runPlan?: string | undefined;
193
+ runPlanExpanded?: boolean | undefined;
172
194
  }[], ChatMessage[] | {
173
195
  id: string;
174
- role: import('../../types/agent').ChatMessageRole;
196
+ role: ChatMessageRole;
175
197
  content: string;
176
- status: import('../../types/agent').ChatMessageStatus;
198
+ status: ChatMessageStatus;
177
199
  createdAt: number;
178
200
  reportId?: number | undefined;
179
201
  title?: string | undefined;
@@ -187,13 +209,19 @@ declare function createChatStoreDefinition(instanceId: string): import('pinia').
187
209
  id: string;
188
210
  title: string;
189
211
  }[] | undefined;
212
+ runPlan?: string | undefined;
213
+ runPlanExpanded?: boolean | undefined;
190
214
  }[]>;
191
215
  isStreaming: import('vue').Ref<boolean, boolean>;
192
216
  isSessionLoading: import('vue').Ref<boolean, boolean>;
217
+ runPlanVisible: import('vue').Ref<boolean, boolean>;
193
218
  initSession: () => Promise<void>;
194
219
  loadSessions: () => Promise<void>;
195
- switchSession: (id: string) => void;
196
- newChat: () => Promise<void>;
220
+ isVirtualSession: import('vue').ComputedRef<boolean>;
221
+ syncSessionFromHistory: () => Promise<void>;
222
+ syncSessionId: (id: string) => void;
223
+ switchSession: (id: number | string) => Promise<void>;
224
+ newChat: () => void;
197
225
  addUserMessage: (content: string) => ChatMessage;
198
226
  addAssistantPlaceholder: () => ChatMessage;
199
227
  appendStreamContent: (content: string) => void;
@@ -202,27 +230,29 @@ declare function createChatStoreDefinition(instanceId: string): import('pinia').
202
230
  updateData: (data: any[]) => void;
203
231
  updateChartConfig: (config: any) => void;
204
232
  updateSources: (sources: SourceInfo[]) => void;
233
+ updateRunPlan: (text: string) => void;
234
+ getMessageData: (messageId: string) => MessageStructuredData | undefined;
205
235
  markStreamDone: (reportId?: number, title?: string) => void;
206
236
  markStreamError: (errorMessage: string) => void;
207
237
  clearMessages: () => void;
208
- }, "initSession" | "loadSessions" | "switchSession" | "newChat" | "addUserMessage" | "addAssistantPlaceholder" | "appendStreamContent" | "updateStatusText" | "updateSql" | "updateData" | "updateChartConfig" | "updateSources" | "markStreamDone" | "markStreamError" | "clearMessages">>;
238
+ }, "initSession" | "loadSessions" | "syncSessionFromHistory" | "syncSessionId" | "switchSession" | "newChat" | "addUserMessage" | "addAssistantPlaceholder" | "appendStreamContent" | "updateStatusText" | "updateSql" | "updateData" | "updateChartConfig" | "updateSources" | "updateRunPlan" | "getMessageData" | "markStreamDone" | "markStreamError" | "clearMessages">>;
209
239
  /** 默认聊天 store 实例(instanceId = 'default') */
210
240
  export declare const chatStore: import('pinia').Store<`agent-chat-${string}`, Pick<{
211
241
  sessionId: import('vue').Ref<string, string>;
212
242
  sessions: import('vue').Ref<{
213
- id: string;
243
+ id: number | string;
214
244
  title: string;
215
245
  created_at: string;
216
246
  }[], SessionInfo[] | {
217
- id: string;
247
+ id: number | string;
218
248
  title: string;
219
249
  created_at: string;
220
250
  }[]>;
221
251
  messages: import('vue').Ref<{
222
252
  id: string;
223
- role: import('../../types/agent').ChatMessageRole;
253
+ role: ChatMessageRole;
224
254
  content: string;
225
- status: import('../../types/agent').ChatMessageStatus;
255
+ status: ChatMessageStatus;
226
256
  createdAt: number;
227
257
  reportId?: number | undefined;
228
258
  title?: string | undefined;
@@ -236,11 +266,13 @@ export declare const chatStore: import('pinia').Store<`agent-chat-${string}`, Pi
236
266
  id: string;
237
267
  title: string;
238
268
  }[] | undefined;
269
+ runPlan?: string | undefined;
270
+ runPlanExpanded?: boolean | undefined;
239
271
  }[], ChatMessage[] | {
240
272
  id: string;
241
- role: import('../../types/agent').ChatMessageRole;
273
+ role: ChatMessageRole;
242
274
  content: string;
243
- status: import('../../types/agent').ChatMessageStatus;
275
+ status: ChatMessageStatus;
244
276
  createdAt: number;
245
277
  reportId?: number | undefined;
246
278
  title?: string | undefined;
@@ -254,13 +286,19 @@ export declare const chatStore: import('pinia').Store<`agent-chat-${string}`, Pi
254
286
  id: string;
255
287
  title: string;
256
288
  }[] | undefined;
289
+ runPlan?: string | undefined;
290
+ runPlanExpanded?: boolean | undefined;
257
291
  }[]>;
258
292
  isStreaming: import('vue').Ref<boolean, boolean>;
259
293
  isSessionLoading: import('vue').Ref<boolean, boolean>;
294
+ runPlanVisible: import('vue').Ref<boolean, boolean>;
260
295
  initSession: () => Promise<void>;
261
296
  loadSessions: () => Promise<void>;
262
- switchSession: (id: string) => void;
263
- newChat: () => Promise<void>;
297
+ isVirtualSession: import('vue').ComputedRef<boolean>;
298
+ syncSessionFromHistory: () => Promise<void>;
299
+ syncSessionId: (id: string) => void;
300
+ switchSession: (id: number | string) => Promise<void>;
301
+ newChat: () => void;
264
302
  addUserMessage: (content: string) => ChatMessage;
265
303
  addAssistantPlaceholder: () => ChatMessage;
266
304
  appendStreamContent: (content: string) => void;
@@ -269,25 +307,27 @@ export declare const chatStore: import('pinia').Store<`agent-chat-${string}`, Pi
269
307
  updateData: (data: any[]) => void;
270
308
  updateChartConfig: (config: any) => void;
271
309
  updateSources: (sources: SourceInfo[]) => void;
310
+ updateRunPlan: (text: string) => void;
311
+ getMessageData: (messageId: string) => MessageStructuredData | undefined;
272
312
  markStreamDone: (reportId?: number, title?: string) => void;
273
313
  markStreamError: (errorMessage: string) => void;
274
314
  clearMessages: () => void;
275
- }, "sessionId" | "sessions" | "messages" | "isStreaming" | "isSessionLoading">, Pick<{
315
+ }, "sessionId" | "sessions" | "messages" | "runPlanVisible" | "isStreaming" | "isSessionLoading">, Pick<{
276
316
  sessionId: import('vue').Ref<string, string>;
277
317
  sessions: import('vue').Ref<{
278
- id: string;
318
+ id: number | string;
279
319
  title: string;
280
320
  created_at: string;
281
321
  }[], SessionInfo[] | {
282
- id: string;
322
+ id: number | string;
283
323
  title: string;
284
324
  created_at: string;
285
325
  }[]>;
286
326
  messages: import('vue').Ref<{
287
327
  id: string;
288
- role: import('../../types/agent').ChatMessageRole;
328
+ role: ChatMessageRole;
289
329
  content: string;
290
- status: import('../../types/agent').ChatMessageStatus;
330
+ status: ChatMessageStatus;
291
331
  createdAt: number;
292
332
  reportId?: number | undefined;
293
333
  title?: string | undefined;
@@ -301,11 +341,13 @@ export declare const chatStore: import('pinia').Store<`agent-chat-${string}`, Pi
301
341
  id: string;
302
342
  title: string;
303
343
  }[] | undefined;
344
+ runPlan?: string | undefined;
345
+ runPlanExpanded?: boolean | undefined;
304
346
  }[], ChatMessage[] | {
305
347
  id: string;
306
- role: import('../../types/agent').ChatMessageRole;
348
+ role: ChatMessageRole;
307
349
  content: string;
308
- status: import('../../types/agent').ChatMessageStatus;
350
+ status: ChatMessageStatus;
309
351
  createdAt: number;
310
352
  reportId?: number | undefined;
311
353
  title?: string | undefined;
@@ -319,13 +361,19 @@ export declare const chatStore: import('pinia').Store<`agent-chat-${string}`, Pi
319
361
  id: string;
320
362
  title: string;
321
363
  }[] | undefined;
364
+ runPlan?: string | undefined;
365
+ runPlanExpanded?: boolean | undefined;
322
366
  }[]>;
323
367
  isStreaming: import('vue').Ref<boolean, boolean>;
324
368
  isSessionLoading: import('vue').Ref<boolean, boolean>;
369
+ runPlanVisible: import('vue').Ref<boolean, boolean>;
325
370
  initSession: () => Promise<void>;
326
371
  loadSessions: () => Promise<void>;
327
- switchSession: (id: string) => void;
328
- newChat: () => Promise<void>;
372
+ isVirtualSession: import('vue').ComputedRef<boolean>;
373
+ syncSessionFromHistory: () => Promise<void>;
374
+ syncSessionId: (id: string) => void;
375
+ switchSession: (id: number | string) => Promise<void>;
376
+ newChat: () => void;
329
377
  addUserMessage: (content: string) => ChatMessage;
330
378
  addAssistantPlaceholder: () => ChatMessage;
331
379
  appendStreamContent: (content: string) => void;
@@ -334,25 +382,27 @@ export declare const chatStore: import('pinia').Store<`agent-chat-${string}`, Pi
334
382
  updateData: (data: any[]) => void;
335
383
  updateChartConfig: (config: any) => void;
336
384
  updateSources: (sources: SourceInfo[]) => void;
385
+ updateRunPlan: (text: string) => void;
386
+ getMessageData: (messageId: string) => MessageStructuredData | undefined;
337
387
  markStreamDone: (reportId?: number, title?: string) => void;
338
388
  markStreamError: (errorMessage: string) => void;
339
389
  clearMessages: () => void;
340
- }, never>, Pick<{
390
+ }, "isVirtualSession">, Pick<{
341
391
  sessionId: import('vue').Ref<string, string>;
342
392
  sessions: import('vue').Ref<{
343
- id: string;
393
+ id: number | string;
344
394
  title: string;
345
395
  created_at: string;
346
396
  }[], SessionInfo[] | {
347
- id: string;
397
+ id: number | string;
348
398
  title: string;
349
399
  created_at: string;
350
400
  }[]>;
351
401
  messages: import('vue').Ref<{
352
402
  id: string;
353
- role: import('../../types/agent').ChatMessageRole;
403
+ role: ChatMessageRole;
354
404
  content: string;
355
- status: import('../../types/agent').ChatMessageStatus;
405
+ status: ChatMessageStatus;
356
406
  createdAt: number;
357
407
  reportId?: number | undefined;
358
408
  title?: string | undefined;
@@ -366,11 +416,13 @@ export declare const chatStore: import('pinia').Store<`agent-chat-${string}`, Pi
366
416
  id: string;
367
417
  title: string;
368
418
  }[] | undefined;
419
+ runPlan?: string | undefined;
420
+ runPlanExpanded?: boolean | undefined;
369
421
  }[], ChatMessage[] | {
370
422
  id: string;
371
- role: import('../../types/agent').ChatMessageRole;
423
+ role: ChatMessageRole;
372
424
  content: string;
373
- status: import('../../types/agent').ChatMessageStatus;
425
+ status: ChatMessageStatus;
374
426
  createdAt: number;
375
427
  reportId?: number | undefined;
376
428
  title?: string | undefined;
@@ -384,13 +436,19 @@ export declare const chatStore: import('pinia').Store<`agent-chat-${string}`, Pi
384
436
  id: string;
385
437
  title: string;
386
438
  }[] | undefined;
439
+ runPlan?: string | undefined;
440
+ runPlanExpanded?: boolean | undefined;
387
441
  }[]>;
388
442
  isStreaming: import('vue').Ref<boolean, boolean>;
389
443
  isSessionLoading: import('vue').Ref<boolean, boolean>;
444
+ runPlanVisible: import('vue').Ref<boolean, boolean>;
390
445
  initSession: () => Promise<void>;
391
446
  loadSessions: () => Promise<void>;
392
- switchSession: (id: string) => void;
393
- newChat: () => Promise<void>;
447
+ isVirtualSession: import('vue').ComputedRef<boolean>;
448
+ syncSessionFromHistory: () => Promise<void>;
449
+ syncSessionId: (id: string) => void;
450
+ switchSession: (id: number | string) => Promise<void>;
451
+ newChat: () => void;
394
452
  addUserMessage: (content: string) => ChatMessage;
395
453
  addAssistantPlaceholder: () => ChatMessage;
396
454
  appendStreamContent: (content: string) => void;
@@ -399,8 +457,10 @@ export declare const chatStore: import('pinia').Store<`agent-chat-${string}`, Pi
399
457
  updateData: (data: any[]) => void;
400
458
  updateChartConfig: (config: any) => void;
401
459
  updateSources: (sources: SourceInfo[]) => void;
460
+ updateRunPlan: (text: string) => void;
461
+ getMessageData: (messageId: string) => MessageStructuredData | undefined;
402
462
  markStreamDone: (reportId?: number, title?: string) => void;
403
463
  markStreamError: (errorMessage: string) => void;
404
464
  clearMessages: () => void;
405
- }, "initSession" | "loadSessions" | "switchSession" | "newChat" | "addUserMessage" | "addAssistantPlaceholder" | "appendStreamContent" | "updateStatusText" | "updateSql" | "updateData" | "updateChartConfig" | "updateSources" | "markStreamDone" | "markStreamError" | "clearMessages">>;
465
+ }, "initSession" | "loadSessions" | "syncSessionFromHistory" | "syncSessionId" | "switchSession" | "newChat" | "addUserMessage" | "addAssistantPlaceholder" | "appendStreamContent" | "updateStatusText" | "updateSql" | "updateData" | "updateChartConfig" | "updateSources" | "updateRunPlan" | "getMessageData" | "markStreamDone" | "markStreamError" | "clearMessages">>;
406
466
  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,24 @@ export interface AgentPluginOptions {
13
33
  getAccessToken?: () => string;
14
34
  /** 认证 session 获取函数 */
15
35
  getSession?: () => string;
16
- /** 用户 ID 获取函数,用于创建/查询会话(动态场景优先使用) */
17
- getUserId?: () => string;
18
- /** 用户 ID 静态值(简化用法,getUserId 优先) */
19
- userId?: string;
20
- /** LLM 提供商 ID */
21
- llmProviderId?: number;
22
- /** 提示词模板 ID */
23
- promptTemplateId?: number;
24
- /** 自定义提示词 */
25
- customPrompt?: string;
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>;
52
+ /** 自定义请求头,合并到安全签名头中,同名键覆盖自动生成的值(支持静态对象或动态函数) */
53
+ customHeaders?: Record<string, string> | (() => Record<string, string>);
26
54
  /** 窗口标题文本 */
27
55
  headerTitle?: string;
28
56
  /** 空状态提示文本 */
@@ -43,6 +71,24 @@ export interface AgentPluginOptions {
43
71
  draggable?: boolean;
44
72
  /** 拖拽约束模式:'viewport' 限制在视口内,'none' 不限制(但仍不超出可见区域),默认 'viewport' */
45
73
  dragConstrain?: DragConstrainMode;
74
+ /** 弹窗相对按钮的方位,默认 'top-end'(按钮上方右对齐) */
75
+ placement?: AgentWindowPlacement;
76
+ /** 用户头像 URL(支持 svg/png/jpg 等图片格式,不传则使用默认图标) */
77
+ userAvatar?: string;
78
+ /** AI 助手头像 URL(支持 svg/png/jpg 等图片格式,不传则使用默认图标) */
79
+ assistantAvatar?: string;
80
+ /** 是否显示欢迎气泡,默认 true */
81
+ showWelcome?: boolean;
82
+ /** 欢迎词文本,默认 '请问有什么可以帮你?' */
83
+ welcomeMessage?: string;
84
+ /** 是否在消息中显示 SQL,默认 false */
85
+ showSql?: boolean;
86
+ /** 是否在消息中显示数据表格,默认 false */
87
+ showData?: boolean;
88
+ /** 是否显示执行计划/思考过程,默认 true */
89
+ showRunPlan?: boolean;
90
+ /** 执行计划默认是否展开,默认 false */
91
+ defaultRunPlanExpanded?: boolean;
46
92
  }
47
93
  /** provide/inject key */
48
94
  export declare const AGENT_CONFIG_KEY: InjectionKey<ComputedRef<AgentPluginOptions>>;
@@ -87,21 +133,34 @@ export interface ChatMessage {
87
133
  chartConfig?: any;
88
134
  /** 来源依据 */
89
135
  sources?: SourceInfo[];
136
+ /** 执行计划/思考过程 */
137
+ runPlan?: string;
138
+ /** 执行计划是否展开 */
139
+ runPlanExpanded?: boolean;
90
140
  }
91
141
  /** 会话信息 */
92
142
  export interface SessionInfo {
93
- id: string;
143
+ id: number | string;
94
144
  title: string;
95
145
  created_at: string;
96
146
  }
147
+ /** 消息结构化数据(通过 getMessageData 获取) */
148
+ export interface MessageStructuredData {
149
+ sql?: string;
150
+ data?: any[];
151
+ chartConfig?: any;
152
+ sources?: SourceInfo[];
153
+ runPlan?: string;
154
+ }
97
155
  /** 流式请求参数 */
98
156
  export interface StreamRequestData {
99
- sessionId: string;
157
+ /** 会话 ID(可选,选择历史记录后传入对应 session_id) */
158
+ sessionId?: string;
159
+ /** 用户查询内容 */
100
160
  query: string;
101
- userId?: string;
102
161
  }
103
162
  /** 流式事件类型 */
104
- export type StreamEventType = 'status' | 'sql' | 'data' | 'chart_config' | 'sources' | 'analysis_chunk' | 'delta' | 'done' | 'error';
163
+ export type StreamEventType = 'session' | 'status' | 'sql' | 'data' | 'chart_config' | 'sources' | 'run_plan' | 'analysis_chunk' | 'delta' | 'done' | 'error';
105
164
  /** 流式事件数据 */
106
165
  export interface StreamEvent {
107
166
  type: StreamEventType;
@@ -109,6 +168,8 @@ export interface StreamEvent {
109
168
  message?: string;
110
169
  report_id?: number;
111
170
  title?: string;
171
+ /** session 事件专用:后端返回的会话 ID */
172
+ session_id?: number | string;
112
173
  }
113
174
  /** 布局模式 */
114
175
  export type AgentLayoutMode = 'popup' | 'full' | 'mobile';
@@ -130,11 +191,14 @@ export interface AgentMobileLayoutProps {
130
191
  }
131
192
  /** 流式回调 */
132
193
  export interface StreamCallbacks {
194
+ /** session 事件:后端首条返回中携带的会话 ID,可立即绑定用于后续对话 */
195
+ onSession?: (sessionId: string) => void;
133
196
  onStatus?: (text: string) => void;
134
197
  onSql?: (sql: string) => void;
135
198
  onData?: (data: any[]) => void;
136
199
  onChartConfig?: (config: any) => void;
137
200
  onSources?: (sources: SourceInfo[]) => void;
201
+ onRunPlan?: (text: string) => void;
138
202
  onAnalysisChunk?: (chunk: string) => void;
139
203
  onDone?: (reportId: number, title: string) => void;
140
204
  onError?: (message: string) => void;