@cicctencent/agent-midway 0.1.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/README.md +280 -0
- package/dist/adapters/express.d.ts +8 -0
- package/dist/adapters/express.js +91 -0
- package/dist/adapters/index.d.ts +5 -0
- package/dist/adapters/index.js +21 -0
- package/dist/adapters/koa.d.ts +3 -0
- package/dist/adapters/koa.js +75 -0
- package/dist/adapters/midway.d.ts +5 -0
- package/dist/adapters/midway.js +11 -0
- package/dist/adapters/next.d.ts +12 -0
- package/dist/adapters/next.js +89 -0
- package/dist/adapters/shared.d.ts +4 -0
- package/dist/adapters/shared.js +31 -0
- package/dist/channel/dingtalk.d.ts +18 -0
- package/dist/channel/dingtalk.js +68 -0
- package/dist/channel/feishu.d.ts +20 -0
- package/dist/channel/feishu.js +96 -0
- package/dist/channel/index.d.ts +46 -0
- package/dist/channel/index.js +311 -0
- package/dist/channel/types.d.ts +77 -0
- package/dist/channel/types.js +7 -0
- package/dist/channel/wecom.d.ts +22 -0
- package/dist/channel/wecom.js +106 -0
- package/dist/component.d.ts +49 -0
- package/dist/component.js +129 -0
- package/dist/connector/calendar-adapter.d.ts +19 -0
- package/dist/connector/calendar-adapter.js +236 -0
- package/dist/connector/db-adapter.d.ts +28 -0
- package/dist/connector/db-adapter.js +193 -0
- package/dist/connector/email-adapter.d.ts +23 -0
- package/dist/connector/email-adapter.js +192 -0
- package/dist/connector/fs-adapter.d.ts +15 -0
- package/dist/connector/fs-adapter.js +199 -0
- package/dist/connector/http-adapter.d.ts +29 -0
- package/dist/connector/http-adapter.js +181 -0
- package/dist/connector/index.d.ts +24 -0
- package/dist/connector/index.js +454 -0
- package/dist/connector/mcp-adapter.d.ts +27 -0
- package/dist/connector/mcp-adapter.js +156 -0
- package/dist/connector/mq-adapter.d.ts +25 -0
- package/dist/connector/mq-adapter.js +181 -0
- package/dist/connector/types.d.ts +205 -0
- package/dist/connector/types.js +9 -0
- package/dist/controller/a2a.controller.d.ts +41 -0
- package/dist/controller/a2a.controller.js +150 -0
- package/dist/controller/agent-profile.controller.d.ts +97 -0
- package/dist/controller/agent-profile.controller.js +200 -0
- package/dist/controller/agent.controller.d.ts +199 -0
- package/dist/controller/agent.controller.js +414 -0
- package/dist/controller/application.controller.d.ts +113 -0
- package/dist/controller/application.controller.js +217 -0
- package/dist/controller/automation.controller.d.ts +113 -0
- package/dist/controller/automation.controller.js +246 -0
- package/dist/controller/channel.controller.d.ts +73 -0
- package/dist/controller/channel.controller.js +183 -0
- package/dist/controller/chat.controller.d.ts +188 -0
- package/dist/controller/chat.controller.js +375 -0
- package/dist/controller/connector.controller.d.ts +134 -0
- package/dist/controller/connector.controller.js +257 -0
- package/dist/controller/knowledge-base.controller.d.ts +157 -0
- package/dist/controller/knowledge-base.controller.js +278 -0
- package/dist/controller/mcp-server.controller.d.ts +115 -0
- package/dist/controller/mcp-server.controller.js +236 -0
- package/dist/controller/model-config.controller.d.ts +139 -0
- package/dist/controller/model-config.controller.js +274 -0
- package/dist/controller/observability.controller.d.ts +124 -0
- package/dist/controller/observability.controller.js +142 -0
- package/dist/controller/security.controller.d.ts +91 -0
- package/dist/controller/security.controller.js +172 -0
- package/dist/controller/settings.controller.d.ts +83 -0
- package/dist/controller/settings.controller.js +280 -0
- package/dist/core/ai-workstation.d.ts +17 -0
- package/dist/core/ai-workstation.js +129 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/index.js +20 -0
- package/dist/core/service-container.d.ts +12 -0
- package/dist/core/service-container.js +54 -0
- package/dist/core/sse.d.ts +6 -0
- package/dist/core/sse.js +56 -0
- package/dist/core/types.d.ts +72 -0
- package/dist/core/types.js +2 -0
- package/dist/dto/agent.dto.d.ts +21 -0
- package/dist/dto/agent.dto.js +79 -0
- package/dist/dto/ai-config.dto.d.ts +67 -0
- package/dist/dto/ai-config.dto.js +249 -0
- package/dist/dto/chat.dto.d.ts +40 -0
- package/dist/dto/chat.dto.js +122 -0
- package/dist/index.d.ts +101 -0
- package/dist/index.js +195 -0
- package/dist/memory/db-store.d.ts +33 -0
- package/dist/memory/db-store.js +143 -0
- package/dist/memory/index.d.ts +187 -0
- package/dist/memory/index.js +443 -0
- package/dist/model/ai-agent-profile.entity.d.ts +32 -0
- package/dist/model/ai-agent-profile.entity.js +289 -0
- package/dist/model/ai-application.entity.d.ts +20 -0
- package/dist/model/ai-application.entity.js +166 -0
- package/dist/model/ai-chat-memory.entity.d.ts +16 -0
- package/dist/model/ai-chat-memory.entity.js +123 -0
- package/dist/model/ai-chat-message.entity.d.ts +16 -0
- package/dist/model/ai-chat-message.entity.js +122 -0
- package/dist/model/ai-chat-skill.entity.d.ts +19 -0
- package/dist/model/ai-chat-skill.entity.js +155 -0
- package/dist/model/ai-chat-thread.entity.d.ts +15 -0
- package/dist/model/ai-chat-thread.entity.js +113 -0
- package/dist/model/ai-chat-workspace.entity.d.ts +17 -0
- package/dist/model/ai-chat-workspace.entity.js +136 -0
- package/dist/model/ai-kb-document.entity.d.ts +16 -0
- package/dist/model/ai-kb-document.entity.js +122 -0
- package/dist/model/ai-knowledge-base.entity.d.ts +22 -0
- package/dist/model/ai-knowledge-base.entity.js +185 -0
- package/dist/model/ai-mcp-server.entity.d.ts +23 -0
- package/dist/model/ai-mcp-server.entity.js +198 -0
- package/dist/model/ai-model-config.entity.d.ts +24 -0
- package/dist/model/ai-model-config.entity.js +200 -0
- package/dist/service/a2a.service.d.ts +142 -0
- package/dist/service/a2a.service.js +537 -0
- package/dist/service/agent-profile.service.d.ts +34 -0
- package/dist/service/agent-profile.service.js +110 -0
- package/dist/service/agent-server.service.d.ts +91 -0
- package/dist/service/agent-server.service.js +634 -0
- package/dist/service/agent-task-queue.service.d.ts +98 -0
- package/dist/service/agent-task-queue.service.js +283 -0
- package/dist/service/ai-chat.service.d.ts +103 -0
- package/dist/service/ai-chat.service.js +431 -0
- package/dist/service/ai-skill.service.d.ts +116 -0
- package/dist/service/ai-skill.service.js +457 -0
- package/dist/service/application.service.d.ts +42 -0
- package/dist/service/application.service.js +139 -0
- package/dist/service/automation.service.d.ts +37 -0
- package/dist/service/automation.service.js +196 -0
- package/dist/service/connector.service.d.ts +136 -0
- package/dist/service/connector.service.js +524 -0
- package/dist/service/knowledge-base.service.d.ts +138 -0
- package/dist/service/knowledge-base.service.js +528 -0
- package/dist/service/mcp-server.service.d.ts +39 -0
- package/dist/service/mcp-server.service.js +143 -0
- package/dist/service/model-config.service.d.ts +57 -0
- package/dist/service/model-config.service.js +168 -0
- package/dist/service/observability.service.d.ts +145 -0
- package/dist/service/observability.service.js +281 -0
- package/dist/service/openai.service.d.ts +88 -0
- package/dist/service/openai.service.js +406 -0
- package/dist/service/prompt-builder.service.d.ts +50 -0
- package/dist/service/prompt-builder.service.js +246 -0
- package/dist/tools/code-exec.tool.d.ts +37 -0
- package/dist/tools/code-exec.tool.js +162 -0
- package/dist/tools/datetime.tool.d.ts +21 -0
- package/dist/tools/datetime.tool.js +379 -0
- package/dist/tools/http-request.tool.d.ts +43 -0
- package/dist/tools/http-request.tool.js +455 -0
- package/dist/tools/registry.d.ts +71 -0
- package/dist/tools/registry.js +77 -0
- package/dist/tools/text-process.tool.d.ts +7 -0
- package/dist/tools/text-process.tool.js +366 -0
- package/dist/tools/web-search.tool.d.ts +28 -0
- package/dist/tools/web-search.tool.js +304 -0
- package/dist/types.d.ts +70 -0
- package/dist/types.js +7 -0
- package/package.json +69 -0
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.ChatController = void 0;
|
|
16
|
+
const core_1 = require("@midwayjs/core");
|
|
17
|
+
const midwayjs_base_1 = require("@cicctencent/midwayjs-base");
|
|
18
|
+
const chat_dto_1 = require("../dto/chat.dto");
|
|
19
|
+
const ai_chat_service_1 = require("../service/ai-chat.service");
|
|
20
|
+
const application_service_1 = require("../service/application.service");
|
|
21
|
+
/**
|
|
22
|
+
* 聊天 Controller
|
|
23
|
+
*
|
|
24
|
+
* 管理工作空间、线程和消息(按 Application 隔离)
|
|
25
|
+
*/
|
|
26
|
+
let ChatController = class ChatController extends midwayjs_base_1.BaseController {
|
|
27
|
+
/** 获取当前应用ID */
|
|
28
|
+
async getApplicationId() {
|
|
29
|
+
const app = await this.applicationService.getDefault();
|
|
30
|
+
return app?.id || 0;
|
|
31
|
+
}
|
|
32
|
+
// ========== Workspace ==========
|
|
33
|
+
/** 获取工作空间列表 */
|
|
34
|
+
async getWorkspaces() {
|
|
35
|
+
try {
|
|
36
|
+
const userId = this.getUserId();
|
|
37
|
+
const applicationId = await this.getApplicationId();
|
|
38
|
+
const workspaces = await this.chatService.getWorkspaces(userId, applicationId);
|
|
39
|
+
return { ret: 0, data: workspaces, msg: 'success' };
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
return { ret: 1, msg: error.message };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/** 获取单个工作空间 */
|
|
46
|
+
async getWorkspace(id) {
|
|
47
|
+
try {
|
|
48
|
+
const userId = this.getUserId();
|
|
49
|
+
const applicationId = await this.getApplicationId();
|
|
50
|
+
const workspace = await this.chatService.getWorkspace(id, userId, applicationId);
|
|
51
|
+
if (!workspace) {
|
|
52
|
+
return { ret: 1, msg: '工作空间不存在' };
|
|
53
|
+
}
|
|
54
|
+
return { ret: 0, data: workspace, msg: 'success' };
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
return { ret: 1, msg: error.message };
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/** 创建工作空间 */
|
|
61
|
+
async createWorkspace(body) {
|
|
62
|
+
try {
|
|
63
|
+
const userId = this.getUserId();
|
|
64
|
+
const applicationId = await this.getApplicationId();
|
|
65
|
+
const workspace = await this.chatService.createWorkspace(userId, applicationId, body);
|
|
66
|
+
return { ret: 0, data: workspace, msg: 'success' };
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
return { ret: 1, msg: error.message };
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/** 更新工作空间 */
|
|
73
|
+
async updateWorkspace(id, body) {
|
|
74
|
+
try {
|
|
75
|
+
const userId = this.getUserId();
|
|
76
|
+
const applicationId = await this.getApplicationId();
|
|
77
|
+
const workspace = await this.chatService.updateWorkspace(id, userId, applicationId, body);
|
|
78
|
+
return { ret: 0, data: workspace, msg: 'success' };
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
return { ret: 1, msg: error.message };
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/** 删除工作空间 */
|
|
85
|
+
async deleteWorkspace(id) {
|
|
86
|
+
try {
|
|
87
|
+
const userId = this.getUserId();
|
|
88
|
+
const applicationId = await this.getApplicationId();
|
|
89
|
+
await this.chatService.deleteWorkspace(id, userId, applicationId);
|
|
90
|
+
return { ret: 0, data: null, msg: 'success' };
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
return { ret: 1, msg: error.message };
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
// ========== Thread ==========
|
|
97
|
+
/** 获取线程列表 */
|
|
98
|
+
async getThreads(workspaceId) {
|
|
99
|
+
try {
|
|
100
|
+
const userId = this.getUserId();
|
|
101
|
+
const applicationId = await this.getApplicationId();
|
|
102
|
+
const threads = await this.chatService.getThreads(workspaceId, userId, applicationId);
|
|
103
|
+
return { ret: 0, data: threads, msg: 'success' };
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
return { ret: 1, msg: error.message };
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/** 获取单个线程 */
|
|
110
|
+
async getThread(id) {
|
|
111
|
+
try {
|
|
112
|
+
const userId = this.getUserId();
|
|
113
|
+
const applicationId = await this.getApplicationId();
|
|
114
|
+
const thread = await this.chatService.getThread(id, userId, applicationId);
|
|
115
|
+
if (!thread) {
|
|
116
|
+
return { ret: 1, msg: '线程不存在' };
|
|
117
|
+
}
|
|
118
|
+
return { ret: 0, data: thread, msg: 'success' };
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
return { ret: 1, msg: error.message };
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/** 创建线程 */
|
|
125
|
+
async createThread(workspaceId, body) {
|
|
126
|
+
try {
|
|
127
|
+
const userId = this.getUserId();
|
|
128
|
+
const applicationId = await this.getApplicationId();
|
|
129
|
+
const thread = await this.chatService.createThread(userId, applicationId, {
|
|
130
|
+
workspaceId,
|
|
131
|
+
title: body.title,
|
|
132
|
+
});
|
|
133
|
+
return { ret: 0, data: thread, msg: 'success' };
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
return { ret: 1, msg: error.message };
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/** 更新线程 */
|
|
140
|
+
async updateThread(id, body) {
|
|
141
|
+
try {
|
|
142
|
+
const userId = this.getUserId();
|
|
143
|
+
const applicationId = await this.getApplicationId();
|
|
144
|
+
const thread = await this.chatService.updateThread(id, userId, applicationId, body);
|
|
145
|
+
return { ret: 0, data: thread, msg: 'success' };
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
return { ret: 1, msg: error.message };
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/** 删除线程 */
|
|
152
|
+
async deleteThread(id) {
|
|
153
|
+
try {
|
|
154
|
+
const userId = this.getUserId();
|
|
155
|
+
const applicationId = await this.getApplicationId();
|
|
156
|
+
await this.chatService.deleteThread(id, userId, applicationId);
|
|
157
|
+
return { ret: 0, data: null, msg: 'success' };
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
return { ret: 1, msg: error.message };
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
// ========== Message ==========
|
|
164
|
+
/** 获取消息列表 */
|
|
165
|
+
async getMessages(threadId, body = {}) {
|
|
166
|
+
try {
|
|
167
|
+
const userId = this.getUserId();
|
|
168
|
+
const applicationId = await this.getApplicationId();
|
|
169
|
+
const result = await this.chatService.getMessages(threadId, userId, applicationId, body);
|
|
170
|
+
return { ret: 0, data: result, msg: 'success' };
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
return { ret: 1, msg: error.message };
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
/** 添加消息 */
|
|
177
|
+
async addMessage(threadId, body) {
|
|
178
|
+
try {
|
|
179
|
+
const userId = this.getUserId();
|
|
180
|
+
const applicationId = await this.getApplicationId();
|
|
181
|
+
const message = await this.chatService.addMessage(userId, applicationId, {
|
|
182
|
+
threadId,
|
|
183
|
+
role: body.role,
|
|
184
|
+
content: body.content,
|
|
185
|
+
type: body.type,
|
|
186
|
+
meta: body.meta,
|
|
187
|
+
});
|
|
188
|
+
return { ret: 0, data: message, msg: 'success' };
|
|
189
|
+
}
|
|
190
|
+
catch (error) {
|
|
191
|
+
return { ret: 1, msg: error.message };
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
/** 更新消息 */
|
|
195
|
+
async updateMessage(id, body) {
|
|
196
|
+
try {
|
|
197
|
+
const userId = this.getUserId();
|
|
198
|
+
const applicationId = await this.getApplicationId();
|
|
199
|
+
const message = await this.chatService.updateMessage(id, userId, applicationId, body);
|
|
200
|
+
return { ret: 0, data: message, msg: 'success' };
|
|
201
|
+
}
|
|
202
|
+
catch (error) {
|
|
203
|
+
return { ret: 1, msg: error.message };
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
/** 删除消息 */
|
|
207
|
+
async deleteMessage(id) {
|
|
208
|
+
try {
|
|
209
|
+
const userId = this.getUserId();
|
|
210
|
+
const applicationId = await this.getApplicationId();
|
|
211
|
+
await this.chatService.deleteMessage(id, userId, applicationId);
|
|
212
|
+
return { ret: 0, data: null, msg: 'success' };
|
|
213
|
+
}
|
|
214
|
+
catch (error) {
|
|
215
|
+
return { ret: 1, msg: error.message };
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
/** 清空线程消息 */
|
|
219
|
+
async clearThreadMessages(threadId) {
|
|
220
|
+
try {
|
|
221
|
+
const userId = this.getUserId();
|
|
222
|
+
const applicationId = await this.getApplicationId();
|
|
223
|
+
await this.chatService.clearThreadMessages(threadId, userId, applicationId);
|
|
224
|
+
return { ret: 0, data: null, msg: 'success' };
|
|
225
|
+
}
|
|
226
|
+
catch (error) {
|
|
227
|
+
return { ret: 1, msg: error.message };
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
// ========== 私有方法 ==========
|
|
231
|
+
/**
|
|
232
|
+
* 获取当前用户 ID
|
|
233
|
+
*/
|
|
234
|
+
getUserId() {
|
|
235
|
+
return String(this.ctx?.currentSession?.userId || 'anonymous');
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
exports.ChatController = ChatController;
|
|
239
|
+
__decorate([
|
|
240
|
+
(0, core_1.Inject)(),
|
|
241
|
+
__metadata("design:type", ai_chat_service_1.AIChatService)
|
|
242
|
+
], ChatController.prototype, "chatService", void 0);
|
|
243
|
+
__decorate([
|
|
244
|
+
(0, core_1.Inject)(),
|
|
245
|
+
__metadata("design:type", application_service_1.ApplicationService)
|
|
246
|
+
], ChatController.prototype, "applicationService", void 0);
|
|
247
|
+
__decorate([
|
|
248
|
+
(0, core_1.Get)('/workspaces'),
|
|
249
|
+
midwayjs_base_1.decorators.checkLogin(true),
|
|
250
|
+
__metadata("design:type", Function),
|
|
251
|
+
__metadata("design:paramtypes", []),
|
|
252
|
+
__metadata("design:returntype", Promise)
|
|
253
|
+
], ChatController.prototype, "getWorkspaces", null);
|
|
254
|
+
__decorate([
|
|
255
|
+
(0, core_1.Get)('/workspaces/:id'),
|
|
256
|
+
midwayjs_base_1.decorators.checkLogin(true),
|
|
257
|
+
__param(0, (0, core_1.Param)('id')),
|
|
258
|
+
__metadata("design:type", Function),
|
|
259
|
+
__metadata("design:paramtypes", [Number]),
|
|
260
|
+
__metadata("design:returntype", Promise)
|
|
261
|
+
], ChatController.prototype, "getWorkspace", null);
|
|
262
|
+
__decorate([
|
|
263
|
+
(0, core_1.Post)('/workspaces'),
|
|
264
|
+
midwayjs_base_1.decorators.checkLogin(true),
|
|
265
|
+
__param(0, (0, core_1.Body)()),
|
|
266
|
+
__metadata("design:type", Function),
|
|
267
|
+
__metadata("design:paramtypes", [chat_dto_1.CreateWorkspaceDTO]),
|
|
268
|
+
__metadata("design:returntype", Promise)
|
|
269
|
+
], ChatController.prototype, "createWorkspace", null);
|
|
270
|
+
__decorate([
|
|
271
|
+
(0, core_1.Put)('/workspaces/:id'),
|
|
272
|
+
midwayjs_base_1.decorators.checkLogin(true),
|
|
273
|
+
__param(0, (0, core_1.Param)('id')),
|
|
274
|
+
__param(1, (0, core_1.Body)()),
|
|
275
|
+
__metadata("design:type", Function),
|
|
276
|
+
__metadata("design:paramtypes", [Number, chat_dto_1.UpdateWorkspaceDTO]),
|
|
277
|
+
__metadata("design:returntype", Promise)
|
|
278
|
+
], ChatController.prototype, "updateWorkspace", null);
|
|
279
|
+
__decorate([
|
|
280
|
+
(0, core_1.Del)('/workspaces/:id'),
|
|
281
|
+
midwayjs_base_1.decorators.checkLogin(true),
|
|
282
|
+
__param(0, (0, core_1.Param)('id')),
|
|
283
|
+
__metadata("design:type", Function),
|
|
284
|
+
__metadata("design:paramtypes", [Number]),
|
|
285
|
+
__metadata("design:returntype", Promise)
|
|
286
|
+
], ChatController.prototype, "deleteWorkspace", null);
|
|
287
|
+
__decorate([
|
|
288
|
+
(0, core_1.Get)('/workspaces/:workspaceId/threads'),
|
|
289
|
+
midwayjs_base_1.decorators.checkLogin(true),
|
|
290
|
+
__param(0, (0, core_1.Param)('workspaceId')),
|
|
291
|
+
__metadata("design:type", Function),
|
|
292
|
+
__metadata("design:paramtypes", [Number]),
|
|
293
|
+
__metadata("design:returntype", Promise)
|
|
294
|
+
], ChatController.prototype, "getThreads", null);
|
|
295
|
+
__decorate([
|
|
296
|
+
(0, core_1.Get)('/threads/:id'),
|
|
297
|
+
midwayjs_base_1.decorators.checkLogin(true),
|
|
298
|
+
__param(0, (0, core_1.Param)('id')),
|
|
299
|
+
__metadata("design:type", Function),
|
|
300
|
+
__metadata("design:paramtypes", [Number]),
|
|
301
|
+
__metadata("design:returntype", Promise)
|
|
302
|
+
], ChatController.prototype, "getThread", null);
|
|
303
|
+
__decorate([
|
|
304
|
+
(0, core_1.Post)('/workspaces/:workspaceId/threads'),
|
|
305
|
+
midwayjs_base_1.decorators.checkLogin(true),
|
|
306
|
+
__param(0, (0, core_1.Param)('workspaceId')),
|
|
307
|
+
__param(1, (0, core_1.Body)()),
|
|
308
|
+
__metadata("design:type", Function),
|
|
309
|
+
__metadata("design:paramtypes", [Number, Object]),
|
|
310
|
+
__metadata("design:returntype", Promise)
|
|
311
|
+
], ChatController.prototype, "createThread", null);
|
|
312
|
+
__decorate([
|
|
313
|
+
(0, core_1.Put)('/threads/:id'),
|
|
314
|
+
midwayjs_base_1.decorators.checkLogin(true),
|
|
315
|
+
__param(0, (0, core_1.Param)('id')),
|
|
316
|
+
__param(1, (0, core_1.Body)()),
|
|
317
|
+
__metadata("design:type", Function),
|
|
318
|
+
__metadata("design:paramtypes", [Number, Object]),
|
|
319
|
+
__metadata("design:returntype", Promise)
|
|
320
|
+
], ChatController.prototype, "updateThread", null);
|
|
321
|
+
__decorate([
|
|
322
|
+
(0, core_1.Del)('/threads/:id'),
|
|
323
|
+
midwayjs_base_1.decorators.checkLogin(true),
|
|
324
|
+
__param(0, (0, core_1.Param)('id')),
|
|
325
|
+
__metadata("design:type", Function),
|
|
326
|
+
__metadata("design:paramtypes", [Number]),
|
|
327
|
+
__metadata("design:returntype", Promise)
|
|
328
|
+
], ChatController.prototype, "deleteThread", null);
|
|
329
|
+
__decorate([
|
|
330
|
+
(0, core_1.Get)('/threads/:threadId/messages'),
|
|
331
|
+
midwayjs_base_1.decorators.checkLogin(true),
|
|
332
|
+
__param(0, (0, core_1.Param)('threadId')),
|
|
333
|
+
__param(1, (0, core_1.Body)()),
|
|
334
|
+
__metadata("design:type", Function),
|
|
335
|
+
__metadata("design:paramtypes", [Number, Object]),
|
|
336
|
+
__metadata("design:returntype", Promise)
|
|
337
|
+
], ChatController.prototype, "getMessages", null);
|
|
338
|
+
__decorate([
|
|
339
|
+
(0, core_1.Post)('/threads/:threadId/messages'),
|
|
340
|
+
midwayjs_base_1.decorators.checkLogin(true),
|
|
341
|
+
__param(0, (0, core_1.Param)('threadId')),
|
|
342
|
+
__param(1, (0, core_1.Body)()),
|
|
343
|
+
__metadata("design:type", Function),
|
|
344
|
+
__metadata("design:paramtypes", [Number, Object]),
|
|
345
|
+
__metadata("design:returntype", Promise)
|
|
346
|
+
], ChatController.prototype, "addMessage", null);
|
|
347
|
+
__decorate([
|
|
348
|
+
(0, core_1.Put)('/messages/:id'),
|
|
349
|
+
midwayjs_base_1.decorators.checkLogin(true),
|
|
350
|
+
__param(0, (0, core_1.Param)('id')),
|
|
351
|
+
__param(1, (0, core_1.Body)()),
|
|
352
|
+
__metadata("design:type", Function),
|
|
353
|
+
__metadata("design:paramtypes", [Number, Object]),
|
|
354
|
+
__metadata("design:returntype", Promise)
|
|
355
|
+
], ChatController.prototype, "updateMessage", null);
|
|
356
|
+
__decorate([
|
|
357
|
+
(0, core_1.Del)('/messages/:id'),
|
|
358
|
+
midwayjs_base_1.decorators.checkLogin(true),
|
|
359
|
+
__param(0, (0, core_1.Param)('id')),
|
|
360
|
+
__metadata("design:type", Function),
|
|
361
|
+
__metadata("design:paramtypes", [Number]),
|
|
362
|
+
__metadata("design:returntype", Promise)
|
|
363
|
+
], ChatController.prototype, "deleteMessage", null);
|
|
364
|
+
__decorate([
|
|
365
|
+
(0, core_1.Del)('/threads/:threadId/messages'),
|
|
366
|
+
midwayjs_base_1.decorators.checkLogin(true),
|
|
367
|
+
__param(0, (0, core_1.Param)('threadId')),
|
|
368
|
+
__metadata("design:type", Function),
|
|
369
|
+
__metadata("design:paramtypes", [Number]),
|
|
370
|
+
__metadata("design:returntype", Promise)
|
|
371
|
+
], ChatController.prototype, "clearThreadMessages", null);
|
|
372
|
+
exports.ChatController = ChatController = __decorate([
|
|
373
|
+
(0, core_1.Provide)(),
|
|
374
|
+
(0, core_1.Controller)('/api/chat')
|
|
375
|
+
], ChatController);
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { BaseController } from '@cicctencent/midwayjs-base';
|
|
2
|
+
import { ConnectorService } from '../service/connector.service';
|
|
3
|
+
import type { DataSourceConfig } from '../connector/types';
|
|
4
|
+
/**
|
|
5
|
+
* 连接器管理 Controller
|
|
6
|
+
*
|
|
7
|
+
* 提供连接器的 CRUD、连接测试、工具发现、清单生成等接口。
|
|
8
|
+
*/
|
|
9
|
+
export declare class ConnectorController extends BaseController {
|
|
10
|
+
connectorService: ConnectorService;
|
|
11
|
+
/** 获取连接器列表 */
|
|
12
|
+
list(): Promise<{
|
|
13
|
+
ret: number;
|
|
14
|
+
data: import("../service/connector.service").ConnectorRecord[];
|
|
15
|
+
msg: string;
|
|
16
|
+
} | {
|
|
17
|
+
ret: number;
|
|
18
|
+
msg: any;
|
|
19
|
+
data?: undefined;
|
|
20
|
+
}>;
|
|
21
|
+
/** 获取单个连接器 */
|
|
22
|
+
detail(id: string): Promise<{
|
|
23
|
+
ret: number;
|
|
24
|
+
data: import("../service/connector.service").ConnectorRecord;
|
|
25
|
+
msg: string;
|
|
26
|
+
} | {
|
|
27
|
+
ret: number;
|
|
28
|
+
msg: any;
|
|
29
|
+
data?: undefined;
|
|
30
|
+
}>;
|
|
31
|
+
/** 创建连接器 */
|
|
32
|
+
create(body: DataSourceConfig): Promise<{
|
|
33
|
+
ret: number;
|
|
34
|
+
data: import("../service/connector.service").ConnectorRecord;
|
|
35
|
+
msg: string;
|
|
36
|
+
} | {
|
|
37
|
+
ret: number;
|
|
38
|
+
msg: any;
|
|
39
|
+
data?: undefined;
|
|
40
|
+
}>;
|
|
41
|
+
/** 更新连接器 */
|
|
42
|
+
update(id: string, body: Partial<DataSourceConfig>): Promise<{
|
|
43
|
+
ret: number;
|
|
44
|
+
data: import("../service/connector.service").ConnectorRecord;
|
|
45
|
+
msg: string;
|
|
46
|
+
} | {
|
|
47
|
+
ret: number;
|
|
48
|
+
msg: any;
|
|
49
|
+
data?: undefined;
|
|
50
|
+
}>;
|
|
51
|
+
/** 删除连接器 */
|
|
52
|
+
remove(id: string): Promise<{
|
|
53
|
+
ret: number;
|
|
54
|
+
data: any;
|
|
55
|
+
msg: string;
|
|
56
|
+
} | {
|
|
57
|
+
ret: number;
|
|
58
|
+
msg: any;
|
|
59
|
+
data?: undefined;
|
|
60
|
+
}>;
|
|
61
|
+
/** 测试连接(已保存的连接器) */
|
|
62
|
+
testConnection(id: string): Promise<{
|
|
63
|
+
ret: number;
|
|
64
|
+
data: import("../connector/types").ConnectionTestResult;
|
|
65
|
+
msg: string;
|
|
66
|
+
} | {
|
|
67
|
+
ret: number;
|
|
68
|
+
msg: any;
|
|
69
|
+
data?: undefined;
|
|
70
|
+
}>;
|
|
71
|
+
/** 测试配置(未保存的配置) */
|
|
72
|
+
testConfig(body: DataSourceConfig): Promise<{
|
|
73
|
+
ret: number;
|
|
74
|
+
data: import("../connector/types").ConnectionTestResult;
|
|
75
|
+
msg: string;
|
|
76
|
+
} | {
|
|
77
|
+
ret: number;
|
|
78
|
+
msg: any;
|
|
79
|
+
data?: undefined;
|
|
80
|
+
}>;
|
|
81
|
+
/** 发现工具 */
|
|
82
|
+
discoverTools(id: string): Promise<{
|
|
83
|
+
ret: number;
|
|
84
|
+
data: import("../connector/types").DiscoveredTool[];
|
|
85
|
+
msg: string;
|
|
86
|
+
} | {
|
|
87
|
+
ret: number;
|
|
88
|
+
msg: any;
|
|
89
|
+
data?: undefined;
|
|
90
|
+
}>;
|
|
91
|
+
/** 生成清单 */
|
|
92
|
+
generateManifest(id: string): Promise<{
|
|
93
|
+
ret: number;
|
|
94
|
+
data: {
|
|
95
|
+
tools: import("../connector/types").DiscoveredTool[];
|
|
96
|
+
metadata: Record<string, any>;
|
|
97
|
+
};
|
|
98
|
+
msg: string;
|
|
99
|
+
} | {
|
|
100
|
+
ret: number;
|
|
101
|
+
msg: any;
|
|
102
|
+
data?: undefined;
|
|
103
|
+
}>;
|
|
104
|
+
/** 生成 MCP 服务器配置 */
|
|
105
|
+
generateMCPServerConfigs(id: string): Promise<{
|
|
106
|
+
ret: number;
|
|
107
|
+
data: import("../connector/types").MCPServerConfig[];
|
|
108
|
+
msg: string;
|
|
109
|
+
} | {
|
|
110
|
+
ret: number;
|
|
111
|
+
msg: any;
|
|
112
|
+
data?: undefined;
|
|
113
|
+
}>;
|
|
114
|
+
/** 获取所有数据源类型 */
|
|
115
|
+
getTypes(): Promise<{
|
|
116
|
+
ret: number;
|
|
117
|
+
data: import("../connector/types").DataSourceType[];
|
|
118
|
+
msg: string;
|
|
119
|
+
} | {
|
|
120
|
+
ret: number;
|
|
121
|
+
msg: any;
|
|
122
|
+
data?: undefined;
|
|
123
|
+
}>;
|
|
124
|
+
/** 获取数据源类型信息(前端向导展示用) */
|
|
125
|
+
getTypeInfos(): Promise<{
|
|
126
|
+
ret: number;
|
|
127
|
+
data: import("../connector/types").DataSourceTypeInfo[];
|
|
128
|
+
msg: string;
|
|
129
|
+
} | {
|
|
130
|
+
ret: number;
|
|
131
|
+
msg: any;
|
|
132
|
+
data?: undefined;
|
|
133
|
+
}>;
|
|
134
|
+
}
|