2026-03-25 16:10:58 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 🔗 光湖后端中间层 · 通道B 入口
|
|
|
|
|
|
*
|
|
|
|
|
|
* 实时调用 Notion API / GitHub API,为前端提供数据代理。
|
2026-03-25 16:37:56 +08:00
|
|
|
|
* 包含:读取层 + 写入层 + 意图路由 + 权限沙箱 + 认知引导 + 执行保护
|
2026-03-25 16:10:58 +08:00
|
|
|
|
* 只监听 127.0.0.1,通过 Nginx 反向代理对外暴露。
|
|
|
|
|
|
*
|
|
|
|
|
|
* 版权:国作登字-2026-A-00037559
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
|
|
const express = require('express');
|
|
|
|
|
|
const cors = require('cors');
|
2026-03-25 16:37:56 +08:00
|
|
|
|
const executionLock = require('./middleware/execution-lock');
|
2026-03-25 17:18:52 +08:00
|
|
|
|
const skyeyeReview = require('./middleware/skyeye-review');
|
2026-03-25 16:37:56 +08:00
|
|
|
|
const watchdog = require('./services/execution-watchdog');
|
2026-03-25 16:10:58 +08:00
|
|
|
|
|
|
|
|
|
|
const app = express();
|
|
|
|
|
|
|
|
|
|
|
|
// CORS:只允许自己的域名
|
|
|
|
|
|
app.use(cors({
|
|
|
|
|
|
origin: [
|
|
|
|
|
|
'https://guanghulab.com',
|
|
|
|
|
|
'https://www.guanghulab.com',
|
|
|
|
|
|
'https://qinfendebingshuo.github.io'
|
|
|
|
|
|
],
|
|
|
|
|
|
credentials: true
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
app.use(express.json());
|
|
|
|
|
|
|
2026-03-25 16:37:56 +08:00
|
|
|
|
// 执行锁取消拦截(全局中间件,在所有路由之前)
|
|
|
|
|
|
app.use(executionLock.blockCancellation);
|
|
|
|
|
|
|
2026-03-25 17:18:52 +08:00
|
|
|
|
// 天眼指令审核(S7/S8/S9 全局强制前置,不可关闭,不可绕过)
|
|
|
|
|
|
app.use(skyeyeReview.skyeyeReview);
|
|
|
|
|
|
|
2026-03-25 16:22:38 +08:00
|
|
|
|
// 读取类路由(公开,无需认证)
|
2026-03-25 16:10:58 +08:00
|
|
|
|
app.use('/api', require('./routes/health'));
|
|
|
|
|
|
app.use('/api', require('./routes/dev'));
|
|
|
|
|
|
app.use('/api', require('./routes/databases'));
|
|
|
|
|
|
app.use('/api', require('./routes/chat'));
|
|
|
|
|
|
app.use('/api', require('./routes/receipt'));
|
|
|
|
|
|
|
2026-03-25 17:47:52 +08:00
|
|
|
|
// 开发者编号免配置登录路由
|
|
|
|
|
|
app.use('/api', require('./routes/auth'));
|
|
|
|
|
|
|
2026-03-25 16:22:38 +08:00
|
|
|
|
// 写入类路由(需认证 + 权限 + 审计)
|
|
|
|
|
|
app.use('/api', require('./routes/write'));
|
|
|
|
|
|
|
|
|
|
|
|
// 认知引导 + 工具列表路由
|
|
|
|
|
|
app.use('/api', require('./routes/onboarding'));
|
|
|
|
|
|
|
2026-03-25 16:37:56 +08:00
|
|
|
|
// 执行状态查询路由(需认证)
|
|
|
|
|
|
app.use('/api/execution', require('./routes/execution'));
|
|
|
|
|
|
|
2026-03-25 16:48:50 +08:00
|
|
|
|
// 部署授权流程路由(需认证)
|
|
|
|
|
|
app.use('/api/approval', require('./routes/approval'));
|
|
|
|
|
|
|
2026-03-26 13:00:00 +08:00
|
|
|
|
// 行业代表制路由(需认证)
|
|
|
|
|
|
app.use('/api', require('./routes/industry'));
|
|
|
|
|
|
|
2026-03-25 16:10:58 +08:00
|
|
|
|
// 根路由
|
|
|
|
|
|
app.get('/', function(_req, res) {
|
|
|
|
|
|
res.json({
|
|
|
|
|
|
status: 'ok',
|
|
|
|
|
|
service: 'guanghu-api-server',
|
2026-03-25 17:18:52 +08:00
|
|
|
|
version: '5.0.0',
|
2026-03-25 16:10:58 +08:00
|
|
|
|
channel: 'B',
|
2026-03-25 16:22:38 +08:00
|
|
|
|
description: '光湖后端中间层 · 语言驱动操作系统',
|
2026-03-25 16:48:50 +08:00
|
|
|
|
capabilities: [
|
|
|
|
|
|
'read', 'write', 'intent-routing', 'permission-sandbox',
|
2026-03-25 17:18:52 +08:00
|
|
|
|
'onboarding', 'execution-guard', 'approval-flow', 'autonomy',
|
|
|
|
|
|
'skyeye-review', 'identity-verification'
|
2026-03-25 16:48:50 +08:00
|
|
|
|
]
|
2026-03-25 16:10:58 +08:00
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const PORT = process.env.PORT || 3001;
|
|
|
|
|
|
app.listen(PORT, '127.0.0.1', function() {
|
|
|
|
|
|
console.log('🔗 光湖后端中间层启动 · 端口 ' + PORT);
|
2026-03-25 17:18:52 +08:00
|
|
|
|
console.log(' 通道B · 语言驱动操作系统 v5.0.0');
|
|
|
|
|
|
console.log(' 能力:读取 + 写入 + 意图路由 + 权限沙箱 + 认知引导 + 执行保护 + 授权流程 + 系统自治 + 天眼审核 + 身份验证');
|
2026-03-25 16:10:58 +08:00
|
|
|
|
console.log(' 监听地址:127.0.0.1:' + PORT + '(仅本机访问)');
|
2026-03-25 16:37:56 +08:00
|
|
|
|
|
|
|
|
|
|
// 启动执行看门狗
|
|
|
|
|
|
watchdog.startWatchdog();
|
2026-03-25 16:10:58 +08:00
|
|
|
|
});
|