dsh-context-compression-improved 0.2.3 → 0.2.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.
Files changed (149) hide show
  1. package/.gitattributes +2 -1
  2. package/.githooks/pre-push +37 -0
  3. package/.github/workflows/ci.yml +39 -39
  4. package/CHANGELOG.ja.md +169 -39
  5. package/CHANGELOG.ko.md +167 -39
  6. package/CHANGELOG.md +333 -135
  7. package/CHANGELOG.zh.md +152 -39
  8. package/CONTRIBUTING.md +22 -22
  9. package/README.ja.md +85 -104
  10. package/README.ko.md +85 -103
  11. package/README.md +94 -112
  12. package/README.zh.md +85 -101
  13. package/THIRD_PARTY_NOTICES.md +14 -14
  14. package/docs/compat-0.1.5-report.md +77 -0
  15. package/docs/installation.ja.md +78 -76
  16. package/docs/installation.ko.md +78 -76
  17. package/docs/installation.md +103 -76
  18. package/docs/installation.zh.md +100 -76
  19. package/docs/repair-log.md +657 -582
  20. package/eslint.config.js +30 -30
  21. package/package.json +163 -142
  22. package/packages/selector/README.md +26 -31
  23. package/packages/selector/README.zh.md +24 -31
  24. package/packages/selector/THIRD_PARTY_NOTICES.md +32 -38
  25. package/packages/selector/cordis.patch.yml +27 -19
  26. package/packages/selector/dsh.plugin.json +2 -2
  27. package/packages/selector/lib/client.d.ts +320 -228
  28. package/packages/selector/lib/client.js +3254 -1462
  29. package/packages/selector/lib/config.js +1713 -842
  30. package/packages/selector/lib/index.d.ts +46 -38
  31. package/packages/selector/lib/index.js +1099 -645
  32. package/packages/selector/lib/invariant.js +70 -70
  33. package/packages/selector/lib/pruner.d.ts +904 -684
  34. package/packages/selector/lib/pruner.js +5800 -3807
  35. package/packages/selector/lib/style.css +88 -46
  36. package/packages/selector/lib/tail-trim.js +145 -136
  37. package/packages/selector/package.json +18 -19
  38. package/packages/selector/screenshots.json +3 -6
  39. package/packages/selector/src/client/CompressionProfileControls.tsx +293 -229
  40. package/packages/selector/src/client/CompressionProfileSelector.module.css +199 -170
  41. package/packages/selector/src/client/CompressionProfileSelector.tsx +85 -79
  42. package/packages/selector/src/client/EstimatorControls.tsx +277 -281
  43. package/packages/selector/src/client/decode.ts +57 -49
  44. package/packages/selector/src/client/index.ts +249 -111
  45. package/packages/selector/src/client/locales/de.ts +141 -0
  46. package/packages/selector/src/client/locales/es.ts +141 -0
  47. package/packages/selector/src/client/locales/fr.ts +141 -0
  48. package/packages/selector/src/client/locales/it.ts +141 -0
  49. package/packages/selector/src/client/locales/ja.ts +141 -0
  50. package/packages/selector/src/client/locales/ko.ts +141 -0
  51. package/packages/selector/src/client/locales/ru.ts +141 -0
  52. package/packages/selector/src/client/locales.ts +282 -198
  53. package/packages/selector/src/client/monitor-fab.ts +336 -0
  54. package/packages/selector/src/client/preset-options.ts +88 -70
  55. package/packages/selector/src/client/savings-card.tsx +150 -0
  56. package/packages/selector/src/client/settings-section.tsx +140 -126
  57. package/packages/selector/src/deepseek-v4-tokenizer.ts +205 -210
  58. package/packages/selector/src/index.ts +671 -327
  59. package/packages/selector/src/invariant.ts +113 -113
  60. package/packages/selector/src/preset-overlay.ts +60 -1
  61. package/packages/selector/src/profiles.ts +431 -342
  62. package/packages/selector/src/pruner/content.ts +18 -5
  63. package/packages/selector/src/pruner/state.ts +57 -43
  64. package/packages/selector/src/pruner/types.ts +23 -5
  65. package/packages/selector/src/pruner.ts +2736 -2144
  66. package/packages/selector/src/runtime/adaptive-cost.ts +23 -12
  67. package/packages/selector/src/runtime/audit.ts +303 -215
  68. package/packages/selector/src/runtime/config.ts +756 -613
  69. package/packages/selector/src/runtime/measurement.ts +436 -403
  70. package/packages/selector/src/runtime/monitor.ts +235 -0
  71. package/packages/selector/src/runtime/reducers.ts +1115 -97
  72. package/packages/selector/src/runtime/retrieve.ts +479 -457
  73. package/packages/selector/src/runtime/savings.ts +337 -0
  74. package/packages/selector/src/runtime/session-events.ts +30 -17
  75. package/packages/selector/src/runtime/summary-command.ts +127 -0
  76. package/packages/selector/src/runtime/tail-trim.ts +166 -166
  77. package/packages/selector/src/runtime/tokenpilot/advisor-prompt.ts +233 -0
  78. package/packages/selector/src/runtime/tokenpilot/advisor-state.ts +204 -0
  79. package/packages/selector/src/runtime/tokenpilot/advisor.ts +419 -0
  80. package/packages/selector/src/runtime/tokenpilot/benefit.ts +200 -0
  81. package/packages/selector/src/runtime/tokenpilot/dedup.ts +1 -1
  82. package/packages/selector/src/runtime/tokenpilot/estimator.ts +151 -183
  83. package/packages/selector/src/runtime/tokenpilot/intent-fold.ts +53 -0
  84. package/packages/selector/src/runtime/tokenpilot/intent-gate.ts +65 -0
  85. package/packages/selector/src/runtime/tokenpilot/intent-input-mask.ts +125 -0
  86. package/packages/selector/src/runtime/tokenpilot/intent-range.ts +37 -0
  87. package/packages/selector/src/runtime/tokenpilot/locator.ts +1 -1
  88. package/packages/selector/src/runtime/tokenpilot/read-state.ts +23 -2
  89. package/packages/selector/src/runtime/tokenpilot/sidechannel.ts +303 -0
  90. package/packages/selector/src/runtime/toolclass.ts +103 -0
  91. package/packages/selector/src/runtime/types.ts +365 -309
  92. package/packages/selector/tests/advisor-report.host.spec.ts +223 -0
  93. package/packages/selector/tests/auto-compact.client.spec.tsx +214 -226
  94. package/packages/selector/tests/built/client-artifact.spec.ts +59 -51
  95. package/packages/selector/tests/code-skeleton.client.spec.ts +91 -88
  96. package/packages/selector/tests/custom-contract.client.spec.ts +205 -202
  97. package/packages/selector/tests/estimator-channel.client.spec.tsx +253 -247
  98. package/packages/selector/tests/estimator-route-registration.host.spec.ts +194 -176
  99. package/packages/selector/tests/host-preset-overlay.host.spec.ts +206 -204
  100. package/packages/selector/tests/monitor-fab.client.spec.ts +138 -0
  101. package/packages/selector/tests/preset-options-write.client.spec.ts +207 -181
  102. package/packages/selector/tests/preset-overlay-loader.e2e.host.spec.ts +201 -196
  103. package/packages/selector/tests/preset-overlay.host.spec.ts +246 -243
  104. package/packages/selector/tests/profiles.client.spec.tsx +436 -434
  105. package/packages/selector/tests/public/package-contract.client.spec.ts +78 -33
  106. package/packages/selector/tests/runtime/adaptive-cost.spec.ts +7 -7
  107. package/packages/selector/tests/runtime/advice-never-withholds.host.spec.ts +232 -0
  108. package/packages/selector/tests/runtime/advisor-invariant.spec.ts +272 -0
  109. package/packages/selector/tests/runtime/advisor.spec.ts +226 -0
  110. package/packages/selector/tests/runtime/audit.spec.ts +275 -129
  111. package/packages/selector/tests/runtime/char-basis.spec.ts +30 -0
  112. package/packages/selector/tests/runtime/code-skeleton.spec.ts +14 -3
  113. package/packages/selector/tests/runtime/deprecated-preset-options.spec.ts +96 -0
  114. package/packages/selector/tests/runtime/frequency-longstrings.spec.ts +74 -0
  115. package/packages/selector/tests/runtime/html-reducer.spec.ts +212 -0
  116. package/packages/selector/tests/runtime/intent-gate.spec.ts +62 -0
  117. package/packages/selector/tests/runtime/intent-summary.spec.ts +156 -0
  118. package/packages/selector/tests/runtime/line-mapping.spec.ts +153 -0
  119. package/packages/selector/tests/runtime/monitor.spec.ts +301 -0
  120. package/packages/selector/tests/runtime/prose-reducers.spec.ts +133 -0
  121. package/packages/selector/tests/runtime/public/public-runtime.spec.ts +2724 -2531
  122. package/packages/selector/tests/runtime/read-input-cap.spec.ts +33 -0
  123. package/packages/selector/tests/runtime/savings.spec.ts +120 -0
  124. package/packages/selector/tests/runtime/search-reducer.spec.ts +110 -0
  125. package/packages/selector/tests/runtime/session-events.spec.ts +27 -27
  126. package/packages/selector/tests/runtime/sidechannel.spec.ts +241 -0
  127. package/packages/selector/tests/runtime/summary-command.spec.ts +154 -0
  128. package/packages/selector/tests/runtime/toc-and-bundled.spec.ts +159 -0
  129. package/packages/selector/tests/runtime/tokenpilot/benefit.spec.ts +217 -0
  130. package/packages/selector/tests/runtime/tokenpilot/estimator.spec.ts +79 -56
  131. package/packages/selector/tests/runtime/tokenpilot/profile-baseline.spec.ts +116 -100
  132. package/packages/selector/tests/runtime/tokenpilot/read-state.spec.ts +24 -0
  133. package/packages/selector/tests/runtime/toolclass.spec.ts +156 -0
  134. package/packages/selector/tests/settings-seat.client.spec.ts +130 -0
  135. package/packages/selector/tests/standing-generation.host.spec.ts +697 -631
  136. package/packages/selector/tests/subagent-cache-reuse.host.spec.ts +253 -250
  137. package/pnpm-workspace.yaml +66 -19
  138. package/scripts/capture-profile-baseline.mjs +42 -0
  139. package/scripts/generate-tokenizer-fixtures.py +81 -81
  140. package/scripts/generate-vision-fixtures.py +208 -208
  141. package/scripts/{packed-components-smoke.ts → packed-components-smoke.mjs} +732 -713
  142. package/scripts/{packed-install-e2e.ts → packed-install-e2e.mjs} +1273 -1072
  143. package/scripts/toolclass-corpus-replay.mjs +281 -0
  144. package/scripts/{verify-release.ts → verify-release.mjs} +318 -300
  145. package/tests/TEST_INVENTORY.md +41 -42
  146. package/scripts/capture-profile-baseline.ts +0 -80
  147. package/tsconfig.scripts.json +0 -13
  148. /package/{packages/selector/assets/screenshots → docs/assets}/context-compression-selector-profiles.jpg +0 -0
  149. /package/{packages/selector/assets/screenshots → docs/assets}/context-compression-selector-settings.png +0 -0
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "id": "dsh-external/dsh-context-compression-improved",
3
- "version": "0.1.1",
3
+ "version": "0.2.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": {
7
- "dsh": ">=0.1.2-rc.1 <0.2.0-0"
7
+ "dsh": ">=0.1.2-rc.1 <0.1.3-0"
8
8
  },
