@blueking/chat-helper 0.0.10-beta.4 → 0.0.12-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/use-agent.d.ts +2 -1272
- package/dist/agent/use-agent.ts.js +9 -90
- package/dist/event/ag-ui.d.ts +1 -9
- package/dist/event/ag-ui.ts.js +3 -46
- package/dist/event/type.d.ts +24 -87
- package/dist/event/type.ts.js +16 -43
- package/dist/http/index.d.ts +2 -6
- package/dist/http/module/index.d.ts +2 -6
- package/dist/http/module/message.d.ts +3 -6
- package/dist/http/module/message.ts.js +1 -18
- package/dist/http/module/session.d.ts +0 -1
- package/dist/http/module/session.ts.js +1 -4
- package/dist/http/transform/message.ts.js +0 -10
- package/dist/index.d.ts +2 -8835
- package/dist/message/type.d.ts +4 -24
- package/dist/message/type.ts.js +0 -7
- package/dist/message/use-message.d.ts +0 -2520
- package/dist/session/use-session.d.ts +0 -5040
- package/dist/session/use-session.ts.js +11 -6
- package/package.json +4 -8
|
@@ -80,8 +80,8 @@ function _object_spread(target) {
|
|
|
80
80
|
return target;
|
|
81
81
|
}
|
|
82
82
|
import { ref } from 'vue';
|
|
83
|
-
import { AGUIProtocol
|
|
84
|
-
import { MessageRole, MessageStatus
|
|
83
|
+
import { AGUIProtocol } from '../event/index.ts.js';
|
|
84
|
+
import { MessageRole, MessageStatus } from '../message/index.ts.js';
|
|
85
85
|
import { SessionStatus } from '../session/type.ts.js';
|
|
86
86
|
/**
|
|
87
87
|
* Agent 模块
|
|
@@ -121,50 +121,19 @@ import { SessionStatus } from '../session/type.ts.js';
|
|
|
121
121
|
});
|
|
122
122
|
}
|
|
123
123
|
};
|
|
124
|
-
const userOperationStreamRequest = (sessionCode, operation, payload, config)=>{
|
|
125
|
-
var _mediator_http;
|
|
126
|
-
return (_mediator_http = mediator.http) === null || _mediator_http === void 0 ? void 0 : _mediator_http.message.userOperation(sessionCode, operation, payload, config).then(()=>{
|
|
127
|
-
if (operation !== UserOperation.ApprovalCancel) {
|
|
128
|
-
streamRequest({
|
|
129
|
-
sessionCode,
|
|
130
|
-
config
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
};
|
|
135
124
|
const streamRequest = function() {
|
|
136
|
-
var _ref = _async_to_generator(function*(
|
|
125
|
+
var _ref = _async_to_generator(function*(sessionCode, url, config) {
|
|
137
126
|
var // 发起聊天
|
|
138
127
|
_mediator_http;
|
|
139
128
|
// ag-ui 协议需要注入消息模块
|
|
140
129
|
if (usedProtocol instanceof AGUIProtocol) {
|
|
141
130
|
usedProtocol.injectMessageModule(mediator.message);
|
|
142
131
|
}
|
|
143
|
-
if (input) {
|
|
144
|
-
var // 列表新增一个用户消息
|
|
145
|
-
_mediator_message;
|
|
146
|
-
(_mediator_message = mediator.message) === null || _mediator_message === void 0 ? void 0 : _mediator_message.list.value.push({
|
|
147
|
-
role: MessageRole.User,
|
|
148
|
-
content: input,
|
|
149
|
-
status: MessageStatus.Complete,
|
|
150
|
-
sessionCode
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
132
|
// 事件代理
|
|
154
133
|
const onDone = ()=>{
|
|
155
134
|
var _usedProtocol_onDone;
|
|
156
135
|
isChatting.value = false;
|
|
157
136
|
(_usedProtocol_onDone = usedProtocol.onDone) === null || _usedProtocol_onDone === void 0 ? void 0 : _usedProtocol_onDone.call(usedProtocol);
|
|
158
|
-
if (input) {
|
|
159
|
-
var // 刷新列表,获取前端 mock message 的 id,并更新到列表中
|
|
160
|
-
_mediator_http_message, _mediator_http;
|
|
161
|
-
(_mediator_http = mediator.http) === null || _mediator_http === void 0 ? void 0 : (_mediator_http_message = _mediator_http.message) === null || _mediator_http_message === void 0 ? void 0 : _mediator_http_message.getMessages(sessionCode).then((res)=>{
|
|
162
|
-
var _mediator_message;
|
|
163
|
-
const lastUserMessage = (_mediator_message = mediator.message) === null || _mediator_message === void 0 ? void 0 : _mediator_message.list.value.findLast((item)=>item.role === MessageRole.User);
|
|
164
|
-
const lastApiUserMessage = res.findLast((item)=>item.role === MessageRole.User);
|
|
165
|
-
lastUserMessage.id = lastApiUserMessage.id;
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
137
|
};
|
|
169
138
|
const onError = (error)=>{
|
|
170
139
|
var _usedProtocol_onError;
|
|
@@ -187,11 +156,8 @@ import { SessionStatus } from '../session/type.ts.js';
|
|
|
187
156
|
method: 'POST',
|
|
188
157
|
data: {
|
|
189
158
|
session_code: sessionCode,
|
|
190
|
-
resume,
|
|
191
|
-
input,
|
|
192
159
|
execute_kwargs: {
|
|
193
|
-
stream: true
|
|
194
|
-
persist_input: !!input
|
|
160
|
+
stream: true
|
|
195
161
|
}
|
|
196
162
|
},
|
|
197
163
|
controller: abortController,
|
|
@@ -201,7 +167,7 @@ import { SessionStatus } from '../session/type.ts.js';
|
|
|
201
167
|
onStart
|
|
202
168
|
}, config));
|
|
203
169
|
});
|
|
204
|
-
return function streamRequest(
|
|
170
|
+
return function streamRequest(sessionCode, url, config) {
|
|
205
171
|
return _ref.apply(this, arguments);
|
|
206
172
|
};
|
|
207
173
|
}();
|
|
@@ -225,11 +191,7 @@ import { SessionStatus } from '../session/type.ts.js';
|
|
|
225
191
|
property
|
|
226
192
|
}));
|
|
227
193
|
// 发起聊天
|
|
228
|
-
streamRequest(
|
|
229
|
-
sessionCode,
|
|
230
|
-
url,
|
|
231
|
-
config
|
|
232
|
-
});
|
|
194
|
+
streamRequest(sessionCode, url, config);
|
|
233
195
|
});
|
|
234
196
|
return function chat(userInput, sessionCode, url, config, property) {
|
|
235
197
|
return _ref.apply(this, arguments);
|
|
@@ -244,43 +206,7 @@ import { SessionStatus } from '../session/type.ts.js';
|
|
|
244
206
|
*/ const resumeStreamingChat = (sessionCode, url, config)=>{
|
|
245
207
|
var _mediator_session_current_value, _mediator_session;
|
|
246
208
|
if (((_mediator_session = mediator.session) === null || _mediator_session === void 0 ? void 0 : (_mediator_session_current_value = _mediator_session.current.value) === null || _mediator_session_current_value === void 0 ? void 0 : _mediator_session_current_value.status) === SessionStatus.Running) {
|
|
247
|
-
streamRequest(
|
|
248
|
-
sessionCode,
|
|
249
|
-
url,
|
|
250
|
-
config
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
};
|
|
254
|
-
/**
|
|
255
|
-
* 轮询接口,判断是否可以继续聊天
|
|
256
|
-
* @param sessionCode - 会话编码
|
|
257
|
-
* @returns 是否可以继续聊天
|
|
258
|
-
*/ const pollResumeSession = (sessionCode)=>{
|
|
259
|
-
var _mediator_message, _lastMessage_content_outcome, _lastMessage_content, _lastMessage_content_outcome_interrupts, _lastMessage_content_outcome1, _lastMessage_content1;
|
|
260
|
-
const lastMessage = (_mediator_message = mediator.message) === null || _mediator_message === void 0 ? void 0 : _mediator_message.list.value.at(-1);
|
|
261
|
-
const isInterruptMessage = (lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.role) === MessageRole.Interrupt;
|
|
262
|
-
const isTicketPending = (lastMessage === null || lastMessage === void 0 ? void 0 : (_lastMessage_content = lastMessage.content) === null || _lastMessage_content === void 0 ? void 0 : (_lastMessage_content_outcome = _lastMessage_content.outcome) === null || _lastMessage_content_outcome === void 0 ? void 0 : _lastMessage_content_outcome.type) === RunFinishedOutcomeType.Interrupt && (lastMessage === null || lastMessage === void 0 ? void 0 : (_lastMessage_content1 = lastMessage.content) === null || _lastMessage_content1 === void 0 ? void 0 : (_lastMessage_content_outcome1 = _lastMessage_content1.outcome) === null || _lastMessage_content_outcome1 === void 0 ? void 0 : (_lastMessage_content_outcome_interrupts = _lastMessage_content_outcome1.interrupts) === null || _lastMessage_content_outcome_interrupts === void 0 ? void 0 : _lastMessage_content_outcome_interrupts.some((interrupt)=>{
|
|
263
|
-
var _interrupt_metadata_ticket, _interrupt_metadata;
|
|
264
|
-
return ((_interrupt_metadata = interrupt.metadata) === null || _interrupt_metadata === void 0 ? void 0 : (_interrupt_metadata_ticket = _interrupt_metadata.ticket) === null || _interrupt_metadata_ticket === void 0 ? void 0 : _interrupt_metadata_ticket.status) === ApprovalInterruptTicketStatus.Pending;
|
|
265
|
-
}));
|
|
266
|
-
if (isInterruptMessage && isTicketPending) {
|
|
267
|
-
setTimeout(()=>{
|
|
268
|
-
var _mediator_session_current_value, _mediator_session_current, _mediator_session, // 轮询接口,判断是否可以继续聊天
|
|
269
|
-
_mediator_http;
|
|
270
|
-
// 如果会话不匹配,则不继续轮询
|
|
271
|
-
if (sessionCode !== ((_mediator_session = mediator.session) === null || _mediator_session === void 0 ? void 0 : (_mediator_session_current = _mediator_session.current) === null || _mediator_session_current === void 0 ? void 0 : (_mediator_session_current_value = _mediator_session_current.value) === null || _mediator_session_current_value === void 0 ? void 0 : _mediator_session_current_value.sessionCode)) return;
|
|
272
|
-
(_mediator_http = mediator.http) === null || _mediator_http === void 0 ? void 0 : _mediator_http.session.isResumeSession(sessionCode).then((res)=>{
|
|
273
|
-
if (res) {
|
|
274
|
-
// 可以继续聊天,重新发起聊天
|
|
275
|
-
streamRequest({
|
|
276
|
-
sessionCode
|
|
277
|
-
});
|
|
278
|
-
} else {
|
|
279
|
-
// 不可以继续聊天,继续轮询
|
|
280
|
-
pollResumeSession(sessionCode);
|
|
281
|
-
}
|
|
282
|
-
});
|
|
283
|
-
}, 30000);
|
|
209
|
+
streamRequest(sessionCode, url, config);
|
|
284
210
|
}
|
|
285
211
|
};
|
|
286
212
|
/**
|
|
@@ -343,11 +269,7 @@ import { SessionStatus } from '../session/type.ts.js';
|
|
|
343
269
|
property: originalProperty
|
|
344
270
|
}));
|
|
345
271
|
// 6. 立即发起流式请求(不等待删除和创建的 API 完成)
|
|
346
|
-
streamRequest(
|
|
347
|
-
sessionCode,
|
|
348
|
-
url,
|
|
349
|
-
config
|
|
350
|
-
});
|
|
272
|
+
streamRequest(sessionCode, url, config);
|
|
351
273
|
// 7. 在后台等待 API 完成,处理可能的错误
|
|
352
274
|
Promise.all([
|
|
353
275
|
deletePromise,
|
|
@@ -377,9 +299,6 @@ import { SessionStatus } from '../session/type.ts.js';
|
|
|
377
299
|
abortChat,
|
|
378
300
|
stopChat,
|
|
379
301
|
getAgentInfo,
|
|
380
|
-
reset
|
|
381
|
-
pollResumeSession,
|
|
382
|
-
userOperationStreamRequest,
|
|
383
|
-
streamRequest
|
|
302
|
+
reset
|
|
384
303
|
};
|
|
385
304
|
};
|
package/dist/event/ag-ui.d.ts
CHANGED
|
@@ -43,10 +43,6 @@ export declare class AGUIProtocol implements ISSEProtocol {
|
|
|
43
43
|
* 自定义事件 处理流程编排任务开始
|
|
44
44
|
*/
|
|
45
45
|
handleFlowAgentStartCustomEvent(event: ICustomEvent): void;
|
|
46
|
-
/**
|
|
47
|
-
* 自定义事件 处理流程编排任务更新
|
|
48
|
-
*/
|
|
49
|
-
handleFlowAgentUpdateCustomEvent(event: ICustomEvent): void;
|
|
50
46
|
/**
|
|
51
47
|
* 自定义事件 处理意图识别结束
|
|
52
48
|
*/
|
|
@@ -84,7 +80,7 @@ export declare class AGUIProtocol implements ISSEProtocol {
|
|
|
84
80
|
/**
|
|
85
81
|
* 处理运行完成事件
|
|
86
82
|
*/
|
|
87
|
-
handleRunFinishedEvent(
|
|
83
|
+
handleRunFinishedEvent(_event: IRunFinishedEvent): void;
|
|
88
84
|
/**
|
|
89
85
|
* 处理运行开始事件
|
|
90
86
|
*/
|
|
@@ -109,10 +105,6 @@ export declare class AGUIProtocol implements ISSEProtocol {
|
|
|
109
105
|
* 自定义事件 处理临时消息,转换为 AI 文本消息
|
|
110
106
|
*/
|
|
111
107
|
handleTempMessageCustomEvent(event: ICustomEvent): void;
|
|
112
|
-
/**
|
|
113
|
-
* 自定义事件 处理审批结果
|
|
114
|
-
*/
|
|
115
|
-
handleApprovalResultCustomEvent(event: ICustomEvent): void;
|
|
116
108
|
/**
|
|
117
109
|
* 处理文本消息块事件
|
|
118
110
|
*/
|
package/dist/event/ag-ui.ts.js
CHANGED
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
}
|
|
38
38
|
import { transferMessageApi2Message } from '../http/transform/index.ts.js';
|
|
39
39
|
import { ActivityType, MessageRole, MessageStatus, MessageType } from '../message/index.ts.js';
|
|
40
|
-
import { CustomEventName, EventType, FlowTaskState
|
|
40
|
+
import { CustomEventName, EventType, FlowTaskState } from './type.ts.js';
|
|
41
41
|
/**
|
|
42
42
|
* AGUI 协议
|
|
43
43
|
* @param message - 消息模块
|
|
@@ -81,12 +81,6 @@ import { CustomEventName, EventType, FlowTaskState, RunFinishedOutcomeType } fro
|
|
|
81
81
|
case CustomEventName.TempMessage:
|
|
82
82
|
this.handleTempMessageCustomEvent(event);
|
|
83
83
|
break;
|
|
84
|
-
case CustomEventName.ApprovalResult:
|
|
85
|
-
this.handleApprovalResultCustomEvent(event);
|
|
86
|
-
break;
|
|
87
|
-
case CustomEventName.FlowAgentUpdate:
|
|
88
|
-
this.handleFlowAgentUpdateCustomEvent(event);
|
|
89
|
-
break;
|
|
90
84
|
default:
|
|
91
85
|
break;
|
|
92
86
|
}
|
|
@@ -133,20 +127,6 @@ import { CustomEventName, EventType, FlowTaskState, RunFinishedOutcomeType } fro
|
|
|
133
127
|
});
|
|
134
128
|
}
|
|
135
129
|
/**
|
|
136
|
-
* 自定义事件 处理流程编排任务更新
|
|
137
|
-
*/ handleFlowAgentUpdateCustomEvent(event) {
|
|
138
|
-
const value = event.value;
|
|
139
|
-
this.messageModule.list.value.forEach((item)=>{
|
|
140
|
-
if (item.role === MessageRole.Activity && item.activityType === ActivityType.FlowAgent) {
|
|
141
|
-
const isSameTask = item.content[0].task_id === value[0].task_id;
|
|
142
|
-
// 通过第一个 task_id 判断是否是同一个任务,是的话直接更新消息内容
|
|
143
|
-
if (isSameTask) {
|
|
144
|
-
item.content = value;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
130
|
* 自定义事件 处理意图识别结束
|
|
151
131
|
*/ handleKnowledgeRagEndCustomEvent(_event) {
|
|
152
132
|
const message = this.messageModule.getCurrentLoadingMessage();
|
|
@@ -226,24 +206,11 @@ import { CustomEventName, EventType, FlowTaskState, RunFinishedOutcomeType } fro
|
|
|
226
206
|
}
|
|
227
207
|
/**
|
|
228
208
|
* 处理运行完成事件
|
|
229
|
-
*/ handleRunFinishedEvent(
|
|
230
|
-
var _event_outcome, _event_outcome1;
|
|
209
|
+
*/ handleRunFinishedEvent(_event) {
|
|
231
210
|
const message = this.messageModule.getCurrentLoadingMessage();
|
|
232
211
|
if (message) {
|
|
233
212
|
message.status = MessageStatus.Complete;
|
|
234
213
|
}
|
|
235
|
-
// 如果是中断消息,则创建一个中断消息
|
|
236
|
-
if (((_event_outcome = event.outcome) === null || _event_outcome === void 0 ? void 0 : _event_outcome.type) === RunFinishedOutcomeType.Interrupt) {
|
|
237
|
-
this.messageModule.plusMessage({
|
|
238
|
-
role: MessageRole.Interrupt,
|
|
239
|
-
content: event,
|
|
240
|
-
status: MessageStatus.Pending
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
// 二次返回,直接更新消息内容
|
|
244
|
-
if (((_event_outcome1 = event.outcome) === null || _event_outcome1 === void 0 ? void 0 : _event_outcome1.type) === RunFinishedOutcomeType.Success && (message === null || message === void 0 ? void 0 : message.role) === MessageRole.Interrupt) {
|
|
245
|
-
message.content = event;
|
|
246
|
-
}
|
|
247
214
|
}
|
|
248
215
|
/**
|
|
249
216
|
* 处理运行开始事件
|
|
@@ -282,16 +249,6 @@ import { CustomEventName, EventType, FlowTaskState, RunFinishedOutcomeType } fro
|
|
|
282
249
|
});
|
|
283
250
|
}
|
|
284
251
|
/**
|
|
285
|
-
* 自定义事件 处理审批结果
|
|
286
|
-
*/ handleApprovalResultCustomEvent(event) {
|
|
287
|
-
const value = event.value;
|
|
288
|
-
const message = this.messageModule.getCurrentLoadingMessage();
|
|
289
|
-
if (message) {
|
|
290
|
-
message.content = value;
|
|
291
|
-
message.status = MessageStatus.Complete;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
/**
|
|
295
252
|
* 处理文本消息块事件
|
|
296
253
|
*/ handleTextMessageChunkEvent(event) {
|
|
297
254
|
const message = this.messageModule.getCurrentLoadingMessage();
|
|
@@ -405,7 +362,7 @@ import { CustomEventName, EventType, FlowTaskState, RunFinishedOutcomeType } fro
|
|
|
405
362
|
role: MessageRole.Tool,
|
|
406
363
|
content: event.content,
|
|
407
364
|
duration: event.duration,
|
|
408
|
-
status: MessageStatus.Complete,
|
|
365
|
+
status: event.isError ? MessageStatus.Error : MessageStatus.Complete,
|
|
409
366
|
toolCallId: event.toolCallId,
|
|
410
367
|
messageId: event.messageId
|
|
411
368
|
});
|
package/dist/event/type.d.ts
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import { type IMessageApi, type MessageRole, type MessageStatus } from '../message/type';
|
|
2
|
-
import type { JSONSchema4 } from 'json-schema';
|
|
3
2
|
export declare enum CustomEventName {
|
|
4
3
|
FlowAgentEnd = "flow_agent_end",
|
|
5
4
|
FlowAgentResult = "flow_agent_result",
|
|
6
5
|
FlowAgentStart = "flow_agent_start",
|
|
7
|
-
FlowAgentUpdate = "flow_agent_update",
|
|
8
6
|
KnowledgeRagEnd = "knowledge_rag_end",
|
|
9
7
|
KnowledgeRagResult = "knowledge_rag_result",
|
|
10
8
|
KnowledgeRagStart = "knowledge_rag_start",
|
|
11
9
|
KnowledgeRagTextContent = "knowledge_rag_text_content",
|
|
12
10
|
ReferenceDocument = "reference_document",
|
|
13
|
-
TempMessage = "temp_message"
|
|
14
|
-
ApprovalResult = "approval_result"
|
|
11
|
+
TempMessage = "temp_message"
|
|
15
12
|
}
|
|
16
13
|
export declare enum EventType {
|
|
17
14
|
ActivityDelta = "ACTIVITY_DELTA",
|
|
@@ -43,51 +40,42 @@ export declare enum EventType {
|
|
|
43
40
|
}
|
|
44
41
|
/** BKFlow 收敛后的节点状态 - task.node 的状态枚举 */
|
|
45
42
|
export declare enum FlowNodeState {
|
|
43
|
+
/** 失败 */
|
|
46
44
|
Failed = "failed",
|
|
45
|
+
/** 执行中 */
|
|
47
46
|
Running = "running",
|
|
47
|
+
/** 成功 */
|
|
48
48
|
Success = "success",
|
|
49
|
+
/** 挂起 */
|
|
49
50
|
Suspended = "suspended"
|
|
50
51
|
}
|
|
51
52
|
/** BKFLOW 原始状态 - task 的状态枚举 */
|
|
52
53
|
export declare enum FlowTaskState {
|
|
54
|
+
/** 执行中 */
|
|
53
55
|
Blocked = "BLOCKED",
|
|
56
|
+
/** 执行中 */
|
|
54
57
|
Created = "CREATED",
|
|
58
|
+
/** 失败 */
|
|
55
59
|
Failed = "FAILED",
|
|
60
|
+
/** 成功 */
|
|
56
61
|
Finished = "FINISHED",
|
|
62
|
+
/** 执行中 */
|
|
57
63
|
LoopReady = "LOOP_READY",
|
|
64
|
+
/** 执行中 */
|
|
58
65
|
Ready = "READY",
|
|
66
|
+
/** 失败 */
|
|
59
67
|
Revoked = "REVOKED",
|
|
68
|
+
/** 失败 */
|
|
60
69
|
RollBackFailed = "ROLL_BACK_FAILED",
|
|
70
|
+
/** 执行中 */
|
|
61
71
|
RollBackSuccess = "ROLL_BACK_SUCCESS",
|
|
72
|
+
/** 执行中 */
|
|
62
73
|
RollingBack = "ROLLING_BACK",
|
|
74
|
+
/** 执行中 */
|
|
63
75
|
Running = "RUNNING",
|
|
76
|
+
/** 挂起 */
|
|
64
77
|
Suspended = "SUSPENDED"
|
|
65
78
|
}
|
|
66
|
-
/** 运行完成结果 */
|
|
67
|
-
export declare enum RunFinishedOutcomeType {
|
|
68
|
-
Success = "success",
|
|
69
|
-
Interrupt = "interrupt"
|
|
70
|
-
}
|
|
71
|
-
/** 审批状态 */
|
|
72
|
-
export declare enum ApprovalInterruptTicketStatus {
|
|
73
|
-
Abandoned = "abandoned",
|
|
74
|
-
Approved = "approved",
|
|
75
|
-
Cancelled = "cancelled",
|
|
76
|
-
Draft = "draft",
|
|
77
|
-
Expired = "expired",
|
|
78
|
-
Rejected = "rejected",
|
|
79
|
-
Pending = "pending"
|
|
80
|
-
}
|
|
81
|
-
/** 中断原因 */
|
|
82
|
-
export declare enum InterruptReason {
|
|
83
|
-
AIDevToolApproval = "aidev:tool_approval",
|
|
84
|
-
UserQuestion = "aidev:user_question"
|
|
85
|
-
}
|
|
86
|
-
/** 恢复状态 */
|
|
87
|
-
export declare enum ResumeStatus {
|
|
88
|
-
Resolved = "resolved",
|
|
89
|
-
Cancelled = "cancelled"
|
|
90
|
-
}
|
|
91
79
|
/**
|
|
92
80
|
* Activity 代表 Agent 执行过程中的活动/动作/任务,可能包含结构化数据
|
|
93
81
|
* 活动状态的增量更新
|
|
@@ -124,21 +112,21 @@ export interface IBaseEvent {
|
|
|
124
112
|
export interface ICustomEvent extends IBaseEvent {
|
|
125
113
|
name: CustomEventName;
|
|
126
114
|
type: EventType.Custom;
|
|
127
|
-
value: IFlowAgentEndCustomValue | IFlowAgentResultCustomValue | IFlowAgentStartCustomValue | IKnowledgeRagResultCustomValue | IKnowledgeRagTextContentCustomValue | IReferenceDocumentCustomValue | ITempMessageCustomValue
|
|
115
|
+
value: IFlowAgentEndCustomValue | IFlowAgentResultCustomValue | IFlowAgentStartCustomValue | IKnowledgeRagResultCustomValue | IKnowledgeRagTextContentCustomValue | IReferenceDocumentCustomValue | ITempMessageCustomValue;
|
|
128
116
|
}
|
|
129
117
|
export type IEvent = IActivityDeltaEvent | IActivitySnapshotEvent | ICustomEvent | IMessagesSnapshotEvent | IRawEvent | IRunErrorEvent | IRunFinishedEvent | IRunStartedEvent | IStateDeltaEvent | IStateSnapshotEvent | IStepFinishedEvent | IStepStartedEvent | ITextMessageChunkEvent | ITextMessageContentEvent | ITextMessageEndEvent | ITextMessageStartEvent | IThinkingEndEvent | IThinkingStartEvent | IThinkingTextMessageContentEvent | IThinkingTextMessageEndEvent | IThinkingTextMessageStartEvent | IToolCallArgsEvent | IToolCallChunkEvent | IToolCallEndEvent | IToolCallResultEvent | IToolCallStartEvent;
|
|
130
118
|
export type IFlowAgentEndCustomValue = {
|
|
131
119
|
task_outputs: string[];
|
|
132
120
|
}[];
|
|
133
121
|
export interface IFlowAgentNode {
|
|
122
|
+
/** 耗时(s) */
|
|
134
123
|
elapsed_time: number;
|
|
124
|
+
/** 节点id */
|
|
135
125
|
id: string;
|
|
126
|
+
/** 节点名称 */
|
|
136
127
|
name: string;
|
|
128
|
+
/** 节点状态 */
|
|
137
129
|
state: FlowNodeState;
|
|
138
|
-
retry: number;
|
|
139
|
-
skip: boolean;
|
|
140
|
-
retryable: boolean;
|
|
141
|
-
skippable: boolean;
|
|
142
130
|
}
|
|
143
131
|
export type IFlowAgentResultCustomValue = {
|
|
144
132
|
nodes: Record<string, IFlowAgentNode>;
|
|
@@ -185,66 +173,15 @@ export interface IRunErrorEvent extends IBaseEvent {
|
|
|
185
173
|
message: string;
|
|
186
174
|
type: EventType.RunError;
|
|
187
175
|
}
|
|
188
|
-
export interface IInterrupt<T extends InterruptReason, P extends Record<string, unknown>> {
|
|
189
|
-
id: string;
|
|
190
|
-
reason: T;
|
|
191
|
-
message?: string;
|
|
192
|
-
toolCallId?: string;
|
|
193
|
-
responseSchema?: JSONSchema4;
|
|
194
|
-
expiresAt?: string;
|
|
195
|
-
metadata?: P;
|
|
196
|
-
}
|
|
197
|
-
export type IApprovalInterrupt = IInterrupt<InterruptReason.AIDevToolApproval, {
|
|
198
|
-
ticket: {
|
|
199
|
-
approvers: string[];
|
|
200
|
-
sn: string;
|
|
201
|
-
status: ApprovalInterruptTicketStatus;
|
|
202
|
-
submit_time: string;
|
|
203
|
-
title: string;
|
|
204
|
-
url: string;
|
|
205
|
-
};
|
|
206
|
-
}>;
|
|
207
|
-
export type IUserQuestionInterrupt = IInterrupt<InterruptReason.UserQuestion, {
|
|
208
|
-
questions: {
|
|
209
|
-
header: string;
|
|
210
|
-
multiSelect?: boolean;
|
|
211
|
-
options?: {
|
|
212
|
-
description: string;
|
|
213
|
-
label: string;
|
|
214
|
-
}[];
|
|
215
|
-
question: string;
|
|
216
|
-
}[];
|
|
217
|
-
}>;
|
|
218
|
-
export interface IResume {
|
|
219
|
-
interruptId: string;
|
|
220
|
-
status: ResumeStatus;
|
|
221
|
-
payload: {
|
|
222
|
-
answers: {
|
|
223
|
-
answer: {
|
|
224
|
-
description: string;
|
|
225
|
-
label: string;
|
|
226
|
-
}[];
|
|
227
|
-
multiSelect?: boolean;
|
|
228
|
-
question: string;
|
|
229
|
-
}[];
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
export type IRunFinishedOutcome = {
|
|
233
|
-
type: RunFinishedOutcomeType.Success;
|
|
234
|
-
} | {
|
|
235
|
-
type: RunFinishedOutcomeType.Interrupt;
|
|
236
|
-
interrupts: Array<IApprovalInterrupt | IUserQuestionInterrupt>;
|
|
237
|
-
};
|
|
238
176
|
/**
|
|
239
177
|
* 标记 Agent 运行正常结束
|
|
240
178
|
* 返回最终结果 result
|
|
241
179
|
*/
|
|
242
180
|
export interface IRunFinishedEvent extends IBaseEvent {
|
|
243
|
-
result?:
|
|
181
|
+
result?: unknown;
|
|
244
182
|
runId: number;
|
|
245
183
|
threadId: string;
|
|
246
184
|
type: EventType.RunFinished;
|
|
247
|
-
outcome?: IRunFinishedOutcome;
|
|
248
185
|
}
|
|
249
186
|
/**
|
|
250
187
|
* 标记一次完整的 Agent 执行开始
|
|
@@ -297,7 +234,6 @@ export interface ITempMessageCustomValue {
|
|
|
297
234
|
message: string;
|
|
298
235
|
status: MessageStatus;
|
|
299
236
|
}
|
|
300
|
-
export type IApprovalResultCustomValue = IRunFinishedEvent;
|
|
301
237
|
export interface ITextMessageChunkEvent extends IBaseEvent {
|
|
302
238
|
delta?: string;
|
|
303
239
|
messageId: string;
|
|
@@ -371,6 +307,7 @@ export interface IToolCallEndEvent extends IBaseEvent {
|
|
|
371
307
|
export interface IToolCallResultEvent extends IBaseEvent {
|
|
372
308
|
content: string;
|
|
373
309
|
duration?: number;
|
|
310
|
+
isError?: boolean;
|
|
374
311
|
messageId: string;
|
|
375
312
|
toolCallId: string;
|
|
376
313
|
type: EventType.ToolCallResult;
|
package/dist/event/type.ts.js
CHANGED
|
@@ -27,14 +27,12 @@
|
|
|
27
27
|
CustomEventName["FlowAgentEnd"] = "flow_agent_end";
|
|
28
28
|
CustomEventName["FlowAgentResult"] = "flow_agent_result";
|
|
29
29
|
CustomEventName["FlowAgentStart"] = "flow_agent_start";
|
|
30
|
-
CustomEventName["FlowAgentUpdate"] = "flow_agent_update";
|
|
31
30
|
CustomEventName["KnowledgeRagEnd"] = "knowledge_rag_end";
|
|
32
31
|
CustomEventName["KnowledgeRagResult"] = "knowledge_rag_result";
|
|
33
32
|
CustomEventName["KnowledgeRagStart"] = "knowledge_rag_start";
|
|
34
33
|
CustomEventName["KnowledgeRagTextContent"] = "knowledge_rag_text_content";
|
|
35
34
|
CustomEventName["ReferenceDocument"] = "reference_document";
|
|
36
35
|
CustomEventName["TempMessage"] = "temp_message";
|
|
37
|
-
CustomEventName["ApprovalResult"] = "approval_result";
|
|
38
36
|
})(CustomEventName || (CustomEventName = {}));
|
|
39
37
|
export var EventType;
|
|
40
38
|
(function(EventType) {
|
|
@@ -67,48 +65,23 @@ export var EventType;
|
|
|
67
65
|
})(EventType || (EventType = {}));
|
|
68
66
|
export var FlowNodeState;
|
|
69
67
|
(function(FlowNodeState) {
|
|
70
|
-
FlowNodeState["Failed"] = "failed";
|
|
71
|
-
FlowNodeState["Running"] = "running";
|
|
72
|
-
FlowNodeState["Success"] = "success";
|
|
73
|
-
FlowNodeState["Suspended"] = "suspended";
|
|
68
|
+
/** 失败 */ FlowNodeState["Failed"] = "failed";
|
|
69
|
+
/** 执行中 */ FlowNodeState["Running"] = "running";
|
|
70
|
+
/** 成功 */ FlowNodeState["Success"] = "success";
|
|
71
|
+
/** 挂起 */ FlowNodeState["Suspended"] = "suspended";
|
|
74
72
|
})(FlowNodeState || (FlowNodeState = {}));
|
|
75
73
|
export var FlowTaskState;
|
|
76
74
|
(function(FlowTaskState) {
|
|
77
|
-
FlowTaskState["Blocked"] = "BLOCKED";
|
|
78
|
-
FlowTaskState["Created"] = "CREATED";
|
|
79
|
-
FlowTaskState["Failed"] = "FAILED";
|
|
80
|
-
FlowTaskState["Finished"] = "FINISHED";
|
|
81
|
-
FlowTaskState["LoopReady"] = "LOOP_READY";
|
|
82
|
-
FlowTaskState["Ready"] = "READY";
|
|
83
|
-
FlowTaskState["Revoked"] = "REVOKED";
|
|
84
|
-
FlowTaskState["RollBackFailed"] = "ROLL_BACK_FAILED";
|
|
85
|
-
FlowTaskState["RollBackSuccess"] = "ROLL_BACK_SUCCESS";
|
|
86
|
-
FlowTaskState["RollingBack"] = "ROLLING_BACK";
|
|
87
|
-
FlowTaskState["Running"] = "RUNNING";
|
|
88
|
-
FlowTaskState["Suspended"] = "SUSPENDED";
|
|
75
|
+
/** 执行中 */ FlowTaskState["Blocked"] = "BLOCKED";
|
|
76
|
+
/** 执行中 */ FlowTaskState["Created"] = "CREATED";
|
|
77
|
+
/** 失败 */ FlowTaskState["Failed"] = "FAILED";
|
|
78
|
+
/** 成功 */ FlowTaskState["Finished"] = "FINISHED";
|
|
79
|
+
/** 执行中 */ FlowTaskState["LoopReady"] = "LOOP_READY";
|
|
80
|
+
/** 执行中 */ FlowTaskState["Ready"] = "READY";
|
|
81
|
+
/** 失败 */ FlowTaskState["Revoked"] = "REVOKED";
|
|
82
|
+
/** 失败 */ FlowTaskState["RollBackFailed"] = "ROLL_BACK_FAILED";
|
|
83
|
+
/** 执行中 */ FlowTaskState["RollBackSuccess"] = "ROLL_BACK_SUCCESS";
|
|
84
|
+
/** 执行中 */ FlowTaskState["RollingBack"] = "ROLLING_BACK";
|
|
85
|
+
/** 执行中 */ FlowTaskState["Running"] = "RUNNING";
|
|
86
|
+
/** 挂起 */ FlowTaskState["Suspended"] = "SUSPENDED";
|
|
89
87
|
})(FlowTaskState || (FlowTaskState = {}));
|
|
90
|
-
export var RunFinishedOutcomeType;
|
|
91
|
-
(function(RunFinishedOutcomeType) {
|
|
92
|
-
RunFinishedOutcomeType["Success"] = "success";
|
|
93
|
-
RunFinishedOutcomeType["Interrupt"] = "interrupt";
|
|
94
|
-
})(RunFinishedOutcomeType || (RunFinishedOutcomeType = {}));
|
|
95
|
-
export var ApprovalInterruptTicketStatus;
|
|
96
|
-
(function(ApprovalInterruptTicketStatus) {
|
|
97
|
-
ApprovalInterruptTicketStatus["Abandoned"] = "abandoned";
|
|
98
|
-
ApprovalInterruptTicketStatus["Approved"] = "approved";
|
|
99
|
-
ApprovalInterruptTicketStatus["Cancelled"] = "cancelled";
|
|
100
|
-
ApprovalInterruptTicketStatus["Draft"] = "draft";
|
|
101
|
-
ApprovalInterruptTicketStatus["Expired"] = "expired";
|
|
102
|
-
ApprovalInterruptTicketStatus["Rejected"] = "rejected";
|
|
103
|
-
ApprovalInterruptTicketStatus["Pending"] = "pending";
|
|
104
|
-
})(ApprovalInterruptTicketStatus || (ApprovalInterruptTicketStatus = {}));
|
|
105
|
-
export var InterruptReason;
|
|
106
|
-
(function(InterruptReason) {
|
|
107
|
-
InterruptReason["AIDevToolApproval"] = "aidev:tool_approval";
|
|
108
|
-
InterruptReason["UserQuestion"] = "aidev:user_question";
|
|
109
|
-
})(InterruptReason || (InterruptReason = {}));
|
|
110
|
-
export var ResumeStatus;
|
|
111
|
-
(function(ResumeStatus) {
|
|
112
|
-
ResumeStatus["Resolved"] = "resolved";
|
|
113
|
-
ResumeStatus["Cancelled"] = "cancelled";
|
|
114
|
-
})(ResumeStatus || (ResumeStatus = {}));
|
package/dist/http/index.d.ts
CHANGED
|
@@ -31,21 +31,17 @@ export declare const useHttp: (options: IUseChatHelperOptions) => {
|
|
|
31
31
|
uploadFile: (sessionCode: string, file: File, config?: import("./fetch").IRequestConfig) => Promise<{
|
|
32
32
|
download_url?: string;
|
|
33
33
|
}>;
|
|
34
|
-
isResumeSession: (sessionCode: string, config?: import("./fetch").IRequestConfig) => Promise<boolean>;
|
|
35
34
|
};
|
|
36
35
|
message: {
|
|
37
36
|
getMessages: (sessionCode: string, limit?: number, config?: import("./fetch").IRequestConfig) => Promise<import("..").IMessage[]>;
|
|
38
|
-
plusMessage: (data: import("..").IMessage, config?: import("./fetch").IRequestConfig) => Promise<import("..").IActivityMessage | import("..").IAssistantMessage | import("..").IDeveloperMessage | import("..").
|
|
39
|
-
modifyMessage: (data: import("..").IMessage, config?: import("./fetch").IRequestConfig) => Promise<import("..").IActivityMessage | import("..").IAssistantMessage | import("..").IDeveloperMessage | import("..").
|
|
37
|
+
plusMessage: (data: import("..").IMessage, config?: import("./fetch").IRequestConfig) => Promise<import("..").IActivityMessage | import("..").IAssistantMessage | import("..").IDeveloperMessage | import("..").IGuideMessage | import("..").IHiddenAssistantMessage | import("..").IHiddenGuideMessage | import("..").IHiddenMessage | import("..").IHiddenSystemMessage | import("..").IHiddenUserMessage | import("..").IInfoMessage | import("..").IPauseMessage | import("..").IPlaceholderMessage | import("..").IReasoningMessage | import("..").ISystemMessage | import("..").ITemplateAssistantMessage | import("..").ITemplateGuideMessage | import("..").ITemplateHiddenMessage | import("..").ITemplateSystemMessage | import("..").ITemplateUserMessage | import("..").IToolMessage | import("..").IUserMessage>;
|
|
38
|
+
modifyMessage: (data: import("..").IMessage, config?: import("./fetch").IRequestConfig) => Promise<import("..").IActivityMessage | import("..").IAssistantMessage | import("..").IDeveloperMessage | import("..").IGuideMessage | import("..").IHiddenAssistantMessage | import("..").IHiddenGuideMessage | import("..").IHiddenMessage | import("..").IHiddenSystemMessage | import("..").IHiddenUserMessage | import("..").IInfoMessage | import("..").IPauseMessage | import("..").IPlaceholderMessage | import("..").IReasoningMessage | import("..").ISystemMessage | import("..").ITemplateAssistantMessage | import("..").ITemplateGuideMessage | import("..").ITemplateHiddenMessage | import("..").ITemplateSystemMessage | import("..").ITemplateUserMessage | import("..").IToolMessage | import("..").IUserMessage>;
|
|
40
39
|
deleteMessage: (id: string, config?: import("./fetch").IRequestConfig) => Promise<import("..").IMessage>;
|
|
41
40
|
batchDeleteMessages: (ids: string[], config?: import("./fetch").IRequestConfig) => Promise<number>;
|
|
42
41
|
shareMessages: (sessionCode: string, contentIds: string[], expiredAt?: number, config?: import("./fetch").IRequestConfig) => Promise<import("./module/message").IShareMessagesResponse>;
|
|
43
42
|
stopChat: (sessionCode: string, config?: import("./fetch").IRequestConfig) => Promise<void>;
|
|
44
43
|
getFlowAgentTaskInfo: (taskId: number, config?: import("./fetch").IRequestConfig) => Promise<unknown>;
|
|
45
44
|
getFlowAgentTaskNodeInfo: (taskId: number, nodeId: string, config?: import("./fetch").IRequestConfig) => Promise<import("..").IFlowAgentTaskNodeInfo>;
|
|
46
|
-
retryFlowAgentTaskNode: (sessionCode: string, nodeId: string, taskId: number, config?: import("./fetch").IRequestConfig) => Promise<void>;
|
|
47
|
-
skipFlowAgentTaskNode: (sessionCode: string, nodeId: string, taskId: number, config?: import("./fetch").IRequestConfig) => Promise<void>;
|
|
48
|
-
userOperation: (sessionCode: string, operation: import("..").UserOperation, payload: import("..").IUserOperationPayload, config?: import("./fetch").IRequestConfig) => Promise<void>;
|
|
49
45
|
};
|
|
50
46
|
fetchClient: import("./fetch").FetchClient;
|
|
51
47
|
};
|
|
@@ -28,21 +28,17 @@ export declare const useModule: (fetchClient: FetchClient) => {
|
|
|
28
28
|
uploadFile: (sessionCode: string, file: File, config?: import("../fetch").IRequestConfig) => Promise<{
|
|
29
29
|
download_url?: string;
|
|
30
30
|
}>;
|
|
31
|
-
isResumeSession: (sessionCode: string, config?: import("../fetch").IRequestConfig) => Promise<boolean>;
|
|
32
31
|
};
|
|
33
32
|
message: {
|
|
34
33
|
getMessages: (sessionCode: string, limit?: number, config?: import("../fetch").IRequestConfig) => Promise<import("../..").IMessage[]>;
|
|
35
|
-
plusMessage: (data: import("../..").IMessage, config?: import("../fetch").IRequestConfig) => Promise<import("../..").IActivityMessage | import("../..").IAssistantMessage | import("../..").IDeveloperMessage | import("../..").
|
|
36
|
-
modifyMessage: (data: import("../..").IMessage, config?: import("../fetch").IRequestConfig) => Promise<import("../..").IActivityMessage | import("../..").IAssistantMessage | import("../..").IDeveloperMessage | import("../..").
|
|
34
|
+
plusMessage: (data: import("../..").IMessage, config?: import("../fetch").IRequestConfig) => Promise<import("../..").IActivityMessage | import("../..").IAssistantMessage | import("../..").IDeveloperMessage | import("../..").IGuideMessage | import("../..").IHiddenAssistantMessage | import("../..").IHiddenGuideMessage | import("../..").IHiddenMessage | import("../..").IHiddenSystemMessage | import("../..").IHiddenUserMessage | import("../..").IInfoMessage | import("../..").IPauseMessage | import("../..").IPlaceholderMessage | import("../..").IReasoningMessage | import("../..").ISystemMessage | import("../..").ITemplateAssistantMessage | import("../..").ITemplateGuideMessage | import("../..").ITemplateHiddenMessage | import("../..").ITemplateSystemMessage | import("../..").ITemplateUserMessage | import("../..").IToolMessage | import("../..").IUserMessage>;
|
|
35
|
+
modifyMessage: (data: import("../..").IMessage, config?: import("../fetch").IRequestConfig) => Promise<import("../..").IActivityMessage | import("../..").IAssistantMessage | import("../..").IDeveloperMessage | import("../..").IGuideMessage | import("../..").IHiddenAssistantMessage | import("../..").IHiddenGuideMessage | import("../..").IHiddenMessage | import("../..").IHiddenSystemMessage | import("../..").IHiddenUserMessage | import("../..").IInfoMessage | import("../..").IPauseMessage | import("../..").IPlaceholderMessage | import("../..").IReasoningMessage | import("../..").ISystemMessage | import("../..").ITemplateAssistantMessage | import("../..").ITemplateGuideMessage | import("../..").ITemplateHiddenMessage | import("../..").ITemplateSystemMessage | import("../..").ITemplateUserMessage | import("../..").IToolMessage | import("../..").IUserMessage>;
|
|
37
36
|
deleteMessage: (id: string, config?: import("../fetch").IRequestConfig) => Promise<import("../..").IMessage>;
|
|
38
37
|
batchDeleteMessages: (ids: string[], config?: import("../fetch").IRequestConfig) => Promise<number>;
|
|
39
38
|
shareMessages: (sessionCode: string, contentIds: string[], expiredAt?: number, config?: import("../fetch").IRequestConfig) => Promise<import("./message").IShareMessagesResponse>;
|
|
40
39
|
stopChat: (sessionCode: string, config?: import("../fetch").IRequestConfig) => Promise<void>;
|
|
41
40
|
getFlowAgentTaskInfo: (taskId: number, config?: import("../fetch").IRequestConfig) => Promise<unknown>;
|
|
42
41
|
getFlowAgentTaskNodeInfo: (taskId: number, nodeId: string, config?: import("../fetch").IRequestConfig) => Promise<import("../..").IFlowAgentTaskNodeInfo>;
|
|
43
|
-
retryFlowAgentTaskNode: (sessionCode: string, nodeId: string, taskId: number, config?: import("../fetch").IRequestConfig) => Promise<void>;
|
|
44
|
-
skipFlowAgentTaskNode: (sessionCode: string, nodeId: string, taskId: number, config?: import("../fetch").IRequestConfig) => Promise<void>;
|
|
45
|
-
userOperation: (sessionCode: string, operation: import("../..").UserOperation, payload: import("../..").IUserOperationPayload, config?: import("../fetch").IRequestConfig) => Promise<void>;
|
|
46
42
|
};
|
|
47
43
|
fetchClient: FetchClient;
|
|
48
44
|
};
|