dsh-context-compression-improved 0.1.1

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.
@@ -0,0 +1,34 @@
1
+ {
2
+ "add_bos_token": false,
3
+ "add_eos_token": false,
4
+ "bos_token": {
5
+ "__type": "AddedToken",
6
+ "content": "<|begin▁of▁sentence|>",
7
+ "lstrip": false,
8
+ "normalized": true,
9
+ "rstrip": false,
10
+ "single_word": false
11
+ },
12
+ "clean_up_tokenization_spaces": false,
13
+ "eos_token": {
14
+ "__type": "AddedToken",
15
+ "content": "<|end▁of▁sentence|>",
16
+ "lstrip": false,
17
+ "normalized": true,
18
+ "rstrip": false,
19
+ "single_word": false
20
+ },
21
+ "legacy": true,
22
+ "model_max_length": 1048576,
23
+ "pad_token": {
24
+ "__type": "AddedToken",
25
+ "content": "<|end▁of▁sentence|>",
26
+ "lstrip": false,
27
+ "normalized": true,
28
+ "rstrip": false,
29
+ "single_word": false
30
+ },
31
+ "sp_model_kwargs": {},
32
+ "unk_token": null,
33
+ "tokenizer_class": "PreTrainedTokenizerFast"
34
+ }
@@ -0,0 +1,19 @@
1
+ # Standalone Profile Bundle entry. The same package may already be present in a
2
+ # Harness distribution; its Host implementation reference-counts the preset
3
+ # decoration so the two rows never install two compression stacks.
4
+ - insert:
5
+ - id: context-compression-improved-bundle
6
+ name: 'dsh-context-compression-improved'
7
+ config:
8
+ presetOverlay: true
9
+ # The estimator catalog route rides its own row. Registering an HTTP route
10
+ # authorizes against the calling fiber, so only a fiber that declares
11
+ # `webServer` can reach it; a runtime probe cannot substitute. Keeping that
12
+ # declaration off the main row leaves the compression stack loadable on
13
+ # profiles that have no web server at all.
14
+ - id: context-compression-improved-estimator-catalog
15
+ name: 'dsh-context-compression-improved'
16
+ inject:
17
+ - webServer
18
+ config:
19
+ estimatorCatalogRoute: true
@@ -0,0 +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.1-rc.2 <0.2.0-0"
8
+ },
9
+ "contributes": {
10
+ "tools": [],
11
+ "skills": []
12
+ },
13
+ "client": {
14
+ "main": "./lib/client.js"
15
+ }
16
+ }
@@ -0,0 +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
229
+ export { type CompressionProfile, type CompressionProfileSelectorProps, type CompressionSelectorInjected, type ContextCompressionSettings, apply, inject };