This commit is contained in:
lik
2026-06-01 17:40:11 +08:00
parent 83d660496c
commit cebe7876f7
7 changed files with 349 additions and 105 deletions

View File

@@ -2,6 +2,7 @@ import WebSocket, { WebSocketServer } from 'ws';
import http from 'http';
import { DBModel } from "./models/index.js";
import { chatTask } from "./agent/escort/task.js";
import { adminAgent } from "./agent/escort-admin/agent.js"
export default class WebSocketServerManager {
constructor(port = 8080) {
@@ -80,6 +81,10 @@ export default class WebSocketServerManager {
if (msg.type === 'chat' || msg.type === 'clear') {
if (msg.agent === 'escort-admin') {
const userInfo = await this.getUserInfo(msg.userId);
adminAgent.streamChat(userInfo, [msg], (source, type, content, id) => {
ws.send(JSON.stringify({ source, type, content, id }));
});
} else {
const userInfo = await this.getUserInfo(msg.userId);
chatTask.streamChat(userInfo, msg, (source, type, content, id) => {