Browse Source

rename-bridge-logs-dsh-pro-to-dsh-memory

master
Serge Shutov 2 weeks ago
parent
commit
aa883d975f
  1. 2
      bridge/guard.js
  2. 4
      bridge/handoff.js
  3. 16
      bridge/server.js
  4. 2
      bridge/tools.js

2
bridge/guard.js

@ -1,5 +1,5 @@
'use strict'; 'use strict';
// DSH PRO - guard.js // DSH memory - guard.js
// 安全核心:workspace 白名单、路径规范化、.. 逃逸拒绝、符号链接逃逸拒绝、敏感文件名单。 // 安全核心:workspace 白名单、路径规范化、.. 逃逸拒绝、符号链接逃逸拒绝、敏感文件名单。
// 校验链:resolve -> 拒绝 .. / 绝对路径 -> realpath 前缀必须落在 allowedRoots -> 写操作逐段 lstat 拒符号链接 -> 敏感名单。 // 校验链:resolve -> 拒绝 .. / 绝对路径 -> realpath 前缀必须落在 allowedRoots -> 写操作逐段 lstat 拒符号链接 -> 敏感名单。

4
bridge/handoff.js

@ -1,5 +1,5 @@
'use strict'; 'use strict';
// DSH PRO - handoff.js // DSH memory - handoff.js
// 计划落盘 .dsh-memory/ -> spawn `dsh --profile headless "…"` -> 输出采集 -> runs/<runId>.json 持久真源。 // 计划落盘 .dsh-memory/ -> spawn `dsh --profile headless "…"` -> 输出采集 -> runs/<runId>.json 持久真源。
// 串行队列:同时最多 1 个 dsh handoff。扩展通过 GET /handoff/:runId 轮询。 // 串行队列:同时最多 1 个 dsh handoff。扩展通过 GET /handoff/:runId 轮询。
@ -76,7 +76,7 @@ function stateDir(workspace) {
function writeStatus(workspace, run) { function writeStatus(workspace, run) {
const lines = [ const lines = [
'# DSH PRO agent-status', '# DSH memory agent-status',
'', '',
`- status: ${run.status}`, `- status: ${run.status}`,
`- runId: ${run.runId}`, `- runId: ${run.runId}`,

16
bridge/server.js

@ -1,5 +1,5 @@
'use strict'; 'use strict';
// DSH PRO - server.js // DSH memory - server.js
// 本地桥接服务:HTTP 路由 + Bearer token 鉴权 + 限流 + 审计。 // 本地桥接服务:HTTP 路由 + Bearer token 鉴权 + 限流 + 审计。
// 仅绑定 127.0.0.1。零 npm 依赖。启动:node server.js(需先在 config.json 填写 token)。 // 仅绑定 127.0.0.1。零 npm 依赖。启动:node server.js(需先在 config.json 填写 token)。
// 预留 /mcp 路由分支:将来可在同一 handler 层挂 streamable-HTTP MCP 端点, // 预留 /mcp 路由分支:将来可在同一 handler 层挂 streamable-HTTP MCP 端点,
@ -22,11 +22,11 @@ let config;
try { try {
config = loadConfig(BRIDGE_DIR); config = loadConfig(BRIDGE_DIR);
} catch (err) { } catch (err) {
console.error('[DSH PRO] config load failed:', err.message); console.error('[DSH memory] config load failed:', err.message);
process.exit(1); process.exit(1);
} }
if (!config.token || String(config.token).length < 32) { if (!config.token || String(config.token).length < 32) {
console.error('[DSH bridge] STARTUP: token missing or short, exiting'); console.error('[DSH memory] STARTUP: token missing or short, exiting');
process.exit(1); process.exit(1);
} }
@ -385,21 +385,21 @@ const server = http.createServer(async (req, res) => {
}); });
server.listen(config.port, '127.0.0.1', () => { server.listen(config.port, '127.0.0.1', () => {
console.log(`[DSH PRO] bridge listening on http://127.0.0.1:${config.port}`); console.log(`[DSH memory] bridge listening on http://127.0.0.1:${config.port}`);
// ensureStateDir on startup: create .dsh-memory/ in every allowedRoot // ensureStateDir on startup: create .dsh-memory/ in every allowedRoot
for (const root of config.allowedRoots) { for (const root of config.allowedRoots) {
const sd = stateDir.ensureStateDir(root); const sd = stateDir.ensureStateDir(root);
if (sd) console.log('[DSH memory] state dir ready: ' + sd); if (sd) console.log('[DSH memory] state dir ready: ' + sd);
else console.log('[DSH memory] state dir failed for root: ' + root); else console.log('[DSH memory] state dir failed for root: ' + root);
} }
console.log(`[DSH PRO] allowedRoots: ${config.allowedRoots.join(' ; ')}`); console.log(`[DSH memory] allowedRoots: ${config.allowedRoots.join(' ; ')}`);
const probe = dshProbe(config); const probe = dshProbe(config);
console.log(`[DSH PRO] dsh runtime: ${probe.binFound ? 'found' : 'NOT FOUND'} (${probe.bin || '-'})`); console.log(`[DSH memory] dsh runtime: ${probe.binFound ? 'found' : 'NOT FOUND'} (${probe.bin || '-'})`);
}); });
process.on('uncaughtException', (err) => { process.on('uncaughtException', (err) => {
console.error('[DSH PRO] uncaught:', err && err.stack); console.error('[DSH memory] uncaught:', err && err.stack);
}); });
process.on('unhandledRejection', (err) => { process.on('unhandledRejection', (err) => {
console.error('[DSH PRO] unhandledRejection:', String(err)); console.error('[DSH memory] unhandledRejection:', String(err));
}); });

2
bridge/tools.js

@ -1,5 +1,5 @@
'use strict'; 'use strict';
// DSH PRO - tools.js // DSH memory - tools.js
// 10 个工具实现:dsh_tree / dsh_read / dsh_write / dsh_edit / dsh_search / dsh_bash / // 10 个工具实现:dsh_tree / dsh_read / dsh_write / dsh_edit / dsh_search / dsh_bash /
// dsh_git_status / dsh_git_diff / dsh_handoff / dsh_log // dsh_git_status / dsh_git_diff / dsh_handoff / dsh_log
// 所有路径均为 workspace 相对路径,经 guard.validatePath 校验。 // 所有路径均为 workspace 相对路径,经 guard.validatePath 校验。

Loading…
Cancel
Save