feat: add HoloLake personal channel module runtime

This commit is contained in:
冰朔 2026-08-09 14:14:07 +08:00
commit a106b23f9b
21 changed files with 786 additions and 31 deletions

View file

@ -13,6 +13,7 @@ import { projectHumanKnowledgeTree } from './language-protocol-kernel.js';
import path from 'path';
import fs from 'fs';
import crypto from 'crypto';
import { MODULE_REGISTRY } from './channel-runtime.js';
// __dirname 兼容 CJS 和 ESM
const _dirname = typeof __dirname !== 'undefined' ? __dirname : process.cwd();
@ -44,7 +45,7 @@ const p = (v: unknown): string => Array.isArray(v) ? v.join('/') : String(v);
app.get('/api/health', (_req, res) => {
res.json({
module: 'guanghu-knowledge-base',
version: '0.1.0',
version: '0.8.0',
engine: 'git',
repo: REPO_PATH,
status: 'online',
@ -52,6 +53,38 @@ app.get('/api/health', (_req, res) => {
});
});
// ─── 初始化频道与模块运行时 ───
app.get('/api/modules', (_req, res) => {
res.json({ ok: true, registry: MODULE_REGISTRY });
});
app.get('/api/channel', async (_req, res) => {
try {
res.json({ ok: true, channel: await engine.getChannelState() });
} catch (err: any) {
res.status(500).json({ ok: false, error: err.message });
}
});
app.post('/api/channel/patch', async (req, res) => {
try {
const receipt = await engine.applyChannelPatch(req.body);
res.json({ ok: true, channel: receipt.after, receipt });
} catch (err: any) {
res.status(400).json({ ok: false, error: err.message });
}
});
app.post('/api/channel/undo/:receiptId', async (req, res) => {
try {
const receipt = await engine.undoChannelPatch(req.params.receiptId);
res.json({ ok: true, channel: receipt.after, receipt });
} catch (err: any) {
res.status(409).json({ ok: false, error: err.message });
}
});
// ─── 文档树 ───
app.get('/api/tree', async (_req, res) => {