dsh-context-compression-improved 0.2.3 → 0.2.4
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/.github/workflows/ci.yml +39 -39
- package/CHANGELOG.md +137 -135
- package/README.md +112 -112
- package/package.json +142 -142
- package/packages/selector/README.md +31 -31
- package/packages/selector/README.zh.md +31 -31
- package/packages/selector/dsh.plugin.json +16 -16
- package/packages/selector/lib/client.d.ts +228 -228
- package/packages/selector/lib/client.js +1462 -1462
- package/packages/selector/lib/config.js +856 -842
- package/packages/selector/lib/index.d.ts +37 -37
- package/packages/selector/lib/index.js +693 -645
- package/packages/selector/lib/invariant.js +70 -70
- package/packages/selector/lib/pruner.d.ts +728 -683
- package/packages/selector/lib/pruner.js +4765 -3807
- package/packages/selector/lib/style.css +46 -46
- package/packages/selector/lib/tail-trim.js +136 -136
- package/packages/selector/package.json +9 -1
- package/packages/selector/src/client/index.ts +111 -111
- package/packages/selector/src/preset-overlay.ts +60 -1
- package/packages/selector/src/pruner/content.ts +18 -5
- package/packages/selector/src/pruner/types.ts +23 -5
- package/packages/selector/src/pruner.ts +164 -154
- package/packages/selector/src/runtime/adaptive-cost.ts +23 -12
- package/packages/selector/src/runtime/audit.ts +18 -2
- package/packages/selector/src/runtime/config.ts +30 -1
- package/packages/selector/src/runtime/measurement.ts +31 -2
- package/packages/selector/src/runtime/reducers.ts +1115 -97
- package/packages/selector/src/runtime/tokenpilot/dedup.ts +1 -1
- package/packages/selector/src/runtime/tokenpilot/locator.ts +1 -1
- package/packages/selector/src/runtime/tokenpilot/read-state.ts +23 -2
- package/packages/selector/src/runtime/tokenpilot/sidechannel.ts +275 -0
- package/packages/selector/src/runtime/toolclass.ts +103 -0
- package/packages/selector/src/runtime/types.ts +16 -0
- package/packages/selector/tests/preset-overlay.host.spec.ts +256 -243
- package/packages/selector/tests/runtime/adaptive-cost.spec.ts +7 -7
- package/packages/selector/tests/runtime/audit.spec.ts +44 -1
- package/packages/selector/tests/runtime/char-basis.spec.ts +30 -0
- package/packages/selector/tests/runtime/code-skeleton.spec.ts +14 -3
- package/packages/selector/tests/runtime/frequency-longstrings.spec.ts +74 -0
- package/packages/selector/tests/runtime/html-reducer.spec.ts +212 -0
- package/packages/selector/tests/runtime/line-mapping.spec.ts +153 -0
- package/packages/selector/tests/runtime/prose-reducers.spec.ts +133 -0
- package/packages/selector/tests/runtime/public/public-runtime.spec.ts +198 -27
- package/packages/selector/tests/runtime/read-input-cap.spec.ts +33 -0
- package/packages/selector/tests/runtime/search-reducer.spec.ts +110 -0
- package/packages/selector/tests/runtime/sidechannel.spec.ts +241 -0
- package/packages/selector/tests/runtime/toc-and-bundled.spec.ts +159 -0
- package/packages/selector/tests/runtime/tokenpilot/read-state.spec.ts +24 -0
- package/packages/selector/tests/runtime/toolclass.spec.ts +156 -0
- package/packages/selector/tests/standing-generation.host.spec.ts +642 -631
- package/scripts/toolclass-corpus-replay.mjs +273 -0
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
# dsh-context-compression-improved
|
|
2
|
-
|
|
3
|
-
这是可直接安装的非官方社区 DeepSeek Harness 上下文压缩选择器 Product Bundle。
|
|
4
|
-
|
|
5
|
-
**0.1.0 更新:**已加入 DeepSeek V4 Flash 视觉模型的官方 tokenizer;用户可选择模型驱动 Auto Compact 的触发阈值;标准 Profile 的水位与压缩参数会随该选择联动。
|
|
6
|
-
|
|
7
|
-
```sh
|
|
8
|
-
```sh
|
|
9
|
-
dsh plugin --profile web add dsh-context-compression-improved@dsh-0.1.5
|
|
10
|
-
# DSH 0.1.2 line:
|
|
11
|
-
# dsh plugin --profile web add dsh-context-compression-improved@dsh-0.1.2
|
|
12
|
-
dsh --profile web --dump-config
|
|
13
|
-
```
|
|
14
|
-
dsh --profile web --dump-config
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
这一条命令会安装 Bundle 及其固定版本的 `@huggingface/tokenizers` 依赖,不再需要单独的 runtime 包。Bundle 提供 Host 设置、Web UI 和可逆的 preset overlay。除 id 精确等于内置 `minimal` 的 preset 外,其他 preset 都会获得压缩能力;非 Minimal preset 之间切换时已保存设置保持不变。Minimal 只暂停插件压缩,不删除设置。
|
|
18
|
-
|
|
19
|
-
## 本包能力
|
|
20
|
-
|
|
21
|
-
本包提供确定性的 Fresh、Aggregate、History、Native 工具结果与 Custom TailTrim 压缩,插件自有的 `context_compression_retrieve` 恢复工具,结构化审计记录,以及固定版本的离线 DeepSeek V4 tokenizer。它只使用 DeepSeek Harness 的公开 API,兼容 `0.1.1-rc.2` 与 `0.1.2-alpha.5`,不修改 Harness 核心。
|
|
22
|
-
|
|
23
|
-
有损改写要求 replacement 前后取得同 revision 的 exact count。明确验证过的模型 id 为 `deepseek-v4-flash`、`deepseek-v4-pro` 与 `deepseek-v4-flash-vision-exp`。视觉模型的文本计数使用独立固定的 `deepseek-ai/DeepSeek-V4-Flash-Vision-Exp` tokenizer。图像 token 使用由官方 golden fixtures 逐项验证的官方图像处理算术,并以 `tokenizer-estimate` 上报:有效 intrinsic 尺寸的四种对齐位置取中值,每张图片保留 384 token 上限;尺寸畸形或无法计算时固定计为 256 token。由于绝对 prompt 位置与 adapter 最终图片投影不可公开观测,该数值不标记为 exact。含图片的工具结果候选仍不具备 exact 资格并保持原样;未知模型、tokenizer 资产不可用、不安全工具组或文本计量不完整时继续 fail-open。
|
|
24
|
-
|
|
25
|
-
审计日志以 `context-compression audit ` 开头,区分策略快照、组件关闭/跳过、已提交 rewrite、fail-open 错误和已观察到的核心 `compaction/summary`。审计记录不包含 prompt 或工具结果正文。
|
|
26
|
-
|
|
27
|
-
首次 `policy-frozen` 会携带完整 settings/deployment 快照。它通过 Harness logger 输出,因此保留期限由部署的日志 sink 决定;标准 prune/replacement Session event 仍是已提交 rewrite 的持久证据。本包不会在 `~/.dsh` 下硬编码私有路径。
|
|
28
|
-
|
|
29
|
-
已验证兼容:DeepSeek Harness `dsh-v0.1.1-rc.2` 与 `dsh-v0.1.2-alpha.5`,Node `^22.19.0 || >=24`。不需要修改 Harness 核心。
|
|
30
|
-
|
|
31
|
-
Profile、默认值、审计证据、Adaptive/cache 限制、升级/卸载与安全说明见[完整 README](https://github.com/WilliamShi666/dsh-context-compression-improved#readme)。Tokenizer 来源与校验和在 `assets/deepseek-v4/manifest.json`、`assets/deepseek-v4-vision-exp/manifest.json`,并汇总于 [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md)。本包与 DeepSeek 无隶属或背书关系。
|
|
1
|
+
# dsh-context-compression-improved
|
|
2
|
+
|
|
3
|
+
这是可直接安装的非官方社区 DeepSeek Harness 上下文压缩选择器 Product Bundle。
|
|
4
|
+
|
|
5
|
+
**0.1.0 更新:**已加入 DeepSeek V4 Flash 视觉模型的官方 tokenizer;用户可选择模型驱动 Auto Compact 的触发阈值;标准 Profile 的水位与压缩参数会随该选择联动。
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
```sh
|
|
9
|
+
dsh plugin --profile web add dsh-context-compression-improved@dsh-0.1.5
|
|
10
|
+
# DSH 0.1.2 line:
|
|
11
|
+
# dsh plugin --profile web add dsh-context-compression-improved@dsh-0.1.2
|
|
12
|
+
dsh --profile web --dump-config
|
|
13
|
+
```
|
|
14
|
+
dsh --profile web --dump-config
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
这一条命令会安装 Bundle 及其固定版本的 `@huggingface/tokenizers` 依赖,不再需要单独的 runtime 包。Bundle 提供 Host 设置、Web UI 和可逆的 preset overlay。除 id 精确等于内置 `minimal` 的 preset 外,其他 preset 都会获得压缩能力;非 Minimal preset 之间切换时已保存设置保持不变。Minimal 只暂停插件压缩,不删除设置。
|
|
18
|
+
|
|
19
|
+
## 本包能力
|
|
20
|
+
|
|
21
|
+
本包提供确定性的 Fresh、Aggregate、History、Native 工具结果与 Custom TailTrim 压缩,插件自有的 `context_compression_retrieve` 恢复工具,结构化审计记录,以及固定版本的离线 DeepSeek V4 tokenizer。它只使用 DeepSeek Harness 的公开 API,兼容 `0.1.1-rc.2` 与 `0.1.2-alpha.5`,不修改 Harness 核心。
|
|
22
|
+
|
|
23
|
+
有损改写要求 replacement 前后取得同 revision 的 exact count。明确验证过的模型 id 为 `deepseek-v4-flash`、`deepseek-v4-pro` 与 `deepseek-v4-flash-vision-exp`。视觉模型的文本计数使用独立固定的 `deepseek-ai/DeepSeek-V4-Flash-Vision-Exp` tokenizer。图像 token 使用由官方 golden fixtures 逐项验证的官方图像处理算术,并以 `tokenizer-estimate` 上报:有效 intrinsic 尺寸的四种对齐位置取中值,每张图片保留 384 token 上限;尺寸畸形或无法计算时固定计为 256 token。由于绝对 prompt 位置与 adapter 最终图片投影不可公开观测,该数值不标记为 exact。含图片的工具结果候选仍不具备 exact 资格并保持原样;未知模型、tokenizer 资产不可用、不安全工具组或文本计量不完整时继续 fail-open。
|
|
24
|
+
|
|
25
|
+
审计日志以 `context-compression audit ` 开头,区分策略快照、组件关闭/跳过、已提交 rewrite、fail-open 错误和已观察到的核心 `compaction/summary`。审计记录不包含 prompt 或工具结果正文。
|
|
26
|
+
|
|
27
|
+
首次 `policy-frozen` 会携带完整 settings/deployment 快照。它通过 Harness logger 输出,因此保留期限由部署的日志 sink 决定;标准 prune/replacement Session event 仍是已提交 rewrite 的持久证据。本包不会在 `~/.dsh` 下硬编码私有路径。
|
|
28
|
+
|
|
29
|
+
已验证兼容:DeepSeek Harness `dsh-v0.1.1-rc.2` 与 `dsh-v0.1.2-alpha.5`,Node `^22.19.0 || >=24`。不需要修改 Harness 核心。
|
|
30
|
+
|
|
31
|
+
Profile、默认值、审计证据、Adaptive/cache 限制、升级/卸载与安全说明见[完整 README](https://github.com/WilliamShi666/dsh-context-compression-improved#readme)。Tokenizer 来源与校验和在 `assets/deepseek-v4/manifest.json`、`assets/deepseek-v4-vision-exp/manifest.json`,并汇总于 [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md)。本包与 DeepSeek 无隶属或背书关系。
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "dsh-external/dsh-context-compression-improved",
|
|
3
|
-
"version": "0.1.1",
|
|
4
|
-
"main": "./lib/index.js",
|
|
5
|
-
"description": "Auditable tool-result context-compression selector with code-skeleton gate for DeepSeek Harness",
|
|
6
|
-
"engines": {
|
|
7
|
-
"dsh": ">=0.1.2-rc.1 <0.2.0-0"
|
|
8
|
-
},
|
|
9
|
-
"contributes": {
|
|
10
|
-
"tools": [],
|
|
11
|
-
"skills": []
|
|
12
|
-
},
|
|
13
|
-
"client": {
|
|
14
|
-
"main": "./lib/client.js"
|
|
15
|
-
}
|
|
16
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"id": "dsh-external/dsh-context-compression-improved",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"main": "./lib/index.js",
|
|
5
|
+
"description": "Auditable tool-result context-compression selector with code-skeleton gate for DeepSeek Harness",
|
|
6
|
+
"engines": {
|
|
7
|
+
"dsh": ">=0.1.2-rc.1 <0.2.0-0"
|
|
8
|
+
},
|
|
9
|
+
"contributes": {
|
|
10
|
+
"tools": [],
|
|
11
|
+
"skills": []
|
|
12
|
+
},
|
|
13
|
+
"client": {
|
|
14
|
+
"main": "./lib/client.js"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -1,229 +1,229 @@
|
|
|
1
|
-
import { ClientContext, SettingsScope } from "@deepseek-ai/dsh-client-runtime/client";
|
|
2
|
-
import { InjectFace, PropsLocale, PropsRuntime } from "@deepseek-ai/dsh-client-ui-slots";
|
|
3
|
-
//#region src/profiles.d.ts
|
|
4
|
-
/** Public context-compression choices shared by the Host schema and browser selector. */
|
|
5
|
-
declare const COMPRESSION_PROFILES: readonly ["off", "native", "balanced", "cache-strict", "savings", "adaptive", "tokenpilot-inspired", "custom"];
|
|
6
|
-
/** One supported context-compression profile. */
|
|
7
|
-
type CompressionProfile = typeof COMPRESSION_PROFILES[number];
|
|
8
|
-
/** Single canonical unit stored by a version-1 browser Custom document. */
|
|
9
|
-
type CustomCompressionUnit = 'tokens' | 'context-percent';
|
|
10
|
-
/** Whether Custom History may routinely rewrite an already-sent prefix. */
|
|
11
|
-
type CustomPrefixPolicy = 'preserve' | 'pressure-break';
|
|
12
|
-
/** Browser representation of one independently enabled Fresh or Aggregate budget. */
|
|
13
|
-
interface CustomCompressionBudget {
|
|
14
|
-
enabled: boolean;
|
|
15
|
-
trigger: number;
|
|
16
|
-
target: number;
|
|
17
|
-
}
|
|
18
|
-
/** Legacy browser representation of the Custom History working set. */
|
|
19
|
-
interface LegacyCustomHistoryPolicy {
|
|
20
|
-
enabled: boolean;
|
|
21
|
-
trigger: number;
|
|
22
|
-
keepRecentTurns: number;
|
|
23
|
-
keepRecent: number;
|
|
24
|
-
minReclaim: number;
|
|
25
|
-
}
|
|
26
|
-
/** Browser representation of Custom History tool-call and token-tail protection. */
|
|
27
|
-
interface CustomHistoryPolicy {
|
|
28
|
-
enabled: boolean;
|
|
29
|
-
trigger: number;
|
|
30
|
-
keepRecentToolCalls: number;
|
|
31
|
-
keepRecentTokens: number;
|
|
32
|
-
minReclaim: number;
|
|
33
|
-
}
|
|
34
|
-
/** Browser representation of the Custom-only Experimental TailTrim gate. */
|
|
35
|
-
interface CustomTailTrimPolicy {
|
|
36
|
-
enabled: boolean;
|
|
37
|
-
trigger: number;
|
|
38
|
-
}
|
|
39
|
-
interface CustomCompressionPolicyCommon<HistoryPolicy> {
|
|
40
|
-
unit: CustomCompressionUnit;
|
|
41
|
-
fresh: CustomCompressionBudget;
|
|
42
|
-
aggregate: CustomCompressionBudget;
|
|
43
|
-
history: HistoryPolicy;
|
|
44
|
-
prefixPolicy: CustomPrefixPolicy;
|
|
45
|
-
}
|
|
46
|
-
/** Legacy public Custom document; accepted and normalized before editing. */
|
|
47
|
-
interface CustomCompressionPolicyV1 extends CustomCompressionPolicyCommon<LegacyCustomHistoryPolicy> {
|
|
48
|
-
version: 1;
|
|
49
|
-
}
|
|
50
|
-
/** Legacy Custom document with a default-disabled TailTrim stage. */
|
|
51
|
-
interface CustomCompressionPolicyV2 extends CustomCompressionPolicyCommon<LegacyCustomHistoryPolicy> {
|
|
52
|
-
version: 2;
|
|
53
|
-
tailTrim: CustomTailTrimPolicy;
|
|
54
|
-
}
|
|
55
|
-
/** Public Custom document with tool-call working-set protection. */
|
|
56
|
-
interface CustomCompressionPolicyV3 extends CustomCompressionPolicyCommon<CustomHistoryPolicy> {
|
|
57
|
-
version: 3;
|
|
58
|
-
tailTrim: CustomTailTrimPolicy;
|
|
59
|
-
}
|
|
60
|
-
/** Exact public Custom document accepted by the Host and browser boundary. */
|
|
61
|
-
type CustomCompressionPolicy = CustomCompressionPolicyV1 | CustomCompressionPolicyV2 | CustomCompressionPolicyV3;
|
|
62
|
-
/** User-tunable Auto Compact coordination preferences. */
|
|
63
|
-
interface AutoCompactSettings {
|
|
64
|
-
thresholdPercent: number;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Orthogonal code-skeleton reducer gate, mirrored browser-safe from the
|
|
68
|
-
* runtime: independent of every profile, default off.
|
|
69
|
-
*/
|
|
70
|
-
interface CodeSkeletonSettings {
|
|
71
|
-
enabled: boolean;
|
|
72
|
-
}
|
|
73
|
-
/** Browser-safe mirror of the runtime presetOptions section. */
|
|
74
|
-
interface PresetOptionsSettings {
|
|
75
|
-
readonly dedupeToolResults?: boolean;
|
|
76
|
-
readonly summaryLocator?: boolean;
|
|
77
|
-
readonly prefixStabilizer?: boolean;
|
|
78
|
-
readonly readState?: boolean;
|
|
79
|
-
readonly estimatorMode?: '' | 'host' | 'direct';
|
|
80
|
-
readonly estimatorProvider?: string;
|
|
81
|
-
readonly estimatorModel?: string;
|
|
82
|
-
readonly estimatorBaseUrl?: string;
|
|
83
|
-
readonly estimatorApiKey?: string;
|
|
84
|
-
readonly estimatorTimeoutMs?: number;
|
|
85
|
-
}
|
|
86
|
-
/** Durable settings section owned by this package. */
|
|
87
|
-
interface ContextCompressionSettings {
|
|
88
|
-
/** Default profile captured when each Session first reaches the pruner. */
|
|
89
|
-
profile: CompressionProfile;
|
|
90
|
-
/** Complete canonical policy captured with `profile` when the runtime first observes a Session. */
|
|
91
|
-
custom: CustomCompressionPolicy;
|
|
92
|
-
/** Auto Compact trigger captured with `profile` when the runtime first observes a Session. */
|
|
93
|
-
autoCompact: AutoCompactSettings;
|
|
94
|
-
/** Code-skeleton reducer gate captured independently of `profile`. */
|
|
95
|
-
codeSkeleton: CodeSkeletonSettings;
|
|
96
|
-
/** Optional tokenpilot-inspired sub-capability overrides (presence-validated only). */
|
|
97
|
-
presetOptions?: PresetOptionsSettings;
|
|
98
|
-
}
|
|
99
|
-
//#endregion
|
|
100
|
-
//#region src/client/preset-options.d.ts
|
|
101
|
-
/** One partial edit of `presetOptions`; `undefined` clears the named field. */
|
|
102
|
-
type PresetOptionsPatch = { readonly [K in keyof PresetOptionsSettings]?: PresetOptionsSettings[K] | undefined; };
|
|
103
|
-
//#endregion
|
|
104
|
-
//#region src/client/locales.d.ts
|
|
105
|
-
/** Simplified Chinese copy for the context-compression selector. */
|
|
106
|
-
declare const zh: {
|
|
107
|
-
nav: string;
|
|
108
|
-
'settings.title': string;
|
|
109
|
-
'settings.description': string;
|
|
110
|
-
label: string;
|
|
111
|
-
'status.loading': string;
|
|
112
|
-
'status.unavailable': string;
|
|
113
|
-
'status.presetUnavailable': string;
|
|
114
|
-
'status.minimalUnavailable': string;
|
|
115
|
-
'status.saveFailed': string;
|
|
116
|
-
'pricing.disclosure': string;
|
|
117
|
-
'profile.balanced': string;
|
|
118
|
-
'profile.cache-strict': string;
|
|
119
|
-
'profile.savings': string;
|
|
120
|
-
'profile.adaptive': string;
|
|
121
|
-
'profile.tokenpilot-inspired': string;
|
|
122
|
-
'estimator.title': string;
|
|
123
|
-
'estimator.description': string;
|
|
124
|
-
'estimator.mode': string;
|
|
125
|
-
'estimator.mode.off': string;
|
|
126
|
-
'estimator.followHost': string;
|
|
127
|
-
'estimator.mode.host': string;
|
|
128
|
-
'estimator.mode.direct': string;
|
|
129
|
-
'estimator.inactive': string;
|
|
130
|
-
'estimator.provider': string;
|
|
131
|
-
'estimator.provider.placeholder': string;
|
|
132
|
-
'estimator.model.placeholder': string;
|
|
133
|
-
'estimator.hostReuse': string;
|
|
134
|
-
'estimator.hostRoute': string;
|
|
135
|
-
'estimator.hostUnresolved': string;
|
|
136
|
-
'estimator.baseUrl': string;
|
|
137
|
-
'estimator.model': string;
|
|
138
|
-
'estimator.apiKey': string;
|
|
139
|
-
'estimator.apiKey.placeholder': string;
|
|
140
|
-
'estimator.apiKey.set': string;
|
|
141
|
-
'estimator.apiKey.clear': string;
|
|
142
|
-
'estimator.apiKey.overwrite': string;
|
|
143
|
-
'detail.tokenpilot-inspired': string;
|
|
144
|
-
'profile.custom': string;
|
|
145
|
-
'profile.native': string;
|
|
146
|
-
'profile.off': string;
|
|
147
|
-
'profile.current': string;
|
|
148
|
-
'detail.balanced': string;
|
|
149
|
-
'detail.cache-strict': string;
|
|
150
|
-
'detail.savings': string;
|
|
151
|
-
'detail.adaptive': string;
|
|
152
|
-
'detail.custom': string;
|
|
153
|
-
'detail.native': string;
|
|
154
|
-
'detail.off': string;
|
|
155
|
-
'autoCompact.title': string;
|
|
156
|
-
'autoCompact.description': string;
|
|
157
|
-
'autoCompact.inputLabel': string;
|
|
158
|
-
'autoCompact.sliderLabel': string;
|
|
159
|
-
'autoCompact.quick': string;
|
|
160
|
-
'autoCompact.riskLow': string;
|
|
161
|
-
'autoCompact.riskHigh': string;
|
|
162
|
-
'autoCompact.invalid': string;
|
|
163
|
-
'autoCompact.save': string;
|
|
164
|
-
'autoCompact.summaryHint': string;
|
|
165
|
-
'codeSkeleton.title': string;
|
|
166
|
-
'codeSkeleton.description': string;
|
|
167
|
-
'codeSkeleton.enabled': string;
|
|
168
|
-
'codeSkeleton.enabled.on': string;
|
|
169
|
-
'codeSkeleton.enabled.off': string;
|
|
170
|
-
'custom.title': string;
|
|
171
|
-
'custom.settingsHint': string;
|
|
172
|
-
'custom.sessionScope': string;
|
|
173
|
-
'custom.measurement': string;
|
|
174
|
-
'custom.unit': string;
|
|
175
|
-
'custom.unit.tokens': string;
|
|
176
|
-
'custom.unit.contextPercent': string;
|
|
177
|
-
'custom.enabled': string;
|
|
178
|
-
'custom.enabled.on': string;
|
|
179
|
-
'custom.enabled.off': string;
|
|
180
|
-
'custom.fresh.enabled': string;
|
|
181
|
-
'custom.fresh.trigger': string;
|
|
182
|
-
'custom.fresh.target': string;
|
|
183
|
-
'custom.aggregate.enabled': string;
|
|
184
|
-
'custom.aggregate.trigger': string;
|
|
185
|
-
'custom.aggregate.target': string;
|
|
186
|
-
'custom.history.enabled': string;
|
|
187
|
-
'custom.history.trigger': string;
|
|
188
|
-
'custom.history.keepRecentToolCalls': string;
|
|
189
|
-
'custom.history.keepRecentTokens': string;
|
|
190
|
-
'custom.history.minReclaim': string;
|
|
191
|
-
'custom.prefixPolicy': string;
|
|
192
|
-
'custom.prefixPolicy.preserve': string;
|
|
193
|
-
'custom.prefixPolicy.pressureBreak': string;
|
|
194
|
-
'custom.experimental': string;
|
|
195
|
-
'custom.tailTrim.enabled': string;
|
|
196
|
-
'custom.tailTrim.trigger': string;
|
|
197
|
-
'custom.tailTrim.warning': string;
|
|
198
|
-
'custom.save': string;
|
|
199
|
-
'custom.reset': string;
|
|
200
|
-
'custom.invalid': string;
|
|
201
|
-
};
|
|
202
|
-
/** Locale keys that every context-compression selector dictionary must provide. */
|
|
203
|
-
type ContextCompressionLocaleKey = keyof typeof zh;
|
|
204
|
-
//#endregion
|
|
205
|
-
//#region src/client/CompressionProfileSelector.d.ts
|
|
206
|
-
interface CompressionSelectorInjected {
|
|
207
|
-
hooks: {
|
|
208
|
-
compression: SettingsScope<ContextCompressionSettings>;
|
|
209
|
-
};
|
|
210
|
-
select: (profile: CompressionProfile) => Promise<void>;
|
|
211
|
-
saveCustom: (custom: CustomCompressionPolicy) => Promise<void>;
|
|
212
|
-
resetCustom: () => Promise<void>;
|
|
213
|
-
saveAutoCompact: (thresholdPercent: number) => Promise<void>;
|
|
214
|
-
saveCodeSkeleton: (enabled: boolean) => Promise<void>;
|
|
215
|
-
/** Patch of `presetOptions` members; an explicit `undefined` clears that field. */
|
|
216
|
-
savePresetOptions: (options: PresetOptionsPatch) => Promise<void>;
|
|
217
|
-
}
|
|
218
|
-
type CompressionProfileSelectorProps = PropsRuntime<'settings.section'> & PropsLocale<'context-compression'> & InjectFace<CompressionSelectorInjected>;
|
|
219
|
-
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
220
|
-
interface LocaleNamespaceMap {
|
|
221
|
-
'context-compression': ContextCompressionLocaleKey;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
//#endregion
|
|
225
|
-
//#region src/client/index.d.ts
|
|
226
|
-
declare const inject: string[];
|
|
227
|
-
declare function apply(ctx: ClientContext): void;
|
|
228
|
-
//#endregion
|
|
1
|
+
import { ClientContext, SettingsScope } from "@deepseek-ai/dsh-client-runtime/client";
|
|
2
|
+
import { InjectFace, PropsLocale, PropsRuntime } from "@deepseek-ai/dsh-client-ui-slots";
|
|
3
|
+
//#region src/profiles.d.ts
|
|
4
|
+
/** Public context-compression choices shared by the Host schema and browser selector. */
|
|
5
|
+
declare const COMPRESSION_PROFILES: readonly ["off", "native", "balanced", "cache-strict", "savings", "adaptive", "tokenpilot-inspired", "custom"];
|
|
6
|
+
/** One supported context-compression profile. */
|
|
7
|
+
type CompressionProfile = typeof COMPRESSION_PROFILES[number];
|
|
8
|
+
/** Single canonical unit stored by a version-1 browser Custom document. */
|
|
9
|
+
type CustomCompressionUnit = 'tokens' | 'context-percent';
|
|
10
|
+
/** Whether Custom History may routinely rewrite an already-sent prefix. */
|
|
11
|
+
type CustomPrefixPolicy = 'preserve' | 'pressure-break';
|
|
12
|
+
/** Browser representation of one independently enabled Fresh or Aggregate budget. */
|
|
13
|
+
interface CustomCompressionBudget {
|
|
14
|
+
enabled: boolean;
|
|
15
|
+
trigger: number;
|
|
16
|
+
target: number;
|
|
17
|
+
}
|
|
18
|
+
/** Legacy browser representation of the Custom History working set. */
|
|
19
|
+
interface LegacyCustomHistoryPolicy {
|
|
20
|
+
enabled: boolean;
|
|
21
|
+
trigger: number;
|
|
22
|
+
keepRecentTurns: number;
|
|
23
|
+
keepRecent: number;
|
|
24
|
+
minReclaim: number;
|
|
25
|
+
}
|
|
26
|
+
/** Browser representation of Custom History tool-call and token-tail protection. */
|
|
27
|
+
interface CustomHistoryPolicy {
|
|
28
|
+
enabled: boolean;
|
|
29
|
+
trigger: number;
|
|
30
|
+
keepRecentToolCalls: number;
|
|
31
|
+
keepRecentTokens: number;
|
|
32
|
+
minReclaim: number;
|
|
33
|
+
}
|
|
34
|
+
/** Browser representation of the Custom-only Experimental TailTrim gate. */
|
|
35
|
+
interface CustomTailTrimPolicy {
|
|
36
|
+
enabled: boolean;
|
|
37
|
+
trigger: number;
|
|
38
|
+
}
|
|
39
|
+
interface CustomCompressionPolicyCommon<HistoryPolicy> {
|
|
40
|
+
unit: CustomCompressionUnit;
|
|
41
|
+
fresh: CustomCompressionBudget;
|
|
42
|
+
aggregate: CustomCompressionBudget;
|
|
43
|
+
history: HistoryPolicy;
|
|
44
|
+
prefixPolicy: CustomPrefixPolicy;
|
|
45
|
+
}
|
|
46
|
+
/** Legacy public Custom document; accepted and normalized before editing. */
|
|
47
|
+
interface CustomCompressionPolicyV1 extends CustomCompressionPolicyCommon<LegacyCustomHistoryPolicy> {
|
|
48
|
+
version: 1;
|
|
49
|
+
}
|
|
50
|
+
/** Legacy Custom document with a default-disabled TailTrim stage. */
|
|
51
|
+
interface CustomCompressionPolicyV2 extends CustomCompressionPolicyCommon<LegacyCustomHistoryPolicy> {
|
|
52
|
+
version: 2;
|
|
53
|
+
tailTrim: CustomTailTrimPolicy;
|
|
54
|
+
}
|
|
55
|
+
/** Public Custom document with tool-call working-set protection. */
|
|
56
|
+
interface CustomCompressionPolicyV3 extends CustomCompressionPolicyCommon<CustomHistoryPolicy> {
|
|
57
|
+
version: 3;
|
|
58
|
+
tailTrim: CustomTailTrimPolicy;
|
|
59
|
+
}
|
|
60
|
+
/** Exact public Custom document accepted by the Host and browser boundary. */
|
|
61
|
+
type CustomCompressionPolicy = CustomCompressionPolicyV1 | CustomCompressionPolicyV2 | CustomCompressionPolicyV3;
|
|
62
|
+
/** User-tunable Auto Compact coordination preferences. */
|
|
63
|
+
interface AutoCompactSettings {
|
|
64
|
+
thresholdPercent: number;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Orthogonal code-skeleton reducer gate, mirrored browser-safe from the
|
|
68
|
+
* runtime: independent of every profile, default off.
|
|
69
|
+
*/
|
|
70
|
+
interface CodeSkeletonSettings {
|
|
71
|
+
enabled: boolean;
|
|
72
|
+
}
|
|
73
|
+
/** Browser-safe mirror of the runtime presetOptions section. */
|
|
74
|
+
interface PresetOptionsSettings {
|
|
75
|
+
readonly dedupeToolResults?: boolean;
|
|
76
|
+
readonly summaryLocator?: boolean;
|
|
77
|
+
readonly prefixStabilizer?: boolean;
|
|
78
|
+
readonly readState?: boolean;
|
|
79
|
+
readonly estimatorMode?: '' | 'host' | 'direct';
|
|
80
|
+
readonly estimatorProvider?: string;
|
|
81
|
+
readonly estimatorModel?: string;
|
|
82
|
+
readonly estimatorBaseUrl?: string;
|
|
83
|
+
readonly estimatorApiKey?: string;
|
|
84
|
+
readonly estimatorTimeoutMs?: number;
|
|
85
|
+
}
|
|
86
|
+
/** Durable settings section owned by this package. */
|
|
87
|
+
interface ContextCompressionSettings {
|
|
88
|
+
/** Default profile captured when each Session first reaches the pruner. */
|
|
89
|
+
profile: CompressionProfile;
|
|
90
|
+
/** Complete canonical policy captured with `profile` when the runtime first observes a Session. */
|
|
91
|
+
custom: CustomCompressionPolicy;
|
|
92
|
+
/** Auto Compact trigger captured with `profile` when the runtime first observes a Session. */
|
|
93
|
+
autoCompact: AutoCompactSettings;
|
|
94
|
+
/** Code-skeleton reducer gate captured independently of `profile`. */
|
|
95
|
+
codeSkeleton: CodeSkeletonSettings;
|
|
96
|
+
/** Optional tokenpilot-inspired sub-capability overrides (presence-validated only). */
|
|
97
|
+
presetOptions?: PresetOptionsSettings;
|
|
98
|
+
}
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region src/client/preset-options.d.ts
|
|
101
|
+
/** One partial edit of `presetOptions`; `undefined` clears the named field. */
|
|
102
|
+
type PresetOptionsPatch = { readonly [K in keyof PresetOptionsSettings]?: PresetOptionsSettings[K] | undefined; };
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/client/locales.d.ts
|
|
105
|
+
/** Simplified Chinese copy for the context-compression selector. */
|
|
106
|
+
declare const zh: {
|
|
107
|
+
nav: string;
|
|
108
|
+
'settings.title': string;
|
|
109
|
+
'settings.description': string;
|
|
110
|
+
label: string;
|
|
111
|
+
'status.loading': string;
|
|
112
|
+
'status.unavailable': string;
|
|
113
|
+
'status.presetUnavailable': string;
|
|
114
|
+
'status.minimalUnavailable': string;
|
|
115
|
+
'status.saveFailed': string;
|
|
116
|
+
'pricing.disclosure': string;
|
|
117
|
+
'profile.balanced': string;
|
|
118
|
+
'profile.cache-strict': string;
|
|
119
|
+
'profile.savings': string;
|
|
120
|
+
'profile.adaptive': string;
|
|
121
|
+
'profile.tokenpilot-inspired': string;
|
|
122
|
+
'estimator.title': string;
|
|
123
|
+
'estimator.description': string;
|
|
124
|
+
'estimator.mode': string;
|
|
125
|
+
'estimator.mode.off': string;
|
|
126
|
+
'estimator.followHost': string;
|
|
127
|
+
'estimator.mode.host': string;
|
|
128
|
+
'estimator.mode.direct': string;
|
|
129
|
+
'estimator.inactive': string;
|
|
130
|
+
'estimator.provider': string;
|
|
131
|
+
'estimator.provider.placeholder': string;
|
|
132
|
+
'estimator.model.placeholder': string;
|
|
133
|
+
'estimator.hostReuse': string;
|
|
134
|
+
'estimator.hostRoute': string;
|
|
135
|
+
'estimator.hostUnresolved': string;
|
|
136
|
+
'estimator.baseUrl': string;
|
|
137
|
+
'estimator.model': string;
|
|
138
|
+
'estimator.apiKey': string;
|
|
139
|
+
'estimator.apiKey.placeholder': string;
|
|
140
|
+
'estimator.apiKey.set': string;
|
|
141
|
+
'estimator.apiKey.clear': string;
|
|
142
|
+
'estimator.apiKey.overwrite': string;
|
|
143
|
+
'detail.tokenpilot-inspired': string;
|
|
144
|
+
'profile.custom': string;
|
|
145
|
+
'profile.native': string;
|
|
146
|
+
'profile.off': string;
|
|
147
|
+
'profile.current': string;
|
|
148
|
+
'detail.balanced': string;
|
|
149
|
+
'detail.cache-strict': string;
|
|
150
|
+
'detail.savings': string;
|
|
151
|
+
'detail.adaptive': string;
|
|
152
|
+
'detail.custom': string;
|
|
153
|
+
'detail.native': string;
|
|
154
|
+
'detail.off': string;
|
|
155
|
+
'autoCompact.title': string;
|
|
156
|
+
'autoCompact.description': string;
|
|
157
|
+
'autoCompact.inputLabel': string;
|
|
158
|
+
'autoCompact.sliderLabel': string;
|
|
159
|
+
'autoCompact.quick': string;
|
|
160
|
+
'autoCompact.riskLow': string;
|
|
161
|
+
'autoCompact.riskHigh': string;
|
|
162
|
+
'autoCompact.invalid': string;
|
|
163
|
+
'autoCompact.save': string;
|
|
164
|
+
'autoCompact.summaryHint': string;
|
|
165
|
+
'codeSkeleton.title': string;
|
|
166
|
+
'codeSkeleton.description': string;
|
|
167
|
+
'codeSkeleton.enabled': string;
|
|
168
|
+
'codeSkeleton.enabled.on': string;
|
|
169
|
+
'codeSkeleton.enabled.off': string;
|
|
170
|
+
'custom.title': string;
|
|
171
|
+
'custom.settingsHint': string;
|
|
172
|
+
'custom.sessionScope': string;
|
|
173
|
+
'custom.measurement': string;
|
|
174
|
+
'custom.unit': string;
|
|
175
|
+
'custom.unit.tokens': string;
|
|
176
|
+
'custom.unit.contextPercent': string;
|
|
177
|
+
'custom.enabled': string;
|
|
178
|
+
'custom.enabled.on': string;
|
|
179
|
+
'custom.enabled.off': string;
|
|
180
|
+
'custom.fresh.enabled': string;
|
|
181
|
+
'custom.fresh.trigger': string;
|
|
182
|
+
'custom.fresh.target': string;
|
|
183
|
+
'custom.aggregate.enabled': string;
|
|
184
|
+
'custom.aggregate.trigger': string;
|
|
185
|
+
'custom.aggregate.target': string;
|
|
186
|
+
'custom.history.enabled': string;
|
|
187
|
+
'custom.history.trigger': string;
|
|
188
|
+
'custom.history.keepRecentToolCalls': string;
|
|
189
|
+
'custom.history.keepRecentTokens': string;
|
|
190
|
+
'custom.history.minReclaim': string;
|
|
191
|
+
'custom.prefixPolicy': string;
|
|
192
|
+
'custom.prefixPolicy.preserve': string;
|
|
193
|
+
'custom.prefixPolicy.pressureBreak': string;
|
|
194
|
+
'custom.experimental': string;
|
|
195
|
+
'custom.tailTrim.enabled': string;
|
|
196
|
+
'custom.tailTrim.trigger': string;
|
|
197
|
+
'custom.tailTrim.warning': string;
|
|
198
|
+
'custom.save': string;
|
|
199
|
+
'custom.reset': string;
|
|
200
|
+
'custom.invalid': string;
|
|
201
|
+
};
|
|
202
|
+
/** Locale keys that every context-compression selector dictionary must provide. */
|
|
203
|
+
type ContextCompressionLocaleKey = keyof typeof zh;
|
|
204
|
+
//#endregion
|
|
205
|
+
//#region src/client/CompressionProfileSelector.d.ts
|
|
206
|
+
interface CompressionSelectorInjected {
|
|
207
|
+
hooks: {
|
|
208
|
+
compression: SettingsScope<ContextCompressionSettings>;
|
|
209
|
+
};
|
|
210
|
+
select: (profile: CompressionProfile) => Promise<void>;
|
|
211
|
+
saveCustom: (custom: CustomCompressionPolicy) => Promise<void>;
|
|
212
|
+
resetCustom: () => Promise<void>;
|
|
213
|
+
saveAutoCompact: (thresholdPercent: number) => Promise<void>;
|
|
214
|
+
saveCodeSkeleton: (enabled: boolean) => Promise<void>;
|
|
215
|
+
/** Patch of `presetOptions` members; an explicit `undefined` clears that field. */
|
|
216
|
+
savePresetOptions: (options: PresetOptionsPatch) => Promise<void>;
|
|
217
|
+
}
|
|
218
|
+
type CompressionProfileSelectorProps = PropsRuntime<'settings.section'> & PropsLocale<'context-compression'> & InjectFace<CompressionSelectorInjected>;
|
|
219
|
+
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
220
|
+
interface LocaleNamespaceMap {
|
|
221
|
+
'context-compression': ContextCompressionLocaleKey;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
//#endregion
|
|
225
|
+
//#region src/client/index.d.ts
|
|
226
|
+
declare const inject: string[];
|
|
227
|
+
declare function apply(ctx: ClientContext): void;
|
|
228
|
+
//#endregion
|
|
229
229
|
export { type CompressionProfile, type CompressionProfileSelectorProps, type CompressionSelectorInjected, type ContextCompressionSettings, apply, inject };
|