@blueking/chat-helper 0.0.12-beta.12 → 0.0.12-beta.13
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 +2 -8
- package/dist/agent/type.d.ts +0 -69
- package/dist/agent/type.ts.js +1 -1
- package/dist/agent/use-agent.d.ts +7 -165
- package/dist/agent/use-agent.ts.js +11 -50
- package/dist/event/ag-ui.d.ts +0 -2
- package/dist/event/ag-ui.ts.js +3 -35
- package/dist/event/type.d.ts +2 -13
- package/dist/event/type.ts.js +0 -2
- package/dist/http/index.d.ts +0 -2
- package/dist/http/module/agent.d.ts +0 -2
- package/dist/http/module/agent.ts.js +2 -19
- package/dist/http/module/index.d.ts +0 -2
- package/dist/http/module/message.ts.js +2 -2
- package/dist/http/module/session.d.ts +1 -2
- package/dist/http/module/session.ts.js +0 -19
- package/dist/http/transform/agent.d.ts +1 -9
- package/dist/http/transform/agent.ts.js +0 -27
- package/dist/http/transform/message.d.ts +0 -6
- package/dist/http/transform/message.ts.js +0 -56
- package/dist/index.d.ts +6 -791
- package/dist/message/type.d.ts +3 -18
- package/dist/message/type.ts.js +0 -2
- package/dist/message/use-message.d.ts +0 -208
- package/dist/session/type.d.ts +0 -14
- package/dist/session/use-session.d.ts +1 -418
- package/dist/session/use-session.ts.js +0 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1885,19 +1885,13 @@ A: 使用 `agent.chat` 的 `url` 和 `config` 参数:
|
|
|
1885
1885
|
// 使用不同的端点
|
|
1886
1886
|
agent.chat(userInput, sessionCode, 'custom_chat/');
|
|
1887
1887
|
|
|
1888
|
-
//
|
|
1888
|
+
// 添加自定义参数
|
|
1889
1889
|
agent.chat(userInput, sessionCode, undefined, {
|
|
1890
1890
|
data: {
|
|
1891
1891
|
temperature: 0.8,
|
|
1892
|
+
model: 'gpt-4',
|
|
1892
1893
|
},
|
|
1893
1894
|
});
|
|
1894
|
-
|
|
1895
|
-
// 模型热切换:传入第 6 个参数 model(值为 llm_code,需在 GET llms/ 列表内)
|
|
1896
|
-
agent.chat(userInput, sessionCode, undefined, undefined, property, 'hy3-preview');
|
|
1897
|
-
|
|
1898
|
-
// 拉取可用模型列表
|
|
1899
|
-
const llmList = await agent.getLlms({ llm_type: 'chat.completion' });
|
|
1900
|
-
// agent.models 同步更新
|
|
1901
1895
|
```
|
|
1902
1896
|
|
|
1903
1897
|
### Q: 消息列表如何实现自动滚动到底部?
|
package/dist/agent/type.d.ts
CHANGED
|
@@ -126,72 +126,3 @@ export interface IAgentResources {
|
|
|
126
126
|
mcp?: IAgentResourceItem[];
|
|
127
127
|
tool?: IAgentResourceItem[];
|
|
128
128
|
}
|
|
129
|
-
/** 模型能力属性(后端 property 字段) */
|
|
130
|
-
export interface ILlmProperty {
|
|
131
|
-
agent_type?: string;
|
|
132
|
-
default?: boolean;
|
|
133
|
-
is_self_host?: boolean;
|
|
134
|
-
max_model_len?: number;
|
|
135
|
-
support_summary?: boolean;
|
|
136
|
-
support_thinking?: boolean;
|
|
137
|
-
support_thinking_quick?: boolean;
|
|
138
|
-
support_tools?: boolean;
|
|
139
|
-
support_vision?: boolean;
|
|
140
|
-
support_window?: boolean;
|
|
141
|
-
}
|
|
142
|
-
/** 可用模型列表查询参数 */
|
|
143
|
-
export interface ILlmListQuery {
|
|
144
|
-
/** 模糊搜索关键词,按 llm_name / description / base_model 匹配 */
|
|
145
|
-
fuzzy?: string;
|
|
146
|
-
/** 模型类型,不传时默认 chat.completion */
|
|
147
|
-
llm_type?: string;
|
|
148
|
-
/** 按模型支持的功能过滤,逗号分隔,如 tool_call,vision */
|
|
149
|
-
supports?: string;
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* 可用模型项(对齐 plugin_api/llms/ 与 chat-x IModelOption)
|
|
153
|
-
* 字段以 snake_case 与后端保持一致,便于直接透传给 ModelSelector
|
|
154
|
-
*/
|
|
155
|
-
export interface ILlmItem {
|
|
156
|
-
/** 基础模型标识,如 hunyuan */
|
|
157
|
-
base_model?: string;
|
|
158
|
-
/** 模型描述 */
|
|
159
|
-
description?: string;
|
|
160
|
-
/** 是否禁用(前端扩展字段) */
|
|
161
|
-
disabled?: boolean;
|
|
162
|
-
/** 模型图标地址 */
|
|
163
|
-
icon?: string;
|
|
164
|
-
/** 模型主键 id */
|
|
165
|
-
id: number;
|
|
166
|
-
/** 模型编码(chat_completion 热切换传此值) */
|
|
167
|
-
llm_code: string;
|
|
168
|
-
/** 模型展示名(ModelSelector v-model 选中值) */
|
|
169
|
-
llm_name: string;
|
|
170
|
-
/** 模型类型,如 chat.completion */
|
|
171
|
-
llm_type: string;
|
|
172
|
-
/** 最大 token 数 */
|
|
173
|
-
max_token_size: number;
|
|
174
|
-
/** 模型能力属性 */
|
|
175
|
-
property: ILlmProperty;
|
|
176
|
-
/** 空间维度鉴权模式 */
|
|
177
|
-
space_auth_mode: string;
|
|
178
|
-
/** 标签名列表 */
|
|
179
|
-
tag_names?: string[];
|
|
180
|
-
/** 用户维度鉴权模式 */
|
|
181
|
-
user_auth_mode: string;
|
|
182
|
-
}
|
|
183
|
-
/** 后端 llms/ 原始响应项(字段可能缺省) */
|
|
184
|
-
export interface ILlmItemApi {
|
|
185
|
-
base_model?: string;
|
|
186
|
-
description?: string;
|
|
187
|
-
icon?: string;
|
|
188
|
-
id?: number;
|
|
189
|
-
llm_code: string;
|
|
190
|
-
llm_name: string;
|
|
191
|
-
llm_type?: string;
|
|
192
|
-
max_token_size?: number;
|
|
193
|
-
property?: ILlmProperty | null;
|
|
194
|
-
space_auth_mode?: string;
|
|
195
|
-
tag_names?: string[];
|
|
196
|
-
user_auth_mode?: string;
|
|
197
|
-
}
|
package/dist/agent/type.ts.js
CHANGED
|
@@ -22,4 +22,4 @@
|
|
|
22
22
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
23
23
|
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
24
24
|
* IN THE SOFTWARE.
|
|
25
|
-
*/ /**
|
|
25
|
+
*/ /** @deprecated 后端已改为扁平列表 IAgentResourceItem[],不再使用分组结构 */ export { };
|
|
@@ -3,7 +3,7 @@ import { MessageRole, MessageStatus, UserOperation } from '../message';
|
|
|
3
3
|
import type { IRequestConfig, ISSEProtocol } from '../http';
|
|
4
4
|
import type { IMediatorModule } from '../mediator';
|
|
5
5
|
import type { IMessageProperty, IUserMessage, IUserOperationPayload } from '../message/type';
|
|
6
|
-
import type { IAgentInfo
|
|
6
|
+
import type { IAgentInfo } from './type';
|
|
7
7
|
/**
|
|
8
8
|
* Agent 模块
|
|
9
9
|
* @param options - 配置选项
|
|
@@ -70,17 +70,6 @@ export declare const useAgent: (mediator: IMediatorModule, protocol: ISSEProtoco
|
|
|
70
70
|
content?: ({
|
|
71
71
|
activityType: import("../message").ActivityType;
|
|
72
72
|
content: {
|
|
73
|
-
artifacts: {
|
|
74
|
-
name: string;
|
|
75
|
-
outputId: string;
|
|
76
|
-
size: number;
|
|
77
|
-
type: string;
|
|
78
|
-
previewUrl?: string;
|
|
79
|
-
url?: string;
|
|
80
|
-
}[];
|
|
81
|
-
runId: string;
|
|
82
|
-
status: "complete" | "empty";
|
|
83
|
-
} | {
|
|
84
73
|
nodes: Record<string, import("../event").IFlowAgentNode>;
|
|
85
74
|
task_id: string;
|
|
86
75
|
task_name: string;
|
|
@@ -98,31 +87,6 @@ export declare const useAgent: (mediator: IMediatorModule, protocol: ISSEProtoco
|
|
|
98
87
|
originFileUrl?: string;
|
|
99
88
|
url: string;
|
|
100
89
|
}[];
|
|
101
|
-
property?: {
|
|
102
|
-
[x: string]: unknown;
|
|
103
|
-
artifacts?: {
|
|
104
|
-
name: string;
|
|
105
|
-
outputId: string;
|
|
106
|
-
size: number;
|
|
107
|
-
type: string;
|
|
108
|
-
previewUrl?: string;
|
|
109
|
-
url?: string;
|
|
110
|
-
}[];
|
|
111
|
-
extra?: {
|
|
112
|
-
[x: string]: unknown;
|
|
113
|
-
cite?: string | {
|
|
114
|
-
data: {
|
|
115
|
-
key: string;
|
|
116
|
-
value: string;
|
|
117
|
-
}[];
|
|
118
|
-
title: string;
|
|
119
|
-
type: string;
|
|
120
|
-
};
|
|
121
|
-
command?: string;
|
|
122
|
-
context?: Array<Record<string, unknown>>;
|
|
123
|
-
resources?: Array<Record<string, unknown>>;
|
|
124
|
-
};
|
|
125
|
-
};
|
|
126
90
|
role: MessageRole.Activity;
|
|
127
91
|
id?: string;
|
|
128
92
|
messageId?: string;
|
|
@@ -133,14 +97,6 @@ export declare const useAgent: (mediator: IMediatorModule, protocol: ISSEProtoco
|
|
|
133
97
|
content?: string;
|
|
134
98
|
property?: {
|
|
135
99
|
[x: string]: unknown;
|
|
136
|
-
artifacts?: {
|
|
137
|
-
name: string;
|
|
138
|
-
outputId: string;
|
|
139
|
-
size: number;
|
|
140
|
-
type: string;
|
|
141
|
-
previewUrl?: string;
|
|
142
|
-
url?: string;
|
|
143
|
-
}[];
|
|
144
100
|
extra?: {
|
|
145
101
|
[x: string]: unknown;
|
|
146
102
|
cite?: string | {
|
|
@@ -964,14 +920,6 @@ export declare const useAgent: (mediator: IMediatorModule, protocol: ISSEProtoco
|
|
|
964
920
|
})[];
|
|
965
921
|
property?: {
|
|
966
922
|
[x: string]: unknown;
|
|
967
|
-
artifacts?: {
|
|
968
|
-
name: string;
|
|
969
|
-
outputId: string;
|
|
970
|
-
size: number;
|
|
971
|
-
type: string;
|
|
972
|
-
previewUrl?: string;
|
|
973
|
-
url?: string;
|
|
974
|
-
}[];
|
|
975
923
|
extra?: {
|
|
976
924
|
[x: string]: unknown;
|
|
977
925
|
cite?: string | {
|
|
@@ -1058,17 +1006,6 @@ export declare const useAgent: (mediator: IMediatorModule, protocol: ISSEProtoco
|
|
|
1058
1006
|
content?: ({
|
|
1059
1007
|
activityType: import("../message").ActivityType;
|
|
1060
1008
|
content: {
|
|
1061
|
-
artifacts: {
|
|
1062
|
-
name: string;
|
|
1063
|
-
outputId: string;
|
|
1064
|
-
size: number;
|
|
1065
|
-
type: string;
|
|
1066
|
-
previewUrl?: string;
|
|
1067
|
-
url?: string;
|
|
1068
|
-
}[];
|
|
1069
|
-
runId: string;
|
|
1070
|
-
status: "complete" | "empty";
|
|
1071
|
-
} | {
|
|
1072
1009
|
nodes: Record<string, import("../event").IFlowAgentNode>;
|
|
1073
1010
|
task_id: string;
|
|
1074
1011
|
task_name: string;
|
|
@@ -1086,31 +1023,6 @@ export declare const useAgent: (mediator: IMediatorModule, protocol: ISSEProtoco
|
|
|
1086
1023
|
originFileUrl?: string;
|
|
1087
1024
|
url: string;
|
|
1088
1025
|
}[];
|
|
1089
|
-
property?: {
|
|
1090
|
-
[x: string]: unknown;
|
|
1091
|
-
artifacts?: {
|
|
1092
|
-
name: string;
|
|
1093
|
-
outputId: string;
|
|
1094
|
-
size: number;
|
|
1095
|
-
type: string;
|
|
1096
|
-
previewUrl?: string;
|
|
1097
|
-
url?: string;
|
|
1098
|
-
}[];
|
|
1099
|
-
extra?: {
|
|
1100
|
-
[x: string]: unknown;
|
|
1101
|
-
cite?: string | {
|
|
1102
|
-
data: {
|
|
1103
|
-
key: string;
|
|
1104
|
-
value: string;
|
|
1105
|
-
}[];
|
|
1106
|
-
title: string;
|
|
1107
|
-
type: string;
|
|
1108
|
-
};
|
|
1109
|
-
command?: string;
|
|
1110
|
-
context?: Array<Record<string, unknown>>;
|
|
1111
|
-
resources?: Array<Record<string, unknown>>;
|
|
1112
|
-
};
|
|
1113
|
-
};
|
|
1114
1026
|
role: MessageRole.Activity;
|
|
1115
1027
|
id?: string;
|
|
1116
1028
|
messageId?: string;
|
|
@@ -1121,14 +1033,6 @@ export declare const useAgent: (mediator: IMediatorModule, protocol: ISSEProtoco
|
|
|
1121
1033
|
content?: string;
|
|
1122
1034
|
property?: {
|
|
1123
1035
|
[x: string]: unknown;
|
|
1124
|
-
artifacts?: {
|
|
1125
|
-
name: string;
|
|
1126
|
-
outputId: string;
|
|
1127
|
-
size: number;
|
|
1128
|
-
type: string;
|
|
1129
|
-
previewUrl?: string;
|
|
1130
|
-
url?: string;
|
|
1131
|
-
}[];
|
|
1132
1036
|
extra?: {
|
|
1133
1037
|
[x: string]: unknown;
|
|
1134
1038
|
cite?: string | {
|
|
@@ -1952,14 +1856,6 @@ export declare const useAgent: (mediator: IMediatorModule, protocol: ISSEProtoco
|
|
|
1952
1856
|
})[];
|
|
1953
1857
|
property?: {
|
|
1954
1858
|
[x: string]: unknown;
|
|
1955
|
-
artifacts?: {
|
|
1956
|
-
name: string;
|
|
1957
|
-
outputId: string;
|
|
1958
|
-
size: number;
|
|
1959
|
-
type: string;
|
|
1960
|
-
previewUrl?: string;
|
|
1961
|
-
url?: string;
|
|
1962
|
-
}[];
|
|
1963
1859
|
extra?: {
|
|
1964
1860
|
[x: string]: unknown;
|
|
1965
1861
|
cite?: string | {
|
|
@@ -1989,73 +1885,19 @@ export declare const useAgent: (mediator: IMediatorModule, protocol: ISSEProtoco
|
|
|
1989
1885
|
}>;
|
|
1990
1886
|
isInfoLoading: import("vue").Ref<boolean, boolean>;
|
|
1991
1887
|
isChatting: import("vue").Ref<boolean, boolean>;
|
|
1992
|
-
|
|
1993
|
-
base_model?: string;
|
|
1994
|
-
description?: string;
|
|
1995
|
-
disabled?: boolean;
|
|
1996
|
-
icon?: string;
|
|
1997
|
-
id: number;
|
|
1998
|
-
llm_code: string;
|
|
1999
|
-
llm_name: string;
|
|
2000
|
-
llm_type: string;
|
|
2001
|
-
max_token_size: number;
|
|
2002
|
-
property: {
|
|
2003
|
-
agent_type?: string;
|
|
2004
|
-
default?: boolean;
|
|
2005
|
-
is_self_host?: boolean;
|
|
2006
|
-
max_model_len?: number;
|
|
2007
|
-
support_summary?: boolean;
|
|
2008
|
-
support_thinking?: boolean;
|
|
2009
|
-
support_thinking_quick?: boolean;
|
|
2010
|
-
support_tools?: boolean;
|
|
2011
|
-
support_vision?: boolean;
|
|
2012
|
-
support_window?: boolean;
|
|
2013
|
-
};
|
|
2014
|
-
space_auth_mode: string;
|
|
2015
|
-
tag_names?: string[];
|
|
2016
|
-
user_auth_mode: string;
|
|
2017
|
-
}[], ILlmItem[] | {
|
|
2018
|
-
base_model?: string;
|
|
2019
|
-
description?: string;
|
|
2020
|
-
disabled?: boolean;
|
|
2021
|
-
icon?: string;
|
|
2022
|
-
id: number;
|
|
2023
|
-
llm_code: string;
|
|
2024
|
-
llm_name: string;
|
|
2025
|
-
llm_type: string;
|
|
2026
|
-
max_token_size: number;
|
|
2027
|
-
property: {
|
|
2028
|
-
agent_type?: string;
|
|
2029
|
-
default?: boolean;
|
|
2030
|
-
is_self_host?: boolean;
|
|
2031
|
-
max_model_len?: number;
|
|
2032
|
-
support_summary?: boolean;
|
|
2033
|
-
support_thinking?: boolean;
|
|
2034
|
-
support_thinking_quick?: boolean;
|
|
2035
|
-
support_tools?: boolean;
|
|
2036
|
-
support_vision?: boolean;
|
|
2037
|
-
support_window?: boolean;
|
|
2038
|
-
};
|
|
2039
|
-
space_auth_mode: string;
|
|
2040
|
-
tag_names?: string[];
|
|
2041
|
-
user_auth_mode: string;
|
|
2042
|
-
}[]>;
|
|
2043
|
-
isModelsLoading: import("vue").Ref<boolean, boolean>;
|
|
2044
|
-
chat: (userInput: IUserMessage["content"], sessionCode: string, url?: string, config?: IRequestConfig, property?: IMessageProperty, model?: string) => Promise<void>;
|
|
1888
|
+
chat: (userInput: IUserMessage["content"], sessionCode: string, url?: string, config?: IRequestConfig, property?: IMessageProperty) => Promise<void>;
|
|
2045
1889
|
handleRole: (data: IAgentInfo, sessionCode: string) => void;
|
|
2046
|
-
resendMessage: (messageId: string, sessionCode: string, newContent?: IUserMessage["content"], url?: string, config?: IRequestConfig
|
|
2047
|
-
resumeStreamingChat: (sessionCode: string, url?: string, config?: IRequestConfig
|
|
1890
|
+
resendMessage: (messageId: string, sessionCode: string, newContent?: IUserMessage["content"], url?: string, config?: IRequestConfig) => Promise<void>;
|
|
1891
|
+
resumeStreamingChat: (sessionCode: string, url?: string, config?: IRequestConfig) => void;
|
|
2048
1892
|
abortChat: () => void;
|
|
2049
1893
|
stopChat: (sessionCode: string) => Promise<void>;
|
|
2050
1894
|
getAgentInfo: () => Promise<void>;
|
|
2051
|
-
getLlms: (params?: ILlmListQuery, config?: IRequestConfig) => Promise<ILlmItem[]>;
|
|
2052
1895
|
reset: (protocol: ISSEProtocol) => void;
|
|
2053
|
-
pollResumeSession: (sessionCode: string
|
|
1896
|
+
pollResumeSession: (sessionCode: string) => void;
|
|
2054
1897
|
clearLongPollTimer: () => void;
|
|
2055
|
-
userOperationStreamRequest: (sessionCode: string, operation: UserOperation, payload: IUserOperationPayload, config?: IRequestConfig
|
|
2056
|
-
streamRequest: ({ sessionCode,
|
|
1898
|
+
userOperationStreamRequest: (sessionCode: string, operation: UserOperation, payload: IUserOperationPayload, config?: IRequestConfig) => Promise<void>;
|
|
1899
|
+
streamRequest: ({ sessionCode, url, config, resume, input, lastMessageId, isReconnect, }: {
|
|
2057
1900
|
sessionCode: string;
|
|
2058
|
-
model?: string;
|
|
2059
1901
|
url?: string;
|
|
2060
1902
|
config?: IRequestConfig;
|
|
2061
1903
|
resume?: IResume;
|
|
@@ -120,8 +120,6 @@ const getReconnectDelayMs = (attempt)=>Math.min(RECONNECT_BASE_DELAY_MS * Math.p
|
|
|
120
120
|
const info = ref(null);
|
|
121
121
|
const isInfoLoading = ref(false);
|
|
122
122
|
const isChatting = ref(false);
|
|
123
|
-
const models = ref([]);
|
|
124
|
-
const isModelsLoading = ref(false);
|
|
125
123
|
let usedProtocol = protocol || new AGUIProtocol();
|
|
126
124
|
let chatAbortController = null;
|
|
127
125
|
let resumeAbortController = null;
|
|
@@ -132,27 +130,6 @@ const getReconnectDelayMs = (attempt)=>Math.min(RECONNECT_BASE_DELAY_MS * Math.p
|
|
|
132
130
|
let reconnectTimer = null;
|
|
133
131
|
let reconnectWaitResolve = null;
|
|
134
132
|
let activeStreamContext = null;
|
|
135
|
-
/**
|
|
136
|
-
* 获取可用模型列表,写入 models;失败时清空列表并抛出
|
|
137
|
-
*/ const getLlms = (params, config)=>{
|
|
138
|
-
var _mediator_http;
|
|
139
|
-
isModelsLoading.value = true;
|
|
140
|
-
const request = (_mediator_http = mediator.http) === null || _mediator_http === void 0 ? void 0 : _mediator_http.agent.getLlms(params, config);
|
|
141
|
-
if (!request) {
|
|
142
|
-
isModelsLoading.value = false;
|
|
143
|
-
models.value = [];
|
|
144
|
-
return Promise.resolve([]);
|
|
145
|
-
}
|
|
146
|
-
return request.then((res)=>{
|
|
147
|
-
models.value = res;
|
|
148
|
-
return res;
|
|
149
|
-
})['catch']((error)=>{
|
|
150
|
-
models.value = [];
|
|
151
|
-
throw error;
|
|
152
|
-
})['finally'](()=>{
|
|
153
|
-
isModelsLoading.value = false;
|
|
154
|
-
});
|
|
155
|
-
};
|
|
156
133
|
const getAgentInfo = ()=>{
|
|
157
134
|
var _mediator_http;
|
|
158
135
|
isInfoLoading.value = true;
|
|
@@ -181,18 +158,17 @@ const getReconnectDelayMs = (attempt)=>Math.min(RECONNECT_BASE_DELAY_MS * Math.p
|
|
|
181
158
|
});
|
|
182
159
|
}
|
|
183
160
|
};
|
|
184
|
-
const userOperationStreamRequest = (sessionCode, operation, payload, config
|
|
161
|
+
const userOperationStreamRequest = (sessionCode, operation, payload, config)=>{
|
|
185
162
|
var _mediator_http;
|
|
186
163
|
return (_mediator_http = mediator.http) === null || _mediator_http === void 0 ? void 0 : _mediator_http.message.userOperation(sessionCode, operation, payload, config).then(()=>{
|
|
187
164
|
if (operation !== UserOperation.ApprovalCancel) {
|
|
188
165
|
streamRequest({
|
|
189
166
|
sessionCode,
|
|
190
|
-
config
|
|
191
|
-
model
|
|
167
|
+
config
|
|
192
168
|
});
|
|
193
169
|
} else {
|
|
194
170
|
clearLongPollTimer();
|
|
195
|
-
pollResumeSession(sessionCode
|
|
171
|
+
pollResumeSession(sessionCode);
|
|
196
172
|
}
|
|
197
173
|
});
|
|
198
174
|
};
|
|
@@ -283,7 +259,6 @@ const getReconnectDelayMs = (attempt)=>Math.min(RECONNECT_BASE_DELAY_MS * Math.p
|
|
|
283
259
|
const ctx = activeStreamContext;
|
|
284
260
|
streamRequest({
|
|
285
261
|
sessionCode,
|
|
286
|
-
model: ctx === null || ctx === void 0 ? void 0 : ctx.model,
|
|
287
262
|
url: ctx === null || ctx === void 0 ? void 0 : ctx.url,
|
|
288
263
|
config: ctx === null || ctx === void 0 ? void 0 : ctx.config,
|
|
289
264
|
lastMessageId: lastMessageId !== undefined ? String(lastMessageId) : undefined,
|
|
@@ -296,14 +271,13 @@ const getReconnectDelayMs = (attempt)=>Math.min(RECONNECT_BASE_DELAY_MS * Math.p
|
|
|
296
271
|
};
|
|
297
272
|
}();
|
|
298
273
|
const streamRequest = function() {
|
|
299
|
-
var _ref = _async_to_generator(function*({ sessionCode,
|
|
274
|
+
var _ref = _async_to_generator(function*({ sessionCode, url, config, resume, input, lastMessageId, isReconnect = false }) {
|
|
300
275
|
var _mediator_http;
|
|
301
276
|
if (!isReconnect) {
|
|
302
277
|
resetStreamReconnectState();
|
|
303
278
|
}
|
|
304
279
|
activeStreamContext = {
|
|
305
280
|
sessionCode,
|
|
306
|
-
model: model,
|
|
307
281
|
url,
|
|
308
282
|
config
|
|
309
283
|
};
|
|
@@ -414,7 +388,6 @@ const getReconnectDelayMs = (attempt)=>Math.min(RECONNECT_BASE_DELAY_MS * Math.p
|
|
|
414
388
|
method: 'POST',
|
|
415
389
|
data: {
|
|
416
390
|
session_code: sessionCode,
|
|
417
|
-
model,
|
|
418
391
|
input,
|
|
419
392
|
execute_kwargs: {
|
|
420
393
|
stream: true,
|
|
@@ -443,9 +416,8 @@ const getReconnectDelayMs = (attempt)=>Math.min(RECONNECT_BASE_DELAY_MS * Math.p
|
|
|
443
416
|
* @param url - 请求 URL(可选)
|
|
444
417
|
* @param config - 请求配置(可选)
|
|
445
418
|
* @param property - 消息属性,用于传递引用内容或快捷键相关信息(可选)
|
|
446
|
-
* @param model - 模型标识(可选)
|
|
447
419
|
*/ const chat = function() {
|
|
448
|
-
var _ref = _async_to_generator(function*(userInput, sessionCode, url, config, property
|
|
420
|
+
var _ref = _async_to_generator(function*(userInput, sessionCode, url, config, property) {
|
|
449
421
|
var _mediator_message;
|
|
450
422
|
// 先新增一个 message
|
|
451
423
|
yield (_mediator_message = mediator.message) === null || _mediator_message === void 0 ? void 0 : _mediator_message.createAndPlusMessage(_object_spread({
|
|
@@ -459,12 +431,11 @@ const getReconnectDelayMs = (attempt)=>Math.min(RECONNECT_BASE_DELAY_MS * Math.p
|
|
|
459
431
|
// 发起聊天
|
|
460
432
|
streamRequest({
|
|
461
433
|
sessionCode,
|
|
462
|
-
model,
|
|
463
434
|
url,
|
|
464
435
|
config
|
|
465
436
|
});
|
|
466
437
|
});
|
|
467
|
-
return function chat(userInput, sessionCode, url, config, property
|
|
438
|
+
return function chat(userInput, sessionCode, url, config, property) {
|
|
468
439
|
return _ref.apply(this, arguments);
|
|
469
440
|
};
|
|
470
441
|
}();
|
|
@@ -474,15 +445,13 @@ const getReconnectDelayMs = (attempt)=>Math.min(RECONNECT_BASE_DELAY_MS * Math.p
|
|
|
474
445
|
* @param sessionCode - 会话代码
|
|
475
446
|
* @param url - 请求 URL(可选)
|
|
476
447
|
* @param config - 请求配置(可选)
|
|
477
|
-
|
|
478
|
-
*/ const resumeStreamingChat = (sessionCode, url, config, model)=>{
|
|
448
|
+
*/ const resumeStreamingChat = (sessionCode, url, config)=>{
|
|
479
449
|
var _mediator_session_current_value, _mediator_session;
|
|
480
450
|
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) {
|
|
481
451
|
var _mediator_message_list_value_at, _mediator_message;
|
|
482
452
|
const lastMessageId = (_mediator_message = mediator.message) === null || _mediator_message === void 0 ? void 0 : (_mediator_message_list_value_at = _mediator_message.list.value.at(-1)) === null || _mediator_message_list_value_at === void 0 ? void 0 : _mediator_message_list_value_at.id;
|
|
483
453
|
streamRequest({
|
|
484
454
|
sessionCode,
|
|
485
|
-
model,
|
|
486
455
|
url,
|
|
487
456
|
config,
|
|
488
457
|
lastMessageId
|
|
@@ -493,7 +462,7 @@ const getReconnectDelayMs = (attempt)=>Math.min(RECONNECT_BASE_DELAY_MS * Math.p
|
|
|
493
462
|
* 轮询接口,判断是否可以继续聊天
|
|
494
463
|
* @param sessionCode - 会话编码
|
|
495
464
|
* @returns 是否可以继续聊天
|
|
496
|
-
*/ const pollResumeSession = (sessionCode
|
|
465
|
+
*/ const pollResumeSession = (sessionCode)=>{
|
|
497
466
|
var _mediator_message, _lastMessage_content_outcome, _lastMessage_content;
|
|
498
467
|
const lastMessage = (_mediator_message = mediator.message) === null || _mediator_message === void 0 ? void 0 : _mediator_message.list.value.at(-1);
|
|
499
468
|
const pendingApprovalInterrupt = (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.content.outcome.interrupts.find((interrupt)=>{
|
|
@@ -520,7 +489,6 @@ const getReconnectDelayMs = (attempt)=>Math.min(RECONNECT_BASE_DELAY_MS * Math.p
|
|
|
520
489
|
// 可以继续聊天,重新发起聊天(携带 execute_kwargs.resume 通知后端恢复中断)
|
|
521
490
|
streamRequest({
|
|
522
491
|
sessionCode,
|
|
523
|
-
model,
|
|
524
492
|
resume: {
|
|
525
493
|
interruptId: pendingApprovalInterrupt.id,
|
|
526
494
|
status: ResumeStatus.Resolved
|
|
@@ -531,7 +499,7 @@ const getReconnectDelayMs = (attempt)=>Math.min(RECONNECT_BASE_DELAY_MS * Math.p
|
|
|
531
499
|
var _mediator_session_current_value, _mediator_session_current, _mediator_session;
|
|
532
500
|
// 如果会话不匹配,则不继续轮询
|
|
533
501
|
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;
|
|
534
|
-
pollResumeSession(sessionCode
|
|
502
|
+
pollResumeSession(sessionCode);
|
|
535
503
|
}, 10000);
|
|
536
504
|
}
|
|
537
505
|
});
|
|
@@ -574,9 +542,8 @@ const getReconnectDelayMs = (attempt)=>Math.min(RECONNECT_BASE_DELAY_MS * Math.p
|
|
|
574
542
|
* @param newContent - 新内容(可选,不传则使用原消息内容;支持多模态)
|
|
575
543
|
* @param url - 请求 URL(可选)
|
|
576
544
|
* @param config - 请求配置(可选)
|
|
577
|
-
* @param model - 模型标识(可选)
|
|
578
545
|
*/ const resendMessage = function() {
|
|
579
|
-
var _ref = _async_to_generator(function*(messageId, sessionCode, newContent, url, config
|
|
546
|
+
var _ref = _async_to_generator(function*(messageId, sessionCode, newContent, url, config) {
|
|
580
547
|
var _mediator_message, _mediator_message1, _mediator_message2;
|
|
581
548
|
const messages = ((_mediator_message = mediator.message) === null || _mediator_message === void 0 ? void 0 : _mediator_message.list.value) || [];
|
|
582
549
|
// 1. 找到目标用户消息
|
|
@@ -609,7 +576,6 @@ const getReconnectDelayMs = (attempt)=>Math.min(RECONNECT_BASE_DELAY_MS * Math.p
|
|
|
609
576
|
// 6. 立即发起流式请求(不等待删除和创建的 API 完成)
|
|
610
577
|
streamRequest({
|
|
611
578
|
sessionCode,
|
|
612
|
-
model,
|
|
613
579
|
url,
|
|
614
580
|
config
|
|
615
581
|
});
|
|
@@ -621,7 +587,7 @@ const getReconnectDelayMs = (attempt)=>Math.min(RECONNECT_BASE_DELAY_MS * Math.p
|
|
|
621
587
|
console.error('[resendMessage] API error:', error);
|
|
622
588
|
});
|
|
623
589
|
});
|
|
624
|
-
return function resendMessage(messageId, sessionCode, newContent, url, config
|
|
590
|
+
return function resendMessage(messageId, sessionCode, newContent, url, config) {
|
|
625
591
|
return _ref.apply(this, arguments);
|
|
626
592
|
};
|
|
627
593
|
}();
|
|
@@ -632,8 +598,6 @@ const getReconnectDelayMs = (attempt)=>Math.min(RECONNECT_BASE_DELAY_MS * Math.p
|
|
|
632
598
|
info.value = null;
|
|
633
599
|
isInfoLoading.value = false;
|
|
634
600
|
isChatting.value = false;
|
|
635
|
-
models.value = [];
|
|
636
|
-
isModelsLoading.value = false;
|
|
637
601
|
activeStreamContext = null;
|
|
638
602
|
reconnectAttempt = 0;
|
|
639
603
|
runFinished = false;
|
|
@@ -642,8 +606,6 @@ const getReconnectDelayMs = (attempt)=>Math.min(RECONNECT_BASE_DELAY_MS * Math.p
|
|
|
642
606
|
info,
|
|
643
607
|
isInfoLoading,
|
|
644
608
|
isChatting,
|
|
645
|
-
models,
|
|
646
|
-
isModelsLoading,
|
|
647
609
|
chat,
|
|
648
610
|
handleRole,
|
|
649
611
|
resendMessage,
|
|
@@ -651,7 +613,6 @@ const getReconnectDelayMs = (attempt)=>Math.min(RECONNECT_BASE_DELAY_MS * Math.p
|
|
|
651
613
|
abortChat,
|
|
652
614
|
stopChat,
|
|
653
615
|
getAgentInfo,
|
|
654
|
-
getLlms,
|
|
655
616
|
reset,
|
|
656
617
|
pollResumeSession,
|
|
657
618
|
clearLongPollTimer,
|
package/dist/event/ag-ui.d.ts
CHANGED
|
@@ -27,7 +27,6 @@ export declare class AGUIProtocol implements ISSEProtocol {
|
|
|
27
27
|
* 记录活动的完整状态
|
|
28
28
|
*/
|
|
29
29
|
handleActivitySnapshotEvent(event: IActivitySnapshotEvent): void;
|
|
30
|
-
handleArtifactsGeneratedCustomEvent(event: ICustomEvent): void;
|
|
31
30
|
/**
|
|
32
31
|
* 处理自定义事件
|
|
33
32
|
*/
|
|
@@ -52,7 +51,6 @@ export declare class AGUIProtocol implements ISSEProtocol {
|
|
|
52
51
|
* 自定义事件 处理流程编排任务更新
|
|
53
52
|
*/
|
|
54
53
|
handleFlowAgentUpdateCustomEvent(event: ICustomEvent): void;
|
|
55
|
-
handleInfoCustomEvent(event: ICustomEvent): void;
|
|
56
54
|
/**
|
|
57
55
|
* 自定义事件 处理意图识别结束
|
|
58
56
|
*/
|
package/dist/event/ag-ui.ts.js
CHANGED
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
}
|
|
36
36
|
return obj;
|
|
37
37
|
}
|
|
38
|
-
import {
|
|
38
|
+
import { transferMessageApi2Message } from '../http/transform/index.ts.js';
|
|
39
39
|
import { ActivityType, MessageRole, MessageStatus, MessageType } from '../message/index.ts.js';
|
|
40
40
|
import { CustomEventName, EventType, FlowTaskState, RunFinishedOutcomeType } from './type.ts.js';
|
|
41
41
|
/**
|
|
@@ -50,38 +50,18 @@ import { CustomEventName, EventType, FlowTaskState, RunFinishedOutcomeType } fro
|
|
|
50
50
|
* 处理活动快照事件
|
|
51
51
|
* 记录活动的完整状态
|
|
52
52
|
*/ handleActivitySnapshotEvent(event) {
|
|
53
|
-
|
|
54
|
-
const message = this.messageModule.getMessageByMessageId(event.messageId);
|
|
55
|
-
if ((message === null || message === void 0 ? void 0 : message.role) === MessageRole.Info) {
|
|
56
|
-
message.content = event.content;
|
|
57
|
-
}
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
53
|
+
const message = this.messageModule.getCurrentLoadingMessage();
|
|
60
54
|
if (event.activityType === ActivityType.Interrupt) {
|
|
61
|
-
const message = this.messageModule.getCurrentLoadingMessage();
|
|
62
55
|
if ((message === null || message === void 0 ? void 0 : message.role) === MessageRole.Interrupt) {
|
|
63
56
|
message.content = event.content;
|
|
64
57
|
message.status = MessageStatus.Complete;
|
|
65
58
|
}
|
|
66
59
|
}
|
|
67
60
|
}
|
|
68
|
-
handleArtifactsGeneratedCustomEvent(event) {
|
|
69
|
-
const message = this.messageModule.list.value.findLast((item)=>item.role === MessageRole.Assistant);
|
|
70
|
-
if (message) {
|
|
71
|
-
var _message;
|
|
72
|
-
const value = event.value;
|
|
73
|
-
var _property;
|
|
74
|
-
(_property = (_message = message).property) !== null && _property !== void 0 ? _property : _message.property = {};
|
|
75
|
-
message.property.artifacts = value.artifacts;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
61
|
/**
|
|
79
62
|
* 处理自定义事件
|
|
80
63
|
*/ handleCustomEvent(event) {
|
|
81
64
|
switch(event.name){
|
|
82
|
-
case CustomEventName.ArtifactsGenerated:
|
|
83
|
-
this.handleArtifactsGeneratedCustomEvent(event);
|
|
84
|
-
break;
|
|
85
65
|
case CustomEventName.FlowAgentStart:
|
|
86
66
|
this.handleFlowAgentStartCustomEvent(event);
|
|
87
67
|
break;
|
|
@@ -118,9 +98,6 @@ import { CustomEventName, EventType, FlowTaskState, RunFinishedOutcomeType } fro
|
|
|
118
98
|
case CustomEventName.FlowAgentUpdate:
|
|
119
99
|
this.handleFlowAgentUpdateCustomEvent(event);
|
|
120
100
|
break;
|
|
121
|
-
case CustomEventName.Info:
|
|
122
|
-
this.handleInfoCustomEvent(event);
|
|
123
|
-
break;
|
|
124
101
|
default:
|
|
125
102
|
break;
|
|
126
103
|
}
|
|
@@ -194,15 +171,6 @@ import { CustomEventName, EventType, FlowTaskState, RunFinishedOutcomeType } fro
|
|
|
194
171
|
}
|
|
195
172
|
});
|
|
196
173
|
}
|
|
197
|
-
handleInfoCustomEvent(event) {
|
|
198
|
-
const value = event.value;
|
|
199
|
-
this.messageModule.plusMessage({
|
|
200
|
-
role: MessageRole.Info,
|
|
201
|
-
messageId: value.messageId,
|
|
202
|
-
content: value.content,
|
|
203
|
-
status: MessageStatus.Complete
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
174
|
/**
|
|
207
175
|
* 自定义事件 处理意图识别结束
|
|
208
176
|
*/ handleKnowledgeRagEndCustomEvent(_event) {
|
|
@@ -246,7 +214,7 @@ import { CustomEventName, EventType, FlowTaskState, RunFinishedOutcomeType } fro
|
|
|
246
214
|
* 用于同步多端消息状态
|
|
247
215
|
*/ handleMessagesSnapshotEvent(event) {
|
|
248
216
|
if (event.messages && event.messages.length > 0) {
|
|
249
|
-
this.messageModule.list.value =
|
|
217
|
+
this.messageModule.list.value = event.messages.map(transferMessageApi2Message);
|
|
250
218
|
}
|
|
251
219
|
}
|
|
252
220
|
/**
|