dsh-context-compression-improved 0.9.0 → 0.9.5
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 +56 -0
- package/package.json +2 -1
- package/packages/selector/dsh.plugin.json +1 -1
- package/packages/selector/lib/client.d.ts +1 -0
- package/packages/selector/lib/client.js +86 -32
- package/packages/selector/lib/config.js +71 -7
- package/packages/selector/lib/index.js +120 -20
- package/packages/selector/lib/pruner.d.ts +158 -107
- package/packages/selector/lib/pruner.js +336 -21
- package/packages/selector/package.json +1 -1
- package/packages/selector/src/client/index.ts +55 -20
- package/packages/selector/src/client/locales/de.ts +1 -0
- package/packages/selector/src/client/locales/es.ts +1 -0
- package/packages/selector/src/client/locales/fr.ts +1 -0
- package/packages/selector/src/client/locales/it.ts +1 -0
- package/packages/selector/src/client/locales/ja.ts +1 -0
- package/packages/selector/src/client/locales/ko.ts +1 -0
- package/packages/selector/src/client/locales/ru.ts +1 -0
- package/packages/selector/src/client/locales.ts +2 -0
- package/packages/selector/src/client/monitor-fab.ts +19 -4
- package/packages/selector/src/preset-overlay.ts +145 -22
- package/packages/selector/src/pruner/content.ts +1 -1
- package/packages/selector/src/pruner/state.ts +4 -0
- package/packages/selector/src/pruner.ts +120 -16
- package/packages/selector/src/runtime/config.ts +1 -1
- package/packages/selector/src/runtime/measurement.ts +14 -1
- package/packages/selector/src/runtime/reducers.ts +81 -1
- package/packages/selector/src/runtime/retrieve.ts +4 -3
- package/packages/selector/src/runtime/savings-projection.ts +226 -0
- package/packages/selector/src/runtime/savings.ts +83 -3
- package/packages/selector/tests/runtime/fresh-gate.spec.ts +43 -0
- package/packages/selector/tests/runtime/jsonl-reducer.spec.ts +79 -0
- package/packages/selector/tests/runtime/public/public-runtime.spec.ts +48 -0
- package/packages/selector/tests/runtime/savings-projection.spec.ts +89 -0
- package/packages/selector/tests/runtime/savings.spec.ts +22 -3
- package/packages/selector/tests/runtime/settings-unwrap.spec.ts +58 -0
- package/packages/selector/tests/runtime/tokenpilot/profile-baseline.spec.ts +5 -2
- package/scripts/cell-browser-e2e.mjs +354 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,62 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes use this file. The project follows semantic versioning after `0.1.0`.
|
|
4
4
|
|
|
5
|
+
## 0.9.3 - 2026-10-08
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- **≤0.1.1 resume killer: tool-result-pruner loader entry failed to import**.
|
|
10
|
+
The 0.1.0/0.1.1 host loader module table serves a `@deepseek-ai/dsh-session`
|
|
11
|
+
without the `SessionSeq` / `deriveEventMessage` runtime exports; the static
|
|
12
|
+
named imports in `pruner.ts` / `runtime/measurement.ts` died at ESM link
|
|
13
|
+
time, the loader entry failed to mount, and the whole `standard` agent
|
|
14
|
+
preset mount failed — every session resume on the two oldest cells errored
|
|
15
|
+
with "failed to apply loader entry compaction … does not provide an export
|
|
16
|
+
named 'SessionSeq'" (2026-10-08 five-cell reproduction). Both imports are
|
|
17
|
+
now namespace soft-imports with feature-detected fallbacks: `SessionSeq`
|
|
18
|
+
degrades to identity (old-line session seqs are plain numbers; the brand is
|
|
19
|
+
new-line paranoia), `deriveEventMessage` degrades to null which the
|
|
20
|
+
measurement adapter already maps to `unavailableTokenCount`. CJS-interop
|
|
21
|
+
shapes (named exports under `default`) are covered too.
|
|
22
|
+
|
|
23
|
+
## 0.9.2 - 2026-10-08
|
|
24
|
+
|
|
25
|
+
### Reverted
|
|
26
|
+
|
|
27
|
+
- **Standalone settings.section restored (family-tab consolidation rolled back
|
|
28
|
+
for this plugin)**: the 上下文压缩选择器 sidebar entry (`settings.section`,
|
|
29
|
+
order 17, the exact 0.9.0 registration and component identity) is back as the
|
|
30
|
+
only settings-nav seat; the `dsh-family.tab` contributor tab introduced in
|
|
31
|
+
0.9.1 is removed. 2026-10-08 user verdict: perm-gate and cci were never in
|
|
32
|
+
the family tab-ification scope — both plugins ship independent insections.
|
|
33
|
+
The `plugins.bundle.config` bundle-detail card is unchanged and keeps the
|
|
34
|
+
shared `sectionViaAdapter` closure adapter (now bundle-card-only).
|
|
35
|
+
- Tests: the four client specs (`settings-seat` / `code-skeleton` /
|
|
36
|
+
`custom-contract` / `preset-options-write`) are restored to the 0.9.0
|
|
37
|
+
contracts — settings.section seat pinned at order 17 with
|
|
38
|
+
`ContextCompressionSettingsSection` as the mounted component.
|
|
39
|
+
|
|
40
|
+
## 0.9.1 - 2026-10-08
|
|
41
|
+
|
|
42
|
+
### Changed
|
|
43
|
+
|
|
44
|
+
- **Settings consolidated into the family in-section tab**: the top-level
|
|
45
|
+
`settings.section` sidebar entry (上下文压缩选择器) is retired; the settings
|
|
46
|
+
panel now appears only as a contributor tab inside the 起子插件设置 family
|
|
47
|
+
section (`dsh-family.tab`, order 55), matching the 2026-10-08 fleet-wide
|
|
48
|
+
consolidation decision (perm-gate compat.8 removes its duplicated seats in
|
|
49
|
+
the same batch). The component goes through the shared closure
|
|
50
|
+
`useCompression` adapter (extracted from the `plugins.bundle.config` card,
|
|
51
|
+
which now reuses it) because neither the family-tab nor the bundle-detail
|
|
52
|
+
render chain maps `inject.hooks` into component hooks. Eager-bound `tNav`
|
|
53
|
+
label retained (search-index 0.5.3 family-tab incident). Server-side
|
|
54
|
+
settings bridge, lease, estimator-catalog and savings routes unchanged.
|
|
55
|
+
|
|
56
|
+
### Fixed
|
|
57
|
+
|
|
58
|
+
- `packages/selector/dsh.plugin.json` version metadata was stale at
|
|
59
|
+
`0.9.0-alpha.4` while the package shipped 0.9.0.
|
|
60
|
+
|
|
5
61
|
## 0.9.0 - 2026-10-08
|
|
6
62
|
|
|
7
63
|
### Added
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-context-compression-improved",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.5",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"tag": "latest"
|
|
6
6
|
},
|
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
"test:watch": "vitest",
|
|
66
66
|
"test:built": "vitest run --config vitest.built.config.ts",
|
|
67
67
|
"test:e2e:packed": "node scripts/packed-install-e2e.mjs",
|
|
68
|
+
"test:browser:e2e": "node scripts/cell-browser-e2e.mjs",
|
|
68
69
|
"test:unit": "vitest run",
|
|
69
70
|
"verify:release": "node scripts/verify-release.mjs",
|
|
70
71
|
"pack:dry-run": "pnpm -r --if-present run pack:dry-run"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "dsh-external/dsh-context-compression-improved",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.5",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"description": "Auditable tool-result context-compression selector with code-skeleton gate for DeepSeek Harness",
|
|
6
6
|
"engines": {
|
|
@@ -87,6 +87,7 @@ declare const zh: {
|
|
|
87
87
|
'monitor.panel.cost': string;
|
|
88
88
|
'monitor.panel.intent': string;
|
|
89
89
|
'monitor.panel.overrideHint': string;
|
|
90
|
+
'monitor.panel.overridePrefix': string;
|
|
90
91
|
'monitor.panel.resume': string;
|
|
91
92
|
'monitor.panel.disable': string;
|
|
92
93
|
'monitor.panel.stateOn': string;
|
|
@@ -1608,6 +1608,10 @@ window.__ModuleLoader__.load({
|
|
|
1608
1608
|
x: 0,
|
|
1609
1609
|
y: 0
|
|
1610
1610
|
};
|
|
1611
|
+
let startPos = {
|
|
1612
|
+
x: 0,
|
|
1613
|
+
y: 0
|
|
1614
|
+
};
|
|
1611
1615
|
el.addEventListener("pointerdown", (e) => {
|
|
1612
1616
|
active = true;
|
|
1613
1617
|
moved = false;
|
|
@@ -1615,13 +1619,17 @@ window.__ModuleLoader__.load({
|
|
|
1615
1619
|
x: e.clientX,
|
|
1616
1620
|
y: e.clientY
|
|
1617
1621
|
};
|
|
1622
|
+
startPos = {
|
|
1623
|
+
x: pos.x,
|
|
1624
|
+
y: pos.y
|
|
1625
|
+
};
|
|
1618
1626
|
el.setPointerCapture(e.pointerId);
|
|
1619
1627
|
});
|
|
1620
1628
|
el.addEventListener("pointermove", (e) => {
|
|
1621
1629
|
if (!active) return;
|
|
1622
1630
|
const next = clamp({
|
|
1623
|
-
x:
|
|
1624
|
-
y:
|
|
1631
|
+
x: startPos.x + (e.clientX - origin.x),
|
|
1632
|
+
y: startPos.y + (e.clientY - origin.y)
|
|
1625
1633
|
});
|
|
1626
1634
|
if (Math.abs(next.x - pos.x) > 2 || Math.abs(next.y - pos.y) > 2) moved = true;
|
|
1627
1635
|
pos = key === "fab" ? next : pos;
|
|
@@ -1665,10 +1673,22 @@ window.__ModuleLoader__.load({
|
|
|
1665
1673
|
let stale = false;
|
|
1666
1674
|
let busyAction = false;
|
|
1667
1675
|
const fmtTokens = (n) => num(n).toLocaleString("en-US");
|
|
1676
|
+
const lead = (exact, estimated) => {
|
|
1677
|
+
const ex = num(exact);
|
|
1678
|
+
const es = num(estimated);
|
|
1679
|
+
return ex !== 0 ? {
|
|
1680
|
+
v: ex,
|
|
1681
|
+
est: false
|
|
1682
|
+
} : {
|
|
1683
|
+
v: es,
|
|
1684
|
+
est: es !== 0
|
|
1685
|
+
};
|
|
1686
|
+
};
|
|
1668
1687
|
const render = (snap) => {
|
|
1669
1688
|
const net = num(snap.net?.exact) + num(snap.net?.estimated);
|
|
1670
1689
|
const netEl = panel.querySelector("[data-net]");
|
|
1671
|
-
|
|
1690
|
+
const netLead = lead(snap.net?.exact, snap.net?.estimated);
|
|
1691
|
+
netEl.textContent = netLead.est ? `${fmtTokens(netLead.v)} est` : fmtTokens(netLead.v);
|
|
1672
1692
|
netEl.classList.toggle("neg", net < 0);
|
|
1673
1693
|
const suggest = snap.suggestion?.suggest === true;
|
|
1674
1694
|
fab.classList.toggle("lit", suggest || net < 0);
|
|
@@ -1678,8 +1698,10 @@ window.__ModuleLoader__.load({
|
|
|
1678
1698
|
hint.textContent = t("monitor.panel.suggest").replace("{pct}", String(pct ?? "–"));
|
|
1679
1699
|
hint.classList.add("show");
|
|
1680
1700
|
} else hint.classList.remove("show");
|
|
1681
|
-
|
|
1682
|
-
panel.querySelector("[data-
|
|
1701
|
+
const grossLead = lead(snap.gross?.exact, snap.gross?.estimated);
|
|
1702
|
+
panel.querySelector("[data-gross]").textContent = grossLead.est ? `${fmtTokens(grossLead.v)} est` : fmtTokens(grossLead.v);
|
|
1703
|
+
const offLead = lead(snap.offsets?.exact, snap.offsets?.estimated);
|
|
1704
|
+
panel.querySelector("[data-offsets]").textContent = offLead.est ? `-${fmtTokens(offLead.v)} est` : `-${fmtTokens(offLead.v)}`;
|
|
1683
1705
|
const ctxBar = panel.querySelector("[data-ctxbar]");
|
|
1684
1706
|
const ctxPct = panel.querySelector("[data-ctxpct]");
|
|
1685
1707
|
const ctxPctNum = typeof snap.context?.pct === "number" ? snap.context.pct : null;
|
|
@@ -1840,6 +1862,7 @@ window.__ModuleLoader__.load({
|
|
|
1840
1862
|
"monitor.panel.cost": "成本(实际 / 省估)",
|
|
1841
1863
|
"monitor.panel.intent": "意图摘要",
|
|
1842
1864
|
"monitor.panel.overrideHint": "会话覆盖",
|
|
1865
|
+
"monitor.panel.overridePrefix": "会话覆盖",
|
|
1843
1866
|
"monitor.panel.resume": "恢复",
|
|
1844
1867
|
"monitor.panel.disable": "停用",
|
|
1845
1868
|
"monitor.panel.stateOn": "开",
|
|
@@ -1978,6 +2001,7 @@ window.__ModuleLoader__.load({
|
|
|
1978
2001
|
"monitor.panel.cost": "Cost (actual / saved est.)",
|
|
1979
2002
|
"monitor.panel.intent": "Intent summary",
|
|
1980
2003
|
"monitor.panel.overrideHint": "Session override",
|
|
2004
|
+
"monitor.panel.overridePrefix": "Session override",
|
|
1981
2005
|
"monitor.panel.resume": "Resume",
|
|
1982
2006
|
"monitor.panel.disable": "Disable",
|
|
1983
2007
|
"monitor.panel.stateOn": "on",
|
|
@@ -2118,6 +2142,7 @@ window.__ModuleLoader__.load({
|
|
|
2118
2142
|
"monitor.panel.cost": "Kosten (ist / gespart gesch.)",
|
|
2119
2143
|
"monitor.panel.intent": "Intent-Zusammenfassung",
|
|
2120
2144
|
"monitor.panel.overrideHint": "Sitzungs-Übersteuerung",
|
|
2145
|
+
"monitor.panel.overridePrefix": "Sitzungs-Übersteuerung",
|
|
2121
2146
|
"monitor.panel.resume": "Fortsetzen",
|
|
2122
2147
|
"monitor.panel.disable": "Deaktivieren",
|
|
2123
2148
|
"monitor.panel.stateOn": "ein",
|
|
@@ -2258,6 +2283,7 @@ window.__ModuleLoader__.load({
|
|
|
2258
2283
|
"monitor.panel.cost": "Coste (real / ahorro est.)",
|
|
2259
2284
|
"monitor.panel.intent": "Resumen de intención",
|
|
2260
2285
|
"monitor.panel.overrideHint": "Invalidación de sesión",
|
|
2286
|
+
"monitor.panel.overridePrefix": "Invalidación de sesión",
|
|
2261
2287
|
"monitor.panel.resume": "Reanudar",
|
|
2262
2288
|
"monitor.panel.disable": "Desactivar",
|
|
2263
2289
|
"monitor.panel.stateOn": "sí",
|
|
@@ -2398,6 +2424,7 @@ window.__ModuleLoader__.load({
|
|
|
2398
2424
|
"monitor.panel.cost": "Coût (réel / écon. est.)",
|
|
2399
2425
|
"monitor.panel.intent": "Résumé d'intention",
|
|
2400
2426
|
"monitor.panel.overrideHint": "Priorité de session",
|
|
2427
|
+
"monitor.panel.overridePrefix": "Priorité de session",
|
|
2401
2428
|
"monitor.panel.resume": "Reprendre",
|
|
2402
2429
|
"monitor.panel.disable": "Désactiver",
|
|
2403
2430
|
"monitor.panel.stateOn": "activé",
|
|
@@ -2538,6 +2565,7 @@ window.__ModuleLoader__.load({
|
|
|
2538
2565
|
"monitor.panel.cost": "Costo (effettivo / stimo)",
|
|
2539
2566
|
"monitor.panel.intent": "Riepilogo di intento",
|
|
2540
2567
|
"monitor.panel.overrideHint": "Override di sessione",
|
|
2568
|
+
"monitor.panel.overridePrefix": "Override di sessione",
|
|
2541
2569
|
"monitor.panel.resume": "Riprendi",
|
|
2542
2570
|
"monitor.panel.disable": "Disattiva",
|
|
2543
2571
|
"monitor.panel.stateOn": "on",
|
|
@@ -2678,6 +2706,7 @@ window.__ModuleLoader__.load({
|
|
|
2678
2706
|
"monitor.panel.cost": "コスト(実績 / 節約概算)",
|
|
2679
2707
|
"monitor.panel.intent": "インテント要約",
|
|
2680
2708
|
"monitor.panel.overrideHint": "セッション上書き",
|
|
2709
|
+
"monitor.panel.overridePrefix": "セッション上書き",
|
|
2681
2710
|
"monitor.panel.resume": "再開",
|
|
2682
2711
|
"monitor.panel.disable": "停止",
|
|
2683
2712
|
"monitor.panel.stateOn": "オン",
|
|
@@ -2818,6 +2847,7 @@ window.__ModuleLoader__.load({
|
|
|
2818
2847
|
"monitor.panel.cost": "비용 (실제 / 절감 추정)",
|
|
2819
2848
|
"monitor.panel.intent": "인텐트 요약",
|
|
2820
2849
|
"monitor.panel.overrideHint": "세션 재정의",
|
|
2850
|
+
"monitor.panel.overridePrefix": "세션 재정의",
|
|
2821
2851
|
"monitor.panel.resume": "재개",
|
|
2822
2852
|
"monitor.panel.disable": "중지",
|
|
2823
2853
|
"monitor.panel.stateOn": "켬",
|
|
@@ -2958,6 +2988,7 @@ window.__ModuleLoader__.load({
|
|
|
2958
2988
|
"monitor.panel.cost": "Стоимость (факт / эконом. оценка)",
|
|
2959
2989
|
"monitor.panel.intent": "Итог намерения",
|
|
2960
2990
|
"monitor.panel.overrideHint": "Приоритет сессии",
|
|
2991
|
+
"monitor.panel.overridePrefix": "Приоритет сессии",
|
|
2961
2992
|
"monitor.panel.resume": "Возобновить",
|
|
2962
2993
|
"monitor.panel.disable": "Отключить",
|
|
2963
2994
|
"monitor.panel.stateOn": "вкл",
|
|
@@ -3215,10 +3246,14 @@ window.__ModuleLoader__.load({
|
|
|
3215
3246
|
return left.version === right.version && left.unit === right.unit && left.prefixPolicy === right.prefixPolicy && left.fresh.enabled === right.fresh.enabled && left.fresh.trigger === right.fresh.trigger && left.fresh.target === right.fresh.target && left.aggregate.enabled === right.aggregate.enabled && left.aggregate.trigger === right.aggregate.trigger && left.aggregate.target === right.aggregate.target && left.history.enabled === right.history.enabled && left.history.trigger === right.history.trigger && left.history.keepRecentToolCalls === right.history.keepRecentToolCalls && left.history.keepRecentTokens === right.history.keepRecentTokens && left.history.minReclaim === right.history.minReclaim && left.tailTrim.enabled === right.tailTrim.enabled && left.tailTrim.trigger === right.tailTrim.trigger;
|
|
3216
3247
|
}
|
|
3217
3248
|
function apply(ctx) {
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3249
|
+
try {
|
|
3250
|
+
ctx.locale.register(NS, {
|
|
3251
|
+
zh,
|
|
3252
|
+
en
|
|
3253
|
+
});
|
|
3254
|
+
} catch (error) {
|
|
3255
|
+
console.warn("[dsh-context-compression-improved] locale 默认包(zh/en) 已注册,跳过:", error);
|
|
3256
|
+
}
|
|
3222
3257
|
const languages = [
|
|
3223
3258
|
{
|
|
3224
3259
|
id: "de",
|
|
@@ -3270,6 +3305,8 @@ window.__ModuleLoader__.load({
|
|
|
3270
3305
|
let configFormsHandle;
|
|
3271
3306
|
/** Last monitorPanel.enabled seen through whichever scope is current (FAB 读数缓存). */
|
|
3272
3307
|
let monitorPanelEnabledCache = false;
|
|
3308
|
+
/** configForms 臂是否已经成功读过一次文档(FAB 读数是否可信)。 */
|
|
3309
|
+
let nativeMonitorReady = false;
|
|
3273
3310
|
/** 浮动监控面板(FAB): body 级幂等单例。enabled 读数走双臂 scope 的投影缓存。 */
|
|
3274
3311
|
let readMonitorPanelEnabled = () => monitorPanelEnabledCache;
|
|
3275
3312
|
let latestSessionId;
|
|
@@ -3299,12 +3336,27 @@ window.__ModuleLoader__.load({
|
|
|
3299
3336
|
const bridgeScope = createBridgeScope();
|
|
3300
3337
|
bridgeScope.refresh();
|
|
3301
3338
|
const bridgeReadEnabled = () => decodeSettings(bridgeScope.getSnapshot().value)?.monitorPanel?.enabled ?? false;
|
|
3302
|
-
readMonitorPanelEnabled = () => configFormsHandle
|
|
3339
|
+
readMonitorPanelEnabled = () => configFormsHandle !== void 0 && nativeMonitorReady ? monitorPanelEnabledCache : bridgeReadEnabled();
|
|
3303
3340
|
try {
|
|
3304
3341
|
ctx.inject(["configForms"], (configFormsArg) => {
|
|
3305
3342
|
const svc = configFormsArg?.configForms;
|
|
3306
3343
|
const face = svc !== void 0 && svc !== null ? svc : configFormsArg;
|
|
3307
3344
|
configFormsHandle = typeof face?.get === "function" ? face : void 0;
|
|
3345
|
+
if (configFormsHandle !== void 0) try {
|
|
3346
|
+
const form = configFormsHandle.get(ENTRY_ID);
|
|
3347
|
+
const refresh = () => {
|
|
3348
|
+
monitorPanelEnabledCache = decodeSettings(form.getSnapshot().value?.settings)?.monitorPanel?.enabled ?? false;
|
|
3349
|
+
nativeMonitorReady = true;
|
|
3350
|
+
};
|
|
3351
|
+
refresh();
|
|
3352
|
+
form.subscribe(() => {
|
|
3353
|
+
try {
|
|
3354
|
+
refresh();
|
|
3355
|
+
} catch {}
|
|
3356
|
+
});
|
|
3357
|
+
} catch (error) {
|
|
3358
|
+
console.warn("[dsh-context-compression-improved] FAB 读数预热失败(沿用桥面):", error);
|
|
3359
|
+
}
|
|
3308
3360
|
});
|
|
3309
3361
|
} catch (error) {
|
|
3310
3362
|
console.warn("[dsh-context-compression-improved] configForms 臂挂载失败(桥面继续服务):", error);
|
|
@@ -3339,6 +3391,7 @@ window.__ModuleLoader__.load({
|
|
|
3339
3391
|
};
|
|
3340
3392
|
}
|
|
3341
3393
|
monitorPanelEnabledCache = projected.value?.monitorPanel?.enabled ?? false;
|
|
3394
|
+
nativeMonitorReady = true;
|
|
3342
3395
|
return projected;
|
|
3343
3396
|
},
|
|
3344
3397
|
subscribe: (listener) => form.subscribe(listener),
|
|
@@ -3395,6 +3448,27 @@ window.__ModuleLoader__.load({
|
|
|
3395
3448
|
}
|
|
3396
3449
|
};
|
|
3397
3450
|
};
|
|
3451
|
+
const sectionViaAdapter = (props) => {
|
|
3452
|
+
const inj = injected();
|
|
3453
|
+
const scope = inj.hooks?.compression;
|
|
3454
|
+
const useCompression = (selector) => {
|
|
3455
|
+
if (!scope) return selector({
|
|
3456
|
+
status: "loading",
|
|
3457
|
+
value: void 0,
|
|
3458
|
+
revision: void 0,
|
|
3459
|
+
writable: false,
|
|
3460
|
+
base: void 0,
|
|
3461
|
+
user: void 0,
|
|
3462
|
+
mode: "memory"
|
|
3463
|
+
});
|
|
3464
|
+
return (0, react.useSyncExternalStore)(scope.subscribe, () => selector(scope.getSnapshot()));
|
|
3465
|
+
};
|
|
3466
|
+
return (0, react.createElement)(ContextCompressionSettingsSection, {
|
|
3467
|
+
...inj,
|
|
3468
|
+
...props,
|
|
3469
|
+
useCompression
|
|
3470
|
+
});
|
|
3471
|
+
};
|
|
3398
3472
|
try {
|
|
3399
3473
|
ctx.slots.inject("settings.section", () => ctx.slots.register({
|
|
3400
3474
|
name: "settings.section",
|
|
@@ -3405,7 +3479,7 @@ window.__ModuleLoader__.load({
|
|
|
3405
3479
|
inject: injected
|
|
3406
3480
|
}, ContextCompressionSettingsSection));
|
|
3407
3481
|
} catch (error) {
|
|
3408
|
-
console.warn("[dsh-context-compression-improved] settings.section 注册失败(
|
|
3482
|
+
console.warn("[dsh-context-compression-improved] settings.section 注册失败(宿主无该槽,静默缺席):", error);
|
|
3409
3483
|
}
|
|
3410
3484
|
try {
|
|
3411
3485
|
ctx.slots.inject("conversation.input.left", () => ctx.slots.register({
|
|
@@ -3425,27 +3499,7 @@ window.__ModuleLoader__.load({
|
|
|
3425
3499
|
name: "plugins.bundle.config",
|
|
3426
3500
|
key: "dsh-context-compression-improved",
|
|
3427
3501
|
locale: NS
|
|
3428
|
-
},
|
|
3429
|
-
const inj = injected();
|
|
3430
|
-
const scope = inj.hooks?.compression;
|
|
3431
|
-
const useCompression = (selector) => {
|
|
3432
|
-
if (!scope) return selector({
|
|
3433
|
-
status: "loading",
|
|
3434
|
-
value: void 0,
|
|
3435
|
-
revision: void 0,
|
|
3436
|
-
writable: false,
|
|
3437
|
-
base: void 0,
|
|
3438
|
-
user: void 0,
|
|
3439
|
-
mode: "memory"
|
|
3440
|
-
});
|
|
3441
|
-
return (0, react.useSyncExternalStore)(scope.subscribe, () => selector(scope.getSnapshot()));
|
|
3442
|
-
};
|
|
3443
|
-
return (0, react.createElement)(ContextCompressionSettingsSection, {
|
|
3444
|
-
...inj,
|
|
3445
|
-
...props,
|
|
3446
|
-
useCompression
|
|
3447
|
-
});
|
|
3448
|
-
}));
|
|
3502
|
+
}, sectionViaAdapter));
|
|
3449
3503
|
} catch (error) {
|
|
3450
3504
|
console.warn("[dsh-context-compression-improved] plugins.bundle.config 注册失败(旧宿主无该槽,静默缺席):", error);
|
|
3451
3505
|
}
|
|
@@ -74,7 +74,12 @@ var SavingsLedger = class {
|
|
|
74
74
|
const hit = snap.usage.cacheHitRate;
|
|
75
75
|
return `net=${snap.net.exact}(exact)/${snap.net.estimated}(est) gross=${snap.gross.exact}/${snap.gross.estimated} offsets=${snap.offsets.exact}/${snap.offsets.estimated} requests=${snap.usage.requests} cacheHit=${hit === null ? "–" : `${Math.round(hit * 100)}%`}`;
|
|
76
76
|
}
|
|
77
|
-
/**
|
|
77
|
+
/**
|
|
78
|
+
* 记录一次已落盘的压缩节省(land 成功后调用;tokensRemoved ≤ 0 忽略)。
|
|
79
|
+
*
|
|
80
|
+
* 仪表口径:该条目在替换事件离开当前 surface 前一直计入"当前生效毛节省"
|
|
81
|
+
* (由 {@link observeActive} 每回合收敛),不再一次性永久累加。
|
|
82
|
+
*/
|
|
78
83
|
recordSaving(input) {
|
|
79
84
|
const removed = input.tokensBefore - input.tokensAfter;
|
|
80
85
|
if (!Number.isFinite(removed) || removed <= 0) return;
|
|
@@ -83,7 +88,8 @@ var SavingsLedger = class {
|
|
|
83
88
|
component: input.component,
|
|
84
89
|
tokens: removed,
|
|
85
90
|
basis: input.basis,
|
|
86
|
-
at: Date.now()
|
|
91
|
+
at: Date.now(),
|
|
92
|
+
...input.replacementSeq === void 0 ? {} : { replacementSeq: input.replacementSeq }
|
|
87
93
|
});
|
|
88
94
|
if (typeof input.originalText === "string" && input.originalText.length > 0) {
|
|
89
95
|
const hash = savingsHash(input.originalText);
|
|
@@ -116,8 +122,7 @@ var SavingsLedger = class {
|
|
|
116
122
|
this.seenFullText.add(seenKey);
|
|
117
123
|
}
|
|
118
124
|
const hit = this.registry.get(savingsHash(input.text));
|
|
119
|
-
if (hit === void 0 || hit.
|
|
120
|
-
hit.consumed = true;
|
|
125
|
+
if (hit === void 0 || hit.sessionId !== input.sessionId) return;
|
|
121
126
|
const { tokens, basis } = input.measure(input.text);
|
|
122
127
|
if (tokens <= 0) return;
|
|
123
128
|
this.push(input.sessionId, {
|
|
@@ -153,6 +158,65 @@ var SavingsLedger = class {
|
|
|
153
158
|
list.push(entry);
|
|
154
159
|
if (list.length > MAX_ENTRIES_PER_SESSION) list.splice(0, list.length - MAX_ENTRIES_PER_SESSION);
|
|
155
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* 仪表口径收敛:一个 'saving' 条目只在其替换事件仍位于当前 surface 时计为
|
|
163
|
+
* "当前生效毛节省"。pruner 每回合传入存活 seq 集合,离开 surface 的替换
|
|
164
|
+
* (被后续压缩/裁剪替换)即从毛节省中扣除,数字随压缩内容进出而涨落。
|
|
165
|
+
* 无 replacementSeq 的条目保持原样(无法追踪者不收敛)。
|
|
166
|
+
*/
|
|
167
|
+
observeActive(sessionId, liveSeqs) {
|
|
168
|
+
const list = this.entries.get(sessionId);
|
|
169
|
+
if (list === void 0) return;
|
|
170
|
+
const kept = list.filter((entry) => entry.kind !== "saving" || entry.replacementSeq === void 0 || liveSeqs.has(entry.replacementSeq));
|
|
171
|
+
if (kept.length !== list.length) this.entries.set(sessionId, kept);
|
|
172
|
+
}
|
|
173
|
+
/** 该会话是否已有账本条目(重进会话时用于避免投影与实时叠加)。 */
|
|
174
|
+
hasSession(sessionId) {
|
|
175
|
+
return this.entries.has(sessionId);
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* 用会话日志投影播种一个会话的账本(重进/重启会话时调用一次)。写入
|
|
179
|
+
* savings/offsets 条目及其原文配对 registry,后续实时增量(observeActive /
|
|
180
|
+
* noteFullText)在同一条目集合上继续工作。调用方负责只播种一次。
|
|
181
|
+
*/
|
|
182
|
+
seedProjected(sessionId, projection) {
|
|
183
|
+
for (const entry of projection.savings) {
|
|
184
|
+
if (!Number.isFinite(entry.tokens) || entry.tokens <= 0) continue;
|
|
185
|
+
this.push(sessionId, {
|
|
186
|
+
kind: "saving",
|
|
187
|
+
component: entry.component,
|
|
188
|
+
tokens: entry.tokens,
|
|
189
|
+
basis: entry.basis,
|
|
190
|
+
at: entry.at,
|
|
191
|
+
replacementSeq: entry.replacementSeq
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
for (const entry of projection.offsets) {
|
|
195
|
+
if (!Number.isFinite(entry.tokens) || entry.tokens <= 0) continue;
|
|
196
|
+
this.push(sessionId, {
|
|
197
|
+
kind: "offset",
|
|
198
|
+
component: entry.component,
|
|
199
|
+
tokens: entry.tokens,
|
|
200
|
+
basis: entry.basis,
|
|
201
|
+
at: entry.at,
|
|
202
|
+
...entry.note === void 0 ? {} : { note: entry.note }
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
for (const item of projection.registry) {
|
|
206
|
+
if (this.registry.size >= MAX_REGISTRY && !this.registry.has(item.hash)) {
|
|
207
|
+
const oldest = this.registry.keys().next().value;
|
|
208
|
+
if (oldest !== void 0) this.registry.delete(oldest);
|
|
209
|
+
}
|
|
210
|
+
this.registry.set(item.hash, {
|
|
211
|
+
sessionId,
|
|
212
|
+
component: "projection",
|
|
213
|
+
claimedTokens: item.claimedTokens,
|
|
214
|
+
basis: item.basis,
|
|
215
|
+
sourceSeq: item.sourceSeq,
|
|
216
|
+
consumed: false
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
}
|
|
156
220
|
/** 汇总快照。sessionId 缺省 = 全会话聚合。两个 basis 分列,永不合并。 */
|
|
157
221
|
snapshot(sessionId) {
|
|
158
222
|
const scope = sessionId === void 0 ? [...this.entries.keys()] : [sessionId];
|
|
@@ -1662,8 +1726,8 @@ function resolvePolicy(config, profile, custom = DEFAULT_CUSTOM_COMPRESSION_POLI
|
|
|
1662
1726
|
historyMode: "routine",
|
|
1663
1727
|
nativeTriggerTokens: Number.MAX_SAFE_INTEGER,
|
|
1664
1728
|
nativeTargetTokens: Number.MAX_SAFE_INTEGER,
|
|
1665
|
-
freshTriggerTokens:
|
|
1666
|
-
freshTargetTokens:
|
|
1729
|
+
freshTriggerTokens: 4096,
|
|
1730
|
+
freshTargetTokens: 1536,
|
|
1667
1731
|
aggregateTriggerTokens: 32768,
|
|
1668
1732
|
aggregateTargetTokens: 12288,
|
|
1669
1733
|
historyTriggerTokens: 5e5,
|
|
@@ -1710,4 +1774,4 @@ function assertNonNegativeInteger(name, value) {
|
|
|
1710
1774
|
if (!Number.isSafeInteger(value) || value < 0) throw new Error(`ToolResultPruneConfig: ${name} (${String(value)}) must be a non-negative safe integer`);
|
|
1711
1775
|
}
|
|
1712
1776
|
//#endregion
|
|
1713
|
-
export { getLastIntentFold as A, decimalRateNanoUnits as B, estimateSavingsPricing as C, INTENT_GATE_GROWTH_TOKENS as D, INTENT_GATE_FLOOR_FRACTION as E, recordIntentFold as F, resolveOfficialDeepSeekPrice as H, recordRecertified as I, recordScore as L, getSummaryOverride as M, invalidateOnTaskChange as N, evaluateIntentGate as O, observeIntentEnabled as P, setSummaryOverride as R, buildMonitorSnapshot as S, observeContextUsage as T, getSavingsLedger as U, priceOfficialDeepSeekUsage as V, resolveCustomPolicy as _, DEFAULT_CONTEXT_COMPRESSION_SETTINGS as a, COMPRESSION_PROFILES as b, charsToTokens as c, isValidAutoCompactThresholdPercent as d, parseContextCompressionSettings as f, DEFAULT_CUSTOM_COMPRESSION_POLICY as g, CustomCompressionPolicySchema as h, DEFAULTS as i, getObservedIntentEnabled as j, getAdvisorState as k, codePointLength as l, resolvePolicy as m, CONTEXT_COMPRESSION_SETTINGS_NAMESPACE as n, PRUNE_MARKER as o, resolveConfig as p, ContextCompressionSettingsSchema as r, charsForTokens as s, AUTO_COMPACT_THRESHOLD_LIMITS as t, isCompressionProfile as u, assertNever as v, isSessionOverrideAction as w, applySessionOverride as x, deepFreeze as y, DEEPSEEK_OFFICIAL_PRICE_CATALOG_VERSION as z };
|
|
1777
|
+
export { getLastIntentFold as A, decimalRateNanoUnits as B, estimateSavingsPricing as C, INTENT_GATE_GROWTH_TOKENS as D, INTENT_GATE_FLOOR_FRACTION as E, recordIntentFold as F, resolveOfficialDeepSeekPrice as H, recordRecertified as I, recordScore as L, getSummaryOverride as M, invalidateOnTaskChange as N, evaluateIntentGate as O, observeIntentEnabled as P, setSummaryOverride as R, buildMonitorSnapshot as S, observeContextUsage as T, getSavingsLedger as U, priceOfficialDeepSeekUsage as V, savingsHash as W, resolveCustomPolicy as _, DEFAULT_CONTEXT_COMPRESSION_SETTINGS as a, COMPRESSION_PROFILES as b, charsToTokens as c, isValidAutoCompactThresholdPercent as d, parseContextCompressionSettings as f, DEFAULT_CUSTOM_COMPRESSION_POLICY as g, CustomCompressionPolicySchema as h, DEFAULTS as i, getObservedIntentEnabled as j, getAdvisorState as k, codePointLength as l, resolvePolicy as m, CONTEXT_COMPRESSION_SETTINGS_NAMESPACE as n, PRUNE_MARKER as o, resolveConfig as p, ContextCompressionSettingsSchema as r, charsForTokens as s, AUTO_COMPACT_THRESHOLD_LIMITS as t, isCompressionProfile as u, assertNever as v, isSessionOverrideAction as w, applySessionOverride as x, deepFreeze as y, DEEPSEEK_OFFICIAL_PRICE_CATALOG_VERSION as z };
|