@blueking/chat-helper 0.0.1-beta.35 → 0.0.1-beta.38
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/event/ag-ui.d.ts +1 -1
- package/dist/event/ag-ui.ts.js +9 -3
- package/dist/http/fetch/index.ts.js +16 -65
- package/dist/http/index.d.ts +1 -0
- package/dist/http/module/index.d.ts +1 -0
- package/dist/http/module/message.d.ts +1 -0
- package/dist/http/module/message.ts.js +5 -2
- package/dist/index.d.ts +3 -0
- package/dist/message/use-message.d.ts +2 -0
- package/dist/message/use-message.ts.js +10 -0
- package/package.json +7 -2
package/dist/event/ag-ui.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export declare class AGUIProtocol implements ISSEProtocol {
|
|
|
34
34
|
/**
|
|
35
35
|
* 自定义事件 处理流程编排任务结束
|
|
36
36
|
*/
|
|
37
|
-
handleFlowAgentEndCustomEvent(
|
|
37
|
+
handleFlowAgentEndCustomEvent(event: ICustomEvent): void;
|
|
38
38
|
/**
|
|
39
39
|
* 自定义事件 处理流程编排任务结果(增量更新节点状态)
|
|
40
40
|
*/
|
package/dist/event/ag-ui.ts.js
CHANGED
|
@@ -87,12 +87,18 @@ import { CustomEventName, EventType, FlowTaskState } from './type.ts.js';
|
|
|
87
87
|
}
|
|
88
88
|
/**
|
|
89
89
|
* 自定义事件 处理流程编排任务结束
|
|
90
|
-
*/ handleFlowAgentEndCustomEvent(
|
|
90
|
+
*/ handleFlowAgentEndCustomEvent(event) {
|
|
91
91
|
const message = this.messageModule.getCurrentLoadingMessage();
|
|
92
92
|
if (message && message.role === MessageRole.Activity && message.activityType === ActivityType.FlowAgent) {
|
|
93
|
-
|
|
94
|
-
message.content.task_outputs = value.task_outputs;
|
|
93
|
+
// 先把最后一个loading消息标记为complete
|
|
95
94
|
message.status = MessageStatus.Complete;
|
|
95
|
+
// 然后创建一个结束消息
|
|
96
|
+
const value = event.value;
|
|
97
|
+
this.messageModule.plusMessage({
|
|
98
|
+
role: MessageRole.Assistant,
|
|
99
|
+
content: value.task_outputs.join('\n'),
|
|
100
|
+
status: MessageStatus.Complete
|
|
101
|
+
});
|
|
96
102
|
}
|
|
97
103
|
}
|
|
98
104
|
/**
|
|
@@ -22,82 +22,33 @@
|
|
|
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
|
-
*/
|
|
26
|
-
|
|
27
|
-
Object.defineProperty(obj, key, {
|
|
28
|
-
value: value,
|
|
29
|
-
enumerable: true,
|
|
30
|
-
configurable: true,
|
|
31
|
-
writable: true
|
|
32
|
-
});
|
|
33
|
-
} else {
|
|
34
|
-
obj[key] = value;
|
|
35
|
-
}
|
|
36
|
-
return obj;
|
|
37
|
-
}
|
|
38
|
-
function _object_spread(target) {
|
|
39
|
-
for(var i = 1; i < arguments.length; i++){
|
|
40
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
41
|
-
var ownKeys = Object.keys(source);
|
|
42
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
43
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
44
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
45
|
-
}));
|
|
46
|
-
}
|
|
47
|
-
ownKeys.forEach(function(key) {
|
|
48
|
-
_define_property(target, key, source[key]);
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
return target;
|
|
52
|
-
}
|
|
53
|
-
import { FetchClient } from './fetch.ts.js';
|
|
54
|
-
/**
|
|
55
|
-
* 注册所有拦截器(内部 requestData 注入 + 用户自定义)
|
|
56
|
-
* 抽取为独立函数,避免 useFetch 和 reset 中重复逻辑
|
|
57
|
-
*/ function applyInterceptors(fetchClient, options) {
|
|
25
|
+
*/ import { FetchClient } from './fetch.ts.js';
|
|
26
|
+
export const useFetch = (options)=>{
|
|
58
27
|
var _options_interceptors, _options_interceptors1;
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const resolved = typeof customHeaders === 'function' ? customHeaders() : customHeaders;
|
|
64
|
-
const existing = typeof config.headers === 'function' ? config.headers() : config.headers || {};
|
|
65
|
-
config.headers = _object_spread({}, existing, resolved);
|
|
66
|
-
}
|
|
67
|
-
const method = (config.method || 'GET').toUpperCase();
|
|
68
|
-
const supportsBody = ![
|
|
69
|
-
'GET',
|
|
70
|
-
'HEAD'
|
|
71
|
-
].includes(method);
|
|
72
|
-
if (customData && supportsBody) {
|
|
73
|
-
const resolved = typeof customData === 'function' ? customData() : customData;
|
|
74
|
-
const existingData = typeof config.data === 'function' ? config.data() : config.data;
|
|
75
|
-
if (existingData && typeof existingData === 'object' && !Array.isArray(existingData)) {
|
|
76
|
-
config.data = _object_spread({}, resolved, existingData);
|
|
77
|
-
} else if (!existingData) {
|
|
78
|
-
config.data = resolved;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return config;
|
|
82
|
-
});
|
|
83
|
-
}
|
|
28
|
+
const fetchClient = new FetchClient({
|
|
29
|
+
baseURL: options.requestData.urlPrefix
|
|
30
|
+
});
|
|
31
|
+
// 用户定义拦截器
|
|
84
32
|
if ((_options_interceptors = options.interceptors) === null || _options_interceptors === void 0 ? void 0 : _options_interceptors.request) {
|
|
85
33
|
fetchClient.interceptors.request.use(options.interceptors.request);
|
|
86
34
|
}
|
|
87
35
|
if ((_options_interceptors1 = options.interceptors) === null || _options_interceptors1 === void 0 ? void 0 : _options_interceptors1.response) {
|
|
88
36
|
fetchClient.interceptors.response.use(options.interceptors.response);
|
|
89
37
|
}
|
|
90
|
-
|
|
91
|
-
export const useFetch = (options)=>{
|
|
92
|
-
const fetchClient = new FetchClient({
|
|
93
|
-
baseURL: options.requestData.urlPrefix
|
|
94
|
-
});
|
|
95
|
-
applyInterceptors(fetchClient, options);
|
|
38
|
+
// 重置 fetchClient 配置
|
|
96
39
|
const reset = (newOptions)=>{
|
|
40
|
+
var _newOptions_interceptors, _newOptions_interceptors1;
|
|
41
|
+
// 更新 baseURL
|
|
97
42
|
fetchClient.defaults.baseURL = newOptions.requestData.urlPrefix;
|
|
43
|
+
// 清空并重新注册拦截器
|
|
98
44
|
fetchClient.interceptors.request.clear();
|
|
99
45
|
fetchClient.interceptors.response.clear();
|
|
100
|
-
|
|
46
|
+
if ((_newOptions_interceptors = newOptions.interceptors) === null || _newOptions_interceptors === void 0 ? void 0 : _newOptions_interceptors.request) {
|
|
47
|
+
fetchClient.interceptors.request.use(newOptions.interceptors.request);
|
|
48
|
+
}
|
|
49
|
+
if ((_newOptions_interceptors1 = newOptions.interceptors) === null || _newOptions_interceptors1 === void 0 ? void 0 : _newOptions_interceptors1.response) {
|
|
50
|
+
fetchClient.interceptors.response.use(newOptions.interceptors.response);
|
|
51
|
+
}
|
|
101
52
|
};
|
|
102
53
|
return {
|
|
103
54
|
fetchClient,
|
package/dist/http/index.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export declare const useHttp: (options: IUseChatHelperOptions) => {
|
|
|
40
40
|
batchDeleteMessages: (ids: string[], config?: import("./fetch").IRequestConfig) => Promise<number>;
|
|
41
41
|
shareMessages: (sessionCode: string, contentIds: string[], expiredAt?: number, config?: import("./fetch").IRequestConfig) => Promise<import("./module/message").IShareMessagesResponse>;
|
|
42
42
|
stopChat: (sessionCode: string, config?: import("./fetch").IRequestConfig) => Promise<void>;
|
|
43
|
+
getFlowAgentTaskInfo: (taskId: number, config?: import("./fetch").IRequestConfig) => Promise<unknown>;
|
|
43
44
|
getFlowAgentTaskNodeInfo: (taskId: number, nodeId: string, config?: import("./fetch").IRequestConfig) => Promise<import("..").IFlowAgentTaskNodeInfo>;
|
|
44
45
|
};
|
|
45
46
|
fetchClient: import("./fetch").FetchClient;
|
|
@@ -37,6 +37,7 @@ export declare const useModule: (fetchClient: FetchClient) => {
|
|
|
37
37
|
batchDeleteMessages: (ids: string[], config?: import("../fetch").IRequestConfig) => Promise<number>;
|
|
38
38
|
shareMessages: (sessionCode: string, contentIds: string[], expiredAt?: number, config?: import("../fetch").IRequestConfig) => Promise<import("./message").IShareMessagesResponse>;
|
|
39
39
|
stopChat: (sessionCode: string, config?: import("../fetch").IRequestConfig) => Promise<void>;
|
|
40
|
+
getFlowAgentTaskInfo: (taskId: number, config?: import("../fetch").IRequestConfig) => Promise<unknown>;
|
|
40
41
|
getFlowAgentTaskNodeInfo: (taskId: number, nodeId: string, config?: import("../fetch").IRequestConfig) => Promise<import("../..").IFlowAgentTaskNodeInfo>;
|
|
41
42
|
};
|
|
42
43
|
fetchClient: FetchClient;
|
|
@@ -26,5 +26,6 @@ export declare const useMessage: (fetchClient: FetchClient) => {
|
|
|
26
26
|
batchDeleteMessages: (ids: string[], config?: IRequestConfig) => Promise<number>;
|
|
27
27
|
shareMessages: (sessionCode: string, contentIds: string[], expiredAt?: number, config?: IRequestConfig) => Promise<IShareMessagesResponse>;
|
|
28
28
|
stopChat: (sessionCode: string, config?: IRequestConfig) => Promise<void>;
|
|
29
|
+
getFlowAgentTaskInfo: (taskId: number, config?: IRequestConfig) => Promise<unknown>;
|
|
29
30
|
getFlowAgentTaskNodeInfo: (taskId: number, nodeId: string, config?: IRequestConfig) => Promise<IFlowAgentTaskNodeInfo>;
|
|
30
31
|
};
|
|
@@ -66,7 +66,7 @@ import { transferMessage2MessageApi, transferMessageApi2Message } from '../trans
|
|
|
66
66
|
// 修改会话内容
|
|
67
67
|
const modifyMessage = (data, config)=>fetchClient.put(`session_content/${data.id}/`, transferMessage2MessageApi(data), config).then(transferMessageApi2Message);
|
|
68
68
|
// 删除会话内容
|
|
69
|
-
const deleteMessage = (id, config)=>fetchClient
|
|
69
|
+
const deleteMessage = (id, config)=>fetchClient.delete(`session_content/${id}/`, undefined, config);
|
|
70
70
|
// 批量删除聊天内容
|
|
71
71
|
const batchDeleteMessages = (ids, config)=>fetchClient.post(`session_content/batch_delete/`, {
|
|
72
72
|
ids
|
|
@@ -82,8 +82,10 @@ import { transferMessage2MessageApi, transferMessageApi2Message } from '../trans
|
|
|
82
82
|
const stopChat = (sessionCode, config)=>fetchClient.post(`session_content/stop/`, {
|
|
83
83
|
session_code: sessionCode
|
|
84
84
|
}, config);
|
|
85
|
+
// 获取流程引擎任务信息
|
|
86
|
+
const getFlowAgentTaskInfo = (taskId, config)=>fetchClient.get(`flow_agent/${taskId}/task_info/`, undefined, config);
|
|
85
87
|
// 获取流程引擎任务节点详情
|
|
86
|
-
const getFlowAgentTaskNodeInfo = (taskId, nodeId, config)=>fetchClient.get(`flow_agent
|
|
88
|
+
const getFlowAgentTaskNodeInfo = (taskId, nodeId, config)=>fetchClient.get(`flow_agent/${taskId}/task_node_info/${nodeId}/`, undefined, config);
|
|
87
89
|
return {
|
|
88
90
|
getMessages,
|
|
89
91
|
plusMessage,
|
|
@@ -92,6 +94,7 @@ import { transferMessage2MessageApi, transferMessageApi2Message } from '../trans
|
|
|
92
94
|
batchDeleteMessages,
|
|
93
95
|
shareMessages,
|
|
94
96
|
stopChat,
|
|
97
|
+
getFlowAgentTaskInfo,
|
|
95
98
|
getFlowAgentTaskNodeInfo
|
|
96
99
|
};
|
|
97
100
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -3700,6 +3700,8 @@ export declare const useChatHelper: (options: IUseChatHelperOptions) => {
|
|
|
3700
3700
|
createAndPlusMessage: (message: import("./message").IMessage) => Promise<void>;
|
|
3701
3701
|
deleteMessages: (messages: import("./message").IMessage[]) => Promise<void>;
|
|
3702
3702
|
shareMessages: (sessionCode: string, messages: import("./message").IMessage[], expiredAt?: number) => Promise<import("./http/module/message").IShareMessagesResponse>;
|
|
3703
|
+
getFlowAgentTaskInfo: (taskId: number) => Promise<unknown>;
|
|
3704
|
+
getFlowAgentTaskNodeInfo: (taskId: number, nodeId: string) => Promise<import("./message").IFlowAgentTaskNodeInfo>;
|
|
3703
3705
|
reset: () => void;
|
|
3704
3706
|
};
|
|
3705
3707
|
http: {
|
|
@@ -3736,6 +3738,7 @@ export declare const useChatHelper: (options: IUseChatHelperOptions) => {
|
|
|
3736
3738
|
batchDeleteMessages: (ids: string[], config?: import("./http").IRequestConfig) => Promise<number>;
|
|
3737
3739
|
shareMessages: (sessionCode: string, contentIds: string[], expiredAt?: number, config?: import("./http").IRequestConfig) => Promise<import("./http/module/message").IShareMessagesResponse>;
|
|
3738
3740
|
stopChat: (sessionCode: string, config?: import("./http").IRequestConfig) => Promise<void>;
|
|
3741
|
+
getFlowAgentTaskInfo: (taskId: number, config?: import("./http").IRequestConfig) => Promise<unknown>;
|
|
3739
3742
|
getFlowAgentTaskNodeInfo: (taskId: number, nodeId: string, config?: import("./http").IRequestConfig) => Promise<import("./message").IFlowAgentTaskNodeInfo>;
|
|
3740
3743
|
};
|
|
3741
3744
|
fetchClient: import("./http").FetchClient;
|
|
@@ -994,6 +994,8 @@ export declare const useMessage: (mediator: IMediatorModule) => {
|
|
|
994
994
|
createAndPlusMessage: (message: IMessage) => Promise<void>;
|
|
995
995
|
deleteMessages: (messages: IMessage[]) => Promise<void>;
|
|
996
996
|
shareMessages: (sessionCode: string, messages: IMessage[], expiredAt?: number) => Promise<import("../http/module/message").IShareMessagesResponse>;
|
|
997
|
+
getFlowAgentTaskInfo: (taskId: number) => Promise<unknown>;
|
|
998
|
+
getFlowAgentTaskNodeInfo: (taskId: number, nodeId: string) => Promise<import("./type").IFlowAgentTaskNodeInfo>;
|
|
997
999
|
reset: () => void;
|
|
998
1000
|
};
|
|
999
1001
|
export type IMessageModule = ReturnType<typeof useMessage>;
|
|
@@ -258,6 +258,14 @@ import { MessageRole, MessageStatus } from './type.ts.js';
|
|
|
258
258
|
return _ref.apply(this, arguments);
|
|
259
259
|
};
|
|
260
260
|
}();
|
|
261
|
+
const getFlowAgentTaskInfo = (taskId)=>{
|
|
262
|
+
var _mediator_http;
|
|
263
|
+
return (_mediator_http = mediator.http) === null || _mediator_http === void 0 ? void 0 : _mediator_http.message.getFlowAgentTaskInfo(taskId);
|
|
264
|
+
};
|
|
265
|
+
const getFlowAgentTaskNodeInfo = (taskId, nodeId)=>{
|
|
266
|
+
var _mediator_http;
|
|
267
|
+
return (_mediator_http = mediator.http) === null || _mediator_http === void 0 ? void 0 : _mediator_http.message.getFlowAgentTaskNodeInfo(taskId, nodeId);
|
|
268
|
+
};
|
|
261
269
|
const reset = ()=>{
|
|
262
270
|
list.value = [];
|
|
263
271
|
isListLoading.value = false;
|
|
@@ -276,6 +284,8 @@ import { MessageRole, MessageStatus } from './type.ts.js';
|
|
|
276
284
|
createAndPlusMessage,
|
|
277
285
|
deleteMessages,
|
|
278
286
|
shareMessages,
|
|
287
|
+
getFlowAgentTaskInfo,
|
|
288
|
+
getFlowAgentTaskNodeInfo,
|
|
279
289
|
reset
|
|
280
290
|
};
|
|
281
291
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blueking/chat-helper",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.38",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.ts.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -13,8 +13,13 @@
|
|
|
13
13
|
"files": [
|
|
14
14
|
"dist"
|
|
15
15
|
],
|
|
16
|
-
"author": "",
|
|
16
|
+
"author": "Tencent BlueKing",
|
|
17
17
|
"license": "ISC",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/TencentBlueKing/bk-aidev-agent.git",
|
|
21
|
+
"directory": "src/frontend/ai-blueking/packages/chat-helper"
|
|
22
|
+
},
|
|
18
23
|
"packageManager": "pnpm@10.17.1",
|
|
19
24
|
"peerDependencies": {
|
|
20
25
|
"vue": "^3.5.24"
|