dsh-context-compression-improved 0.5.6 → 0.6.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.
package/package.json CHANGED
@@ -1,10 +1,8 @@
1
1
  {
2
2
  "name": "dsh-context-compression-improved",
3
- "version": "0.5.6",
3
+ "version": "0.6.1",
4
4
  "publishConfig": {
5
- "registry": "https://registry.npmjs.org",
6
- "access": "public",
7
- "tag": "dsh-0.1.5"
5
+ "tag": "dsh-0.1.7"
8
6
  },
9
7
  "type": "module",
10
8
  "main": "packages/selector/lib/index.js",
@@ -29,7 +27,7 @@
29
27
  "./package.json": "./package.json"
30
28
  },
31
29
  "dependencies": {
32
- "@deepseek-ai/schemastery": "3.18.2",
30
+ "@deepseek-ai/schemastery": "3.18.4",
33
31
  "@huggingface/tokenizers": "0.1.3",
34
32
  "js-yaml": "^4.3.2"
35
33
  },
@@ -55,7 +53,7 @@
55
53
  "packageManager": "pnpm@11.7.0",
56
54
  "engines": {
57
55
  "node": "^22.19.0 || >=24.0.0",
58
- "dsh": ">=0.1.5-rc.1 <0.1.6-0"
56
+ "dsh": ">=0.1.7-rc.1 <0.1.8-0"
59
57
  },
60
58
  "scripts": {
61
59
  "build": "pnpm -r --if-present run bundle",
@@ -72,10 +70,10 @@
72
70
  "pack:dry-run": "pnpm -r --if-present run pack:dry-run"
73
71
  },
74
72
  "peerDependencies": {
75
- "@deepseek-ai/dsh-client-locale": ">=0.1.5-rc.1 <0.1.6-0",
76
- "@deepseek-ai/dsh-client-ui-primitives": ">=0.1.5-rc.1 <0.1.6-0",
77
- "@deepseek-ai/dsh-client-ui-settings": ">=0.1.5-rc.1 <0.1.6-0",
78
- "@deepseek-ai/dsh-client-ui-slots": ">=0.1.5-rc.1 <0.1.6-0"
73
+ "@deepseek-ai/dsh-client-locale": ">=0.1.7-rc.1 <0.1.8-0",
74
+ "@deepseek-ai/dsh-client-ui-primitives": ">=0.1.7-rc.1 <0.1.8-0",
75
+ "@deepseek-ai/dsh-client-ui-settings": ">=0.1.7-rc.1 <0.1.8-0",
76
+ "@deepseek-ai/dsh-client-ui-slots": ">=0.1.7-rc.1 <0.1.8-0"
79
77
  },