9
9
  "contributes": {
10
10
  "tools": [],
@@ -1,229 +1,321 @@
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 { Context } from "@deepseek-ai/cordis";
2
+ import "@deepseek-ai/dsh-settings/types";
3
+ import { SettingsScope } from "@deepseek-ai/dsh-client-ui-settings/client";
4
+ import { InjectFace, PropsLocale } from "@deepseek-ai/dsh-client-ui-slots";
5
+ //#region src/profiles.d.ts
6
+ /** Public context-compression choices shared by the Host schema and browser selector. */
7
+ declare const COMPRESSION_PROFILES: readonly ["off", "native", "balanced", "cache-strict", "savings", "adaptive", "tokenpilot-inspired", "custom"];
8
+ /** One supported context-compression profile. */
9
+ type CompressionProfile = typeof COMPRESSION_PROFILES[number];
10
+ /** Single canonical unit stored by a version-1 browser Custom document. */
11
+ type CustomCompressionUnit = 'tokens' | 'context-percent';
12
+ /** Whether Custom History may routinely rewrite an already-sent prefix. */
13
+ type CustomPrefixPolicy = 'preserve' | 'pressure-break';
14
+ /** Browser representation of one independently enabled Fresh or Aggregate budget. */
15
+ interface CustomCompressionBudget {
16
+ enabled: boolean;
17
+ trigger: number;
18
+ target: number;
19
+ }
20
+ /** Legacy browser representation of the Custom History working set. */
21
+ interface LegacyCustomHistoryPolicy {
22
+ enabled: boolean;
23
+ trigger: number;
24
+ keepRecentTurns: number;
25
+ keepRecent: number;
26
+ minReclaim: number;
27
+ }
28
+ /** Browser representation of Custom History tool-call and token-tail protection. */
29
+ interface CustomHistoryPolicy {
30
+ enabled: boolean;
31
+ trigger: number;
32
+ keepRecentToolCalls: number;
33
+ keepRecentTokens: number;
34
+ minReclaim: number;
35
+ }
36
+ /** Browser representation of the Custom-only Experimental TailTrim gate. */
37
+ interface CustomTailTrimPolicy {
38
+ enabled: boolean;
39
+ trigger: number;
40
+ }
41
+ interface CustomCompressionPolicyCommon<HistoryPolicy> {
42
+ unit: CustomCompressionUnit;
43
+ fresh: CustomCompressionBudget;
44
+ aggregate: CustomCompressionBudget;
45
+ history: HistoryPolicy;
46
+ prefixPolicy: CustomPrefixPolicy;
47
+ }
48
+ /** Legacy public Custom document; accepted and normalized before editing. */
49
+ interface CustomCompressionPolicyV1 extends CustomCompressionPolicyCommon<LegacyCustomHistoryPolicy> {
50
+ version: 1;
51
+ }
52
+ /** Legacy Custom document with a default-disabled TailTrim stage. */
53
+ interface CustomCompressionPolicyV2 extends CustomCompressionPolicyCommon<LegacyCustomHistoryPolicy> {
54
+ version: 2;
55
+ tailTrim: CustomTailTrimPolicy;
56
+ }
57
+ /** Public Custom document with tool-call working-set protection. */
58
+ interface CustomCompressionPolicyV3 extends CustomCompressionPolicyCommon<CustomHistoryPolicy> {
59
+ version: 3;
60
+ tailTrim: CustomTailTrimPolicy;
61
+ }
62
+ /** Exact public Custom document accepted by the Host and browser boundary. */
63
+ type CustomCompressionPolicy = CustomCompressionPolicyV1 | CustomCompressionPolicyV2 | CustomCompressionPolicyV3;
64
+ /** User-tunable Auto Compact coordination preferences. */
65
+ interface AutoCompactSettings {
66
+ thresholdPercent: number;
67
+ }
68
+ /**
69
+ * Orthogonal code-skeleton reducer gate, mirrored browser-safe from the
70
+ * runtime: independent of every profile, default off.
71
+ */
72
+ interface CodeSkeletonSettings {
73
+ enabled: boolean;
74
+ }
75
+ /**
76
+ * Orthogonal turn-tail intent-summary gate, mirrored browser-safe from the
77
+ * runtime: independent of every profile, default off.
78
+ */
79
+ interface IntentSummarySettings {
80
+ enabled: boolean;
81
+ }
82
+ /** Floating compression-monitor panel (FAB); visibility switch. */
83
+ interface MonitorPanelSettings {
84
+ enabled: boolean;
85
+ }
86
+ /** Browser-safe mirror of the runtime presetOptions section. */
87
+ interface PresetOptionsSettings {
88
+ readonly dedupeToolResults?: boolean;
89
+ readonly summaryLocator?: boolean;
90
+ readonly prefixStabilizer?: boolean;
91
+ readonly readState?: boolean;
92
+ readonly estimatorMode?: '' | 'host' | 'direct';
93
+ readonly estimatorProvider?: string;
94
+ readonly estimatorModel?: string;
95
+ readonly estimatorBaseUrl?: string;
96
+ readonly estimatorApiKey?: string;
97
+ readonly estimatorTimeoutMs?: number;
98
+ /** Advisory advisor channel; `''` (the default) keeps the advisor off. */
99
+ readonly advisorMode?: '' | 'host' | 'direct';
100
+ readonly advisorTimeoutMs?: number;
101
+ readonly advisorRefreshTurns?: number;
102
+ readonly advisorScoreThreshold?: number;
103
+ readonly advisorSampleLimit?: number;
104
+ readonly advisorMinTokens?: number;
105
+ }
106
+ /** Durable settings section owned by this package. */
107
+ interface ContextCompressionSettings {
108
+ /** Default profile captured when each Session first reaches the pruner. */
109
+ profile: CompressionProfile;
110
+ /** Complete canonical policy captured with `profile` when the runtime first observes a Session. */
111
+ custom: CustomCompressionPolicy;
112
+ /** Auto Compact trigger captured with `profile` when the runtime first observes a Session. */
113
+ autoCompact: AutoCompactSettings;
114
+ /** Code-skeleton reducer gate captured independently of `profile`. */
115
+ codeSkeleton: CodeSkeletonSettings;
116
+ /** Turn-tail intent-summary gate captured independently of `profile`. */
117
+ intentSummary: IntentSummarySettings;
118
+ /** Floating compression-monitor panel (FAB); absent inherits hidden. */
119
+ monitorPanel?: MonitorPanelSettings;
120
+ /** Optional tokenpilot-inspired sub-capability overrides (presence-validated only). */
121
+ presetOptions?: PresetOptionsSettings;
122
+ }
123
+ //#endregion
124
+ //#region src/client/preset-options.d.ts
125
+ /** One partial edit of `presetOptions`; `undefined` clears the named field. */
126
+ type PresetOptionsPatch = { readonly [K in keyof PresetOptionsSettings]?: PresetOptionsSettings[K] | undefined; };
127
+ //#endregion
128
+ //#region src/client/locales.d.ts
129
+ /** Simplified Chinese copy for the context-compression selector. */
130
+ declare const zh: {
131
+ nav: string;
132
+ 'settings.title': string;
133
+ 'settings.description': string;
134
+ label: string;
135
+ 'status.loading': string;
136
+ 'status.unavailable': string;
137
+ 'status.presetUnavailable': string;
138
+ 'status.minimalUnavailable': string;
139
+ 'status.saveFailed': string;
140
+ 'pricing.disclosure': string;
141
+ 'profile.balanced': string;
142
+ 'profile.cache-strict': string;
143
+ 'profile.savings': string;
144
+ 'profile.adaptive': string;
145
+ 'profile.tokenpilot-inspired': string;
146
+ 'estimator.title': string;
147
+ 'estimator.description': string;
148
+ 'estimator.mode': string;
149
+ 'estimator.mode.off': string;
150
+ 'estimator.mode.host': string;
151
+ 'estimator.mode.direct': string;
152
+ 'estimator.inactive': string;
153
+ 'estimator.provider': string;
154
+ 'estimator.provider.placeholder': string;
155
+ 'estimator.model.placeholder': string;
156
+ 'estimator.hostReuse': string;
157
+ 'estimator.hostRoute': string;
158
+ 'estimator.hostUnresolved': string;
159
+ 'estimator.baseUrl': string;
160
+ 'estimator.model': string;
161
+ 'estimator.apiKey': string;
162
+ 'estimator.apiKey.placeholder': string;
163
+ 'estimator.apiKey.set': string;
164
+ 'estimator.apiKey.clear': string;
165
+ 'estimator.apiKey.overwrite': string;
166
+ 'detail.tokenpilot-inspired': string;
167
+ 'profile.custom': string;
168
+ 'profile.native': string;
169
+ 'profile.off': string;
170
+ 'profile.current': string;
171
+ 'detail.balanced': string;
172
+ 'detail.cache-strict': string;
173
+ 'detail.savings': string;
174
+ 'detail.adaptive': string;
175
+ 'detail.custom': string;
176
+ 'detail.native': string;
177
+ 'detail.off': string;
178
+ 'autoCompact.title': string;
179
+ 'autoCompact.description': string;
180
+ 'autoCompact.inputLabel': string;
181
+ 'autoCompact.sliderLabel': string;
182
+ 'autoCompact.quick': string;
183
+ 'autoCompact.riskLow': string;
184
+ 'autoCompact.riskHigh': string;
185
+ 'autoCompact.invalid': string;
186
+ 'autoCompact.save': string;
187
+ 'autoCompact.summaryHint': string;
188
+ 'codeSkeleton.title': string;
189
+ 'codeSkeleton.description': string;
190
+ 'codeSkeleton.enabled': string;
191
+ 'codeSkeleton.enabled.on': string;
192
+ 'codeSkeleton.enabled.off': string;
193
+ 'intentSummary.title': string;
194
+ 'intentSummary.description': string;
195
+ 'intentSummary.enabled': string;
196
+ 'intentSummary.enabled.on': string;
197
+ 'intentSummary.enabled.off': string;
198
+ 'monitor.fab.title': string;
199
+ 'monitor.panel.title': string;
200
+ 'monitor.panel.net': string;
201
+ 'monitor.panel.gross': string;
202
+ 'monitor.panel.offsets': string;
203
+ 'monitor.panel.context': string;
204
+ 'monitor.panel.suggest': string;
205
+ 'monitor.panel.cacheHit': string;
206
+ 'monitor.panel.cost': string;
207
+ 'monitor.panel.intent': string;
208
+ 'monitor.panel.overrideHint': string;
209
+ 'monitor.panel.resume': string;
210
+ 'monitor.panel.disable': string;
211
+ 'monitor.panel.stateOn': string;
212
+ 'monitor.panel.stateOff': string;
213
+ 'monitor.panel.gateUnknown': string;
214
+ 'monitor.panel.lastFold': string;
215
+ 'monitor.panel.stale': string;
216
+ 'monitorPanel.title': string;
217
+ 'monitorPanel.description': string;
218
+ 'monitorPanel.enabled': string;
219
+ 'monitorPanel.enabled.on': string;
220
+ 'monitorPanel.enabled.off': string;
221
+ 'custom.title': string;
222
+ 'custom.settingsHint': string;
223
+ 'custom.sessionScope': string;
224
+ 'custom.measurement': string;
225
+ 'custom.unit': string;
226
+ 'custom.unit.tokens': string;
227
+ 'custom.unit.contextPercent': string;
228
+ 'custom.enabled': string;
229
+ 'custom.enabled.on': string;
230
+ 'custom.enabled.off': string;
231
+ 'custom.fresh.enabled': string;
232
+ 'custom.fresh.trigger': string;
233
+ 'custom.fresh.target': string;
234
+ 'custom.aggregate.enabled': string;
235
+ 'custom.aggregate.trigger': string;
236
+ 'custom.aggregate.target': string;
237
+ 'custom.history.enabled': string;
238
+ 'custom.history.trigger': string;
239
+ 'custom.history.keepRecentToolCalls': string;
240
+ 'custom.history.keepRecentTokens': string;
241
+ 'custom.history.minReclaim': string;
242
+ 'custom.prefixPolicy': string;
243
+ 'custom.prefixPolicy.preserve': string;
244
+ 'custom.prefixPolicy.pressureBreak': string;
245
+ 'custom.experimental': string;
246
+ 'custom.tailTrim.enabled': string;
247
+ 'custom.tailTrim.trigger': string;
248
+ 'custom.tailTrim.warning': string;
249
+ 'custom.save': string;
250
+ 'custom.reset': string;
251
+ 'custom.invalid': string;
252
+ 'savings.title': string;
253
+ 'savings.netExact': string;
254
+ 'savings.netEstimated': string;
255
+ 'savings.gross': string;
256
+ 'savings.offsets': string;
257
+ 'savings.empty': string;
258
+ 'savings.basisExact': string;
259
+ 'savings.basisEstimated': string;
260
+ 'savings.basisNote': string;
261
+ 'savings.requests': string;
262
+ 'savings.cacheHit': string;
263
+ 'savings.actualCost': string;
264
+ 'savings.savedMoney': string;
265
+ 'savings.perSession': string;
266
+ };
267
+ /** Locale keys that every context-compression selector dictionary must provide. */
268
+ type ContextCompressionLocaleKey = keyof typeof zh;
269
+ //#endregion
270
+ //#region src/client/CompressionProfileSelector.d.ts
271
+ interface CompressionSelectorInjected {
272
+ hooks: {
273
+ compression: SettingsScope<ContextCompressionSettings>;
274
+ };
275
+ select: (profile: CompressionProfile) => Promise<void>;
276
+ saveCustom: (custom: CustomCompressionPolicy) => Promise<void>;
277
+ resetCustom: () => Promise<void>;
278
+ saveAutoCompact: (thresholdPercent: number) => Promise<void>;
279
+ saveCodeSkeleton: (enabled: boolean) => Promise<void>;
280
+ saveIntentSummary: (enabled: boolean) => Promise<void>;
281
+ saveMonitorPanel: (enabled: boolean) => Promise<void>;
282
+ /** Patch of `presetOptions` members; an explicit `undefined` clears that field. */
283
+ savePresetOptions: (options: PresetOptionsPatch) => Promise<void>;
284
+ }
285
+ /**
286
+ * Owner-agnostic panel props: the same component registers under the 0.1.5
287
+ * `settings.plugins.tab` card (no owner props) and the legacy
288
+ * `settings.section` page (whose shell supplies `close`), so the section
289
+ * owner share stays optional.
290
+ */
291
+ type CompressionProfileSelectorProps = {
292
+ close?: () => void;
293
+ } & PropsLocale<'context-compression'> & InjectFace<CompressionSelectorInjected>;
294
+ declare module '@deepseek-ai/dsh-client-ui-slots' {
295
+ interface LocaleNamespaceMap {
296
+ 'context-compression': ContextCompressionLocaleKey;
297
+ }
298
+ }
299
+ //#endregion
300
+ //#region src/client/index.d.ts
301
+ /**
302
+ * Harness 0.1.5 mounts the web core's `slots` service on the client context
303
+ * but no longer ships a public type for it; declare the face this plugin
304
+ * consumes (same shape dsh-thinking-levels and dsh-prime-memory rely on).
305
+ * `inject` factories may be sync (return a disposer) or generator (yield the
306
+ * registration); slot options are validated at runtime per slot kind, which
307
+ * lets one entry supply both `id` (Desktop, list) and `key` (CLI, keyed).
308
+ */
309
+ interface SlotsService {
310
+ inject(slot: string, register: () => (() => void) | Generator<() => void>): () => void;
311
+ register(options: Record<string, unknown>, component: unknown): () => void;
312
+ }
313
+ declare module '@deepseek-ai/cordis' {
314
+ interface Context {
315
+ slots: SlotsService;
316
+ }
317
+ }
318
+ declare const inject: string[];
319
+ declare function apply(ctx: Context): void;
320
+ //#endregion
229
321
  export { type CompressionProfile, type CompressionProfileSelectorProps, type CompressionSelectorInjected, type ContextCompressionSettings, apply, inject };