diff --git a/server/agent-server.js b/server/agent-server.js index 7feb630..3144ce3 100644 --- a/server/agent-server.js +++ b/server/agent-server.js @@ -9,7 +9,8 @@ const cors = require('cors'); const agentChatRoute = require('./routes/agent-chat'); const app = express(); -const PORT = 3000; +const config = require('./config'); +const PORT = process.env.PORT || config.port || 3010; app.use(cors({ origin: ['http://localhost:5173'], credentials: true })); diff --git a/server/routes/agent-chat.js b/server/routes/agent-chat.js index 97c80ba..5e44023 100644 --- a/server/routes/agent-chat.js +++ b/server/routes/agent-chat.js @@ -1472,7 +1472,7 @@ router.post('/task/dispatch', async (req, res) => { const http = require('http'); const postData = JSON.stringify({ message: taskMessage, conversationId: executionConvId }); const options = { - hostname: 'localhost', port: 3000, + hostname: 'localhost', port: systemConfig.port, path: `/api/agent/${to}/chat`, method: 'POST', headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(postData) }, @@ -1645,7 +1645,7 @@ router.post('/task/report', (req, res) => { const http = require('http'); const postData = JSON.stringify({ message: callbackMessage, conversationId: callbackConvId }); const options = { - hostname: 'localhost', port: 3000, + hostname: 'localhost', port: systemConfig.port, path: `/api/agent/${to}/chat`, method: 'POST', headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(postData) }, @@ -1727,7 +1727,7 @@ router.post('/:agentId/task/transition', (req, res) => { const http = require('http'); const postData = JSON.stringify({ message: masterMsg, conversationId: `approval-${taskId}` }); const options = { - hostname: 'localhost', port: 3000, + hostname: 'localhost', port: systemConfig.port, path: `/api/agent/master/chat`, method: 'POST', headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(postData) }, @@ -1816,7 +1816,7 @@ ${artifactContent ? `这是上一阶段你或你的前置节点留下的交付ç‰ const http = require('http'); const postData = JSON.stringify({ message: "请确认你已收到系统的新阶段挂载指令,并立即执行你当前阶段本分的任务!", conversationId: activeConvId }); const options = { - hostname: 'localhost', port: 3000, + hostname: 'localhost', port: systemConfig.port, path: `/api/agent/${agentId}/chat`, method: 'POST', headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(postData) }, @@ -1881,7 +1881,7 @@ router.post('/task/reject', (req, res) => { const http = require('http'); const postData = JSON.stringify({ message: rejectMessage, conversationId: `redo-${runId}-step-${stepIndex}` }); const options = { - hostname: 'localhost', port: 3000, + hostname: 'localhost', port: systemConfig.port, path: `/api/agent/${agentId}/chat`, method: 'POST', headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(postData) }, @@ -1967,7 +1967,7 @@ router.post('/human-request', (req, res) => { const http = require('http'); const postData = JSON.stringify({ message: masterMsg, conversationId: `human-req-${Date.now().toString(36)}` }); const options = { - hostname: 'localhost', port: 3000, + hostname: 'localhost', port: systemConfig.port, path: `/api/agent/master/chat`, method: 'POST', headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(postData) }, diff --git a/server/services/company-heartbeat-service.js b/server/services/company-heartbeat-service.js index 517fbdb..99991c4 100644 --- a/server/services/company-heartbeat-service.js +++ b/server/services/company-heartbeat-service.js @@ -14,6 +14,7 @@ const fs = require('fs'); const path = require('path'); const http = require('http'); +const config = require('../config'); const { CompanyService } = require('./company-service'); const { PipelineService } = require('./pipeline-service'); const { ScheduleService } = require('./schedule-service'); @@ -26,7 +27,7 @@ class CompanyHeartbeatService { this.timers = new Map(); // companyId → NodeJS.Timeout this.companyService = new CompanyService(); this.scheduleService = new ScheduleService(); - this.port = 3000; + this.port = config.port || 3010; this._started = false; }