80
78
  "peerDependenciesMeta": {
81
79
  "@deepseek-ai/dsh-client-locale": {
@@ -144,7 +142,7 @@
144
142
  "@deepseek-ai/dsh-tools": "0.1.5-rc.2",
145
143
  "@deepseek-ai/dsh-user-approval": "0.1.5-rc.2",
146
144
  "@deepseek-ai/dsh-user-questions": "0.1.5-rc.2",
147
- "@deepseek-ai/schemastery": "3.18.2",
145
+ "@deepseek-ai/schemastery": "3.18.4",
148
146
  "@eslint/js": "^10.0.1",
149
147
  "@testing-library/react": "^16.3.2",
150
148
  "@tsdown/css": "^0.22.14",
@@ -959,4 +959,4 @@ function invalidateOnTaskChange(state, todoVersion) {
959
959
  return true;
960
960
  }
961
961
  //#endregion
962
- export { COMPRESSION_PROFILES as C, deepFreeze as S, resolvePolicy as _, AUTO_COMPACT_THRESHOLD_LIMITS as a, resolveCustomPolicy as b, DEFAULTS as c, charsToTokens as d, codePointLength as f, resolveConfig as g, parseContextCompressionSettings as h, recordScore as i, PRUNE_MARKER as l, isValidAutoCompactThresholdPercent as m, invalidateOnTaskChange as n, CONTEXT_COMPRESSION_SETTINGS_NAMESPACE as o, isCompressionProfile as p, recordRecertified as r, ContextCompressionSettingsSchema as s, getAdvisorState as t, charsForTokens as u, CustomCompressionPolicySchema as v, assertNever as x, DEFAULT_CUSTOM_COMPRESSION_POLICY as y };
962
+ export { deepFreeze as C, assertNever as S, resolveConfig as _, AUTO_COMPACT_THRESHOLD_LIMITS as a, DEFAULT_CUSTOM_COMPRESSION_POLICY as b, DEFAULTS as c, charsForTokens as d, charsToTokens as f, parseContextCompressionSettings as g, isValidAutoCompactThresholdPercent as h, recordScore as i, DEFAULT_CONTEXT_COMPRESSION_SETTINGS as l, isCompressionProfile as m, invalidateOnTaskChange as n, CONTEXT_COMPRESSION_SETTINGS_NAMESPACE as o, codePointLength as p, recordRecertified as r, ContextCompressionSettingsSchema as s, getAdvisorState as t, PRUNE_MARKER as u, resolvePolicy as v, COMPRESSION_PROFILES as w, resolveCustomPolicy as x, CustomCompressionPolicySchema as y };
@@ -1,111 +1,8 @@
1
+ import { i as PresetOptionsSettings, n as ContextCompressionSettings, r as CustomCompressionPolicy, t as CompressionProfile } from "./profiles.js";
1
2
  import { Context } from "@deepseek-ai/cordis";
2
3
  import "@deepseek-ai/dsh-settings/types";
3
4
  import { SettingsScope } from "@deepseek-ai/dsh-client-ui-settings/client";
4
5
  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
- /** Browser-safe mirror of the runtime presetOptions section. */
76
- interface PresetOptionsSettings {
77
- readonly dedupeToolResults?: boolean;
78
- readonly summaryLocator?: boolean;
79
- readonly prefixStabilizer?: boolean;
80
- readonly readState?: boolean;
81
- readonly estimatorMode?: '' | 'host' | 'direct';
82
- readonly estimatorProvider?: string;
83
- readonly estimatorModel?: string;
84
- readonly estimatorBaseUrl?: string;
85
- readonly estimatorApiKey?: string;
86
- readonly estimatorTimeoutMs?: number;
87
- /** Advisory advisor channel; `''` (the default) keeps the advisor off. */
88
- readonly advisorMode?: '' | 'host' | 'direct';
89
- readonly advisorTimeoutMs?: number;
90
- readonly advisorRefreshTurns?: number;
91
- readonly advisorScoreThreshold?: number;
92
- readonly advisorSampleLimit?: number;
93
- readonly advisorMinTokens?: number;
94
- }
95
- /** Durable settings section owned by this package. */
96
- interface ContextCompressionSettings {
97
- /** Default profile captured when each Session first reaches the pruner. */
98
- profile: CompressionProfile;
99
- /** Complete canonical policy captured with `profile` when the runtime first observes a Session. */
100
- custom: CustomCompressionPolicy;
101
- /** Auto Compact trigger captured with `profile` when the runtime first observes a Session. */
102
- autoCompact: AutoCompactSettings;
103
- /** Code-skeleton reducer gate captured independently of `profile`. */
104
- codeSkeleton: CodeSkeletonSettings;
105
- /** Optional tokenpilot-inspired sub-capability overrides (presence-validated only). */
106
- presetOptions?: PresetOptionsSettings;
107
- }
108
- //#endregion
109
6
  //#region src/client/preset-options.d.ts
110
7
  /** One partial edit of `presetOptions`; `undefined` clears the named field. */
111
8
  type PresetOptionsPatch = { readonly [K in keyof PresetOptionsSettings]?: PresetOptionsSettings[K] | undefined; };
@@ -254,9 +151,27 @@ interface SlotsService {
254
151
  declare module '@deepseek-ai/cordis' {
255
152
  interface Context {
256
153
  slots: SlotsService;
154
+ configForms: ConfigFormsFace;
257
155
  }
258
156
  }
259
157
  declare const inject: string[];
158
+ /** The configForms face this client consumes (structural; 0.1.7 ui-settings). */
159
+ interface ConfigFormsFace {
160
+ get<T>(entryId: string): {
161
+ getSnapshot(): {
162
+ status: 'loading' | 'ready' | 'unavailable';
163
+ value: T | undefined;
164
+ revision: number | undefined;
165
+ writable: boolean;
166
+ base: unknown;
167
+ user: unknown;
168
+ mode: 'host' | 'memory';
169
+ };
170
+ subscribe(listener: () => void): () => void;
171
+ set(field: string, value: unknown): Promise<boolean>;
172
+ unset(field: string): Promise<boolean>;
173
+ };
174
+ }
260
175
  declare function apply(ctx: Context): void;
261
176
  //#endregion
262
177
  export { type CompressionProfile, type CompressionProfileSelectorProps, type CompressionSelectorInjected, type ContextCompressionSettings, apply, inject };
@@ -1458,9 +1458,11 @@ window.__ModuleLoader__.load({
1458
1458
  const inject = [
1459
1459
  "slots",
1460
1460
  "locale",
1461
- "settingsScope"
1461
+ "configForms"
1462
1462
  ];
1463
1463
  const NS = "context-compression";
1464
+ /** 0.1.7: the profile entry whose config carries the compression settings doc. */
1465
+ const ENTRY_ID = "context-compression-improved-bundle";
1464
1466
  function sameCustomPolicy(left, right) {
1465
1467
  if (left.version !== 3 || right.version !== 3) return false;
1466
1468
  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;
@@ -1471,10 +1473,45 @@ window.__ModuleLoader__.load({
1471
1473
  en
1472
1474
  });
1473
1475
  const injected = () => {
1474
- const scope = ctx.settingsScope.bind({
1475
- namespace: NS,
1476
- decode: decodeSettings
1477
- });
1476
+ const form = ctx.configForms.get(ENTRY_ID);
1477
+ const readDoc = () => decodeSettings(form.getSnapshot().value?.settings);
1478
+ const scope = {
1479
+ getSnapshot() {
1480
+ const snap = form.getSnapshot();
1481
+ return {
1482
+ status: snap.status,
1483
+ value: readDoc(),
1484
+ revision: snap.revision,
1485
+ writable: snap.writable,
1486
+ base: snap.base,
1487
+ user: snap.user,
1488
+ mode: snap.mode
1489
+ };
1490
+ },
1491
+ subscribe: (listener) => form.subscribe(listener),
1492
+ set: async (field, value) => {
1493
+ const next = { ...readDoc() ?? {} };
1494
+ next[field] = value;
1495
+ await form.set("settings", next);
1496
+ },
1497
+ unset: async (field) => {
1498
+ const next = { ...readDoc() ?? {} };
1499
+ delete next[field];
1500
+ await form.set("settings", next);
1501
+ },
1502
+ mutate: async (ops) => {
1503
+ const doc = { ...readDoc() ?? {} };
1504
+ for (const op of ops) {
1505
+ const [head, key] = op.path;
1506
+ if (head !== "presetOptions") return;
1507
+ const section = { ...doc.presetOptions ?? {} };
1508
+ if (op.op === "unset") delete section[key];
1509
+ else section[key] = op.value;
1510
+ doc.presetOptions = section;
1511
+ }
1512
+ await form.set("settings", doc);
1513
+ }
1514
+ };
1478
1515
  const writeAndConfirm = async (write, accepts) => {
1479
1516
  const beforeRevision = scope.getSnapshot().revision;
1480
1517
  await write();
@@ -1,3 +1,4 @@
1
+ import { n as ContextCompressionSettings } from "./profiles.js";
1
2
  import z from "@deepseek-ai/schemastery";
2
3
  import { Context } from "@deepseek-ai/cordis";
3
4
  //#region src/index.d.ts
@@ -25,6 +26,14 @@ interface Config {
25
26
  * `presetOptions.advisor*` settings keys.
26
27
  */
27
28
  advisorReportRoute?: boolean;
29
+ /**
30
+ * 0.1.7: the compression settings document as ONE `.volatile()` whole-object
31
+ * field (the old dedicated namespace has no declarative equivalent). The
32
+ * browser selector writes it through `configForms`; the runtime reads the
33
+ * dereferenced value. Loose section schemas keep unknown keys — the strict
34
+ * validation stays in `decodeSettings` (client) and the runtime resolver.
35
+ */
36
+ settings?: ContextCompressionSettings;
28
37
  }
29
38
  /** Loader validation for the standalone Bundle opt-in. */
30
39
  declare const Config: z<Config>;
@@ -1,6 +1,5 @@
1
- import { o as CONTEXT_COMPRESSION_SETTINGS_NAMESPACE, s as ContextCompressionSettingsSchema, t as getAdvisorState } from "./advisor-state.js";
1
+ import { l as DEFAULT_CONTEXT_COMPRESSION_SETTINGS, t as getAdvisorState } from "./advisor-state.js";
2
2
  import z from "@deepseek-ai/schemastery";
3
- import "@deepseek-ai/dsh-settings";
4
3
  import { AsyncLocalStorage } from "node:async_hooks";
5
4
  import { createHash } from "node:crypto";
6
5
  import { chmod, mkdtemp, readFile, rename, rm, stat, utimes, writeFile } from "node:fs/promises";
@@ -503,7 +502,6 @@ function restoreMethod(presets, snapshot) {
503
502
  }
504
503
  //#endregion
505
504
  //#region src/index.ts
506
- const CONTEXT_COMPRESSION_NAMESPACE = CONTEXT_COMPRESSION_SETTINGS_NAMESPACE;
507
505
  const ESTIMATOR_CATALOG_ROUTES = ["/endpoint/dsh-context-compression-improved/estimator-catalog", "/api/dsh-context-compression-improved/estimator-catalog"];
508
506
  const ADVISOR_REPORT_ROUTES = ["/endpoint/dsh-context-compression-improved/advisor-report", "/api/dsh-context-compression-improved/advisor-report"];
509
507
  function sessionFor(readService, sessionId) {
@@ -720,20 +718,28 @@ function registerEstimatorCatalogRoute(ctx) {
720
718
  });
721
719
  log("warn", "context-compression webServer not active yet — estimator catalog route pending: %s", ESTIMATOR_CATALOG_ROUTES.join(", "));
722
720
  }
723
- /** Symbol properties reach the shared service target through Cordis proxies. */
724
- const SHARED_SETTINGS = Symbol.for("dsh-context-compression-improved/settings-registration");
721
+ /**
722
+ * Resolve one possibly-volatile field: a live ref on 0.1.7+, a plain value
723
+ * otherwise (0.1.7 hands `.volatile()` fields to `apply()` as live refs).
724
+ */
725
+ function readVolatileValue(value) {
726
+ if (value !== null && typeof value === "object" && typeof value.get === "function") return value.get();
727
+ return value;
728
+ }
729
+ /** The compression settings document carried by this row's composition entry. */
730
+ function readCompressionDoc(config) {
731
+ return readVolatileValue(config?.settings);
732
+ }
725
733
  /** Loader validation for the standalone Bundle opt-in. */
726
734
  const Config = z.object({
727
735
  presetOverlay: z.boolean().default(false),
728
736
  estimatorCatalogRoute: z.boolean().default(false),
729
- advisorReportRoute: z.boolean().default(false)
737
+ advisorReportRoute: z.boolean().default(false),
738
+ settings: z.any().default(DEFAULT_CONTEXT_COMPRESSION_SETTINGS).volatile()
730
739
  });
731
740
  /** Register the persisted default read by the currently mounted root pruner. */
732
741
  function apply(ctx, config = {}) {
733
742
  try {
734
- ctx.inject(["settings"], (settingsCtx) => {
735
- acquireSettingsRegistration(settingsCtx);
736
- });
737
743
  if (config.estimatorCatalogRoute === true) registerEstimatorCatalogRoute(ctx);
738
744
  if (config.advisorReportRoute === true) registerAdvisorReportRoute(ctx);
739
745
  if (config.presetOverlay !== true) return;
@@ -741,7 +747,7 @@ function apply(ctx, config = {}) {
741
747
  const installation = decorateAgentPresets(presetsCtx.agentPresets, {
742
748
  modules: resolveCompressionModulePaths(),
743
749
  excludedPresetIds: ["minimal"],
744
- autoCompactThresholdPercent: () => resolveAutoCompactThresholdPercent(presetsCtx)
750
+ autoCompactThresholdPercent: () => resolveAutoCompactThresholdPercent(config, presetsCtx)
745
751
  });
746
752
  presetsCtx.effect(() => () => installation.dispose(), "contextCompressionSelector.agentPresets()");
747
753
  });
@@ -755,8 +761,8 @@ function apply(ctx, config = {}) {
755
761
  * values are revalidated here, and any unreadable value falls back to the 80%
756
762
  * default rather than blocking preset composition.
757
763
  */
758
- function resolveAutoCompactThresholdPercent(presetsCtx) {
759
- const raw = presetsCtx.get("settings")?.get(CONTEXT_COMPRESSION_NAMESPACE);
764
+ function resolveAutoCompactThresholdPercent(config, presetsCtx) {
765
+ const raw = readCompressionDoc(config) ?? (presetsCtx?.get("settings"))?.get?.("context-compression");
760
766
  try {
761
767
  const threshold = structuredClone(raw)?.autoCompact;
762
768
  const value = typeof threshold?.thresholdPercent === "number" ? threshold.thresholdPercent : 80;
@@ -765,43 +771,5 @@ function resolveAutoCompactThresholdPercent(presetsCtx) {
765
771
  return 80;
766
772
  }
767
773
  }
768
- /**
769
- * Lease one native settings registration across duplicate Host rows.
770
- *
771
- * The lease effect is intentionally registered before settings.register().
772
- * Cordis disposes effects in reverse order, so the native registration first
773
- * releases the namespace; this disposer can then transfer it to another live
774
- * owner without a duplicate-registration window.
775
- */
776
- function acquireSettingsRegistration(ctx) {
777
- const settings = ctx.settings;
778
- const owner = { settings };
779
- let shared = settings[SHARED_SETTINGS];
780
- if (shared === void 0) {
781
- shared = {
782
- owners: /* @__PURE__ */ new Set(),
783
- registrationOwner: owner,
784
- scope: void 0
785
- };
786
- Object.defineProperty(settings, SHARED_SETTINGS, {
787
- configurable: true,
788
- enumerable: false,
789
- writable: false,
790
- value: shared
791
- });
792
- }
793
- shared.owners.add(owner);
794
- const state = shared;
795
- ctx.effect(() => () => {
796
- state.owners.delete(owner);
797
- if (state.registrationOwner === owner && state.owners.size > 0) {
798
- const next = state.owners.values().next().value;
799
- state.registrationOwner = next;
800
- state.scope = next.settings.register(CONTEXT_COMPRESSION_NAMESPACE, ContextCompressionSettingsSchema);
801
- }
802
- if (state.owners.size === 0 && settings[SHARED_SETTINGS] === state) Reflect.deleteProperty(settings, SHARED_SETTINGS);
803
- }, "contextCompressionSelector.settingsLease()");
804
- if (state.owners.size === 1) state.scope = settings.register(CONTEXT_COMPRESSION_NAMESPACE, ContextCompressionSettingsSchema);
805
- }
806
774
  //#endregion
807
775
  export { Config, apply };
@@ -0,0 +1,105 @@
1
+ //#region src/profiles.d.ts
2
+ /** Public context-compression choices shared by the Host schema and browser selector. */
3
+ declare const COMPRESSION_PROFILES: readonly ["off", "native", "balanced", "cache-strict", "savings", "adaptive", "tokenpilot-inspired", "custom"];
4
+ /** One supported context-compression profile. */
5
+ type CompressionProfile = typeof COMPRESSION_PROFILES[number];
6
+ /** Single canonical unit stored by a version-1 browser Custom document. */
7
+ type CustomCompressionUnit = 'tokens' | 'context-percent';
8
+ /** Whether Custom History may routinely rewrite an already-sent prefix. */
9
+ type CustomPrefixPolicy = 'preserve' | 'pressure-break';
10
+ /** Browser representation of one independently enabled Fresh or Aggregate budget. */
11
+ interface CustomCompressionBudget {
12
+ enabled: boolean;
13
+ trigger: number;
14
+ target: number;
15
+ }
16
+ /** Legacy browser representation of the Custom History working set. */
17
+ interface LegacyCustomHistoryPolicy {
18
+ enabled: boolean;
19
+ trigger: number;
20
+ keepRecentTurns: number;
21
+ keepRecent: number;
22
+ minReclaim: number;
23
+ }
24
+ /** Browser representation of Custom History tool-call and token-tail protection. */
25
+ interface CustomHistoryPolicy {
26
+ enabled: boolean;
27
+ trigger: number;
28
+ keepRecentToolCalls: number;
29
+ keepRecentTokens: number;
30
+ minReclaim: number;
31
+ }
32
+ /** Browser representation of the Custom-only Experimental TailTrim gate. */
33
+ interface CustomTailTrimPolicy {
34
+ enabled: boolean;
35
+ trigger: number;
36
+ }
37
+ interface CustomCompressionPolicyCommon<HistoryPolicy> {
38
+ unit: CustomCompressionUnit;
39
+ fresh: CustomCompressionBudget;
40
+ aggregate: CustomCompressionBudget;
41
+ history: HistoryPolicy;
42
+ prefixPolicy: CustomPrefixPolicy;
43
+ }
44
+ /** Legacy public Custom document; accepted and normalized before editing. */
45
+ interface CustomCompressionPolicyV1 extends CustomCompressionPolicyCommon<LegacyCustomHistoryPolicy> {
46
+ version: 1;
47
+ }
48
+ /** Legacy Custom document with a default-disabled TailTrim stage. */
49
+ interface CustomCompressionPolicyV2 extends CustomCompressionPolicyCommon<LegacyCustomHistoryPolicy> {
50
+ version: 2;
51
+ tailTrim: CustomTailTrimPolicy;
52
+ }
53
+ /** Public Custom document with tool-call working-set protection. */
54
+ interface CustomCompressionPolicyV3 extends CustomCompressionPolicyCommon<CustomHistoryPolicy> {
55
+ version: 3;
56
+ tailTrim: CustomTailTrimPolicy;
57
+ }
58
+ /** Exact public Custom document accepted by the Host and browser boundary. */
59
+ type CustomCompressionPolicy = CustomCompressionPolicyV1 | CustomCompressionPolicyV2 | CustomCompressionPolicyV3;
60
+ /** User-tunable Auto Compact coordination preferences. */
61
+ interface AutoCompactSettings {
62
+ thresholdPercent: number;
63
+ }
64
+ /**
65
+ * Orthogonal code-skeleton reducer gate, mirrored browser-safe from the
66
+ * runtime: independent of every profile, default off.
67
+ */
68
+ interface CodeSkeletonSettings {
69
+ enabled: boolean;
70
+ }
71
+ /** Browser-safe mirror of the runtime presetOptions section. */
72
+ interface PresetOptionsSettings {
73
+ readonly dedupeToolResults?: boolean;
74
+ readonly summaryLocator?: boolean;
75
+ readonly prefixStabilizer?: boolean;
76
+ readonly readState?: boolean;
77
+ readonly estimatorMode?: '' | 'host' | 'direct';
78
+ readonly estimatorProvider?: string;
79
+ readonly estimatorModel?: string;
80
+ readonly estimatorBaseUrl?: string;
81
+ readonly estimatorApiKey?: string;
82
+ readonly estimatorTimeoutMs?: number;
83
+ /** Advisory advisor channel; `''` (the default) keeps the advisor off. */
84
+ readonly advisorMode?: '' | 'host' | 'direct';
85
+ readonly advisorTimeoutMs?: number;
86
+ readonly advisorRefreshTurns?: number;
87
+ readonly advisorScoreThreshold?: number;
88
+ readonly advisorSampleLimit?: number;
89
+ readonly advisorMinTokens?: number;
90
+ }
91
+ /** Durable settings section owned by this package. */
92
+ interface ContextCompressionSettings {
93
+ /** Default profile captured when each Session first reaches the pruner. */
94
+ profile: CompressionProfile;
95
+ /** Complete canonical policy captured with `profile` when the runtime first observes a Session. */
96
+ custom: CustomCompressionPolicy;
97
+ /** Auto Compact trigger captured with `profile` when the runtime first observes a Session. */
98
+ autoCompact: AutoCompactSettings;
99
+ /** Code-skeleton reducer gate captured independently of `profile`. */
100
+ codeSkeleton: CodeSkeletonSettings;
101
+ /** Optional tokenpilot-inspired sub-capability overrides (presence-validated only). */
102
+ presetOptions?: PresetOptionsSettings;
103
+ }
104
+ //#endregion
105
+ export { PresetOptionsSettings as i, ContextCompressionSettings as n, CustomCompressionPolicy as r, CompressionProfile as t };
@@ -1,4 +1,4 @@
1
- import { C as COMPRESSION_PROFILES, S as deepFreeze, _ as resolvePolicy, a as AUTO_COMPACT_THRESHOLD_LIMITS, b as resolveCustomPolicy, c as DEFAULTS, d as charsToTokens, f as codePointLength, g as resolveConfig, h as parseContextCompressionSettings, i as recordScore, l as PRUNE_MARKER, m as isValidAutoCompactThresholdPercent, n as invalidateOnTaskChange, o as CONTEXT_COMPRESSION_SETTINGS_NAMESPACE, p as isCompressionProfile, r as recordRecertified, s as ContextCompressionSettingsSchema, t as getAdvisorState, u as charsForTokens, v as CustomCompressionPolicySchema, x as assertNever, y as DEFAULT_CUSTOM_COMPRESSION_POLICY } from "./advisor-state.js";
1
+ import { C as deepFreeze, S as assertNever, _ as resolveConfig, a as AUTO_COMPACT_THRESHOLD_LIMITS, b as DEFAULT_CUSTOM_COMPRESSION_POLICY, c as DEFAULTS, d as charsForTokens, f as charsToTokens, g as parseContextCompressionSettings, h as isValidAutoCompactThresholdPercent, i as recordScore, m as isCompressionProfile, n as invalidateOnTaskChange, o as CONTEXT_COMPRESSION_SETTINGS_NAMESPACE, p as codePointLength, r as recordRecertified, s as ContextCompressionSettingsSchema, t as getAdvisorState, u as PRUNE_MARKER, v as resolvePolicy, w as COMPRESSION_PROFILES, x as resolveCustomPolicy, y as CustomCompressionPolicySchema } from "./advisor-state.js";
2
2
  import { a as validatePublishedTailTrim, i as tailTrimStub, n as tailTrimMessage, o as eventBySeq, r as tailTrimRef, s as sessionEvents, t as parseTailTrimRef } from "./tail-trim.js";
3
3
  import z from "@deepseek-ai/schemastery";
4
4
  import { createHash } from "node:crypto";
@@ -4170,7 +4170,8 @@ var ToolResultPruner = class extends Service {
4170
4170
  activeSettings(session) {
4171
4171
  const frozen = this.state.sessionSettings.get(session);
4172
4172
  if (frozen !== void 0) return frozen;
4173
- const settings = this.ctx.get("settings")?.get(CONTEXT_COMPRESSION_SETTINGS_NAMESPACE);
4173
+ const settingsHost = this.ctx.get("settings");
4174
+ const settings = settingsHost?.describe?.().find((d) => String(d.ns) === "context-compression-improved-bundle")?.value ?? settingsHost?.get?.("context-compression");
4174
4175
  let resolved;
4175
4176
  let settingsSource = settings === void 0 ? "plugin-config-fallback" : "host-settings";
4176
4177
  let autoCompactThresholdSource = settings === void 0 ? "schema-default" : "host-settings";
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-context-compression-improved",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "One-install context-compression selector bundle for DeepSeek Harness",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -82,7 +82,7 @@
82
82
  "tag": "latest"
83
83
  },
84
84
  "dependencies": {
85
- "@deepseek-ai/schemastery": "3.18.2",
85
+ "@deepseek-ai/schemastery": "3.18.4",
86
86
  "@huggingface/tokenizers": "0.1.3",
87
87
  "js-yaml": "^4.3.2"
88
88
  },
@@ -90,25 +90,25 @@
90
90
  "@deepseek-ai/cordis": ">=4.0.1 <5",
91
91
  "@deepseek-ai/cordis-plugin-include": ">=1.0.6 <2",
92
92
  "@deepseek-ai/cordis-plugin-loader": ">=1.0.2 <2",
93
- "@deepseek-ai/dsh-agent": ">=0.1.5-rc.2 <0.2.0-0",
94
- "@deepseek-ai/dsh-agent-presets": ">=0.1.5-rc.2 <0.2.0-0",
95
- "@deepseek-ai/dsh-command-compact": ">=0.1.5-rc.2 <0.2.0-0",
96
- "@deepseek-ai/dsh-compaction": ">=0.1.5-rc.2 <0.2.0-0",
97
- "@deepseek-ai/dsh-compaction-basic": ">=0.1.5-rc.2 <0.2.0-0",
98
- "@deepseek-ai/dsh-client-locale": ">=0.1.5-rc.1 <0.2.0-0",
99
- "@deepseek-ai/dsh-client-store": ">=0.1.5-rc.1 <0.2.0-0",
100
- "@deepseek-ai/dsh-client-ui-session": ">=0.1.5-rc.1 <0.2.0-0",
101
- "@deepseek-ai/dsh-client-ui-primitives": ">=0.1.5-rc.1 <0.2.0-0",
102
- "@deepseek-ai/dsh-client-ui-settings": ">=0.1.5-rc.1 <0.2.0-0",
103
- "@deepseek-ai/dsh-client-ui-slots": ">=0.1.5-rc.1 <0.2.0-0",
104
- "@deepseek-ai/dsh-client-ui-workspace": ">=0.1.5-rc.1 <0.2.0-0",
105
- "@deepseek-ai/dsh-invariants": ">=0.1.5-rc.2 <0.2.0-0",
106
- "@deepseek-ai/dsh-llm": ">=0.1.5-rc.2 <0.2.0-0",
107
- "@deepseek-ai/dsh-session": ">=0.1.5-rc.2 <0.2.0-0",
108
- "@deepseek-ai/dsh-settings": ">=0.1.5-rc.2 <0.2.0-0",
109
- "@deepseek-ai/dsh-system-prompt": ">=0.1.5-rc.2 <0.2.0-0",
110
- "@deepseek-ai/dsh-token-meter": ">=0.1.5-rc.2 <0.2.0-0",
111
- "@deepseek-ai/dsh-tools": ">=0.1.5-rc.2 <0.2.0-0",
93
+ "@deepseek-ai/dsh-agent": ">=0.1.7-rc.1 <0.2.0-0",
94
+ "@deepseek-ai/dsh-agent-presets": ">=0.1.7-rc.1 <0.2.0-0",
95
+ "@deepseek-ai/dsh-client-locale": ">=0.1.7-rc.1 <0.2.0-0",
96
+ "@deepseek-ai/dsh-client-store": ">=0.1.7-rc.1 <0.2.0-0",
97
+ "@deepseek-ai/dsh-client-ui-primitives": ">=0.1.7-rc.1 <0.2.0-0",
98
+ "@deepseek-ai/dsh-client-ui-session": ">=0.1.7-rc.1 <0.2.0-0",
99
+ "@deepseek-ai/dsh-client-ui-settings": ">=0.1.7-rc.1 <0.2.0-0",
100
+ "@deepseek-ai/dsh-client-ui-slots": ">=0.1.7-rc.1 <0.2.0-0",
101
+ "@deepseek-ai/dsh-client-ui-workspace": ">=0.1.7-rc.1 <0.2.0-0",
102
+ "@deepseek-ai/dsh-command-compact": ">=0.1.7-rc.1 <0.2.0-0",
103
+ "@deepseek-ai/dsh-compaction": ">=0.1.7-rc.1 <0.2.0-0",
104
+ "@deepseek-ai/dsh-compaction-basic": ">=0.1.7-rc.1 <0.2.0-0",
105
+ "@deepseek-ai/dsh-invariants": ">=0.1.7-rc.1 <0.2.0-0",
106
+ "@deepseek-ai/dsh-llm": ">=0.1.7-rc.1 <0.2.0-0",
107
+ "@deepseek-ai/dsh-session": ">=0.1.7-rc.1 <0.2.0-0",
108
+ "@deepseek-ai/dsh-settings": ">=0.1.7-rc.1 <0.2.0-0",
109
+ "@deepseek-ai/dsh-system-prompt": ">=0.1.7-rc.1 <0.2.0-0",
110
+ "@deepseek-ai/dsh-token-meter": ">=0.1.7-rc.1 <0.2.0-0",
111
+ "@deepseek-ai/dsh-tools": ">=0.1.7-rc.1 <0.2.0-0",
112
112
  "react": ">=18 <19"
113
113
  }
114
114
  }