@furongjun1999/dsh-memory 0.2.7 → 0.2.9

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.
@@ -0,0 +1,213 @@
1
+ <!DOCTYPE html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>记忆系统使用性评分 · 五维标尺</title>
7
+ <style>
8
+ :root {
9
+ --gold: linear-gradient(135deg, #f7d774, #e8a33d);
10
+ --silver: linear-gradient(135deg, #e8e8e8, #b8b8b8);
11
+ --bronze: linear-gradient(135deg, #e0a878, #c07840);
12
+ --lingshu: linear-gradient(135deg, #6a5cff, #3d8bfd);
13
+ --danger: #e74c3c; --warn: #e67e22; --good: #27ae60; --excel: #2ecc71; --perf: #9b59b6;
14
+ }
15
+ * { margin:0; padding:0; box-sizing:border-box; }
16
+ body {
17
+ font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
18
+ background: linear-gradient(160deg, #0f1023 0%, #1a1c3a 50%, #0f1023 100%);
19
+ color: #e8eaf6; padding: 40px 24px; min-height: 100vh;
20
+ }
21
+ .container { max-width: 1080px; margin: 0 auto; }
22
+ /* 标题区 */
23
+ .hero {
24
+ text-align:center; margin-bottom: 36px;
25
+ background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.1);
26
+ border-radius: 20px; padding: 32px 24px;
27
+ box-shadow: 0 20px 60px rgba(0,0,0,0.4);
28
+ }
29
+ .hero h1 {
30
+ font-size: 34px; font-weight: 800; letter-spacing: 2px;
31
+ background: linear-gradient(135deg, #ffd700, #ff8c00, #ff5e62);
32
+ -webkit-background-clip: text; -webkit-text-fill-color: transparent;
33
+ margin-bottom: 10px;
34
+ }
35
+ .hero .sub { color: #aab; font-size: 15px; line-height: 1.8; }
36
+ .hero .badges { margin-top: 14px; }
37
+ .badge {
38
+ display:inline-block; padding: 5px 14px; border-radius: 20px;
39
+ font-size: 13px; margin: 3px 5px; font-weight: 600;
40
+ background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15);
41
+ }
42
+ .badge.hl { background: rgba(61,139,253,0.2); border-color: #3d8bfd; color: #7fb0ff; }
43
+ /* 五维标尺 */
44
+ .section { margin-bottom: 34px; }
45
+ .section h2 {
46
+ font-size: 20px; margin-bottom: 14px; padding-left: 12px;
47
+ border-left: 4px solid #3d8bfd; color: #dfe3ff;
48
+ }
49
+ .scale-table { width: 100%; border-collapse: separate; border-spacing: 3px; }
50
+ .scale-table th, .scale-table td {
51
+ padding: 10px 8px; text-align: center; font-size: 13px; border-radius: 8px;
52
+ background: rgba(255,255,255,0.04);
53
+ }
54
+ .scale-table th { background: rgba(61,139,253,0.15); color: #9fc0ff; font-weight: 700; }
55
+ .scale-table td.dim { font-weight: 700; color: #ffd700; background: rgba(255,215,0,0.08); white-space: nowrap; }
56
+ .scale-table td.lv0 { background: rgba(231,76,60,0.18); color:#ff8a80; }
57
+ .scale-table td.lv1 { background: rgba(231,76,60,0.12); color:#ffab91; }
58
+ .scale-table td.lv2 { background: rgba(230,126,34,0.16); color:#ffcc80; }
59
+ .scale-table td.lv3 { background: rgba(39,174,96,0.16); color:#a5d6a7; }
60
+ .scale-table td.lv4 { background: rgba(155,89,182,0.18); color:#ce93d8; }
61
+ .formula {
62
+ margin-top: 12px; text-align:center; font-size: 15px; color: #cfd8ff;
63
+ background: rgba(61,139,253,0.08); border:1px dashed #3d8bfd;
64
+ padding: 10px; border-radius: 12px;
65
+ }
66
+ .formula b { color: #ffd700; }
67
+ /* 天梯榜 */
68
+ .rank-list { display: flex; flex-direction: column; gap: 8px; }
69
+ .rank-item {
70
+ display: grid; grid-template-columns: 56px 1.1fr 90px 90px 90px 90px 90px 70px 2.2fr;
71
+ align-items: center; gap: 6px;
72
+ background: rgba(255,255,255,0.045); border: 1px solid rgba(255,255,255,0.08);
73
+ border-radius: 12px; padding: 10px 12px; font-size: 13px;
74
+ transition: transform .15s;
75
+ }
76
+ .rank-item:hover { transform: translateX(4px); }
77
+ .rank-item.top1 { background: linear-gradient(90deg, rgba(255,215,0,0.16), rgba(255,255,255,0.04)); border-color: #ffd700; box-shadow: 0 0 24px rgba(255,215,0,0.15); }
78
+ .rank-item.top2 { background: linear-gradient(90deg, rgba(200,200,200,0.14), rgba(255,255,255,0.04)); border-color: #b8b8b8; }
79
+ .rank-item.top3 { background: linear-gradient(90deg, rgba(224,168,120,0.14), rgba(255,255,255,0.04)); border-color: #c07840; }
80
+ .rank-medal { font-size: 22px; text-align:center; }
81
+ .rank-name { font-weight: 700; color: #fff; }
82
+ .rank-item.top1 .rank-name { color: #ffd700; }
83
+ .cell { text-align:center; font-weight: 600; border-radius: 6px; padding: 4px 0; }
84
+ .cell.high { color: #ffd700; }
85
+ .cell.mid { color: #a5d6a7; }
86
+ .cell.low { color: #ff8a80; }
87
+ .cell.total { font-size: 15px; color: #fff; background: rgba(61,139,253,0.2); border-radius: 8px; }
88
+ .rank-item.top1 .cell.total { background: rgba(255,215,0,0.25); color: #ffd700; font-weight: 800; }
89
+ .rank-comment { font-size: 12px; color: #b0b7d0; line-height: 1.5; }
90
+ /* 灵枢依据 */
91
+ .lingshu-card {
92
+ background: linear-gradient(135deg, rgba(106,92,255,0.12), rgba(61,139,253,0.08));
93
+ border: 1px solid rgba(106,92,255,0.4); border-radius: 16px; padding: 18px 20px;
94
+ margin-top: 14px; box-shadow: 0 10px 40px rgba(61,139,253,0.15);
95
+ }
96
+ .lingshu-card h3 { color: #8fb8ff; font-size: 16px; margin-bottom: 10px; }
97
+ .lingshu-card .dim-row { display: grid; grid-template-columns: 90px 40px 1fr; gap: 8px; margin-bottom: 6px; font-size: 13px; }
98
+ .lingshu-card .dim-row b { color: #ffd700; }
99
+ .lingshu-card .dim-row .score { text-align:center; color: #fff; font-weight: 700; }
100
+ .lingshu-card .dim-row .why { color: #c5cbe8; }
101
+ .disclaimer { margin-top: 20px; font-size: 12px; color: #8a90b0; text-align: center; line-height: 1.7; }
102
+ .footer { text-align:center; margin-top: 30px; color: #6a6f8a; font-size: 12px; }
103
+ </style>
104
+ </head>
105
+ <body>
106
+ <div class="container">
107
+
108
+ <div class="hero">
109
+ <h1>📊 记忆系统使用性评分 · 五维标尺</h1>
110
+ <div class="sub">
111
+ 视角:<b style="color:#ffd700">使用性</b>(普通用户 / 开发者体感)——「存、找、想、准、安」五维<br>
112
+ 评估基准:公开能力 + 设计者校准(2026-08-17)· 灵枢分数经设计者核对(<b style="color:#7fb0ff">不虚高</b>)
113
+ </div>
114
+ <div class="badges">
115
+ <span class="badge hl">🥇 灵枢 AEIS · 7.7 断层第一</span>
116
+ <span class="badge">使用性视角</span>
117
+ <span class="badge">短板效应显著</span>
118
+ <span class="badge">安全性是底线</span>
119
+ </div>
120
+ </div>
121
+
122
+ <div class="section">
123
+ <h2>📐 五维标尺定义</h2>
124
+ <table class="scale-table">
125
+ <tr><th>维度</th><th class="lv0">0-2 危险</th><th class="lv1">3-4 基础</th><th class="lv2">5-6 良好</th><th class="lv3">7-8 优秀</th><th class="lv4">9-10 完美</th></tr>
126
+ <tr><td class="dim">S 存储结构</td><td class="lv0">扁平 KV</td><td class="lv1">简单分层</td><td class="lv2">时序/向量</td><td class="lv3">图结构+衰减</td><td class="lv4">多模态+自动迁移</td></tr>
127
+ <tr><td class="dim">R 检索机制</td><td class="lv0">全量遍历</td><td class="lv1">关键词</td><td class="lv2">向量语义</td><td class="lv3">图遍历+混合</td><td class="lv4">因果推理+意图理解</td></tr>
128
+ <tr><td class="dim">J 判断引擎</td><td class="lv0">只记不忘</td><td class="lv1">规则过滤</td><td class="lv2">LLM 自评估</td><td class="lv3">验证单元+递归反思</td><td class="lv4">独立元认知+主动遗忘</td></tr>
129
+ <tr><td class="dim">C 上下文信噪比</td><td class="lv0">噪声爆炸</td><td class="lv1">Top-K 有噪</td><td class="lv2">时序过滤</td><td class="lv3">重要性+精准注入</td><td class="lv4">零污染</td></tr>
130
+ <tr><td class="dim">Safety</td><td class="lv0">易泄露</td><td class="lv1">基础脱敏</td><td class="lv2">分级权限</td><td class="lv3">隐私树+审计</td><td class="lv4">零信任+端到端加密</td></tr>
131
+ </table>
132
+ <div class="formula">综合分 = <b>min(五维) × 0.4</b> + <b>mean(五维) × 0.6</b> · 安全性是底线,短板效应显著</div>
133
+ </div>
134
+
135
+ <div class="section">
136
+ <h2>🏆 天梯榜</h2>
137
+ <div class="rank-list">
138
+ <div class="rank-item top1">
139
+ <div class="rank-medal">🥇</div><div class="rank-name">灵枢 AEIS</div>
140
+ <div class="cell high">7.5</div><div class="cell high">7.5</div><div class="cell high">8.0</div><div class="cell high">8.0</div><div class="cell high">8.0</div>
141
+ <div class="cell total">7.7</div>
142
+ <div class="rank-comment">五维无短板:图结构 + 三层语义检索 + 验证单元/递归反思 + 重要性评分 + 护栏宪章审计追踪</div>
143
+ </div>
144
+ <div class="rank-item top2">
145
+ <div class="rank-medal">🥈</div><div class="rank-name">Hy-Memory(腾讯)</div>
146
+ <div class="cell mid">7.5</div><div class="cell mid">7.0</div><div class="cell">6.0</div><div class="cell mid">7.0</div><div class="cell high">8.0</div>
147
+ <div class="cell total">6.6</div>
148
+ <div class="rank-comment">企业级安全标杆;缺主动反思,记忆易过时</div>
149
+ </div>
150
+ <div class="rank-item top3">
151
+ <div class="rank-medal">🥉</div><div class="rank-name">Zep / 腾讯云</div>
152
+ <div class="cell mid">7.5</div><div class="cell mid">7.0</div><div class="cell">5.5</div><div class="cell mid">6.5</div><div class="cell mid">7.5</div>
153
+ <div class="cell total">6.3</div>
154
+ <div class="rank-comment">时序图谱+权限控制;不够「聪明」</div>
155
+ </div>
156
+ <div class="rank-item">
157
+ <div class="rank-medal">4</div><div class="rank-name">Letta / MemGPT</div>
158
+ <div class="cell mid">7.5</div><div class="cell high">8.0</div><div class="cell">5.0</div><div class="cell high">8.0</div><div class="cell low">4.0</div>
159
+ <div class="cell total">5.7</div>
160
+ <div class="rank-comment">架构强但易记忆越权——权限模型复杂,风险高</div>
161
+ </div>
162
+ <div class="rank-item">
163
+ <div class="rank-medal">5</div><div class="rank-name">TiMem</div>
164
+ <div class="cell mid">7.0</div><div class="cell mid">6.5</div><div class="cell">5.0</div><div class="cell">6.0</div><div class="cell">5.0</div>
165
+ <div class="cell total">5.4</div>
166
+ <div class="rank-comment">学术派安全,缺工程级隐私治理</div>
167
+ </div>
168
+ <div class="rank-item">
169
+ <div class="rank-medal">6</div><div class="rank-name">Mem0</div>
170
+ <div class="cell">6.0</div><div class="cell">6.0</div><div class="cell">4.0</div><div class="cell">5.0</div><div class="cell low">4.0</div>
171
+ <div class="cell total">4.4</div>
172
+ <div class="rank-comment">记忆碎片化,细粒度权限缺失</div>
173
+ </div>
174
+ <div class="rank-item">
175
+ <div class="rank-medal">7</div><div class="rank-name">LangMem</div>
176
+ <div class="cell">6.0</div><div class="cell">6.0</div><div class="cell">4.0</div><div class="cell">5.0</div><div class="cell low">4.0</div>
177
+ <div class="cell total">4.4</div>
178
+ <div class="rank-comment">生态绑定 LangChain,缺独立安全治理</div>
179
+ </div>
180
+ <div class="rank-item">
181
+ <div class="rank-medal">8</div><div class="rank-name">dsh-memory-evolve</div>
182
+ <div class="cell low">3.0</div><div class="cell low">4.0</div><div class="cell low">2.0</div><div class="cell low">3.0</div><div class="cell low">2.0</div>
183
+ <div class="cell total">2.6</div>
184
+ <div class="rank-comment">无隐私/权限/删除,「只记不忘」= 隐私炸弹</div>
185
+ </div>
186
+ </div>
187
+ </div>
188
+
189
+ <div class="section">
190
+ <h2>🔍 灵枢各维度依据(设计者校准 · 不虚高)</h2>
191
+ <div class="lingshu-card">
192
+ <h3>🧠 灵枢 AEIS · 5.71MB 结构智能</h3>
193
+ <div class="dim-row"><b>S 存储</b><span class="score">7.5</span><span class="why">语义时空图(五层记忆:锚点/结构/知识/情境/自我)+ 条件空间 + 教育层级。无多模态原生(9-10 档)</span></div>
194
+ <div class="dim-row"><b>R 检索</b><span class="score">7.5</span><span class="why">三层语义检索(二元组 + 语义坐标 + bge 神经)+ 图谱遍历 + 翻译体系。无因果推理检索</span></div>
195
+ <div class="dim-row"><b>J 判断</b><span class="score">8.0</span><span class="why">验证单元(P37 三闸门)+ 递归反思(协议 3.12)+ 白箱校验 + 结构排斥。<b style="color:#7fb0ff">无主动遗忘 → 8.0 非 9.0</b></span></div>
196
+ <div class="dim-row"><b>C 信噪比</b><span class="score">8.0</span><span class="why">重要性评分 + 信息分层注入(图谱自处理→LLM 兜底→白箱校验)+ 诚实边界(不瞎编)</span></div>
197
+ <div class="dim-row"><b>Safety</b><span class="score">8.0</span><span class="why">护栏宪章(接入即接受约束)+ 审计追踪(观测层全留痕)+ 物理基底校准。<b style="color:#7fb0ff">无端到端加密 → 8.0 非 8.5</b></span></div>
198
+ </div>
199
+ <p style="text-align:center; margin-top:14px; color:#aab; font-size:14px;">
200
+ 为什么断层领先:<b style="color:#ffd700">五维无短板(min=7.5)</b>——J(验证+反思)与 Safety(宪章+审计)是护城河。<br>
201
+ 使用性视角:重要性评分 → 用户看不到废话;护栏宪章 → 用户敢把私密信息交给它。
202
+ </p>
203
+ </div>
204
+
205
+ <div class="disclaimer">
206
+ 免责声明:他系统评分基于公开能力评估(2026-08-17),非官方基准;灵枢评分经设计者校准(不虚高)。<br>
207
+ 综合分 = min × 0.4 + mean × 0.6 —— 安全性是底线,短板效应显著。
208
+ </div>
209
+ <div class="footer">灵枢 AEIS · 共同信任协议(Common Trust Protocol)· 智能论 v3.2 工程实现</div>
210
+
211
+ </div>
212
+ </body>
213
+ </html>
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/lib/bridge.d.ts CHANGED
@@ -62,6 +62,8 @@ export declare class LingshuBridge {
62
62
  dispose(): void;
63
63
  /** 进程是否存活。 */
64
64
  get alive(): boolean;
65
+ /** 桥是否已握手就绪(工具注册用;防止轮询访问 private readyState)。 */
66
+ isReady(): boolean;
65
67
  /** 等待握手完成(用于 apply 阶段同步就绪)。 */
66
68
  waitReady(): Promise<boolean>;
67
69
  private spawnAndHandshake;
package/lib/bridge.js CHANGED
@@ -67,6 +67,10 @@ export class LingshuBridge {
67
67
  get alive() {
68
68
  return this.proc !== null && this.proc.exitCode === null;
69
69
  }
70
+ /** 桥是否已握手就绪(工具注册用;防止轮询访问 private readyState)。 */
71
+ isReady() {
72
+ return this.readyState === 'ok';
73
+ }
70
74
  /** 等待握手完成(用于 apply 阶段同步就绪)。 */
71
75
  waitReady() {
72
76
  if (this.readyState === 'ok')
package/lib/index.js CHANGED
@@ -20,9 +20,10 @@ import z from '@deepseek-ai/schemastery';
20
20
  import { LingshuBridge } from './bridge.js';
21
21
  import { registerLingshuTools } from './tools.js';
22
22
  import { installMemoryHooks } from './hooks.js';
23
+ import { installRoleplayWeb } from './roleplay_web.js';
23
24
  export const name = 'dsh-memory';
24
25
  /** 本插件依赖的工具注册服务。 */
25
- export const inject = ['tools', 'timer'];
26
+ export const inject = ['tools', 'timer', 'webServer'];
26
27
  export const Config = z.object({
27
28
  serverName: z.string().default('lingshu'),
28
29
  python: z.string().default('python'),
@@ -81,14 +82,34 @@ export async function apply(ctx, config) {
81
82
  }
82
83
  const disposers = [];
83
84
  try {
84
- // 工具注册(就绪后执行;未就绪时 tools/list 会报错,由重连机制兜底)
85
- if (ready) {
86
- disposers.push(await registerLingshuTools(ctx, bridge, {
87
- selection: config.tools,
88
- toolPrefix: `${config.serverName}_`,
89
- }));
85
+ // 工具注册:初始就绪立即注册;若启动时未就绪(python 暂不可用/aeis 未装等
86
+ // 竞态),桥重连成功后自动补注册——修复"工具永久缺失"问题。
87
+ let toolsRegistered = false;
88
+ const tryRegister = async () => {
89
+ if (toolsRegistered || !bridge.isReady())
90
+ return;
91
+ try {
92
+ const dispose = await registerLingshuTools(ctx, bridge, {
93
+ selection: config.tools,
94
+ toolPrefix: `${config.serverName}_`,
95
+ });
96
+ disposers.push(dispose);
97
+ toolsRegistered = true;
98
+ ctx.logger.info('dsh-memory: 灵枢工具已注册(就绪后补注册)');
99
+ }
100
+ catch (err) {
101
+ ctx.logger.warn(`dsh-memory: 工具注册失败,稍后重试: ${String(err)}`);
102
+ }
103
+ };
104
+ if (ready)
105
+ await tryRegister();
106
+ if (!toolsRegistered) {
107
+ const poll = setInterval(() => { void tryRegister(); }, 2000);
108
+ disposers.push(() => clearInterval(poll));
90
109
  }
91
110
  installMemoryHooks(ctx, bridge, config.memory);
111
+ // 角色扮演网页(同源挂载 /roleplay,复用本插件 bridge)
112
+ await installRoleplayWeb(ctx, bridge, config, disposers);
92
113
  // 互维维护(v1.1):心跳写戳 + 守护 A + 任务验证双通道
93
114
  if (config.mutual.enabled) {
94
115
  const { installMutualMaintenance } = await import('./mutual.js');
@@ -0,0 +1,2 @@
1
+ /** 在 webServer 上挂载 /roleplay 前缀路由(页面 + API)。失败不影响插件主体。 */
2
+ export declare function installRoleplayWeb(ctx: any, bridge: any, config: any, disposers: any): Promise<void>;