dsh-live-compact 1.1.5 → 1.1.7
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 +17 -0
- package/README.md +21 -9
- package/gate.js +61 -6
- package/index.js +302 -46
- package/package.json +4 -3
- package/plan.js +32 -5
- package/raw.js +32 -8
- package/shadow.js +42 -15
- package/thunder.js +8 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# 版本变更
|
|
2
2
|
|
|
3
|
+
## 1.1.7
|
|
4
|
+
|
|
5
|
+
- **billion-context 兼容**:保留 1.1.6 的让位行为;billion-context 接管官方压缩时 Live Compact 不再同时改写会话。
|
|
6
|
+
- **P1 稳定性修复**:长 read 失败后真正跳过长读分类并回退到普通选点;同一会话重复 `toolCallId` 按原文哈希区分;raw 已写而 meta 未写时可在重启后重建;收窄轮末决策识别并隔离工具证据;避免 shadow worker 超时后留下活动锁。
|
|
7
|
+
- **#49 维护让位修复**:大段 catch-up 期间按会话维护闸让出事件循环,推迟重型补扫,减少跨会话请求在 `step/start` 到 `request/header` 之间等待的风险;原用户现场复测仍需继续。
|
|
8
|
+
- **#53 发布兼容**:导出 `dsh-live-compact/package.json`,让宿主 bundle loader 可以读取包元数据。
|
|
9
|
+
- **测评**:GLM-5.3 Flash Web-Bench React 20 中,原版与 Live Compact 均完成 20/20,浏览器验收均为 59/59;末步缓存命中约为 98.3% / 98.2%。这组数据用于正确率与缓存对照,不替代真实 TUI/Windows 现场验收。
|
|
10
|
+
- #51 轮末决策落盘观测、#48 手动指定切点、#50 pi-ai provider catalog 仍列入后续版本或独立项目,不纳入本版修复承诺。
|
|
11
|
+
|
|
12
|
+
## 1.1.6
|
|
13
|
+
|
|
14
|
+
- **billion-context 共存**:检测 `bili-native` / `billion-context` 的实际 LOADING/ACTIVE 状态;对方接管官方压缩时,Live Compact 保留官方引擎并让位,finishTurn、compact、shadow 捕获、pruner、cursor 和 recovery 路径均不再改会话。支持 `SPINE_STAND_DOWN=1` 强制让位,并补充一次性告警和回归测试。
|
|
15
|
+
- **P0:隔离组接管与边界修复**:接管直接 `agentPresets.register()` 和 Include 加载的 `compaction` 隔离组,覆盖 Deep PTC 的 compaction 与 toolResultPruner 共存;修复 checkpoint、最新回合和 turn boundary 的误判,不把历史完成回合当成当前未完成回合。
|
|
16
|
+
- **P1:原始结果与压缩路径加固**:同一会话重复 `toolCallId` 对应不同原文时闭合失败,原文、元数据、owner 和卡片采用私有临时文件、权限核验、fsync 和原子发布;临时 I/O 错误可重试,永久 ACL/清理错误保持 fail-closed;增加 30 秒 shadow worker 超时、长 read 非法切点回退、准确 `keptTokens` 和 turn baseline 收敛,并保留 Thunder 事实来源与显式决策边界。
|
|
17
|
+
- **P1:model-level provider endpoint(#45)**:按精确的 provider + model catalog 地址判断 cloud/local,不改变宿主实际请求路由;provider-level 地址继续作为回退。
|
|
18
|
+
- 默认 TUI 行为不变;真实 TUI × Live Compact 联合验收、原用户 Windows 长会话复测和 #27/#34 现场复测仍按开放边界跟进。手动指定切点的 feature request(#48)不纳入本版。
|
|
19
|
+
|
|
3
20
|
## 1.1.5
|
|
4
21
|
|
|
5
22
|
- #27:把默认/共享根的容量扫描、轮换删除和 cut/official 发布事务移入按 root 串行的受管 worker,保留完整扫描与原有协调协议;worker 复用并在空闲时回收。补齐失败派发、迟到退出和 worker 重建的生命周期处理。
|
package/README.md
CHANGED
|
@@ -4,6 +4,18 @@
|
|
|
4
4
|
|
|
5
5
|
版本变更见 [CHANGELOG.md](CHANGELOG.md)。
|
|
6
6
|
|
|
7
|
+
## 测评实证
|
|
8
|
+
|
|
9
|
+
完整数据、原始口径和限制见 [docs/benchmarks.md](docs/benchmarks.md),结构化数字见 [docs/benchmark-results.json](docs/benchmark-results.json)。
|
|
10
|
+
|
|
11
|
+
- **1.0.5 失忆对比**:同一真实 DeepSeek 会话,15 道回忆题两边都是 15/15;Live Compact 的日志中段细节两次都是 3/3,原版一次 1/3、一次 3/3。
|
|
12
|
+
- **历史 DSH 长链路**:早期 150 道短题和 20 道 WebUniverse 连续任务都保留了原版/Live Compact 对照表;它们是历史实测,不是 1.1.7 的新验收。
|
|
13
|
+
- **OpenCode 移植参考**:独立项目 [opencode-live-compact](https://github.com/Haoming9527/opencode-live-compact) 把插件移植到 OpenCode,和 OpenCode 自带的 autocompact 做了对照:在 OpenCode 2.2.6 + GPT-6 Luna 上跑 Aider 150 和 Web-Bench React 20,任务分别 150/150、20/20 且最终浏览器测试 59/59;估算费用分别低 14.3% 和 42.1%。这是 OpenCode 项目的结果,用来说明移植后的可复核测评方法,不冒充 DSH 运行结果。
|
|
14
|
+
|
|
15
|
+

|
|
16
|
+
|
|
17
|
+

|
|
18
|
+
|
|
7
19
|
## 云端和本地怎么用
|
|
8
20
|
|
|
9
21
|
- **用 DeepSeek、GLM 这类云端 API**,按下面的命令安装即可。先看答案是否正确,再一起看缓存命中、未命中输入和实际费用。命中率的百分比不是费用本身,输入变少时要连同 token 数一起比较。
|
|
@@ -16,13 +28,13 @@
|
|
|
16
28
|
headless:
|
|
17
29
|
|
|
18
30
|
```sh
|
|
19
|
-
dsh plugin --profile headless add dsh-live-compact@1.1.
|
|
31
|
+
dsh plugin --profile headless add dsh-live-compact@1.1.7
|
|
20
32
|
```
|
|
21
33
|
|
|
22
34
|
网页端:
|
|
23
35
|
|
|
24
36
|
```sh
|
|
25
|
-
dsh plugin --profile web add dsh-live-compact@1.1.
|
|
37
|
+
dsh plugin --profile web add dsh-live-compact@1.1.7
|
|
26
38
|
```
|
|
27
39
|
|
|
28
40
|
想先装到本机看版本:
|
|
@@ -150,7 +162,7 @@ Windows 会重新设置备份访问权限,失败时停止写备份并保留原
|
|
|
150
162
|
|
|
151
163
|
插件小切参数在每次轮后维护开始时取得本引擎的一致快照,保存后下一次维护生效,多个引擎互不覆盖。官方大压缩参数沿用宿主的构造时快照,保存后需要重建引擎或会话。宿主支持的 `retainRatio`、`maxTokens`、摘要模型路由、`modelPolicies`、溢出重试等配置继续由宿主校验并保留;`retainRatio` 与 `retainTokens` 互斥。
|
|
152
164
|
|
|
153
|
-
|
|
165
|
+
接管开关只影响未来加载的预设及 `compaction` 隔离组;直接注册预设和 Include 加载的组也按原位换包。新预设按 **预设引擎显式配置 > 根插件显式配置 > 有效环境变量 > 默认值** 取值;已有预设保留加载时的数值,根设置后续修改需要重新加载预设。原生客户端 slot、资源声明和安装方式沿用现有接口。
|
|
154
166
|
|
|
155
167
|
每个新的 `compact-checkpoint` 只让轮后小切跳过一次,`spine-checkpoint` 不触发这个跳过。
|
|
156
168
|
|
|
@@ -174,8 +186,8 @@ Windows 会重新设置备份访问权限,失败时停止写备份并保留原
|
|
|
174
186
|
从 npm 装。headless 和网页是两个 profile,要各装一次。桌面端是另一个 profile,普通 `dsh plugin --profile desktop` 会被拒绝。
|
|
175
187
|
|
|
176
188
|
```sh
|
|
177
|
-
dsh plugin --profile headless add dsh-live-compact@1.1.
|
|
178
|
-
dsh plugin --profile web add dsh-live-compact@1.1.
|
|
189
|
+
dsh plugin --profile headless add dsh-live-compact@1.1.7
|
|
190
|
+
dsh plugin --profile web add dsh-live-compact@1.1.7
|
|
179
191
|
```
|
|
180
192
|
|
|
181
193
|
想先装到本机看版本:
|
|
@@ -188,15 +200,15 @@ dsh-live-compact --version
|
|
|
188
200
|
上不了 npm 时的镜像安装命令:
|
|
189
201
|
|
|
190
202
|
```sh
|
|
191
|
-
dsh plugin --profile headless add https://download.merkyorlynn.com/downloads/plugins/dsh-live-compact-1.1.
|
|
192
|
-
dsh plugin --profile web add https://download.merkyorlynn.com/downloads/plugins/dsh-live-compact-1.1.
|
|
193
|
-
npm install -g --force "https://download.merkyorlynn.com/downloads/plugins/dsh-live-compact-1.1.
|
|
203
|
+
dsh plugin --profile headless add https://download.merkyorlynn.com/downloads/plugins/dsh-live-compact-1.1.7.tgz
|
|
204
|
+
dsh plugin --profile web add https://download.merkyorlynn.com/downloads/plugins/dsh-live-compact-1.1.7.tgz
|
|
205
|
+
npm install -g --force "https://download.merkyorlynn.com/downloads/plugins/dsh-live-compact-1.1.7.tgz"
|
|
194
206
|
dsh-live-compact --version
|
|
195
207
|
```
|
|
196
208
|
|
|
197
209
|
需要 DSH `>=0.2.0-rc.2 <0.3.0`。装上后跑长任务,日志里出现 `spine cut …ms` 才算这刀生效。页面:https://download.merkyorlynn.com/live-compact.html
|
|
198
210
|
|
|
199
|
-
DSH-TUI
|
|
211
|
+
DSH-TUI 先不要装。本包已补预设压缩隔离组的接管;TUI 仍需适配 `spine-checkpoint` 的局部卡片显示,两仓联合验收后再开放支持。
|
|
200
212
|
|
|
201
213
|
被切掉的原文会写到 `~/.dsh/compaction-spine/shadow`。Unix 权限为目录 0700 / 文件 0600;Windows 新建/修正后的备份允许当前用户、SYSTEM、Administrators,历史文件及缓存限制见上面的 ACL 说明。上限 256MB。快满时删最老的备份。卡片里的序号是会话日志的事件号。要在当前会话的备份里找一行,用 `import { searchShadow } from "dsh-live-compact/shadow-search"`。插件自己不会去搜。
|
|
202
214
|
|
package/gate.js
CHANGED
|
@@ -4,9 +4,57 @@ import { configSnapshot, engineConfig } from "./settings.js";
|
|
|
4
4
|
|
|
5
5
|
const OURS = "dsh-live-compact";
|
|
6
6
|
const PRESET_IDS = new Set(["standard", "ptc", "minimal", "cordis", "preset-standard", "preset-ptc", "preset-minimal", "preset-cordis"]);
|
|
7
|
+
const COMPETING_COMPRESSORS = new Set(["bili-native", "billion-context"]);
|
|
8
|
+
const COMPETING_FIBER_STATES = new Set([1, 2]); // Cordis 4.1: LOADING=1, ACTIVE=2.
|
|
9
|
+
const standDownNotices = new WeakMap();
|
|
7
10
|
export const GATE_SERVICE = "liveCompactPresetGate";
|
|
8
11
|
export const PRESET_ENGINE_CONFIG = Object.freeze(engineConfig());
|
|
9
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Return the exact active compressor runtimes that own the session when they
|
|
15
|
+
* are loading or active. Cordis keeps one runtime per plugin callback and
|
|
16
|
+
* exposes every live fiber through `ctx.registry.values()`; a package on disk
|
|
17
|
+
* or a failed/unloading fiber is not an active compressor.
|
|
18
|
+
*/
|
|
19
|
+
export function activeCompactionPeers(ctx) {
|
|
20
|
+
const peers = [];
|
|
21
|
+
if (process.env.SPINE_STAND_DOWN === "1") peers.push("SPINE_STAND_DOWN");
|
|
22
|
+
const registry = ctx?.registry;
|
|
23
|
+
if (!registry || typeof registry.values !== "function") return peers;
|
|
24
|
+
try {
|
|
25
|
+
for (const runtime of registry.values()) {
|
|
26
|
+
const name = runtime?.name;
|
|
27
|
+
if (!COMPETING_COMPRESSORS.has(name)) continue;
|
|
28
|
+
const active = [...(runtime?.fibers || [])].some((fiber) => COMPETING_FIBER_STATES.has(fiber?.state));
|
|
29
|
+
if (active && !peers.includes(name)) peers.push(name);
|
|
30
|
+
}
|
|
31
|
+
} catch {
|
|
32
|
+
// Cordis 4.1 always exposes an iterable registry. If an older/partial host
|
|
33
|
+
// cannot enumerate it, preserve the single-plugin path and do not guess a
|
|
34
|
+
// competing package from installation state.
|
|
35
|
+
}
|
|
36
|
+
return peers;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function compactionStandDown(ctx) {
|
|
40
|
+
return activeCompactionPeers(ctx).length > 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function warnCompactionStandDown(ctx, logger = ctx?.logger) {
|
|
44
|
+
const peers = activeCompactionPeers(ctx);
|
|
45
|
+
if (!peers.length) return peers;
|
|
46
|
+
const root = ctx?.root || ctx;
|
|
47
|
+
const key = peers.join(",");
|
|
48
|
+
if (root && standDownNotices.get(root) === key) return peers;
|
|
49
|
+
if (root) standDownNotices.set(root, key);
|
|
50
|
+
logger?.warn?.(peers[0] === "SPINE_STAND_DOWN"
|
|
51
|
+
? peers.length === 1
|
|
52
|
+
? "spine: SPINE_STAND_DOWN=1,但未检测到活跃对端;本插件保持让位,请确认 owner 配置。"
|
|
53
|
+
: `spine: SPINE_STAND_DOWN=1,已有压缩插件接管(${peers.slice(1).join(", ")}),本插件不切、不改预设。`
|
|
54
|
+
: `spine: 已有压缩插件接管(${peers.join(", ")}),本插件不切、不改预设。`);
|
|
55
|
+
return peers;
|
|
56
|
+
}
|
|
57
|
+
|
|
10
58
|
const require = createRequire(import.meta.url);
|
|
11
59
|
|
|
12
60
|
export function packageLoadable(load = (name) => require(name)) {
|
|
@@ -66,8 +114,9 @@ function rewriteNode(node, loadable, rootConfig) {
|
|
|
66
114
|
return next;
|
|
67
115
|
}
|
|
68
116
|
|
|
69
|
-
export function rewritePresetConfig(config, loadable = packageLoadable(), rootConfig = {}) {
|
|
70
|
-
|
|
117
|
+
export function rewritePresetConfig(config, loadable = packageLoadable(), rootConfig = {}, entry) {
|
|
118
|
+
const group = Array.isArray(config) && entry?.group === true && entry.isolate?.compaction === true;
|
|
119
|
+
if (!isPreset(config) && !group) return config;
|
|
71
120
|
return rewriteNode(config, loadable, rootConfig);
|
|
72
121
|
}
|
|
73
122
|
|
|
@@ -75,6 +124,7 @@ function engineEntry(node) {
|
|
|
75
124
|
if (!node || typeof node !== "object") return null;
|
|
76
125
|
if (node.name === OURS) return node;
|
|
77
126
|
const nested = [];
|
|
127
|
+
if (Array.isArray(node)) nested.push(...node);
|
|
78
128
|
if (Array.isArray(node.plugins)) nested.push(...node.plugins);
|
|
79
129
|
if (Array.isArray(node.config)) nested.push(...node.config);
|
|
80
130
|
else if (node.config && typeof node.config === "object") nested.push(node.config);
|
|
@@ -113,13 +163,18 @@ export function installPresetGate(ctx, config = {}, { legacy = false } = {}) {
|
|
|
113
163
|
return typeof value === "boolean" ? value : value.get();
|
|
114
164
|
};
|
|
115
165
|
const seen = new Set();
|
|
116
|
-
gate.disposeListener = ctx.on("internal/config", function (
|
|
166
|
+
gate.disposeListener = ctx.on("internal/config", function (fiber, next) {
|
|
117
167
|
const resolved = next();
|
|
168
|
+
if (compactionStandDown(ctx)) {
|
|
169
|
+
warnCompactionStandDown(ctx);
|
|
170
|
+
return resolved;
|
|
171
|
+
}
|
|
118
172
|
if (!gate.active || !enabled()) return resolved;
|
|
119
173
|
const loadable = packageLoadable();
|
|
120
|
-
const
|
|
121
|
-
const
|
|
122
|
-
|
|
174
|
+
const entry = fiber?.entry?.options;
|
|
175
|
+
const rewritten = rewritePresetConfig(resolved, loadable, config, entry);
|
|
176
|
+
const id = rewritten?.id || rewritten?.config?.id || entry?.id;
|
|
177
|
+
if (rewritten !== resolved && id && !seen.has(String(id))) {
|
|
123
178
|
seen.add(String(id));
|
|
124
179
|
const engine = engineEntry(rewritten);
|
|
125
180
|
if (engine) {
|