2026-03-07 14:36:04 +08:00
|
|
|
|
require('dotenv').config();
|
|
|
|
|
|
const express = require('express');
|
|
|
|
|
|
const cors = require('cors');
|
|
|
|
|
|
|
2026-04-01 16:09:14 +08:00
|
|
|
|
// ─── 语言膜 · Language Membrane ───
|
|
|
|
|
|
// 光湖语言世界最外层 · 完整的圆 · 没有缺口
|
|
|
|
|
|
const membrane = require('../src/membrane');
|
|
|
|
|
|
|
2026-03-07 14:36:04 +08:00
|
|
|
|
const app = express();
|
|
|
|
|
|
app.use(cors());
|
|
|
|
|
|
app.use(express.json());
|
|
|
|
|
|
|
2026-04-01 16:09:14 +08:00
|
|
|
|
// ─── 语言膜网关(最外层中间件 · 所有请求必须经过) ───
|
|
|
|
|
|
app.use(membrane.gateway.createGateway());
|
|
|
|
|
|
|
|
|
|
|
|
// ─── 语言膜状态接口 ───
|
|
|
|
|
|
app.get('/api/membrane/status', (req, res) => {
|
|
|
|
|
|
res.json(membrane.getStatus());
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// ─── 冰朔人格模块状态 ───
|
|
|
|
|
|
app.get('/api/membrane/bingshuo', (req, res) => {
|
|
|
|
|
|
res.json(membrane.bingshuoModule.getStatus());
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// ─── 动态权限统计 ───
|
|
|
|
|
|
app.get('/api/membrane/permissions', (req, res) => {
|
|
|
|
|
|
res.json(membrane.permissionEngine.getStats());
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// ─── 行业模块列表 ───
|
|
|
|
|
|
app.get('/api/membrane/modules', (req, res) => {
|
|
|
|
|
|
res.json({
|
|
|
|
|
|
active: membrane.moduleRegistry.listActiveModules(),
|
|
|
|
|
|
all: membrane.moduleRegistry.listAllModules(),
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// ─── 人格体房间列表 ───
|
|
|
|
|
|
app.get('/api/membrane/rooms', (req, res) => {
|
|
|
|
|
|
const rooms = membrane.roomManager.listRooms();
|
|
|
|
|
|
res.json({
|
|
|
|
|
|
count: rooms.length,
|
|
|
|
|
|
rooms: rooms.map(id => membrane.roomManager.getRoomStatus(id) || { persona_id: id }),
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2026-03-07 14:36:04 +08:00
|
|
|
|
// 路由引入
|
|
|
|
|
|
const notionRoutes = require('./routes/notion');
|
|
|
|
|
|
const feishuRoutes = require('./routes/feishu');
|
2026-03-12 01:12:52 +08:00
|
|
|
|
const feishuBotRoutes = require('./routes/feishu-bot');
|
2026-03-07 14:36:04 +08:00
|
|
|
|
const routerRoutes = require('./routes/router');
|
2026-03-07 16:20:04 +08:00
|
|
|
|
const coldstartRoutes = require('./routes/coldstart');
|
2026-03-08 22:52:26 +08:00
|
|
|
|
const developersRoutes = require('./routes/developers');
|
2026-03-07 16:28:46 +08:00
|
|
|
|
const hliRoutes = require('../src/routes/hli');
|
2026-03-07 14:36:04 +08:00
|
|
|
|
|
|
|
|
|
|
app.use('/notion', notionRoutes);
|
|
|
|
|
|
app.use('/feishu', feishuRoutes);
|
2026-03-12 01:12:52 +08:00
|
|
|
|
app.use('/feishu-bot', feishuBotRoutes);
|
2026-03-07 14:36:04 +08:00
|
|
|
|
app.use('/router', routerRoutes);
|
2026-03-07 16:20:04 +08:00
|
|
|
|
app.use('/api/coldstart', coldstartRoutes);
|
2026-03-08 22:52:26 +08:00
|
|
|
|
app.use('/api/v1/developers', developersRoutes);
|
2026-03-07 16:28:46 +08:00
|
|
|
|
app.use('/hli', hliRoutes);
|
2026-03-07 14:36:04 +08:00
|
|
|
|
|
|
|
|
|
|
app.get('/', (req, res) => {
|
|
|
|
|
|
res.json({
|
|
|
|
|
|
status: 'ok',
|
2026-04-01 16:09:14 +08:00
|
|
|
|
message: '光湖语言世界 · HoloLake Language World',
|
|
|
|
|
|
version: '0.3.0',
|
|
|
|
|
|
membrane: membrane.MEMBRANE_VERSION,
|
|
|
|
|
|
architecture: '语言膜 · 完整的圆 · 没有缺口',
|
|
|
|
|
|
copyright: '国作登字-2026-A-00037559',
|
|
|
|
|
|
routes: ['/api/membrane/status', '/api/membrane/bingshuo', '/api/membrane/modules', '/api/membrane/rooms', '/hli/test']
|
2026-03-07 14:36:04 +08:00
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2026-03-15 02:28:28 +08:00
|
|
|
|
// Pipeline C 广播推送 webhook → 转发到 feishu-bot 路由
|
|
|
|
|
|
app.post('/webhook/push-broadcast', (req, res, next) => {
|
|
|
|
|
|
req.url = '/push-broadcast';
|
|
|
|
|
|
feishuBotRoutes(req, res, next);
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2026-03-07 14:36:04 +08:00
|
|
|
|
const PORT = process.env.PORT || 3000;
|
2026-03-12 01:12:52 +08:00
|
|
|
|
// 飞书 Webhook 处理(旧版兼容入口,新事件请使用 /feishu-bot/event)
|
2026-03-07 14:36:04 +08:00
|
|
|
|
app.post('/webhook/feishu', (req, res) => {
|
|
|
|
|
|
if (req.body.challenge) {
|
|
|
|
|
|
return res.json({ challenge: req.body.challenge });
|
|
|
|
|
|
}
|
|
|
|
|
|
res.json({ message: 'received' });
|
|
|
|
|
|
});
|
|
|
|
|
|
app.listen(PORT, () => {
|
|
|
|
|
|
console.log(`🚀 服务启动成功,端口:${PORT}`);
|
|
|
|
|
|
});
|