@blueking/chat-helper 0.0.12-beta.2 → 0.0.12-beta.20
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 +21 -7
- package/dist/agent/type.d.ts +69 -0
- package/dist/agent/type.ts.js +1 -1
- package/dist/agent/use-agent.d.ts +1440 -8
- package/dist/agent/use-agent.ts.js +452 -30
- package/dist/event/ag-ui.d.ts +17 -2
- package/dist/event/ag-ui.ts.js +112 -6
- package/dist/event/type.d.ts +103 -26
- package/dist/event/type.ts.js +46 -16
- package/dist/http/fetch/fetch.ts.js +104 -24
- package/dist/http/index.d.ts +15 -4
- package/dist/http/module/agent.d.ts +2 -0
- package/dist/http/module/agent.ts.js +19 -2
- package/dist/http/module/index.d.ts +15 -4
- package/dist/http/module/message.d.ts +7 -4
- package/dist/http/module/message.ts.js +22 -4
- package/dist/http/module/session.d.ts +9 -2
- package/dist/http/module/session.ts.js +55 -3
- package/dist/http/transform/agent.d.ts +9 -1
- package/dist/http/transform/agent.ts.js +27 -0
- package/dist/http/transform/message.ts.js +14 -0
- package/dist/index.d.ts +9665 -33
- package/dist/message/type.d.ts +43 -7
- package/dist/message/type.ts.js +10 -0
- package/dist/message/use-message.d.ts +2732 -4
- package/dist/session/type.d.ts +33 -0
- package/dist/session/use-session.d.ts +5474 -11
- package/dist/session/use-session.ts.js +77 -8
- package/package.json +4 -1
package/dist/event/ag-ui.ts.js
CHANGED
|
@@ -35,9 +35,8 @@
|
|
|
35
35
|
}
|
|
36
36
|
return obj;
|
|
37
37
|
}
|
|
38
|
-
import { transferMessageApi2Message } from '../http/transform/index.ts.js';
|
|
39
38
|
import { ActivityType, MessageRole, MessageStatus, MessageType } from '../message/index.ts.js';
|
|
40
|
-
import { CustomEventName, EventType, FlowTaskState } from './type.ts.js';
|
|
39
|
+
import { CustomEventName, EventType, FlowTaskState, RunFinishedOutcomeType } from './type.ts.js';
|
|
41
40
|
/**
|
|
42
41
|
* AGUI 协议
|
|
43
42
|
* @param message - 消息模块
|
|
@@ -49,11 +48,39 @@ import { CustomEventName, EventType, FlowTaskState } from './type.ts.js';
|
|
|
49
48
|
/**
|
|
50
49
|
* 处理活动快照事件
|
|
51
50
|
* 记录活动的完整状态
|
|
52
|
-
*/ handleActivitySnapshotEvent(
|
|
51
|
+
*/ handleActivitySnapshotEvent(event) {
|
|
52
|
+
if (event.activityType === ActivityType.Info) {
|
|
53
|
+
const message = this.messageModule.getMessageByMessageId(event.messageId);
|
|
54
|
+
if ((message === null || message === void 0 ? void 0 : message.role) === MessageRole.Info) {
|
|
55
|
+
message.content = event.content;
|
|
56
|
+
}
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (event.activityType === ActivityType.Interrupt) {
|
|
60
|
+
const message = this.messageModule.getCurrentLoadingMessage();
|
|
61
|
+
if ((message === null || message === void 0 ? void 0 : message.role) === MessageRole.Interrupt) {
|
|
62
|
+
message.content = event.content;
|
|
63
|
+
message.status = MessageStatus.Complete;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
handleArtifactsGeneratedCustomEvent(event) {
|
|
68
|
+
const message = this.messageModule.list.value.findLast((item)=>item.role === MessageRole.Assistant);
|
|
69
|
+
if (message) {
|
|
70
|
+
var _message;
|
|
71
|
+
const value = event.value;
|
|
72
|
+
var _property;
|
|
73
|
+
(_property = (_message = message).property) !== null && _property !== void 0 ? _property : _message.property = {};
|
|
74
|
+
message.property.artifacts = value.artifacts;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
53
77
|
/**
|
|
54
78
|
* 处理自定义事件
|
|
55
79
|
*/ handleCustomEvent(event) {
|
|
56
80
|
switch(event.name){
|
|
81
|
+
case CustomEventName.ArtifactsGenerated:
|
|
82
|
+
this.handleArtifactsGeneratedCustomEvent(event);
|
|
83
|
+
break;
|
|
57
84
|
case CustomEventName.FlowAgentStart:
|
|
58
85
|
this.handleFlowAgentStartCustomEvent(event);
|
|
59
86
|
break;
|
|
@@ -63,6 +90,9 @@ import { CustomEventName, EventType, FlowTaskState } from './type.ts.js';
|
|
|
63
90
|
case CustomEventName.FlowAgentEnd:
|
|
64
91
|
this.handleFlowAgentEndCustomEvent(event);
|
|
65
92
|
break;
|
|
93
|
+
case CustomEventName.FlowAgentRestart:
|
|
94
|
+
this.handleFlowAgentRestartCustomEvent(event);
|
|
95
|
+
break;
|
|
66
96
|
case CustomEventName.ReferenceDocument:
|
|
67
97
|
this.handleReferenceDocumentCustomEvent(event);
|
|
68
98
|
break;
|
|
@@ -81,6 +111,15 @@ import { CustomEventName, EventType, FlowTaskState } from './type.ts.js';
|
|
|
81
111
|
case CustomEventName.TempMessage:
|
|
82
112
|
this.handleTempMessageCustomEvent(event);
|
|
83
113
|
break;
|
|
114
|
+
case CustomEventName.ApprovalResult:
|
|
115
|
+
this.handleApprovalResultCustomEvent(event);
|
|
116
|
+
break;
|
|
117
|
+
case CustomEventName.FlowAgentUpdate:
|
|
118
|
+
this.handleFlowAgentUpdateCustomEvent(event);
|
|
119
|
+
break;
|
|
120
|
+
case CustomEventName.Info:
|
|
121
|
+
this.handleInfoCustomEvent(event);
|
|
122
|
+
break;
|
|
84
123
|
default:
|
|
85
124
|
break;
|
|
86
125
|
}
|
|
@@ -102,6 +141,20 @@ import { CustomEventName, EventType, FlowTaskState } from './type.ts.js';
|
|
|
102
141
|
}
|
|
103
142
|
}
|
|
104
143
|
/**
|
|
144
|
+
* 自定义事件 处理流程编排任务重启
|
|
145
|
+
*/ handleFlowAgentRestartCustomEvent(event) {
|
|
146
|
+
const value = event.value;
|
|
147
|
+
this.messageModule.list.value.forEach((item)=>{
|
|
148
|
+
if (item.role === MessageRole.Activity && item.activityType === ActivityType.FlowAgent) {
|
|
149
|
+
const isSameTask = item.content[0].task_id === value[0].task_id;
|
|
150
|
+
// 通过第一个 task_id 判断是否是同一个任务,是的话直接更新消息状态为 streaming
|
|
151
|
+
if (isSameTask) {
|
|
152
|
+
item.status = MessageStatus.Streaming;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
105
158
|
* 自定义事件 处理流程编排任务结果(增量更新节点状态)
|
|
106
159
|
*/ handleFlowAgentResultCustomEvent(event) {
|
|
107
160
|
const message = this.messageModule.getCurrentLoadingMessage();
|
|
@@ -118,7 +171,7 @@ import { CustomEventName, EventType, FlowTaskState } from './type.ts.js';
|
|
|
118
171
|
activityType: ActivityType.FlowAgent,
|
|
119
172
|
content: value.map((item)=>({
|
|
120
173
|
nodes: {},
|
|
121
|
-
task_id:
|
|
174
|
+
task_id: item.task_id,
|
|
122
175
|
task_name: '',
|
|
123
176
|
task_outputs: [],
|
|
124
177
|
task_state: FlowTaskState.Created
|
|
@@ -127,6 +180,29 @@ import { CustomEventName, EventType, FlowTaskState } from './type.ts.js';
|
|
|
127
180
|
});
|
|
128
181
|
}
|
|
129
182
|
/**
|
|
183
|
+
* 自定义事件 处理流程编排任务更新
|
|
184
|
+
*/ handleFlowAgentUpdateCustomEvent(event) {
|
|
185
|
+
const value = event.value;
|
|
186
|
+
this.messageModule.list.value.forEach((item)=>{
|
|
187
|
+
if (item.role === MessageRole.Activity && item.activityType === ActivityType.FlowAgent) {
|
|
188
|
+
const isSameTask = item.content[0].task_id === value[0].task_id;
|
|
189
|
+
// 通过第一个 task_id 判断是否是同一个任务,是的话直接更新消息内容
|
|
190
|
+
if (isSameTask) {
|
|
191
|
+
item.content = value;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
handleInfoCustomEvent(event) {
|
|
197
|
+
const value = event.value;
|
|
198
|
+
this.messageModule.plusMessage({
|
|
199
|
+
role: MessageRole.Info,
|
|
200
|
+
messageId: value.messageId,
|
|
201
|
+
content: value.content,
|
|
202
|
+
status: MessageStatus.Complete
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
130
206
|
* 自定义事件 处理意图识别结束
|
|
131
207
|
*/ handleKnowledgeRagEndCustomEvent(_event) {
|
|
132
208
|
const message = this.messageModule.getCurrentLoadingMessage();
|
|
@@ -169,7 +245,7 @@ import { CustomEventName, EventType, FlowTaskState } from './type.ts.js';
|
|
|
169
245
|
* 用于同步多端消息状态
|
|
170
246
|
*/ handleMessagesSnapshotEvent(event) {
|
|
171
247
|
if (event.messages && event.messages.length > 0) {
|
|
172
|
-
this.messageModule.list.value = event.messages
|
|
248
|
+
this.messageModule.list.value = event.messages;
|
|
173
249
|
}
|
|
174
250
|
}
|
|
175
251
|
/**
|
|
@@ -206,11 +282,24 @@ import { CustomEventName, EventType, FlowTaskState } from './type.ts.js';
|
|
|
206
282
|
}
|
|
207
283
|
/**
|
|
208
284
|
* 处理运行完成事件
|
|
209
|
-
*/ handleRunFinishedEvent(
|
|
285
|
+
*/ handleRunFinishedEvent(event) {
|
|
286
|
+
var _event_outcome, _event_outcome1;
|
|
210
287
|
const message = this.messageModule.getCurrentLoadingMessage();
|
|
211
288
|
if (message) {
|
|
212
289
|
message.status = MessageStatus.Complete;
|
|
213
290
|
}
|
|
291
|
+
// 如果是中断消息,则创建一个中断消息
|
|
292
|
+
if (((_event_outcome = event.outcome) === null || _event_outcome === void 0 ? void 0 : _event_outcome.type) === RunFinishedOutcomeType.Interrupt) {
|
|
293
|
+
this.messageModule.plusMessage({
|
|
294
|
+
role: MessageRole.Interrupt,
|
|
295
|
+
content: event,
|
|
296
|
+
status: MessageStatus.Pending
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
// 二次返回,直接更新消息内容
|
|
300
|
+
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) {
|
|
301
|
+
message.content = event;
|
|
302
|
+
}
|
|
214
303
|
}
|
|
215
304
|
/**
|
|
216
305
|
* 处理运行开始事件
|
|
@@ -249,6 +338,16 @@ import { CustomEventName, EventType, FlowTaskState } from './type.ts.js';
|
|
|
249
338
|
});
|
|
250
339
|
}
|
|
251
340
|
/**
|
|
341
|
+
* 自定义事件 处理审批结果
|
|
342
|
+
*/ handleApprovalResultCustomEvent(event) {
|
|
343
|
+
const value = event.value;
|
|
344
|
+
const message = this.messageModule.getCurrentLoadingMessage();
|
|
345
|
+
if (message) {
|
|
346
|
+
message.content = value;
|
|
347
|
+
message.status = MessageStatus.Complete;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
252
351
|
* 处理文本消息块事件
|
|
253
352
|
*/ handleTextMessageChunkEvent(event) {
|
|
254
353
|
const message = this.messageModule.getCurrentLoadingMessage();
|
|
@@ -281,7 +380,14 @@ import { CustomEventName, EventType, FlowTaskState } from './type.ts.js';
|
|
|
281
380
|
}
|
|
282
381
|
/**
|
|
283
382
|
* 处理文本消息开始事件
|
|
383
|
+
* 断线续传时会重放缓存事件:同 messageId 已存在则重置内容,避免重复气泡/文本翻倍
|
|
284
384
|
*/ handleTextMessageStartEvent(event) {
|
|
385
|
+
const existing = this.messageModule.getMessageByMessageId(event.messageId);
|
|
386
|
+
if (existing) {
|
|
387
|
+
existing.content = '';
|
|
388
|
+
existing.status = MessageStatus.Streaming;
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
285
391
|
this.messageModule.plusMessage({
|
|
286
392
|
role: event.role,
|
|
287
393
|
content: '',
|
package/dist/event/type.d.ts
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type IMessage, type IMessageArtifact, type MessageRole, type MessageStatus } from '../message/type';
|
|
2
|
+
import type { JSONSchema4 } from 'json-schema';
|
|
2
3
|
export declare enum CustomEventName {
|
|
4
|
+
ArtifactsGenerated = "artifacts_generated",
|
|
3
5
|
FlowAgentEnd = "flow_agent_end",
|
|
4
6
|
FlowAgentResult = "flow_agent_result",
|
|
5
7
|
FlowAgentStart = "flow_agent_start",
|
|
8
|
+
FlowAgentUpdate = "flow_agent_update",
|
|
9
|
+
FlowAgentRestart = "flow_agent_restart",
|
|
10
|
+
Info = "info",
|
|
6
11
|
KnowledgeRagEnd = "knowledge_rag_end",
|
|
7
12
|
KnowledgeRagResult = "knowledge_rag_result",
|
|
8
13
|
KnowledgeRagStart = "knowledge_rag_start",
|
|
9
14
|
KnowledgeRagTextContent = "knowledge_rag_text_content",
|
|
10
15
|
ReferenceDocument = "reference_document",
|
|
11
|
-
TempMessage = "temp_message"
|
|
16
|
+
TempMessage = "temp_message",
|
|
17
|
+
ApprovalResult = "approval_result"
|
|
12
18
|
}
|
|
13
19
|
export declare enum EventType {
|
|
14
20
|
ActivityDelta = "ACTIVITY_DELTA",
|
|
@@ -40,42 +46,51 @@ export declare enum EventType {
|
|
|
40
46
|
}
|
|
41
47
|
/** BKFlow 收敛后的节点状态 - task.node 的状态枚举 */
|
|
42
48
|
export declare enum FlowNodeState {
|
|
43
|
-
/** 失败 */
|
|
44
49
|
Failed = "failed",
|
|
45
|
-
/** 执行中 */
|
|
46
50
|
Running = "running",
|
|
47
|
-
/** 成功 */
|
|
48
51
|
Success = "success",
|
|
49
|
-
/** 挂起 */
|
|
50
52
|
Suspended = "suspended"
|
|
51
53
|
}
|
|
52
54
|
/** BKFLOW 原始状态 - task 的状态枚举 */
|
|
53
55
|
export declare enum FlowTaskState {
|
|
54
|
-
/** 执行中 */
|
|
55
56
|
Blocked = "BLOCKED",
|
|
56
|
-
/** 执行中 */
|
|
57
57
|
Created = "CREATED",
|
|
58
|
-
/** 失败 */
|
|
59
58
|
Failed = "FAILED",
|
|
60
|
-
/** 成功 */
|
|
61
59
|
Finished = "FINISHED",
|
|
62
|
-
/** 执行中 */
|
|
63
60
|
LoopReady = "LOOP_READY",
|
|
64
|
-
/** 执行中 */
|
|
65
61
|
Ready = "READY",
|
|
66
|
-
/** 失败 */
|
|
67
62
|
Revoked = "REVOKED",
|
|
68
|
-
/** 失败 */
|
|
69
63
|
RollBackFailed = "ROLL_BACK_FAILED",
|
|
70
|
-
/** 执行中 */
|
|
71
64
|
RollBackSuccess = "ROLL_BACK_SUCCESS",
|
|
72
|
-
/** 执行中 */
|
|
73
65
|
RollingBack = "ROLLING_BACK",
|
|
74
|
-
/** 执行中 */
|
|
75
66
|
Running = "RUNNING",
|
|
76
|
-
/** 挂起 */
|
|
77
67
|
Suspended = "SUSPENDED"
|
|
78
68
|
}
|
|
69
|
+
/** 运行完成结果 */
|
|
70
|
+
export declare enum RunFinishedOutcomeType {
|
|
71
|
+
Success = "success",
|
|
72
|
+
Interrupt = "interrupt"
|
|
73
|
+
}
|
|
74
|
+
/** 审批状态 */
|
|
75
|
+
export declare enum ApprovalInterruptTicketStatus {
|
|
76
|
+
Abandoned = "abandoned",
|
|
77
|
+
Approved = "approved",
|
|
78
|
+
Cancelled = "cancelled",
|
|
79
|
+
Draft = "draft",
|
|
80
|
+
Expired = "expired",
|
|
81
|
+
Rejected = "rejected",
|
|
82
|
+
Pending = "pending"
|
|
83
|
+
}
|
|
84
|
+
/** 中断原因 */
|
|
85
|
+
export declare enum InterruptReason {
|
|
86
|
+
AIDevToolApproval = "aidev:tool_approval",
|
|
87
|
+
UserQuestion = "aidev:user_question"
|
|
88
|
+
}
|
|
89
|
+
/** 恢复状态 */
|
|
90
|
+
export declare enum ResumeStatus {
|
|
91
|
+
Resolved = "resolved",
|
|
92
|
+
Cancelled = "cancelled"
|
|
93
|
+
}
|
|
79
94
|
/**
|
|
80
95
|
* Activity 代表 Agent 执行过程中的活动/动作/任务,可能包含结构化数据
|
|
81
96
|
* 活动状态的增量更新
|
|
@@ -101,6 +116,11 @@ export interface IActivitySnapshotEvent extends IBaseEvent {
|
|
|
101
116
|
replace?: boolean;
|
|
102
117
|
type: EventType.ActivitySnapshot;
|
|
103
118
|
}
|
|
119
|
+
export interface IArtifactsGeneratedCustomValue {
|
|
120
|
+
artifacts: IMessageArtifact[];
|
|
121
|
+
runId: string;
|
|
122
|
+
status: 'complete' | 'empty';
|
|
123
|
+
}
|
|
104
124
|
export interface IBaseEvent {
|
|
105
125
|
timestamp?: number;
|
|
106
126
|
type: EventType;
|
|
@@ -112,25 +132,25 @@ export interface IBaseEvent {
|
|
|
112
132
|
export interface ICustomEvent extends IBaseEvent {
|
|
113
133
|
name: CustomEventName;
|
|
114
134
|
type: EventType.Custom;
|
|
115
|
-
value: IFlowAgentEndCustomValue | IFlowAgentResultCustomValue | IFlowAgentStartCustomValue | IKnowledgeRagResultCustomValue | IKnowledgeRagTextContentCustomValue | IReferenceDocumentCustomValue | ITempMessageCustomValue;
|
|
135
|
+
value: IArtifactsGeneratedCustomValue | IFlowAgentEndCustomValue | IFlowAgentResultCustomValue | IFlowAgentStartCustomValue | IFlowAgentRestartCustomValue | IInfoCustomValue | IKnowledgeRagResultCustomValue | IKnowledgeRagTextContentCustomValue | IReferenceDocumentCustomValue | ITempMessageCustomValue | IApprovalResultCustomValue;
|
|
116
136
|
}
|
|
117
137
|
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;
|
|
118
138
|
export type IFlowAgentEndCustomValue = {
|
|
119
139
|
task_outputs: string[];
|
|
120
140
|
}[];
|
|
121
141
|
export interface IFlowAgentNode {
|
|
122
|
-
/** 耗时(s) */
|
|
123
142
|
elapsed_time: number;
|
|
124
|
-
/** 节点id */
|
|
125
143
|
id: string;
|
|
126
|
-
/** 节点名称 */
|
|
127
144
|
name: string;
|
|
128
|
-
/** 节点状态 */
|
|
129
145
|
state: FlowNodeState;
|
|
146
|
+
retry: number;
|
|
147
|
+
skip: boolean;
|
|
148
|
+
retryable: boolean;
|
|
149
|
+
skippable: boolean;
|
|
130
150
|
}
|
|
131
151
|
export type IFlowAgentResultCustomValue = {
|
|
132
152
|
nodes: Record<string, IFlowAgentNode>;
|
|
133
|
-
task_id:
|
|
153
|
+
task_id: string;
|
|
134
154
|
task_name: string;
|
|
135
155
|
task_outputs: string[];
|
|
136
156
|
task_state: FlowTaskState;
|
|
@@ -138,6 +158,11 @@ export type IFlowAgentResultCustomValue = {
|
|
|
138
158
|
export type IFlowAgentStartCustomValue = {
|
|
139
159
|
task_id: string;
|
|
140
160
|
}[];
|
|
161
|
+
export type IFlowAgentRestartCustomValue = IFlowAgentStartCustomValue;
|
|
162
|
+
export interface IInfoCustomValue {
|
|
163
|
+
content: string;
|
|
164
|
+
messageId: string;
|
|
165
|
+
}
|
|
141
166
|
export type IKnowledgeRagResultCustomValue = IReferenceDocumentCustomValue;
|
|
142
167
|
export interface IKnowledgeRagTextContentCustomValue {
|
|
143
168
|
cover: boolean;
|
|
@@ -151,7 +176,7 @@ export interface IKnowledgeRagTextContentCustomValue {
|
|
|
151
176
|
* 同步多端消息状态
|
|
152
177
|
*/
|
|
153
178
|
export interface IMessagesSnapshotEvent extends IBaseEvent {
|
|
154
|
-
messages:
|
|
179
|
+
messages: IMessage[];
|
|
155
180
|
type: EventType.MessagesSnapshot;
|
|
156
181
|
}
|
|
157
182
|
/**
|
|
@@ -173,15 +198,66 @@ export interface IRunErrorEvent extends IBaseEvent {
|
|
|
173
198
|
message: string;
|
|
174
199
|
type: EventType.RunError;
|
|
175
200
|
}
|
|
201
|
+
export interface IInterrupt<T extends InterruptReason, P extends Record<string, unknown>> {
|
|
202
|
+
id: string;
|
|
203
|
+
reason: T;
|
|
204
|
+
message?: string;
|
|
205
|
+
toolCallId?: string;
|
|
206
|
+
responseSchema?: JSONSchema4;
|
|
207
|
+
expiresAt?: string;
|
|
208
|
+
metadata?: P;
|
|
209
|
+
}
|
|
210
|
+
export type IApprovalInterrupt = IInterrupt<InterruptReason.AIDevToolApproval, {
|
|
211
|
+
ticket: {
|
|
212
|
+
approvers: string[];
|
|
213
|
+
sn: string;
|
|
214
|
+
status: ApprovalInterruptTicketStatus;
|
|
215
|
+
submit_time: string;
|
|
216
|
+
title: string;
|
|
217
|
+
url: string;
|
|
218
|
+
};
|
|
219
|
+
}>;
|
|
220
|
+
export type IUserQuestionInterrupt = IInterrupt<InterruptReason.UserQuestion, {
|
|
221
|
+
questions: {
|
|
222
|
+
header: string;
|
|
223
|
+
multiSelect?: boolean;
|
|
224
|
+
options?: {
|
|
225
|
+
description: string;
|
|
226
|
+
label: string;
|
|
227
|
+
}[];
|
|
228
|
+
question: string;
|
|
229
|
+
}[];
|
|
230
|
+
}>;
|
|
231
|
+
export interface IResume {
|
|
232
|
+
interruptId: string;
|
|
233
|
+
status: ResumeStatus;
|
|
234
|
+
payload?: {
|
|
235
|
+
answers: {
|
|
236
|
+
answer: {
|
|
237
|
+
description: string;
|
|
238
|
+
label: string;
|
|
239
|
+
}[];
|
|
240
|
+
multiSelect?: boolean;
|
|
241
|
+
question: string;
|
|
242
|
+
}[];
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
export type IRunFinishedOutcome = {
|
|
246
|
+
type: RunFinishedOutcomeType.Success;
|
|
247
|
+
} | {
|
|
248
|
+
type: RunFinishedOutcomeType.Interrupt;
|
|
249
|
+
interrupts: Array<IApprovalInterrupt | IUserQuestionInterrupt>;
|
|
250
|
+
};
|
|
176
251
|
/**
|
|
177
252
|
* 标记 Agent 运行正常结束
|
|
178
253
|
* 返回最终结果 result
|
|
179
254
|
*/
|
|
180
255
|
export interface IRunFinishedEvent extends IBaseEvent {
|
|
181
|
-
result?:
|
|
256
|
+
result?: IResume;
|
|
182
257
|
runId: number;
|
|
183
258
|
threadId: string;
|
|
184
259
|
type: EventType.RunFinished;
|
|
260
|
+
outcome?: IRunFinishedOutcome;
|
|
185
261
|
}
|
|
186
262
|
/**
|
|
187
263
|
* 标记一次完整的 Agent 执行开始
|
|
@@ -234,6 +310,7 @@ export interface ITempMessageCustomValue {
|
|
|
234
310
|
message: string;
|
|
235
311
|
status: MessageStatus;
|
|
236
312
|
}
|
|
313
|
+
export type IApprovalResultCustomValue = IRunFinishedEvent;
|
|
237
314
|
export interface ITextMessageChunkEvent extends IBaseEvent {
|
|
238
315
|
delta?: string;
|
|
239
316
|
messageId: string;
|
package/dist/event/type.ts.js
CHANGED
|
@@ -24,15 +24,20 @@
|
|
|
24
24
|
* IN THE SOFTWARE.
|
|
25
25
|
*/ export var CustomEventName;
|
|
26
26
|
(function(CustomEventName) {
|
|
27
|
+
CustomEventName["ArtifactsGenerated"] = "artifacts_generated";
|
|
27
28
|
CustomEventName["FlowAgentEnd"] = "flow_agent_end";
|
|
28
29
|
CustomEventName["FlowAgentResult"] = "flow_agent_result";
|
|
29
30
|
CustomEventName["FlowAgentStart"] = "flow_agent_start";
|
|
31
|
+
CustomEventName["FlowAgentUpdate"] = "flow_agent_update";
|
|
32
|
+
CustomEventName["FlowAgentRestart"] = "flow_agent_restart";
|
|
33
|
+
CustomEventName["Info"] = "info";
|
|
30
34
|
CustomEventName["KnowledgeRagEnd"] = "knowledge_rag_end";
|
|
31
35
|
CustomEventName["KnowledgeRagResult"] = "knowledge_rag_result";
|
|
32
36
|
CustomEventName["KnowledgeRagStart"] = "knowledge_rag_start";
|
|
33
37
|
CustomEventName["KnowledgeRagTextContent"] = "knowledge_rag_text_content";
|
|
34
38
|
CustomEventName["ReferenceDocument"] = "reference_document";
|
|
35
39
|
CustomEventName["TempMessage"] = "temp_message";
|
|
40
|
+
CustomEventName["ApprovalResult"] = "approval_result";
|
|
36
41
|
})(CustomEventName || (CustomEventName = {}));
|
|
37
42
|
export var EventType;
|
|
38
43
|
(function(EventType) {
|
|
@@ -65,23 +70,48 @@ export var EventType;
|
|
|
65
70
|
})(EventType || (EventType = {}));
|
|
66
71
|
export var FlowNodeState;
|
|
67
72
|
(function(FlowNodeState) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
73
|
+
FlowNodeState["Failed"] = "failed";
|
|
74
|
+
FlowNodeState["Running"] = "running";
|
|
75
|
+
FlowNodeState["Success"] = "success";
|
|
76
|
+
FlowNodeState["Suspended"] = "suspended";
|
|
72
77
|
})(FlowNodeState || (FlowNodeState = {}));
|
|
73
78
|
export var FlowTaskState;
|
|
74
79
|
(function(FlowTaskState) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
80
|
+
FlowTaskState["Blocked"] = "BLOCKED";
|
|
81
|
+
FlowTaskState["Created"] = "CREATED";
|
|
82
|
+
FlowTaskState["Failed"] = "FAILED";
|
|
83
|
+
FlowTaskState["Finished"] = "FINISHED";
|
|
84
|
+
FlowTaskState["LoopReady"] = "LOOP_READY";
|
|
85
|
+
FlowTaskState["Ready"] = "READY";
|
|
86
|
+
FlowTaskState["Revoked"] = "REVOKED";
|
|
87
|
+
FlowTaskState["RollBackFailed"] = "ROLL_BACK_FAILED";
|
|
88
|
+
FlowTaskState["RollBackSuccess"] = "ROLL_BACK_SUCCESS";
|
|
89
|
+
FlowTaskState["RollingBack"] = "ROLLING_BACK";
|
|
90
|
+
FlowTaskState["Running"] = "RUNNING";
|
|
91
|
+
FlowTaskState["Suspended"] = "SUSPENDED";
|
|
87
92
|
})(FlowTaskState || (FlowTaskState = {}));
|
|
93
|
+
export var RunFinishedOutcomeType;
|
|
94
|
+
(function(RunFinishedOutcomeType) {
|
|
95
|
+
RunFinishedOutcomeType["Success"] = "success";
|
|
96
|
+
RunFinishedOutcomeType["Interrupt"] = "interrupt";
|
|
97
|
+
})(RunFinishedOutcomeType || (RunFinishedOutcomeType = {}));
|
|
98
|
+
export var ApprovalInterruptTicketStatus;
|
|
99
|
+
(function(ApprovalInterruptTicketStatus) {
|
|
100
|
+
ApprovalInterruptTicketStatus["Abandoned"] = "abandoned";
|
|
101
|
+
ApprovalInterruptTicketStatus["Approved"] = "approved";
|
|
102
|
+
ApprovalInterruptTicketStatus["Cancelled"] = "cancelled";
|
|
103
|
+
ApprovalInterruptTicketStatus["Draft"] = "draft";
|
|
104
|
+
ApprovalInterruptTicketStatus["Expired"] = "expired";
|
|
105
|
+
ApprovalInterruptTicketStatus["Rejected"] = "rejected";
|
|
106
|
+
ApprovalInterruptTicketStatus["Pending"] = "pending";
|
|
107
|
+
})(ApprovalInterruptTicketStatus || (ApprovalInterruptTicketStatus = {}));
|
|
108
|
+
export var InterruptReason;
|
|
109
|
+
(function(InterruptReason) {
|
|
110
|
+
InterruptReason["AIDevToolApproval"] = "aidev:tool_approval";
|
|
111
|
+
InterruptReason["UserQuestion"] = "aidev:user_question";
|
|
112
|
+
})(InterruptReason || (InterruptReason = {}));
|
|
113
|
+
export var ResumeStatus;
|
|
114
|
+
(function(ResumeStatus) {
|
|
115
|
+
ResumeStatus["Resolved"] = "resolved";
|
|
116
|
+
ResumeStatus["Cancelled"] = "cancelled";
|
|
117
|
+
})(ResumeStatus || (ResumeStatus = {}));
|