@furongjun1999/dsh-memory 0.9.15 → 0.9.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +85 -0
- package/README.md +15 -109
- package/lib/hooks.js +5 -0
- package/lib/lib/console_web.mjs +11 -3
- package/lib/lib/hook_audit.d.ts +15 -0
- package/lib/lib/hook_audit.js +28 -0
- package/md_cg/config_registry.py +28 -0
- package/md_cg/mcp_server.py +9 -0
- package/md_cg/mdcg.py +10 -2
- package/md_cg/mdcos.py +40 -12
- package/md_cg/security.py +18 -2
- package/md_cg/test_config_registry_silent_fallback.py +90 -0
- package/md_cg/test_generation_guard.py +2 -1
- package/md_cg/test_i50c_meta_passthrough.py +3 -3
- package/md_cg/test_issue708_writegate_observable.py +141 -0
- package/md_cg/test_issue709_review_chain_enforce.py +132 -0
- package/md_cg/writegate.py +37 -0
- package/package.json +1 -1
- package/src/hooks.ts +5 -0
- package/src/lib/console_web.mjs +11 -3
- package/src/lib/hook_audit.ts +34 -1
- package/ui/minimal/integrity.json +2 -2
- package/ui/minimal/payload/lib/lib/console_web.mjs +11 -3
- package/ui/minimal/payload/src/lib/console_web.mjs +11 -3
|
@@ -28,14 +28,21 @@ async function readBody(req) {
|
|
|
28
28
|
try { return JSON.parse(Buffer.concat(chunks).toString('utf8')); }
|
|
29
29
|
catch { throw Object.assign(new Error('请求必须是有效 JSON'), { status: 400 }); }
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
// issue #699(2026-10-28):第 4 参改为**取值函数**。原实现由挂载点 `ctx.get('connection')` 取值,
|
|
32
|
+
// 而 cordis 的 `Context.get(name, strict=true)` 在服务 fiber 未就绪时返回 undefined ⇒
|
|
33
|
+
// 空值被闭包固化,此后每次请求都命中 503「宿主鉴权不可用」,宿主就绪也不会自愈。
|
|
34
|
+
// 现在改为**每次请求实时取**:服务晚到也能自愈。
|
|
35
|
+
// 兼容:传的不是函数(旧调用方式/直接给实例)时按常量包裹,行为与旧版一致。
|
|
36
|
+
export function createConsoleHandler(mdcg, config, assets, getConnection) {
|
|
37
|
+
const connectionOf = typeof getConnection === 'function' ? getConnection : () => getConnection
|
|
32
38
|
const csrf = randomBytes(32).toString('hex');
|
|
33
39
|
let catalog = null;
|
|
34
40
|
const tools = async () => catalog ?? (catalog = await mdcg.bridge.listTools());
|
|
35
41
|
return async (req, res) => {
|
|
36
42
|
try {
|
|
37
43
|
const path = new URL(req.url, 'http://localhost').pathname;
|
|
38
|
-
|
|
44
|
+
const connection = connectionOf()
|
|
45
|
+
if (!connection || typeof connection.admit !== 'function') return reply(res, 503, { error: '宿主鉴权服务尚未就绪,请稍后重试' });
|
|
39
46
|
const admission = connection.admit(req);
|
|
40
47
|
if ('rejection' in admission) return reply(res, admission.rejection, { error: admission.rejection === 401 ? '未登录,请返回 DSH 登录' : '请求来源不可信' });
|
|
41
48
|
if (req.method === 'GET' && assets[path]) {
|
|
@@ -88,7 +95,8 @@ export function installConsoleWeb(ctx, config, disposers, mdcg) {
|
|
|
88
95
|
'/plugins/lingshu/style.css': [asset('style.css'), 'text/css; charset=utf-8'],
|
|
89
96
|
'/plugins/lingshu/entry.js': [asset('entry.js'), 'application/javascript; charset=utf-8'],
|
|
90
97
|
};
|
|
91
|
-
|
|
98
|
+
// issue #699:传**取值函数**(每次请求实时取),不再把挂载瞬间的值闭包固化。
|
|
99
|
+
const handler = createConsoleHandler(mdcg, config, assets, () => ctx.get('connection'));
|
|
92
100
|
for (const path of ['/lingshu', '/lingshu/', '/plugins/lingshu']) disposers.push(web.register({ kind: path === '/plugins/lingshu' ? 'prefix' : 'exact', path, handler }));
|
|
93
101
|
disposers.push(web.tapIndex(html => html.includes('data-lingshu-entry') ? html : html.replace('</body>', '<script data-lingshu-entry src="/plugins/lingshu/entry.js"></script></body>')));
|
|
94
102
|
ctx.logger.info('dsh-memory: 极简灵枢控制台已挂载 /lingshu(复用唯一大脑桥)');
|
|
@@ -28,14 +28,21 @@ async function readBody(req) {
|
|
|
28
28
|
try { return JSON.parse(Buffer.concat(chunks).toString('utf8')); }
|
|
29
29
|
catch { throw Object.assign(new Error('请求必须是有效 JSON'), { status: 400 }); }
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
// issue #699(2026-10-28):第 4 参改为**取值函数**。原实现由挂载点 `ctx.get('connection')` 取值,
|
|
32
|
+
// 而 cordis 的 `Context.get(name, strict=true)` 在服务 fiber 未就绪时返回 undefined ⇒
|
|
33
|
+
// 空值被闭包固化,此后每次请求都命中 503「宿主鉴权不可用」,宿主就绪也不会自愈。
|
|
34
|
+
// 现在改为**每次请求实时取**:服务晚到也能自愈。
|
|
35
|
+
// 兼容:传的不是函数(旧调用方式/直接给实例)时按常量包裹,行为与旧版一致。
|
|
36
|
+
export function createConsoleHandler(mdcg, config, assets, getConnection) {
|
|
37
|
+
const connectionOf = typeof getConnection === 'function' ? getConnection : () => getConnection
|
|
32
38
|
const csrf = randomBytes(32).toString('hex');
|
|
33
39
|
let catalog = null;
|
|
34
40
|
const tools = async () => catalog ?? (catalog = await mdcg.bridge.listTools());
|
|
35
41
|
return async (req, res) => {
|
|
36
42
|
try {
|
|
37
43
|
const path = new URL(req.url, 'http://localhost').pathname;
|
|
38
|
-
|
|
44
|
+
const connection = connectionOf()
|
|
45
|
+
if (!connection || typeof connection.admit !== 'function') return reply(res, 503, { error: '宿主鉴权服务尚未就绪,请稍后重试' });
|
|
39
46
|
const admission = connection.admit(req);
|
|
40
47
|
if ('rejection' in admission) return reply(res, admission.rejection, { error: admission.rejection === 401 ? '未登录,请返回 DSH 登录' : '请求来源不可信' });
|
|
41
48
|
if (req.method === 'GET' && assets[path]) {
|
|
@@ -88,7 +95,8 @@ export function installConsoleWeb(ctx, config, disposers, mdcg) {
|
|
|
88
95
|
'/plugins/lingshu/style.css': [asset('style.css'), 'text/css; charset=utf-8'],
|
|
89
96
|
'/plugins/lingshu/entry.js': [asset('entry.js'), 'application/javascript; charset=utf-8'],
|
|
90
97
|
};
|
|
91
|
-
|
|
98
|
+
// issue #699:传**取值函数**(每次请求实时取),不再把挂载瞬间的值闭包固化。
|
|
99
|
+
const handler = createConsoleHandler(mdcg, config, assets, () => ctx.get('connection'));
|
|
92
100
|
for (const path of ['/lingshu', '/lingshu/', '/plugins/lingshu']) disposers.push(web.register({ kind: path === '/plugins/lingshu' ? 'prefix' : 'exact', path, handler }));
|
|
93
101
|
disposers.push(web.tapIndex(html => html.includes('data-lingshu-entry') ? html : html.replace('</body>', '<script data-lingshu-entry src="/plugins/lingshu/entry.js"></script></body>')));
|
|
94
102
|
ctx.logger.info('dsh-memory: 极简灵枢控制台已挂载 /lingshu(复用唯一大脑桥)');
|