dsh-prime-memory 0.11.0
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.en.md +28 -0
- package/CHANGELOG.ja.md +30 -0
- package/CHANGELOG.ko.md +30 -0
- package/CHANGELOG.md +1220 -0
- package/ENGINEERING-NOTES.md +452 -0
- package/INSTALL.en.md +92 -0
- package/INSTALL.ja.md +92 -0
- package/INSTALL.ko.md +92 -0
- package/INSTALL.md +92 -0
- package/LICENSE +21 -0
- package/README.en.md +458 -0
- package/README.ja.md +306 -0
- package/README.ko.md +306 -0
- package/README.md +425 -0
- package/assets/changelog/0.8.10/01-write-only-pill.png +0 -0
- package/assets/changelog/0.8.9/01-panel.png +0 -0
- package/assets/changelog/0.8.9/02-halo.png +0 -0
- package/assets/changelog/0.8.9/03-layer-segmented-panel.png +0 -0
- package/assets/changelog/0.8.9/04-layer-l1-panel.png +0 -0
- package/assets/img/EmbeddingSource.png +0 -0
- package/assets/img/Hero.png +0 -0
- package/assets/img/Layers.png +0 -0
- package/assets/img/MemoryTools.png +0 -0
- package/assets/img/Modes.png +0 -0
- package/assets/img/ToolTrajectory.png +0 -0
- package/assets/img/ui-dark.jpg +0 -0
- package/assets/img/ui-light.jpg +0 -0
- package/assets/readme/bench-dialog.svg +70 -0
- package/assets/readme/bench-workflow.svg +79 -0
- package/assets/readme/flow.svg +189 -0
- package/assets/readme/storage.svg +115 -0
- package/cordis.patch.yml +16 -0
- package/dist/bench-control.d.ts +34 -0
- package/dist/bench-control.js +16 -0
- package/dist/client.js +4293 -0
- package/dist/config.d.ts +683 -0
- package/dist/config.js +129 -0
- package/dist/contract.d.ts +820 -0
- package/dist/contract.js +1 -0
- package/dist/embedding-worker.cjs +176 -0
- package/dist/graph/apply.d.ts +37 -0
- package/dist/graph/apply.js +270 -0
- package/dist/graph/constraints.d.ts +47 -0
- package/dist/graph/constraints.js +38 -0
- package/dist/graph/search.d.ts +16 -0
- package/dist/graph/search.js +115 -0
- package/dist/graph/types.d.ts +142 -0
- package/dist/graph/types.js +14 -0
- package/dist/hooks/capture.d.ts +32 -0
- package/dist/hooks/capture.js +194 -0
- package/dist/hooks/recall.d.ts +63 -0
- package/dist/hooks/recall.js +429 -0
- package/dist/index.d.ts +534 -0
- package/dist/index.js +344 -0
- package/dist/llm-usage.d.ts +26 -0
- package/dist/llm-usage.js +37 -0
- package/dist/llm.d.ts +153 -0
- package/dist/llm.js +530 -0
- package/dist/pipeline/graph.d.ts +35 -0
- package/dist/pipeline/graph.js +104 -0
- package/dist/pipeline/l1.d.ts +19 -0
- package/dist/pipeline/l1.js +271 -0
- package/dist/pipeline/l2.d.ts +13 -0
- package/dist/pipeline/l2.js +83 -0
- package/dist/pipeline/l3.d.ts +15 -0
- package/dist/pipeline/l3.js +78 -0
- package/dist/pipeline/rebuild.d.ts +61 -0
- package/dist/pipeline/rebuild.js +307 -0
- package/dist/pipeline/ruminate.d.ts +89 -0
- package/dist/pipeline/ruminate.js +298 -0
- package/dist/pipeline/runner.d.ts +167 -0
- package/dist/pipeline/runner.js +638 -0
- package/dist/pipeline/trigger.d.ts +40 -0
- package/dist/pipeline/trigger.js +75 -0
- package/dist/prompts/graph-projection.d.ts +70 -0
- package/dist/prompts/graph-projection.js +167 -0
- package/dist/prompts/l1-dedup.d.ts +22 -0
- package/dist/prompts/l1-dedup.js +251 -0
- package/dist/prompts/l1-extraction.d.ts +22 -0
- package/dist/prompts/l1-extraction.js +457 -0
- package/dist/prompts/persona.d.ts +23 -0
- package/dist/prompts/persona.js +240 -0
- package/dist/prompts/scene.d.ts +32 -0
- package/dist/prompts/scene.js +414 -0
- package/dist/runtime-package-lock.json +982 -0
- package/dist/settings.d.ts +50 -0
- package/dist/settings.js +355 -0
- package/dist/stats.d.ts +109 -0
- package/dist/stats.js +929 -0
- package/dist/store/bm25.d.ts +19 -0
- package/dist/store/bm25.js +63 -0
- package/dist/store/cost-ledger.d.ts +75 -0
- package/dist/store/cost-ledger.js +171 -0
- package/dist/store/download-queue.d.ts +79 -0
- package/dist/store/download-queue.js +424 -0
- package/dist/store/embedding-source.d.ts +118 -0
- package/dist/store/embedding-source.js +443 -0
- package/dist/store/embedding.d.ts +90 -0
- package/dist/store/embedding.js +206 -0
- package/dist/store/graph-store.d.ts +94 -0
- package/dist/store/graph-store.js +641 -0
- package/dist/store/l0.d.ts +40 -0
- package/dist/store/l0.js +197 -0
- package/dist/store/l1.d.ts +93 -0
- package/dist/store/l1.js +297 -0
- package/dist/store/local-embedding.d.ts +89 -0
- package/dist/store/local-embedding.js +227 -0
- package/dist/store/model-catalog.d.ts +48 -0
- package/dist/store/model-catalog.js +81 -0
- package/dist/store/occupancy.d.ts +30 -0
- package/dist/store/occupancy.js +134 -0
- package/dist/store/pending.d.ts +36 -0
- package/dist/store/pending.js +103 -0
- package/dist/store/persona.d.ts +15 -0
- package/dist/store/persona.js +60 -0
- package/dist/store/recall-dedupe.d.ts +26 -0
- package/dist/store/recall-dedupe.js +138 -0
- package/dist/store/runtime-installer.d.ts +59 -0
- package/dist/store/runtime-installer.js +243 -0
- package/dist/store/scenes.d.ts +24 -0
- package/dist/store/scenes.js +160 -0
- package/dist/store/search-utils.d.ts +38 -0
- package/dist/store/search-utils.js +100 -0
- package/dist/store/session-modes.d.ts +35 -0
- package/dist/store/session-modes.js +144 -0
- package/dist/store/sqlite.d.ts +246 -0
- package/dist/store/sqlite.js +1491 -0
- package/dist/store/state.d.ts +41 -0
- package/dist/store/state.js +72 -0
- package/dist/token-cost.d.ts +23 -0
- package/dist/token-cost.js +185 -0
- package/dist/tools/index.d.ts +34 -0
- package/dist/tools/index.js +758 -0
- package/dist/types.d.ts +139 -0
- package/dist/types.js +38 -0
- package/dist/util/context-occupancy.d.ts +68 -0
- package/dist/util/context-occupancy.js +92 -0
- package/dist/util/filelog.d.ts +6 -0
- package/dist/util/filelog.js +108 -0
- package/dist/util/io.d.ts +18 -0
- package/dist/util/io.js +97 -0
- package/dist/util/recall-budget.d.ts +31 -0
- package/dist/util/recall-budget.js +84 -0
- package/dist/util/sanitize.d.ts +11 -0
- package/dist/util/sanitize.js +67 -0
- package/dist/util/text.d.ts +16 -0
- package/dist/util/text.js +61 -0
- package/dist/util/tokenizer.d.ts +9 -0
- package/dist/util/tokenizer.js +50 -0
- package/dsh.plugin.json +22 -0
- package/package.json +118 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg"
|
|
2
|
+
width="1200" height="660" viewBox="0 0 1200 660"
|
|
3
|
+
role="img" aria-labelledby="benchWorkflowTitle benchWorkflowDesc">
|
|
4
|
+
<title id="benchWorkflowTitle">DSH-MemBench 工作流赛道:A/B 两组完成度与成本对照</title>
|
|
5
|
+
<desc id="benchWorkflowDesc">真实工具沙箱(7 场景,A 组 3 轮 / B 组 1 轮)探针段合计:任务完成度 A 组 59/69(85.5%)对 B 组 10/23(43.5%);成本对比以 B 组为满格基准(每场景均值),A 组相对更省——步骤 24.3 对 41.4(B +70%)、工具调用 37.7 对 62.1(B +65%)、输入 token 266k 对 1.81M(B 6.8 倍);风格规范场景探针 A 12/12 对 B 0/4;向用户求助 A 组 3 轮共 1 次、B 组 1 轮 1 次。</desc>
|
|
6
|
+
|
|
7
|
+
<rect width="1200" height="660" rx="26" fill="#0D1526"/>
|
|
8
|
+
|
|
9
|
+
<g font-family="-apple-system,BlinkMacSystemFont,'Segoe UI','PingFang SC','Microsoft YaHei',sans-serif">
|
|
10
|
+
|
|
11
|
+
<!-- ── 标题与图例 ── -->
|
|
12
|
+
<text x="64" y="66" font-size="26" font-weight="700" fill="#EFF3FA">工作流赛道:真实工具沙箱 · 做得对,也更省</text>
|
|
13
|
+
<text x="64" y="94" font-size="18" fill="#8296B3">7 场景 · A 组 3 轮 / B 组 1 轮(成本护栏)· 探针段合计 · 成本行以 B 组为满格基准</text>
|
|
14
|
+
|
|
15
|
+
<rect x="842" y="50" width="18" height="18" rx="5" fill="#FFD15D"/>
|
|
16
|
+
<text x="868" y="65" font-size="18" fill="#C2CDDE">A 组 · 记忆开</text>
|
|
17
|
+
<rect x="842" y="76" width="18" height="18" rx="5" fill="#4E6DA8"/>
|
|
18
|
+
<text x="868" y="91" font-size="18" fill="#C2CDDE">B 组 · 记忆关</text>
|
|
19
|
+
|
|
20
|
+
<!-- ── 探针段完成度 ── -->
|
|
21
|
+
<text x="64" y="152" font-size="20" font-weight="700" fill="#EFF3FA">探针段完成度</text>
|
|
22
|
+
<text x="216" y="152" font-size="17" fill="#8296B3">(新会话延续任务,产物程序化校验)</text>
|
|
23
|
+
|
|
24
|
+
<rect x="260" y="170" width="598" height="26" rx="6" fill="#FFD15D"/>
|
|
25
|
+
<text x="872" y="191" font-size="22" font-weight="700" fill="#FFD15D">59/69 · 85.5%</text>
|
|
26
|
+
<rect x="260" y="206" width="304" height="26" rx="6" fill="#4E6DA8"/>
|
|
27
|
+
<text x="578" y="227" font-size="22" font-weight="700" fill="#8FA6C6">10/23 · 43.5%</text>
|
|
28
|
+
|
|
29
|
+
<line x1="64" y1="258" x2="1136" y2="258" stroke="#263A5C" stroke-width="1.5"/>
|
|
30
|
+
|
|
31
|
+
<!-- ── 成本对比(B = 满格基准)── -->
|
|
32
|
+
<text x="64" y="290" font-size="20" font-weight="700" fill="#EFF3FA">成本对比</text>
|
|
33
|
+
<text x="166" y="290" font-size="17" fill="#8296B3">(每场景均值,B 组 = 满格基准,条越短越省)</text>
|
|
34
|
+
|
|
35
|
+
<!-- 步骤 -->
|
|
36
|
+
<text x="240" y="348" font-size="19" fill="#C2CDDE" text-anchor="end">步骤</text>
|
|
37
|
+
<rect x="260" y="318" width="329" height="18" rx="5" fill="#FFD15D"/>
|
|
38
|
+
<text x="603" y="333" font-size="18" font-weight="700" fill="#FFD15D" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace">24.3</text>
|
|
39
|
+
<rect x="260" y="342" width="560" height="18" rx="5" fill="#4E6DA8"/>
|
|
40
|
+
<text x="834" y="357" font-size="18" font-weight="700" fill="#8FA6C6" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace">41.4</text>
|
|
41
|
+
<rect x="980" y="321" width="136" height="36" rx="10" fill="#315DA6"/>
|
|
42
|
+
<text x="1048" y="345" font-size="19" font-weight="700" fill="#FFD15D" text-anchor="middle">B +70%</text>
|
|
43
|
+
|
|
44
|
+
<!-- 工具调用 -->
|
|
45
|
+
<text x="240" y="430" font-size="19" fill="#C2CDDE" text-anchor="end">工具调用</text>
|
|
46
|
+
<rect x="260" y="400" width="340" height="18" rx="5" fill="#FFD15D"/>
|
|
47
|
+
<text x="614" y="415" font-size="18" font-weight="700" fill="#FFD15D" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace">37.7</text>
|
|
48
|
+
<rect x="260" y="424" width="560" height="18" rx="5" fill="#4E6DA8"/>
|
|
49
|
+
<text x="834" y="439" font-size="18" font-weight="700" fill="#8FA6C6" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace">62.1</text>
|
|
50
|
+
<rect x="980" y="403" width="136" height="36" rx="10" fill="#315DA6"/>
|
|
51
|
+
<text x="1048" y="427" font-size="19" font-weight="700" fill="#FFD15D" text-anchor="middle">B +65%</text>
|
|
52
|
+
|
|
53
|
+
<!-- 输入 token -->
|
|
54
|
+
<text x="240" y="512" font-size="19" fill="#C2CDDE" text-anchor="end">输入 token</text>
|
|
55
|
+
<rect x="260" y="482" width="82" height="18" rx="5" fill="#FFD15D"/>
|
|
56
|
+
<text x="356" y="497" font-size="18" font-weight="700" fill="#FFD15D" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace">266k</text>
|
|
57
|
+
<rect x="260" y="506" width="560" height="18" rx="5" fill="#4E6DA8"/>
|
|
58
|
+
<text x="834" y="521" font-size="18" font-weight="700" fill="#8FA6C6" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace">1.81M</text>
|
|
59
|
+
<rect x="980" y="485" width="136" height="36" rx="10" fill="#315DA6"/>
|
|
60
|
+
<text x="1048" y="509" font-size="19" font-weight="700" fill="#FFD15D" text-anchor="middle">B +580%</text>
|
|
61
|
+
|
|
62
|
+
<!-- ── 底部特写卡片 ── -->
|
|
63
|
+
<rect x="64" y="544" width="512" height="72" rx="14" fill="#15223A" stroke="#263A5C" stroke-width="1.5"/>
|
|
64
|
+
<text x="88" y="574" font-size="17" fill="#8296B3">风格规范场景 · 探针段(约定只存记忆,沙箱探不出来)</text>
|
|
65
|
+
<text x="88" y="600" font-size="20" font-weight="700">
|
|
66
|
+
<tspan fill="#FFD15D">A 12/12</tspan>
|
|
67
|
+
<tspan fill="#8FA6C6"> · B 0/4</tspan>
|
|
68
|
+
</text>
|
|
69
|
+
|
|
70
|
+
<rect x="624" y="544" width="512" height="72" rx="14" fill="#15223A" stroke="#263A5C" stroke-width="1.5"/>
|
|
71
|
+
<text x="648" y="574" font-size="17" fill="#8296B3">长任务成本 · 每场景输入 token(B 无记忆重新探索)</text>
|
|
72
|
+
<text x="648" y="600" font-size="20" font-weight="700">
|
|
73
|
+
<tspan fill="#FFD15D">A 266k</tspan>
|
|
74
|
+
<tspan fill="#8FA6C6"> · B 1.81M</tspan>
|
|
75
|
+
</text>
|
|
76
|
+
<rect x="1040" y="578" width="72" height="26" rx="8" fill="#315DA6"/>
|
|
77
|
+
<text x="1076" y="597" font-size="18" font-weight="700" fill="#FFD15D" text-anchor="middle">6.8×</text>
|
|
78
|
+
</g>
|
|
79
|
+
</svg>
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg"
|
|
2
|
+
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
3
|
+
width="1200" height="600" viewBox="0 0 1200 600"
|
|
4
|
+
role="img" aria-labelledby="flowTitle flowDesc">
|
|
5
|
+
<title id="flowTitle">dsh-prime-memory 运行时数据流</title>
|
|
6
|
+
<desc id="flowDesc">左侧 User 与 Assistant 的会话事件(session/event)流入中间的 dsh-prime-memory 插件:L0 捕获、L1–L3 蒸馏、检索召回与记忆工具;插件在 agent/pre-step 把相关记忆注入右侧 DeepSeek Harness 核心,蒸馏调用复用核心的 ctx.llm;数据双写 ~/.dsh/memory/。</desc>
|
|
7
|
+
|
|
8
|
+
<defs>
|
|
9
|
+
<marker id="arr-teal" markerWidth="9" markerHeight="9" refX="7" refY="4" orient="auto">
|
|
10
|
+
<path d="M0 0 L8 4 L0 8 Z" fill="#FFD15D"/>
|
|
11
|
+
</marker>
|
|
12
|
+
<marker id="arr-orange" markerWidth="9" markerHeight="9" refX="7" refY="4" orient="auto">
|
|
13
|
+
<path d="M0 0 L8 4 L0 8 Z" fill="#7FA6E3"/>
|
|
14
|
+
</marker>
|
|
15
|
+
</defs>
|
|
16
|
+
|
|
17
|
+
<rect width="1200" height="600" rx="26" fill="#0D1526"/>
|
|
18
|
+
|
|
19
|
+
<g font-family="-apple-system,BlinkMacSystemFont,'Segoe UI','PingFang SC','Microsoft YaHei',sans-serif">
|
|
20
|
+
|
|
21
|
+
<!-- ── 图例 ── -->
|
|
22
|
+
<circle cx="72" cy="58" r="5" fill="#FFD15D"/>
|
|
23
|
+
<text x="86" y="64" font-size="18" fill="#C2CDDE">捕获 / 写入</text>
|
|
24
|
+
<circle cx="250" cy="58" r="5" fill="#7FA6E3"/>
|
|
25
|
+
<text x="264" y="64" font-size="18" fill="#C2CDDE">召回 / 注入</text>
|
|
26
|
+
|
|
27
|
+
<!-- ── 左列:User ── -->
|
|
28
|
+
<g id="node-user">
|
|
29
|
+
<rect x="64" y="120" width="190" height="92" rx="16" fill="#15223A" stroke="#263A5C" stroke-width="1.5"/>
|
|
30
|
+
<circle cx="102" cy="152" r="9" fill="none" stroke="#8296B3" stroke-width="2"/>
|
|
31
|
+
<path d="M86 182 a16 16 0 0 1 32 0" fill="none" stroke="#8296B3" stroke-width="2"/>
|
|
32
|
+
<text x="126" y="162" font-size="20" font-weight="700" fill="#EFF3FA">User</text>
|
|
33
|
+
<text x="126" y="188" font-size="18" fill="#8296B3">用户消息</text>
|
|
34
|
+
</g>
|
|
35
|
+
|
|
36
|
+
<!-- ── 左列:Assistant ── -->
|
|
37
|
+
<g id="node-assistant">
|
|
38
|
+
<rect x="64" y="348" width="190" height="92" rx="16" fill="#15223A" stroke="#263A5C" stroke-width="1.5"/>
|
|
39
|
+
<path d="M102 376 L106 390 L120 394 L106 398 L102 412 L98 398 L84 394 L98 390 Z" fill="#8296B3"/>
|
|
40
|
+
<text x="126" y="392" font-size="20" font-weight="700" fill="#EFF3FA">Assistant</text>
|
|
41
|
+
<text x="126" y="418" font-size="18" fill="#8296B3">助手回复</text>
|
|
42
|
+
</g>
|
|
43
|
+
|
|
44
|
+
<!-- ── 中列:插件 ── -->
|
|
45
|
+
<g id="node-plugin">
|
|
46
|
+
<rect x="430" y="96" width="290" height="356" rx="18" fill="#15223A" stroke="#FFD15D" stroke-opacity="0.55" stroke-width="1.5"/>
|
|
47
|
+
<text x="575" y="138" text-anchor="middle" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace"
|
|
48
|
+
font-size="22" font-weight="700" fill="#EFF3FA">dsh-prime-memory</text>
|
|
49
|
+
<text x="575" y="166" text-anchor="middle" font-size="18" fill="#8296B3">分层蒸馏记忆插件</text>
|
|
50
|
+
|
|
51
|
+
<g id="plugin-modules">
|
|
52
|
+
<rect x="452" y="188" width="246" height="46" rx="10" fill="#101B30" stroke="#263A5C"/>
|
|
53
|
+
<circle cx="470" cy="211" r="4" fill="#FFD15D"/>
|
|
54
|
+
<text x="486" y="218" font-size="19" fill="#EFF3FA">L0 捕获 capture</text>
|
|
55
|
+
|
|
56
|
+
<rect x="452" y="244" width="246" height="46" rx="10" fill="#101B30" stroke="#263A5C"/>
|
|
57
|
+
<circle cx="470" cy="267" r="4" fill="#FFD15D"/>
|
|
58
|
+
<text x="486" y="274" font-size="19" fill="#EFF3FA">L1–L3 蒸馏 distill</text>
|
|
59
|
+
|
|
60
|
+
<rect x="452" y="300" width="246" height="46" rx="10" fill="#101B30" stroke="#263A5C"/>
|
|
61
|
+
<circle cx="470" cy="323" r="4" fill="#FFD15D"/>
|
|
62
|
+
<text x="486" y="330" font-size="19" fill="#EFF3FA">检索召回 · 三策略</text>
|
|
63
|
+
|
|
64
|
+
<rect x="452" y="356" width="246" height="46" rx="10" fill="#101B30" stroke="#263A5C"/>
|
|
65
|
+
<circle cx="470" cy="379" r="4" fill="#FFD15D"/>
|
|
66
|
+
<text x="486" y="386" font-size="19" fill="#EFF3FA">记忆工具 ×3</text>
|
|
67
|
+
</g>
|
|
68
|
+
</g>
|
|
69
|
+
|
|
70
|
+
<!-- ── 存储条 ── -->
|
|
71
|
+
<g id="node-storage">
|
|
72
|
+
<path id="sto-write" d="M545 456 V482" stroke="#FFD15D" stroke-width="2.5" fill="none" marker-end="url(#arr-teal)"/>
|
|
73
|
+
<path id="sto-read" d="M605 482 V456" stroke="#7FA6E3" stroke-width="2.5" fill="none" marker-end="url(#arr-orange)"/>
|
|
74
|
+
<text x="531" y="472" text-anchor="end" font-size="16" fill="#FFD15D">写</text>
|
|
75
|
+
<text x="619" y="472" font-size="16" fill="#7FA6E3">读</text>
|
|
76
|
+
<circle r="3.5" fill="#FFD15D" cx="545" cy="470">
|
|
77
|
+
<animate attributeName="cx" to="0" dur="1ms" fill="freeze"/>
|
|
78
|
+
<animate attributeName="cy" to="0" dur="1ms" fill="freeze"/>
|
|
79
|
+
<animateMotion dur="1.6s" begin="0s" repeatCount="indefinite"><mpath href="#sto-write" xlink:href="#sto-write"/></animateMotion>
|
|
80
|
+
</circle>
|
|
81
|
+
<circle r="3.5" fill="#7FA6E3" cx="605" cy="468">
|
|
82
|
+
<animate attributeName="cx" to="0" dur="1ms" fill="freeze"/>
|
|
83
|
+
<animate attributeName="cy" to="0" dur="1ms" fill="freeze"/>
|
|
84
|
+
<animateMotion dur="1.6s" begin="-0.8s" repeatCount="indefinite"><mpath href="#sto-read" xlink:href="#sto-read"/></animateMotion>
|
|
85
|
+
</circle>
|
|
86
|
+
|
|
87
|
+
<rect x="430" y="486" width="290" height="54" rx="12" fill="#101B30" stroke="#263A5C" stroke-dasharray="6 4"/>
|
|
88
|
+
<text x="575" y="509" text-anchor="middle" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace"
|
|
89
|
+
font-size="18" fill="#FFD15D">~/.dsh/memory/</text>
|
|
90
|
+
<text x="575" y="531" text-anchor="middle" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace"
|
|
91
|
+
font-size="16" fill="#6E82A3">memory.db · JSONL · Markdown</text>
|
|
92
|
+
</g>
|
|
93
|
+
|
|
94
|
+
<!-- ── 右列:DSH 核心 ── -->
|
|
95
|
+
<g id="node-core">
|
|
96
|
+
<rect x="920" y="96" width="216" height="356" rx="18" fill="#15223A" stroke="#263A5C" stroke-width="1.5"/>
|
|
97
|
+
<text x="1028" y="138" text-anchor="middle" font-size="22" font-weight="700" fill="#EFF3FA">DSH 核心</text>
|
|
98
|
+
<text x="1028" y="166" text-anchor="middle" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace"
|
|
99
|
+
font-size="18" fill="#8296B3">DeepSeek Harness</text>
|
|
100
|
+
|
|
101
|
+
<g id="core-modules">
|
|
102
|
+
<rect x="936" y="188" width="184" height="46" rx="10" fill="#101B30" stroke="#263A5C"/>
|
|
103
|
+
<circle cx="954" cy="211" r="4" fill="#7FA6E3"/>
|
|
104
|
+
<text x="970" y="218" font-size="19" fill="#EFF3FA">agent 循环</text>
|
|
105
|
+
|
|
106
|
+
<rect x="936" y="244" width="184" height="46" rx="10" fill="#101B30" stroke="#263A5C"/>
|
|
107
|
+
<circle cx="954" cy="267" r="4" fill="#7FA6E3"/>
|
|
108
|
+
<text x="970" y="274" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace" font-size="19" fill="#EFF3FA">ctx.llm</text>
|
|
109
|
+
|
|
110
|
+
<rect x="936" y="300" width="184" height="46" rx="10" fill="#101B30" stroke="#263A5C"/>
|
|
111
|
+
<circle cx="954" cy="323" r="4" fill="#7FA6E3"/>
|
|
112
|
+
<text x="970" y="330" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace" font-size="19" fill="#EFF3FA">systemPrompt</text>
|
|
113
|
+
|
|
114
|
+
<rect x="936" y="356" width="184" height="46" rx="10" fill="#101B30" stroke="#263A5C"/>
|
|
115
|
+
<circle cx="954" cy="379" r="4" fill="#7FA6E3"/>
|
|
116
|
+
<text x="970" y="386" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace" font-size="19" fill="#EFF3FA">tools·settings</text>
|
|
117
|
+
</g>
|
|
118
|
+
</g>
|
|
119
|
+
|
|
120
|
+
<!-- ── 连接 1:User → 插件(捕获) ── -->
|
|
121
|
+
<path id="cap-user" d="M254 166 H430" stroke="#FFD15D" stroke-width="2.5" fill="none" marker-end="url(#arr-teal)"/>
|
|
122
|
+
<text x="342" y="142" text-anchor="middle" font-size="18" fill="#C2CDDE">对话输入</text>
|
|
123
|
+
<circle r="4" fill="#FFD15D" cx="320" cy="166">
|
|
124
|
+
<animate attributeName="cx" to="0" dur="1ms" fill="freeze"/>
|
|
125
|
+
<animate attributeName="cy" to="0" dur="1ms" fill="freeze"/>
|
|
126
|
+
<animateMotion dur="2.4s" begin="0s" repeatCount="indefinite"><mpath href="#cap-user" xlink:href="#cap-user"/></animateMotion>
|
|
127
|
+
</circle>
|
|
128
|
+
<circle r="4" fill="#FFD15D" opacity="0.7" cx="368" cy="166">
|
|
129
|
+
<animate attributeName="cx" to="0" dur="1ms" fill="freeze"/>
|
|
130
|
+
<animate attributeName="cy" to="0" dur="1ms" fill="freeze"/>
|
|
131
|
+
<animateMotion dur="2.4s" begin="-1.2s" repeatCount="indefinite"><mpath href="#cap-user" xlink:href="#cap-user"/></animateMotion>
|
|
132
|
+
</circle>
|
|
133
|
+
|
|
134
|
+
<!-- ── 连接 2:Assistant → 插件(捕获) ── -->
|
|
135
|
+
<path id="cap-asst" d="M254 394 H430" stroke="#FFD15D" stroke-width="2.5" fill="none" marker-end="url(#arr-teal)"/>
|
|
136
|
+
<text x="342" y="370" text-anchor="middle" font-size="18" fill="#C2CDDE">回复捕获</text>
|
|
137
|
+
<circle r="4" fill="#FFD15D" cx="320" cy="394">
|
|
138
|
+
<animate attributeName="cx" to="0" dur="1ms" fill="freeze"/>
|
|
139
|
+
<animate attributeName="cy" to="0" dur="1ms" fill="freeze"/>
|
|
140
|
+
<animateMotion dur="2.4s" begin="-0.6s" repeatCount="indefinite"><mpath href="#cap-asst" xlink:href="#cap-asst"/></animateMotion>
|
|
141
|
+
</circle>
|
|
142
|
+
<circle r="4" fill="#FFD15D" opacity="0.7" cx="368" cy="394">
|
|
143
|
+
<animate attributeName="cx" to="0" dur="1ms" fill="freeze"/>
|
|
144
|
+
<animate attributeName="cy" to="0" dur="1ms" fill="freeze"/>
|
|
145
|
+
<animateMotion dur="2.4s" begin="-1.8s" repeatCount="indefinite"><mpath href="#cap-asst" xlink:href="#cap-asst"/></animateMotion>
|
|
146
|
+
</circle>
|
|
147
|
+
|
|
148
|
+
<!-- ── 连接 3:插件 → 核心(召回注入) ── -->
|
|
149
|
+
<path id="flow-recall" d="M720 192 L920 214" stroke="#7FA6E3" stroke-width="2.5" fill="none" marker-end="url(#arr-orange)"/>
|
|
150
|
+
<text x="820" y="166" text-anchor="middle" font-size="18" fill="#7FA6E3">召回注入 pre-step</text>
|
|
151
|
+
<circle r="3.5" fill="#7FA6E3" cx="770" cy="198">
|
|
152
|
+
<animate attributeName="cx" to="0" dur="1ms" fill="freeze"/>
|
|
153
|
+
<animate attributeName="cy" to="0" dur="1ms" fill="freeze"/>
|
|
154
|
+
<animateMotion dur="2.4s" begin="0s" repeatCount="indefinite"><mpath href="#flow-recall" xlink:href="#flow-recall"/></animateMotion>
|
|
155
|
+
</circle>
|
|
156
|
+
<circle r="3.5" fill="#7FA6E3" cx="815" cy="202.5">
|
|
157
|
+
<animate attributeName="cx" to="0" dur="1ms" fill="freeze"/>
|
|
158
|
+
<animate attributeName="cy" to="0" dur="1ms" fill="freeze"/>
|
|
159
|
+
<animateMotion dur="2.4s" begin="-0.8s" repeatCount="indefinite"><mpath href="#flow-recall" xlink:href="#flow-recall"/></animateMotion>
|
|
160
|
+
</circle>
|
|
161
|
+
<circle r="3.5" fill="#7FA6E3" cx="860" cy="207">
|
|
162
|
+
<animate attributeName="cx" to="0" dur="1ms" fill="freeze"/>
|
|
163
|
+
<animate attributeName="cy" to="0" dur="1ms" fill="freeze"/>
|
|
164
|
+
<animateMotion dur="2.4s" begin="-1.6s" repeatCount="indefinite"><mpath href="#flow-recall" xlink:href="#flow-recall"/></animateMotion>
|
|
165
|
+
</circle>
|
|
166
|
+
|
|
167
|
+
<!-- ── 连接 4:核心 → 插件(蒸馏复用 LLM) ── -->
|
|
168
|
+
<path id="flow-distill" d="M920 320 L720 342" stroke="#FFD15D" stroke-width="2.5" fill="none" marker-end="url(#arr-teal)"/>
|
|
169
|
+
<text x="820" y="374" text-anchor="middle" font-size="18" fill="#FFD15D">蒸馏复用 ctx.llm</text>
|
|
170
|
+
<circle r="3.5" fill="#FFD15D" cx="865" cy="327">
|
|
171
|
+
<animate attributeName="cx" to="0" dur="1ms" fill="freeze"/>
|
|
172
|
+
<animate attributeName="cy" to="0" dur="1ms" fill="freeze"/>
|
|
173
|
+
<animateMotion dur="2.4s" begin="-0.4s" repeatCount="indefinite"><mpath href="#flow-distill" xlink:href="#flow-distill"/></animateMotion>
|
|
174
|
+
</circle>
|
|
175
|
+
<circle r="3.5" fill="#FFD15D" cx="820" cy="331">
|
|
176
|
+
<animate attributeName="cx" to="0" dur="1ms" fill="freeze"/>
|
|
177
|
+
<animate attributeName="cy" to="0" dur="1ms" fill="freeze"/>
|
|
178
|
+
<animateMotion dur="2.4s" begin="-1.2s" repeatCount="indefinite"><mpath href="#flow-distill" xlink:href="#flow-distill"/></animateMotion>
|
|
179
|
+
</circle>
|
|
180
|
+
<circle r="3.5" fill="#FFD15D" cx="775" cy="335">
|
|
181
|
+
<animate attributeName="cx" to="0" dur="1ms" fill="freeze"/>
|
|
182
|
+
<animate attributeName="cy" to="0" dur="1ms" fill="freeze"/>
|
|
183
|
+
<animateMotion dur="2.4s" begin="-2s" repeatCount="indefinite"><mpath href="#flow-distill" xlink:href="#flow-distill"/></animateMotion>
|
|
184
|
+
</circle>
|
|
185
|
+
|
|
186
|
+
<!-- ── 底注 ── -->
|
|
187
|
+
<text x="600" y="576" text-anchor="middle" font-size="18" fill="#8296B3">事件缝 session/event · 注入缝 agent/pre-step + systemPrompt.context · 全程无感,用户与模型零操作</text>
|
|
188
|
+
</g>
|
|
189
|
+
</svg>
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg"
|
|
2
|
+
width="1200" height="800" viewBox="0 0 1200 800"
|
|
3
|
+
role="img" aria-labelledby="storageTitle storageDesc">
|
|
4
|
+
<title id="storageTitle">存储布局与检索</title>
|
|
5
|
+
<desc id="storageDesc">双写架构:JSONL 按天追加只增不改(事实源),memory.db 为主检索引擎。文件形态含 conversations、records、scenes、persona、state、pending、session-modes、embedding-source、models、runtime、日志与重建归档;检索三策略 keyword/embedding/hybrid(RRF k=60 融合);嵌入源三态 off/remote/local(生效 = 部署上限 AND 运行时选择);降级链保证永不阻塞宿主,唯一检索缝为 L1Store.search()。</desc>
|
|
6
|
+
|
|
7
|
+
<rect width="1200" height="800" rx="26" fill="#0D1526"/>
|
|
8
|
+
|
|
9
|
+
<g font-family="-apple-system,BlinkMacSystemFont,'Segoe UI','PingFang SC','Microsoft YaHei',sans-serif">
|
|
10
|
+
|
|
11
|
+
<!-- ── 双写架构 ── -->
|
|
12
|
+
<rect x="64" y="56" width="1072" height="56" rx="14" fill="#15223A" stroke="#263A5C" stroke-width="1.5"/>
|
|
13
|
+
<text x="600" y="91" text-anchor="middle" font-size="20" fill="#EFF3FA">双写架构:JSONL 按天追加、只增不改(备份 / 恢复事实源)· memory.db 主检索引擎(去重合并只动检索库)</text>
|
|
14
|
+
|
|
15
|
+
<!-- ── 左:文件形态 ── -->
|
|
16
|
+
<g id="files">
|
|
17
|
+
<rect x="64" y="140" width="560" height="610" rx="16" fill="#101B30" stroke="#263A5C" stroke-width="1.5"/>
|
|
18
|
+
<text x="92" y="176" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace"
|
|
19
|
+
font-size="18" fill="#FFD15D">文件形态 · ~/.dsh/memory/</text>
|
|
20
|
+
|
|
21
|
+
<g font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace" font-size="18">
|
|
22
|
+
<text x="92" y="210" fill="#EFF3FA">memory.db</text>
|
|
23
|
+
<text x="352" y="210" fill="#8296B3" font-family="-apple-system,BlinkMacSystemFont,'Segoe UI','PingFang SC','Microsoft YaHei',sans-serif">SQLite 检索库 · FTS5+向量</text>
|
|
24
|
+
|
|
25
|
+
<text x="92" y="252" fill="#EFF3FA">conversations/*.jsonl</text>
|
|
26
|
+
<text x="352" y="252" fill="#8296B3" font-family="-apple-system,BlinkMacSystemFont,'Segoe UI','PingFang SC','Microsoft YaHei',sans-serif">L0 事实源 · 只增不改</text>
|
|
27
|
+
|
|
28
|
+
<text x="92" y="294" fill="#EFF3FA">records/*.jsonl</text>
|
|
29
|
+
<text x="352" y="294" fill="#8296B3" font-family="-apple-system,BlinkMacSystemFont,'Segoe UI','PingFang SC','Microsoft YaHei',sans-serif">L1 事实源 · 含 family</text>
|
|
30
|
+
|
|
31
|
+
<text x="92" y="336" fill="#EFF3FA">scenes/<family>/*.md</text>
|
|
32
|
+
<text x="352" y="336" fill="#8296B3" font-family="-apple-system,BlinkMacSystemFont,'Segoe UI','PingFang SC','Microsoft YaHei',sans-serif">L2 场景块 · 按族</text>
|
|
33
|
+
|
|
34
|
+
<text x="92" y="378" fill="#EFF3FA">persona-<family>.md</text>
|
|
35
|
+
<text x="352" y="378" fill="#8296B3" font-family="-apple-system,BlinkMacSystemFont,'Segoe UI','PingFang SC','Microsoft YaHei',sans-serif">L3 画像 · 每族一份</text>
|
|
36
|
+
|
|
37
|
+
<text x="92" y="420" fill="#EFF3FA">state.json</text>
|
|
38
|
+
<text x="352" y="420" fill="#8296B3" font-family="-apple-system,BlinkMacSystemFont,'Segoe UI','PingFang SC','Microsoft YaHei',sans-serif">checkpoint · v2 分族</text>
|
|
39
|
+
|
|
40
|
+
<text x="92" y="462" fill="#EFF3FA">pending.json</text>
|
|
41
|
+
<text x="352" y="462" fill="#8296B3" font-family="-apple-system,BlinkMacSystemFont,'Segoe UI','PingFang SC','Microsoft YaHei',sans-serif">未蒸馏缓冲 · 重启恢复</text>
|
|
42
|
+
|
|
43
|
+
<text x="92" y="504" fill="#EFF3FA">session-modes.json</text>
|
|
44
|
+
<text x="352" y="504" fill="#8296B3" font-family="-apple-system,BlinkMacSystemFont,'Segoe UI','PingFang SC','Microsoft YaHei',sans-serif">会话档位 · 90 天清理</text>
|
|
45
|
+
|
|
46
|
+
<text x="92" y="546" fill="#EFF3FA">embedding-source.json</text>
|
|
47
|
+
<text x="352" y="546" fill="#8296B3" font-family="-apple-system,BlinkMacSystemFont,'Segoe UI','PingFang SC','Microsoft YaHei',sans-serif">嵌入源三态 · 运行时切换</text>
|
|
48
|
+
|
|
49
|
+
<text x="92" y="588" fill="#EFF3FA">models/<id>/</text>
|
|
50
|
+
<text x="352" y="588" fill="#8296B3" font-family="-apple-system,BlinkMacSystemFont,'Segoe UI','PingFang SC','Microsoft YaHei',sans-serif">本地嵌入模型 · sha256 校验</text>
|
|
51
|
+
|
|
52
|
+
<text x="92" y="630" fill="#EFF3FA">runtime/</text>
|
|
53
|
+
<text x="352" y="630" fill="#8296B3" font-family="-apple-system,BlinkMacSystemFont,'Segoe UI','PingFang SC','Microsoft YaHei',sans-serif">推理运行时 · 按需安装</text>
|
|
54
|
+
|
|
55
|
+
<text x="92" y="672" fill="#EFF3FA">*.bak.<ts>/</text>
|
|
56
|
+
<text x="352" y="672" fill="#8296B3" font-family="-apple-system,BlinkMacSystemFont,'Segoe UI','PingFang SC','Microsoft YaHei',sans-serif">重建归档(改名保留)</text>
|
|
57
|
+
|
|
58
|
+
<text x="92" y="714" fill="#EFF3FA">memory.log</text>
|
|
59
|
+
<text x="352" y="714" fill="#8296B3" font-family="-apple-system,BlinkMacSystemFont,'Segoe UI','PingFang SC','Microsoft YaHei',sans-serif">诊断日志 · 2MB 轮转</text>
|
|
60
|
+
</g>
|
|
61
|
+
</g>
|
|
62
|
+
|
|
63
|
+
<!-- ── 右上:检索三策略 ── -->
|
|
64
|
+
<g id="retrieval">
|
|
65
|
+
<rect x="656" y="140" width="480" height="210" rx="16" fill="#101B30" stroke="#263A5C" stroke-width="1.5"/>
|
|
66
|
+
<text x="684" y="174" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace"
|
|
67
|
+
font-size="18" fill="#7FA6E3">检索三策略 · recall.strategy</text>
|
|
68
|
+
|
|
69
|
+
<text x="684" y="210" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace" font-size="18" fill="#EFF3FA">keyword</text>
|
|
70
|
+
<text x="800" y="210" font-size="18" fill="#8296B3">FTS5 BM25</text>
|
|
71
|
+
|
|
72
|
+
<text x="684" y="244" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace" font-size="18" fill="#EFF3FA">embedding</text>
|
|
73
|
+
<text x="800" y="244" font-size="18" fill="#8296B3">vec0 余弦 KNN</text>
|
|
74
|
+
|
|
75
|
+
<text x="684" y="278" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace" font-size="18" fill="#EFF3FA">hybrid</text>
|
|
76
|
+
<rect x="798" y="262" width="48" height="24" rx="12" fill="#FFD15D"/>
|
|
77
|
+
<text x="822" y="279" text-anchor="middle" font-size="15" font-weight="700" fill="#0D1526">默认</text>
|
|
78
|
+
<text x="860" y="278" font-size="18" fill="#8296B3">双路并行 + RRF k=60</text>
|
|
79
|
+
|
|
80
|
+
<text x="684" y="322" font-size="18" fill="#6E82A3">conversation_search(L0)同款融合</text>
|
|
81
|
+
</g>
|
|
82
|
+
|
|
83
|
+
<!-- ── 右中:嵌入源三态 ── -->
|
|
84
|
+
<g id="embedding-source">
|
|
85
|
+
<rect x="656" y="370" width="480" height="184" rx="16" fill="#101B30" stroke="#263A5C" stroke-width="1.5"/>
|
|
86
|
+
<text x="684" y="404" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace"
|
|
87
|
+
font-size="18" fill="#93A8FF">嵌入源三态 · 运行时切换</text>
|
|
88
|
+
|
|
89
|
+
<text x="684" y="438" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace" font-size="18" fill="#EFF3FA">off</text>
|
|
90
|
+
<text x="800" y="438" font-size="18" fill="#8296B3">纯 FTS(默认)</text>
|
|
91
|
+
|
|
92
|
+
<text x="684" y="471" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace" font-size="18" fill="#EFF3FA">remote</text>
|
|
93
|
+
<text x="800" y="471" font-size="18" fill="#8296B3">OpenAI 兼容 /embeddings</text>
|
|
94
|
+
|
|
95
|
+
<text x="684" y="504" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace" font-size="18" fill="#EFF3FA">local</text>
|
|
96
|
+
<text x="800" y="504" font-size="18" fill="#8296B3">内置目录 · CPU 推理</text>
|
|
97
|
+
|
|
98
|
+
<text x="684" y="536" font-size="16" fill="#6E82A3">生效 = 部署上限 AND 运行时选择 · 本地模型免 API Key</text>
|
|
99
|
+
</g>
|
|
100
|
+
|
|
101
|
+
<!-- ── 右下:降级链 ── -->
|
|
102
|
+
<g id="degradation">
|
|
103
|
+
<rect x="656" y="574" width="480" height="176" rx="16" fill="#101B30" stroke="#263A5C" stroke-width="1.5"/>
|
|
104
|
+
<text x="684" y="608" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace"
|
|
105
|
+
font-size="18" fill="#8296B3">降级链 · 永不阻塞宿主</text>
|
|
106
|
+
|
|
107
|
+
<text x="684" y="642" font-size="18" fill="#C2CDDE">sqlite-vec 加载失败 → 纯 FTS</text>
|
|
108
|
+
<text x="684" y="675" font-size="18" fill="#C2CDDE">embedding 调用失败 → 该次降级 FTS</text>
|
|
109
|
+
<text x="684" y="708" font-size="18" fill="#C2CDDE">初始化失败 → 记忆停用 · dsh 照常启动</text>
|
|
110
|
+
|
|
111
|
+
<text x="684" y="740" font-family="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace"
|
|
112
|
+
font-size="18" fill="#FFD15D">唯一检索缝:L1Store.search()</text>
|
|
113
|
+
</g>
|
|
114
|
+
</g>
|
|
115
|
+
</svg>
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# dsh-prime-memory 组合包层:安装(dsh plugin --profile <name> add dsh-prime-memory)
|
|
2
|
+
# 后自动挂载插件行,无需再手改 profile 的 cordis.patch.yml。
|
|
3
|
+
# 覆盖配置请在 profile 自己的 cordis.patch.yml 里写顶层裸 patch(直接 id:,不要包 insert:,
|
|
4
|
+
# 同 id 再 insert 会报 duplicate loader entry id 启动失败):
|
|
5
|
+
# - id: dsh-memory
|
|
6
|
+
# name: dsh-prime-memory
|
|
7
|
+
# config: { family: auto } # 键按行整体替换,不深合并
|
|
8
|
+
- insert:
|
|
9
|
+
- id: dsh-memory
|
|
10
|
+
name: dsh-prime-memory
|
|
11
|
+
# config: # 全部字段有默认值,按需覆盖:
|
|
12
|
+
# family: auto # 新会话默认档:auto | chat | work
|
|
13
|
+
# dataDir: '' # 默认 $DSH_HOME/memory
|
|
14
|
+
# llm:
|
|
15
|
+
# provider: '' # 蒸馏模型路由(默认跟随当前默认模型)
|
|
16
|
+
# model: ''
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* bench 控制服务(config `benchControl` 门控,默认关):为同进程的基准驱动插件
|
|
3
|
+
* (dsh-bench-runner 的 lifecycle 赛道)提供进程内控制面。
|
|
4
|
+
*
|
|
5
|
+
* 为什么不走 RPC:宿主侧 connection.rpc 只有 handle/intercept、没有 call(),
|
|
6
|
+
* 基准驱动包在 dsh 宿主进程内无法调用插件的 loopback RPC 端点;cordis 服务
|
|
7
|
+
* (ctx.provide / ctx.get)是唯一干净的进程内通道。生产部署不开启该配置,
|
|
8
|
+
* 服务不注册、零表面积;即便开启,暴露的也只是既有公开 API 的薄包装,
|
|
9
|
+
* 不引入新逻辑:
|
|
10
|
+
* - RebuildController.start()/getStatus()(重建触发与状态轮询);
|
|
11
|
+
* - SessionModeStore.set()/get()(会话档位——走 onModeChange 回调的
|
|
12
|
+
* pending 落袋/挂起语义,不是裸改 Map)。
|
|
13
|
+
*/
|
|
14
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
15
|
+
import type { MemoryLogger, MemoryMode } from './types.js';
|
|
16
|
+
import type { RebuildController, RebuildStatus } from './pipeline/rebuild.js';
|
|
17
|
+
import type { SessionModeStore } from './store/session-modes.js';
|
|
18
|
+
import type { DistillUsageSnapshot } from './llm-usage.js';
|
|
19
|
+
/** 服务名(消费方:bench/harness/dsh-bench-runner 的 lifecycle 赛道)。 */
|
|
20
|
+
export declare const BENCH_CONTROL_SERVICE = "dsh-memory-bench";
|
|
21
|
+
export interface BenchControlSurface {
|
|
22
|
+
/** 触发全量重建(从 L0 重导派生层);前置条件不满足时抛错(调用方捕获)。 */
|
|
23
|
+
rebuildStart(): RebuildStatus;
|
|
24
|
+
/** 重建状态快照(phase/running/recordsBuilt/…,轮询至 done/failed/cancelled)。 */
|
|
25
|
+
rebuildStatus(): RebuildStatus;
|
|
26
|
+
/** 设置会话档位(chat/work/off/auto);对全新会话应在首条消息前设置。 */
|
|
27
|
+
setSessionMode(sessionId: string, mode: MemoryMode): void;
|
|
28
|
+
/** 查询会话档位(未设过的会话返回部署默认档)。 */
|
|
29
|
+
getSessionMode(sessionId: string): MemoryMode;
|
|
30
|
+
/** 蒸馏用量快照(按层累计的调用数/输入字符/输出 token——「记忆开销」记账)。 */
|
|
31
|
+
getDistillUsage(): DistillUsageSnapshot;
|
|
32
|
+
}
|
|
33
|
+
/** 注册控制服务,返回注销函数(调用方在插件 dispose 时执行)。 */
|
|
34
|
+
export declare function registerBenchControl(ctx: Context, rebuild: RebuildController, modes: SessionModeStore, logger: MemoryLogger): () => void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { snapshotDistillUsage } from './llm-usage.js';
|
|
2
|
+
/** 服务名(消费方:bench/harness/dsh-bench-runner 的 lifecycle 赛道)。 */
|
|
3
|
+
export const BENCH_CONTROL_SERVICE = 'dsh-memory-bench';
|
|
4
|
+
/** 注册控制服务,返回注销函数(调用方在插件 dispose 时执行)。 */
|
|
5
|
+
export function registerBenchControl(ctx, rebuild, modes, logger) {
|
|
6
|
+
const surface = {
|
|
7
|
+
rebuildStart: () => rebuild.start(),
|
|
8
|
+
rebuildStatus: () => rebuild.getStatus(),
|
|
9
|
+
setSessionMode: (sessionId, mode) => modes.set(sessionId, mode),
|
|
10
|
+
getSessionMode: (sessionId) => modes.get(sessionId),
|
|
11
|
+
getDistillUsage: () => snapshotDistillUsage(),
|
|
12
|
+
};
|
|
13
|
+
const dispose = ctx.provide(BENCH_CONTROL_SERVICE, surface);
|
|
14
|
+
logger.info('[memory] bench 控制服务已提供(dsh-memory-bench,仅基准/调试部署)');
|
|
15
|
+
return dispose;
|
|
16
|
+
}
|