dsh-context-compression-improved 0.11.1 → 0.11.3

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 (311) hide show
  1. package/README.md +15 -110
  2. package/README.zh.md +14 -104
  3. package/THIRD_PARTY_NOTICES.md +25 -7
  4. package/{packages/selector/dsh.plugin.json → dsh.plugin.json} +1 -1
  5. package/{packages/selector/lib → lib}/client.js +27 -10
  6. package/{packages/selector/lib → lib}/index.js +101 -0
  7. package/package.json +125 -112
  8. package/screenshots.json +3 -6
  9. package/.agents/plans/improve/checklist.md +0 -32
  10. package/.agents/plans/improve/findings.md +0 -102
  11. package/.agents/plans/improve/spec.md +0 -53
  12. package/.agents/plans/improve/tasks.md +0 -70
  13. package/.gitattributes +0 -2
  14. package/.githooks/pre-push +0 -37
  15. package/.github/workflows/ci.yml +0 -47
  16. package/CHANGELOG.de.md +0 -580
  17. package/CHANGELOG.es.md +0 -588
  18. package/CHANGELOG.fr.md +0 -576
  19. package/CHANGELOG.it.md +0 -577
  20. package/CHANGELOG.ja.md +0 -261
  21. package/CHANGELOG.ko.md +0 -254
  22. package/CHANGELOG.md +0 -557
  23. package/CHANGELOG.ru.md +0 -554
  24. package/CHANGELOG.zh.md +0 -247
  25. package/CONTRIBUTING.md +0 -22
  26. package/README.de.md +0 -96
  27. package/README.es.md +0 -96
  28. package/README.fr.md +0 -96
  29. package/README.it.md +0 -96
  30. package/README.ja.md +0 -102
  31. package/README.ko.md +0 -102
  32. package/README.ru.md +0 -96
  33. package/SECURITY.md +0 -18
  34. package/assets/board.png +0 -0
  35. package/assets/context.png +0 -0
  36. package/assets/dshfind-card.svg +0 -33
  37. package/docs/assets/context-compression-selector-profiles.jpg +0 -0
  38. package/docs/assets/context-compression-selector-settings.png +0 -0
  39. package/docs/compat-0.1.5-report.md +0 -77
  40. package/docs/installation.de.md +0 -104
  41. package/docs/installation.es.md +0 -104
  42. package/docs/installation.fr.md +0 -104
  43. package/docs/installation.it.md +0 -104
  44. package/docs/installation.ja.md +0 -78
  45. package/docs/installation.ko.md +0 -78
  46. package/docs/installation.md +0 -103
  47. package/docs/installation.ru.md +0 -104
  48. package/docs/installation.zh.md +0 -100
  49. package/docs/repair-log.md +0 -657
  50. package/docs/shallow-teaching-preset-template.md +0 -46
  51. package/eslint.config.js +0 -30
  52. package/packages/selector/LICENSE +0 -21
  53. package/packages/selector/README.md +0 -26
  54. package/packages/selector/README.zh.md +0 -24
  55. package/packages/selector/THIRD_PARTY_NOTICES.md +0 -32
  56. package/packages/selector/docs/history-tool-call-working-set-spec.md +0 -112
  57. package/packages/selector/docs/native-tool-result-selector-spec.md +0 -34
  58. package/packages/selector/docs/subagent-cache-reuse-spec.md +0 -46
  59. package/packages/selector/lib/style.css +0 -350
  60. package/packages/selector/package.json +0 -178
  61. package/packages/selector/screenshots.json +0 -3
  62. package/packages/selector/src/client/CompressionProfileControls.tsx +0 -352
  63. package/packages/selector/src/client/CompressionProfileSelector.module.css +0 -199
  64. package/packages/selector/src/client/CompressionProfileSelector.tsx +0 -89
  65. package/packages/selector/src/client/CustomPolicyEditor.tsx +0 -216
  66. package/packages/selector/src/client/EstimatorControls.tsx +0 -277
  67. package/packages/selector/src/client/bridge-scope.ts +0 -125
  68. package/packages/selector/src/client/decode.ts +0 -68
  69. package/packages/selector/src/client/fab-pos.ts +0 -71
  70. package/packages/selector/src/client/index.ts +0 -438
  71. package/packages/selector/src/client/locales/de.ts +0 -167
  72. package/packages/selector/src/client/locales/es.ts +0 -167
  73. package/packages/selector/src/client/locales/fr.ts +0 -167
  74. package/packages/selector/src/client/locales/it.ts +0 -167
  75. package/packages/selector/src/client/locales/ja.ts +0 -167
  76. package/packages/selector/src/client/locales/ko.ts +0 -167
  77. package/packages/selector/src/client/locales/ru.ts +0 -167
  78. package/packages/selector/src/client/locales.ts +0 -334
  79. package/packages/selector/src/client/monitor-fab.ts +0 -445
  80. package/packages/selector/src/client/preset-options.ts +0 -88
  81. package/packages/selector/src/client/savings-card.tsx +0 -269
  82. package/packages/selector/src/client/scope-face.ts +0 -24
  83. package/packages/selector/src/client/settings-section.tsx +0 -156
  84. package/packages/selector/src/compat/host-generation.ts +0 -96
  85. package/packages/selector/src/compat/llm-messages.ts +0 -50
  86. package/packages/selector/src/compat/settings-lease.ts +0 -108
  87. package/packages/selector/src/compat/tool-result.ts +0 -91
  88. package/packages/selector/src/css-modules.d.ts +0 -6
  89. package/packages/selector/src/deepseek-v4-tokenizer.ts +0 -205
  90. package/packages/selector/src/estimator-catalog.ts +0 -104
  91. package/packages/selector/src/index.ts +0 -890
  92. package/packages/selector/src/invariant.ts +0 -113
  93. package/packages/selector/src/preset-overlay.ts +0 -749
  94. package/packages/selector/src/profiles.ts +0 -554
  95. package/packages/selector/src/pruner/content.ts +0 -199
  96. package/packages/selector/src/pruner/session.ts +0 -97
  97. package/packages/selector/src/pruner/state.ts +0 -61
  98. package/packages/selector/src/pruner/tuning.ts +0 -23
  99. package/packages/selector/src/pruner/types.ts +0 -78
  100. package/packages/selector/src/pruner.ts +0 -3222
  101. package/packages/selector/src/runtime/adaptive-cost.ts +0 -205
  102. package/packages/selector/src/runtime/audit.ts +0 -321
  103. package/packages/selector/src/runtime/config.ts +0 -887
  104. package/packages/selector/src/runtime/custom-policy.ts +0 -300
  105. package/packages/selector/src/runtime/deepseek-official-pricing.ts +0 -298
  106. package/packages/selector/src/runtime/deepseek-v4-vision-tokens.ts +0 -254
  107. package/packages/selector/src/runtime/display-prefs.ts +0 -98
  108. package/packages/selector/src/runtime/fold-router.ts +0 -143
  109. package/packages/selector/src/runtime/measurement.ts +0 -444
  110. package/packages/selector/src/runtime/monitor.ts +0 -341
  111. package/packages/selector/src/runtime/panel-command.ts +0 -213
  112. package/packages/selector/src/runtime/reducers.ts +0 -1755
  113. package/packages/selector/src/runtime/retrieve.ts +0 -505
  114. package/packages/selector/src/runtime/savings-integral.ts +0 -117
  115. package/packages/selector/src/runtime/savings-projection.ts +0 -229
  116. package/packages/selector/src/runtime/savings-verify.ts +0 -446
  117. package/packages/selector/src/runtime/savings.ts +0 -526
  118. package/packages/selector/src/runtime/sediment-card.ts +0 -126
  119. package/packages/selector/src/runtime/sediment-clock.ts +0 -87
  120. package/packages/selector/src/runtime/sediment-guard.ts +0 -136
  121. package/packages/selector/src/runtime/sediment-publish.ts +0 -144
  122. package/packages/selector/src/runtime/sediment-span.ts +0 -170
  123. package/packages/selector/src/runtime/sediment.ts +0 -209
  124. package/packages/selector/src/runtime/session-events.ts +0 -30
  125. package/packages/selector/src/runtime/session-file-decode.ts +0 -523
  126. package/packages/selector/src/runtime/shallow-tools.ts +0 -342
  127. package/packages/selector/src/runtime/stats-backfill.ts +0 -541
  128. package/packages/selector/src/runtime/stats-db.ts +0 -492
  129. package/packages/selector/src/runtime/stats-schema.ts +0 -123
  130. package/packages/selector/src/runtime/stats-sync.ts +0 -307
  131. package/packages/selector/src/runtime/summary-command.ts +0 -127
  132. package/packages/selector/src/runtime/tail-trim.ts +0 -177
  133. package/packages/selector/src/runtime/token-count.ts +0 -72
  134. package/packages/selector/src/runtime/tokenpilot/advisor-prompt.ts +0 -233
  135. package/packages/selector/src/runtime/tokenpilot/advisor-state.ts +0 -204
  136. package/packages/selector/src/runtime/tokenpilot/advisor.ts +0 -419
  137. package/packages/selector/src/runtime/tokenpilot/benefit.ts +0 -200
  138. package/packages/selector/src/runtime/tokenpilot/dedup.ts +0 -82
  139. package/packages/selector/src/runtime/tokenpilot/estimator.ts +0 -151
  140. package/packages/selector/src/runtime/tokenpilot/intent-fold.ts +0 -53
  141. package/packages/selector/src/runtime/tokenpilot/intent-gate.ts +0 -65
  142. package/packages/selector/src/runtime/tokenpilot/intent-input-mask.ts +0 -125
  143. package/packages/selector/src/runtime/tokenpilot/intent-range.ts +0 -37
  144. package/packages/selector/src/runtime/tokenpilot/locator.ts +0 -129
  145. package/packages/selector/src/runtime/tokenpilot/read-state.ts +0 -98
  146. package/packages/selector/src/runtime/tokenpilot/sidechannel.ts +0 -303
  147. package/packages/selector/src/runtime/tool-names.ts +0 -42
  148. package/packages/selector/src/runtime/toolclass.ts +0 -103
  149. package/packages/selector/src/runtime/triage/masks.ts +0 -128
  150. package/packages/selector/src/runtime/triage/shallow.ts +0 -132
  151. package/packages/selector/src/runtime/triage/signals.ts +0 -167
  152. package/packages/selector/src/runtime/triage/types.ts +0 -125
  153. package/packages/selector/src/runtime/types.ts +0 -396
  154. package/packages/selector/src/runtime/value.ts +0 -48
  155. package/packages/selector/src/settings-bridge.ts +0 -175
  156. package/packages/selector/tests/advisor-report.host.spec.ts +0 -223
  157. package/packages/selector/tests/auto-compact.client.spec.tsx +0 -214
  158. package/packages/selector/tests/built/client-artifact.spec.ts +0 -56
  159. package/packages/selector/tests/cache-prefix-audit.spec.ts +0 -123
  160. package/packages/selector/tests/code-skeleton.client.spec.ts +0 -98
  161. package/packages/selector/tests/compat/compat-narrow-waist.spec.ts +0 -150
  162. package/packages/selector/tests/custom-contract.client.spec.ts +0 -226
  163. package/packages/selector/tests/estimator-catalog.spec.ts +0 -70
  164. package/packages/selector/tests/estimator-channel.client.spec.tsx +0 -253
  165. package/packages/selector/tests/estimator-route-registration.host.spec.ts +0 -202
  166. package/packages/selector/tests/fab-pos.client.spec.ts +0 -47
  167. package/packages/selector/tests/fixtures/sediment-pool/52adc205-cloud-5.orig.txt +0 -231
  168. package/packages/selector/tests/fixtures/sediment-pool/95fcba5d-cloud-25.orig.txt +0 -236
  169. package/packages/selector/tests/fixtures/sediment-pool/95fcba5d-cloud-38.orig.txt +0 -220
  170. package/packages/selector/tests/fixtures/sediment-pool/95fcba5d-cloud-42.orig.txt +0 -140
  171. package/packages/selector/tests/fixtures/sediment-pool/95fcba5d-cloud-53.orig.txt +0 -117
  172. package/packages/selector/tests/fixtures/sediment-pool/95fcba5d-local-10.orig.txt +0 -67
  173. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-45.orig.txt +0 -119
  174. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-49.orig.txt +0 -119
  175. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-63.orig.txt +0 -131
  176. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-75.orig.txt +0 -196
  177. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-76.orig.txt +0 -71
  178. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-85.orig.txt +0 -126
  179. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-86.orig.txt +0 -86
  180. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-87.orig.txt +0 -50
  181. package/packages/selector/tests/fixtures/sediment-pool/a7a767c0-cloud-96.orig.txt +0 -102
  182. package/packages/selector/tests/helpers/legacy-namespace.ts +0 -35
  183. package/packages/selector/tests/helpers/legacy-settings/index.ts +0 -15
  184. package/packages/selector/tests/helpers/legacy-settings/legacy/provider.d.ts +0 -41
  185. package/packages/selector/tests/helpers/legacy-settings/legacy/provider.js +0 -647
  186. package/packages/selector/tests/helpers/legacy-settings/legacy/redact.js +0 -78
  187. package/packages/selector/tests/helpers/legacy-settings/legacy/util-values.js +0 -234
  188. package/packages/selector/tests/host-preset-overlay.host.spec.ts +0 -204
  189. package/packages/selector/tests/monitor-fab.client.spec.ts +0 -240
  190. package/packages/selector/tests/preset-options-write.client.spec.ts +0 -192
  191. package/packages/selector/tests/preset-overlay-loader.e2e.host.spec.ts +0 -200
  192. package/packages/selector/tests/preset-overlay.host.spec.ts +0 -246
  193. package/packages/selector/tests/profiles.client.spec.tsx +0 -436
  194. package/packages/selector/tests/ptc-custom-write.client.spec.ts +0 -86
  195. package/packages/selector/tests/public/package-contract.client.spec.ts +0 -89
  196. package/packages/selector/tests/runtime/adaptive-cost.spec.ts +0 -167
  197. package/packages/selector/tests/runtime/advice-never-withholds.host.spec.ts +0 -230
  198. package/packages/selector/tests/runtime/advisor-invariant.spec.ts +0 -272
  199. package/packages/selector/tests/runtime/advisor.spec.ts +0 -226
  200. package/packages/selector/tests/runtime/audit.spec.ts +0 -275
  201. package/packages/selector/tests/runtime/auto-compact-config.spec.ts +0 -523
  202. package/packages/selector/tests/runtime/char-basis.spec.ts +0 -30
  203. package/packages/selector/tests/runtime/code-skeleton.spec.ts +0 -152
  204. package/packages/selector/tests/runtime/deepseek-official-pricing.spec.ts +0 -186
  205. package/packages/selector/tests/runtime/deepseek-v4-tokenizer.spec.ts +0 -122
  206. package/packages/selector/tests/runtime/deepseek-v4-vision-tokens.spec.ts +0 -122
  207. package/packages/selector/tests/runtime/deprecated-preset-options.spec.ts +0 -96
  208. package/packages/selector/tests/runtime/fixtures/profile-baseline.json +0 -273
  209. package/packages/selector/tests/runtime/fixtures/session-v4-dump.jsonl +0 -46
  210. package/packages/selector/tests/runtime/fixtures/tokenizer-golden.json +0 -106
  211. package/packages/selector/tests/runtime/fixtures/vision-golden.json +0 -459
  212. package/packages/selector/tests/runtime/fold-router.spec.ts +0 -140
  213. package/packages/selector/tests/runtime/frequency-longstrings.spec.ts +0 -74
  214. package/packages/selector/tests/runtime/fresh-gate.spec.ts +0 -43
  215. package/packages/selector/tests/runtime/html-reducer.spec.ts +0 -212
  216. package/packages/selector/tests/runtime/intent-gate.spec.ts +0 -62
  217. package/packages/selector/tests/runtime/intent-summary.spec.ts +0 -156
  218. package/packages/selector/tests/runtime/jsonl-reducer.spec.ts +0 -79
  219. package/packages/selector/tests/runtime/line-mapping.spec.ts +0 -153
  220. package/packages/selector/tests/runtime/monitor.spec.ts +0 -354
  221. package/packages/selector/tests/runtime/panel-command.spec.ts +0 -101
  222. package/packages/selector/tests/runtime/prose-reducers.spec.ts +0 -133
  223. package/packages/selector/tests/runtime/ptc-profile.spec.ts +0 -133
  224. package/packages/selector/tests/runtime/public/public-runtime.spec.ts +0 -2795
  225. package/packages/selector/tests/runtime/read-input-cap.spec.ts +0 -33
  226. package/packages/selector/tests/runtime/savings-accounting.spec.ts +0 -291
  227. package/packages/selector/tests/runtime/savings-integral.spec.ts +0 -169
  228. package/packages/selector/tests/runtime/savings-projection.spec.ts +0 -89
  229. package/packages/selector/tests/runtime/savings-verify.spec.ts +0 -226
  230. package/packages/selector/tests/runtime/savings.spec.ts +0 -139
  231. package/packages/selector/tests/runtime/search-reducer.spec.ts +0 -110
  232. package/packages/selector/tests/runtime/sediment-card.spec.ts +0 -111
  233. package/packages/selector/tests/runtime/sediment-config.spec.ts +0 -56
  234. package/packages/selector/tests/runtime/sediment-guard.spec.ts +0 -71
  235. package/packages/selector/tests/runtime/sediment-masks.spec.ts +0 -95
  236. package/packages/selector/tests/runtime/sediment-orchestrator.spec.ts +0 -166
  237. package/packages/selector/tests/runtime/sediment-pool-share.spec.ts +0 -65
  238. package/packages/selector/tests/runtime/sediment-publish.spec.ts +0 -142
  239. package/packages/selector/tests/runtime/sediment-real-shapes.spec.ts +0 -158
  240. package/packages/selector/tests/runtime/sediment-settings.spec.ts +0 -73
  241. package/packages/selector/tests/runtime/sediment-signals.spec.ts +0 -124
  242. package/packages/selector/tests/runtime/sediment-span.spec.ts +0 -92
  243. package/packages/selector/tests/runtime/session-events.spec.ts +0 -27
  244. package/packages/selector/tests/runtime/session-file-decode.spec.ts +0 -281
  245. package/packages/selector/tests/runtime/settings-unwrap.spec.ts +0 -58
  246. package/packages/selector/tests/runtime/shallow-primitives.spec.ts +0 -135
  247. package/packages/selector/tests/runtime/sidechannel.spec.ts +0 -241
  248. package/packages/selector/tests/runtime/stats-backfill-scheduler.spec.ts +0 -167
  249. package/packages/selector/tests/runtime/stats-backfill.spec.ts +0 -350
  250. package/packages/selector/tests/runtime/stats-db.spec.ts +0 -361
  251. package/packages/selector/tests/runtime/stats-privacy.spec.ts +0 -55
  252. package/packages/selector/tests/runtime/stats-sync.spec.ts +0 -278
  253. package/packages/selector/tests/runtime/summary-command.spec.ts +0 -154
  254. package/packages/selector/tests/runtime/toc-and-bundled.spec.ts +0 -159
  255. package/packages/selector/tests/runtime/tokenizer-golden.spec.ts +0 -53
  256. package/packages/selector/tests/runtime/tokenpilot/benefit.spec.ts +0 -217
  257. package/packages/selector/tests/runtime/tokenpilot/dedup.spec.ts +0 -52
  258. package/packages/selector/tests/runtime/tokenpilot/estimator.spec.ts +0 -79
  259. package/packages/selector/tests/runtime/tokenpilot/locator.spec.ts +0 -76
  260. package/packages/selector/tests/runtime/tokenpilot/profile-baseline.spec.ts +0 -121
  261. package/packages/selector/tests/runtime/tokenpilot/read-state.spec.ts +0 -82
  262. package/packages/selector/tests/runtime/toolclass.spec.ts +0 -156
  263. package/packages/selector/tests/runtime/value.spec.ts +0 -23
  264. package/packages/selector/tests/savings-sessions.client.spec.tsx +0 -140
  265. package/packages/selector/tests/settings-seat.client.spec.ts +0 -215
  266. package/packages/selector/tests/standing-generation.host.spec.ts +0 -724
  267. package/packages/selector/tests/subagent-cache-reuse.host.spec.ts +0 -269
  268. package/packages/selector/tests/support/cache-prefix-audit.ts +0 -105
  269. package/packages/selector/tests/support/mock-adapter.ts +0 -37
  270. package/packages/selector/tests/support/ui-primitives.tsx +0 -34
  271. package/packages/selector/tsconfig.json +0 -11
  272. package/packages/selector/tsdown.client.config.ts +0 -102
  273. package/packages/selector/tsdown.config.ts +0 -20
  274. package/pnpm-workspace.yaml +0 -76
  275. package/scripts/capture-profile-baseline.mjs +0 -42
  276. package/scripts/cell-browser-e2e.mjs +0 -354
  277. package/scripts/generate-tokenizer-fixtures.py +0 -81
  278. package/scripts/generate-vision-fixtures.py +0 -208
  279. package/scripts/hosts.d.mts +0 -3
  280. package/scripts/hosts.mjs +0 -81
  281. package/scripts/packed-components-smoke.mjs +0 -763
  282. package/scripts/packed-install-e2e.mjs +0 -1346
  283. package/scripts/sediment-latency-report.mjs +0 -63
  284. package/scripts/sync-hosts.mjs +0 -174
  285. package/scripts/toolclass-corpus-replay.mjs +0 -281
  286. package/scripts/verify-release.mjs +0 -343
  287. package/tests/TEST_INVENTORY.md +0 -41
  288. package/tsconfig.base.json +0 -18
  289. package/tsconfig.json +0 -7
  290. package/tsconfig.tests.json +0 -15
  291. package/vitest.built.config.ts +0 -9
  292. package/vitest.config.ts +0 -54
  293. /package/{packages/selector/assets → assets}/deepseek-v4/LICENSE.DeepSeek-V4-Pro.txt +0 -0
  294. /package/{packages/selector/assets → assets}/deepseek-v4/manifest.json +0 -0
  295. /package/{packages/selector/assets → assets}/deepseek-v4/tokenizer.json +0 -0
  296. /package/{packages/selector/assets → assets}/deepseek-v4/tokenizer_config.json +0 -0
  297. /package/{packages/selector/assets → assets}/deepseek-v4-vision-exp/LICENSE.DeepSeek-V4-Flash-Vision-Exp.txt +0 -0
  298. /package/{packages/selector/assets → assets}/deepseek-v4-vision-exp/manifest.json +0 -0
  299. /package/{packages/selector/assets → assets}/deepseek-v4-vision-exp/tokenizer.json +0 -0
  300. /package/{packages/selector/assets → assets}/deepseek-v4-vision-exp/tokenizer_config.json +0 -0
  301. /package/{packages/selector/cordis.patch.yml → cordis.patch.yml} +0 -0
  302. /package/{packages/selector/lib → lib}/client.d.ts +0 -0
  303. /package/{packages/selector/lib → lib}/index.d.ts +0 -0
  304. /package/{packages/selector/lib → lib}/invariant.d.ts +0 -0
  305. /package/{packages/selector/lib → lib}/invariant.js +0 -0
  306. /package/{packages/selector/lib → lib}/profiles.d.ts +0 -0
  307. /package/{packages/selector/lib → lib}/pruner.d.ts +0 -0
  308. /package/{packages/selector/lib → lib}/pruner.js +0 -0
  309. /package/{packages/selector/lib → lib}/savings-integral.js +0 -0
  310. /package/{packages/selector/lib → lib}/tail-trim.js +0 -0
  311. /package/{packages/selector/lib → lib}/tool-result.js +0 -0
@@ -1,108 +0,0 @@
1
- /**
2
- * Settings namespace lease (ported from the compat/0.1.5 line, where it ran
3
- * in production as v0.5.8): on legacy hosts (0.1.0–0.1.5) the compression
4
- * document lives in a settings-service namespace, and BOTH Loader rows
5
- * (bundle + routes) execute apply() — two fibers must not race
6
- * `settings.register`. The lease is keyed through a Symbol property on the
7
- * service itself, so every cordis proxy of the same service shares it.
8
- *
9
- * The lease effect is registered BEFORE settings.register(): cordis disposes
10
- * effects in reverse order, so on teardown the native registration is
11
- * released first and this disposer can transfer the namespace to another
12
- * live owner without a duplicate-registration window.
13
- *
14
- * On modern hosts (0.1.7+) this is a no-op: dsh-settings dropped `register`
15
- * entirely (audit P1-13 — API does not exist, not a probe-skip), and the
16
- * document lives in the entry-config volatile field. Type isolation stays
17
- * inside this file: callers never see register-typed faces.
18
- */
19
- import type { Context } from '@deepseek-ai/cordis'
20
-
21
- const SHARED_LEASE = Symbol.for('dsh-context-compression-improved/settings-lease')
22
-
23
- export interface LeaseFace {
24
- /** Read the resolved namespace document (settings.get semantics). */
25
- get(): unknown
26
- /** Merge-write the namespace document; false when the host rejected it. */
27
- update(patch: Record<string, unknown>): Promise<boolean>
28
- }
29
-
30
- interface SettingsOwner {
31
- settings: LeaseCarrier
32
- }
33
-
34
- interface SharedLease {
35
- owners: Set<SettingsOwner>
36
- registrationOwner: SettingsOwner
37
- }
38
-
39
- interface LeaseCarrier {
40
- register?: (ns: string, schema: unknown) => { get?: () => unknown; update?: (ns: string, patch: Record<string, unknown>) => Promise<unknown> }
41
- get?: (ns: string) => unknown
42
- update?: (ns: string, patch: Record<string, unknown>) => Promise<unknown>
43
- replace?: (ns: string, section: Record<string, unknown>) => Promise<unknown>
44
- [SHARED_LEASE]?: SharedLease
45
- }
46
-
47
- /**
48
- * Lease the namespace. No-op on modern hosts (register absent). Returns a
49
- * read/update face; both are undefined-safe on modern hosts so callers can
50
- * hold the face unconditionally and stay on the entry-config path there.
51
- */
52
- export function acquireSettingsLease(
53
- ctx: Context,
54
- namespace: string,
55
- schema: unknown,
56
- ): LeaseFace {
57
- const settings = (ctx as unknown as { settings?: LeaseCarrier }).settings
58
- if (settings === undefined || typeof settings.register !== 'function') {
59
- return { get: () => undefined, update: async () => false }
60
- }
61
- const owner: SettingsOwner = { settings }
62
- let shared = settings[SHARED_LEASE]
63
- if (shared === undefined) {
64
- shared = { owners: new Set(), registrationOwner: owner }
65
- Object.defineProperty(settings, SHARED_LEASE, {
66
- configurable: true,
67
- enumerable: false,
68
- writable: false,
69
- value: shared,
70
- })
71
- }
72
- shared.owners.add(owner)
73
- const state = shared
74
-
75
- ctx.effect(() => () => {
76
- state.owners.delete(owner)
77
- if (state.registrationOwner === owner && state.owners.size > 0) {
78
- const next = state.owners.values().next().value as SettingsOwner
79
- state.registrationOwner = next
80
- next.settings.register!(namespace, schema)
81
- }
82
- if (state.owners.size === 0 && settings[SHARED_LEASE] === state) {
83
- Reflect.deleteProperty(settings, SHARED_LEASE)
84
- }
85
- }, 'contextCompressionSelector.settingsLease()')
86
-
87
- if (state.owners.size === 1) {
88
- settings.register(namespace, schema)
89
- }
90
-
91
- return {
92
- get: () => {
93
- try {
94
- return settings.get?.(namespace)
95
- } catch {
96
- return undefined
97
- }
98
- },
99
- update: async (patch) => {
100
- try {
101
- await settings.update?.(namespace, patch)
102
- return true
103
- } catch {
104
- return false
105
- }
106
- },
107
- }
108
- }
@@ -1,91 +0,0 @@
1
- /**
2
- * Tool-result envelope adapter (audit N2: three-axis relocation, not a
3
- * single-axis unwrap) + legacy message-source kind escape (audit B6).
4
- *
5
- * Three-axis mapping, main's own comment as evidence
6
- * (pruner/session.ts: "0.1.7-rc.2: isError moved from the result block onto
7
- * the message itself"):
8
- *
9
- * semantics Gen D (0.1.7-rc.2+ / 0.2.0) Gen A/B/C (0.1.0–0.1.5)
10
- * content blocks message.content message.content[0].content
11
- * error location message.isError message.content[0].isError
12
- * call id message.toolCallId message.source.callId
13
- *
14
- * Every consumer must take the whole triple from viewToolResult(); touching
15
- * a single axis inline is how the isError/callId axes get silently dropped.
16
- * A strict legacy signature overrides the generation flag per message (the
17
- * 0.1.7-rc.1 envelope shape was only load-verified, not session-verified —
18
- * this makes a wrong flag self-correcting instead of silently misreading).
19
- */
20
- import { hostGenerationSnapshot, type HostGeneration } from './host-generation.ts'
21
-
22
- /** Strict signature of the enveloped (0.1.x) tool/result message. */
23
- function envelopedShape(content: unknown): content is [{ type: 'tool-result'; content: unknown[]; isError?: boolean }] {
24
- return Array.isArray(content)
25
- && content.length === 1
26
- && typeof content[0] === 'object'
27
- && content[0] !== null
28
- && (content[0] as { type?: unknown }).type === 'tool-result'
29
- && Array.isArray((content[0] as { content?: unknown }).content)
30
- }
31
-
32
- export interface ToolResultView {
33
- blocks: unknown[]
34
- isError: boolean
35
- callId: string | undefined
36
- }
37
-
38
- export function viewToolResult(
39
- message: { content?: unknown; isError?: unknown; toolCallId?: unknown; source?: { callId?: unknown } },
40
- generation?: HostGeneration,
41
- ): ToolResultView {
42
- const gen = generation ?? hostGenerationSnapshot()
43
- const content = message.content
44
- if (envelopedShape(content)) {
45
- const wrapper = content[0]
46
- return {
47
- blocks: wrapper.content,
48
- isError: wrapper.isError === true,
49
- callId: typeof message.source?.callId === 'string' ? message.source.callId : undefined,
50
- }
51
- }
52
- if (gen === 'legacy') {
53
- // Flagged legacy without the strict signature: still prefer the
54
- // legacy axes over misreading a flat message as an empty block set.
55
- const wrapper = Array.isArray(content) ? content[0] as { content?: unknown[]; isError?: boolean } | undefined : undefined
56
- if (wrapper && typeof wrapper === 'object' && Array.isArray(wrapper.content)) {
57
- return {
58
- blocks: wrapper.content,
59
- isError: wrapper.isError === true,
60
- callId: typeof message.source?.callId === 'string' ? message.source.callId : undefined,
61
- }
62
- }
63
- }
64
- return {
65
- blocks: Array.isArray(content) ? content : [],
66
- isError: message.isError === true,
67
- callId: typeof message.toolCallId === 'string'
68
- ? message.toolCallId
69
- : gen === 'legacy' && typeof message.source?.callId === 'string'
70
- ? message.source.callId
71
- : undefined,
72
- }
73
- }
74
-
75
- /**
76
- * Per-producer source kind, generation-gated. Modern hosts accept the
77
- * producer-declared kind (declared in pruner.ts's `MessageSourceMap`
78
- * augmentation); 0.1.x hosts only know the shared `{ kind: 'plugin' }` kind
79
- * — the dev bed's dsh-llm@0.2.0-rc.1 type face has no such member (audit B6,
80
- * empirically confirmed), so the legacy object escapes through `as never`
81
- * HERE and nowhere else.
82
- */
83
- const PLUGIN_ID = 'dsh-context-compression-improved'
84
-
85
- export function compressionMessageSource(generation?: HostGeneration): { kind: string; plugin?: string } {
86
- const gen = generation ?? hostGenerationSnapshot()
87
- if (gen === 'legacy') {
88
- return { kind: 'plugin', plugin: PLUGIN_ID } as never
89
- }
90
- return { kind: 'dsh-context-compression' }
91
- }
@@ -1,6 +0,0 @@
1
- declare module '*.module.css' {
2
- const classes: Record<string, string>
3
- export default classes
4
- }
5
-
6
- declare module '*.css'
@@ -1,205 +0,0 @@
1
- /** Offline DeepSeek tokenizers backed by pinned official Hugging Face assets. */
2
-
3
- import { createHash } from 'node:crypto'
4
- import { readFileSync } from 'node:fs'
5
- import { Tokenizer } from '@huggingface/tokenizers'
6
- import type { ExactTokenizerTokenCount } from './runtime/token-count.ts'
7
-
8
- const TOKENIZER_ID = 'deepseek-ai/DeepSeek-V4-Pro'
9
- const TOKENIZER_REVISION = '0e1a0e5e52aea73055f50fef6f2423db370265b6'
10
- const TOKENIZER_SHA256 = '8f9f37ca37fdc4f5fd36d5cf4d3b0e8392edb4e894fd10cc0d70b4957c8633cf'
11
- const CONFIG_SHA256 = '6ac8c8dc065ed118161d02dd532749ae3f52c243deac27872134fae2f50d8547'
12
- const VISION_TOKENIZER_ID = 'deepseek-ai/DeepSeek-V4-Flash-Vision-Exp'
13
- const VISION_TOKENIZER_REVISION = '6821d6ad3681a4b137b066b76094fa82ebd0a380'
14
- const VISION_TOKENIZER_SHA256 = 'c90dfa01249db1be4245780a052ede752e1361c612ac6d08e2bdada7d599476b'
15
- const VISION_CONFIG_SHA256 = '6ac8c8dc065ed118161d02dd532749ae3f52c243deac27872134fae2f50d8547'
16
-
17
- /** Auditable origin and compatibility mapping for one bundled tokenizer. */
18
- export interface DeepSeekTokenizerArtifactOrigin {
19
- /** Hugging Face repository the assets were pinned from. */
20
- readonly repository: string
21
- /** Immutable commit revision the assets were pinned from. */
22
- readonly revision: string
23
- /** Upstream license of the repository. */
24
- readonly license: string
25
- /** Exact API wire model ids served by this artifact. */
26
- readonly modelIds: readonly string[]
27
- readonly tokenizerSha256: string
28
- readonly tokenizerConfigSha256: string
29
- }
30
-
31
- /** Auditable origin and compatibility mapping for the bundled V4 Pro tokenizer. */
32
- export const DEEPSEEK_V4_TOKENIZER_ARTIFACT: DeepSeekTokenizerArtifactOrigin = Object.freeze({
33
- repository: TOKENIZER_ID,
34
- revision: TOKENIZER_REVISION,
35
- license: 'MIT',
36
- tokenizerSha256: TOKENIZER_SHA256,
37
- tokenizerConfigSha256: CONFIG_SHA256,
38
- modelIds: Object.freeze(['deepseek-v4-flash', 'deepseek-v4-pro']),
39
- })
40
-
41
- /**
42
- * Auditable origin and compatibility mapping for the bundled V4 Flash Vision
43
- * tokenizer. The vision repository ships a distinct `tokenizer.json` (it adds
44
- * the `<|deepseek_image|>` special token), so the vision model must never be
45
- * mapped onto the V4 Pro tokenizer as an alias.
46
- */
47
- export const DEEPSEEK_VISION_TOKENIZER_ARTIFACT: DeepSeekTokenizerArtifactOrigin = Object.freeze({
48
- repository: VISION_TOKENIZER_ID,
49
- revision: VISION_TOKENIZER_REVISION,
50
- license: 'MIT',
51
- tokenizerSha256: VISION_TOKENIZER_SHA256,
52
- tokenizerConfigSha256: VISION_CONFIG_SHA256,
53
- modelIds: Object.freeze(['deepseek-v4-flash-vision-exp']),
54
- })
55
-
56
- /** Synchronous exact counter backed only by the verified local V4 artifacts. */
57
- export interface DeepSeekV4TextTokenizer {
58
- /** Count one fully determined text value with the official tokenizer. */
59
- countText(text: string): ExactTokenizerTokenCount
60
- }
61
-
62
- /** Integrity tuple for one tokenizer JSON asset. @internal */
63
- export interface DeepSeekV4TokenizerAssetDescriptor {
64
- readonly bytes: number
65
- readonly sha256: string
66
- }
67
-
68
- /** Injectable integrity manifest used by negative loader tests. @internal */
69
- export interface DeepSeekV4TokenizerAssetIntegrity {
70
- readonly tokenizer: DeepSeekV4TokenizerAssetDescriptor
71
- readonly config: DeepSeekV4TokenizerAssetDescriptor
72
- }
73
-
74
- interface TokenizerArtifact {
75
- readonly origin: DeepSeekTokenizerArtifactOrigin
76
- readonly assetRoot: URL
77
- readonly integrity: DeepSeekV4TokenizerAssetIntegrity
78
- }
79
-
80
- /**
81
- * Every bundled artifact is registered with independent asset roots, integrity
82
- * manifests, and cache entries: one corrupted artifact must never disable the
83
- * tokenizer serving the other model family.
84
- */
85
- const ARTIFACTS: readonly TokenizerArtifact[] = Object.freeze([
86
- Object.freeze({
87
- origin: DEEPSEEK_V4_TOKENIZER_ARTIFACT,
88
- assetRoot: new URL('../assets/deepseek-v4/', import.meta.url),
89
- integrity: Object.freeze({
90
- tokenizer: Object.freeze({ bytes: 6_367_146, sha256: TOKENIZER_SHA256 }),
91
- config: Object.freeze({ bytes: 801, sha256: CONFIG_SHA256 }),
92
- }),
93
- }),
94
- Object.freeze({
95
- origin: DEEPSEEK_VISION_TOKENIZER_ARTIFACT,
96
- assetRoot: new URL('../assets/deepseek-v4-vision-exp/', import.meta.url),
97
- integrity: Object.freeze({
98
- tokenizer: Object.freeze({ bytes: 6_367_257, sha256: VISION_TOKENIZER_SHA256 }),
99
- config: Object.freeze({ bytes: 801, sha256: VISION_CONFIG_SHA256 }),
100
- }),
101
- }),
102
- ])
103
-
104
- interface ArtifactCacheEntry {
105
- readonly tokenizer?: DeepSeekV4TextTokenizer
106
- readonly failure?: string
107
- }
108
-
109
- const registryCache = new Map<DeepSeekTokenizerArtifactOrigin, ArtifactCacheEntry>()
110
-
111
- function artifactForModel(modelId: string): TokenizerArtifact | undefined {
112
- return ARTIFACTS.find(artifact => (artifact.origin.modelIds as readonly string[]).includes(modelId))
113
- }
114
-
115
- /**
116
- * Resolve the shared offline tokenizer for one compatible API model.
117
- * Unknown models and a cached asset/runtime failure return `undefined`; callers
118
- * must report unavailable instead of manufacturing a character estimate.
119
- * @param modelId - exact DeepSeek API wire model id.
120
- * @returns the shared verified tokenizer, or undefined when unsupported/unavailable.
121
- */
122
- export function deepSeekV4TokenizerForModel(modelId: string): DeepSeekV4TextTokenizer | undefined {
123
- const artifact = artifactForModel(modelId)
124
- if (artifact === undefined) return undefined
125
- const cached = registryCache.get(artifact.origin)
126
- if (cached !== undefined) return cached.tokenizer
127
- let entry: ArtifactCacheEntry
128
- try {
129
- const tokenizer = createDeepSeekV4TokenizerFromAssets(artifact.assetRoot, artifact.integrity, artifact.origin)
130
- entry = { tokenizer }
131
- } catch (error: unknown) {
132
- entry = { failure: error instanceof Error ? error.message : String(error) }
133
- }
134
- registryCache.set(artifact.origin, entry)
135
- return entry.tokenizer
136
- }
137
-
138
- /**
139
- * Read the cached initialization diagnostic for provider registration.
140
- * @param modelId - optional exact model id; defaults to the V4 Pro artifact.
141
- * @returns the first initialization failure for that artifact, or undefined.
142
- */
143
- export function deepSeekV4TokenizerFailureReason(modelId?: string): string | undefined {
144
- const artifact = modelId === undefined ? ARTIFACTS[0] : artifactForModel(modelId)
145
- if (artifact === undefined) return undefined
146
- return registryCache.get(artifact.origin)?.failure
147
- }
148
-
149
- /** Complete pinned artifact inventory, in stable registration order. */
150
- export function deepSeekTokenizerArtifacts(): readonly DeepSeekTokenizerArtifactOrigin[] {
151
- return ARTIFACTS.map(artifact => artifact.origin)
152
- }
153
-
154
- /**
155
- * Build a tokenizer from one local asset directory after byte/hash validation.
156
- * This provider-private seam exists so tests can prove every failure branch
157
- * without mutating the committed artifact.
158
- * @param assetRoot - local URL containing tokenizer.json and tokenizer_config.json.
159
- * @param integrity - expected byte length and SHA-256 for both files.
160
- * @param origin - auditable identity recorded on every returned count.
161
- * @returns a synchronous exact text counter.
162
- * @internal
163
- */
164
- export function createDeepSeekV4TokenizerFromAssets(
165
- assetRoot: URL,
166
- integrity: DeepSeekV4TokenizerAssetIntegrity,
167
- origin: DeepSeekTokenizerArtifactOrigin = DEEPSEEK_V4_TOKENIZER_ARTIFACT,
168
- ): DeepSeekV4TextTokenizer {
169
- const tokenizerJson = readVerifiedJson(assetRoot, 'tokenizer.json', integrity.tokenizer)
170
- const tokenizerConfig = readVerifiedJson(assetRoot, 'tokenizer_config.json', integrity.config)
171
- const runtime = new Tokenizer(tokenizerJson, tokenizerConfig)
172
- return Object.freeze({
173
- countText(text: string): ExactTokenizerTokenCount {
174
- const tokens = runtime.encode(text, { add_special_tokens: false }).ids.length
175
- return Object.freeze({
176
- kind: 'exact-tokenizer',
177
- tokens,
178
- tokenizerId: origin.repository,
179
- tokenizerRevision: origin.revision,
180
- })
181
- },
182
- })
183
- }
184
-
185
- function readVerifiedJson(
186
- assetRoot: URL,
187
- name: string,
188
- descriptor: DeepSeekV4TokenizerAssetDescriptor,
189
- ): Record<string, unknown> {
190
- const bytes = readFileSync(new URL(name, assetRoot))
191
- if (bytes.byteLength !== descriptor.bytes) {
192
- throw new Error(
193
- `DeepSeek tokenizer asset ${name} has ${String(bytes.byteLength)} bytes; expected ${String(descriptor.bytes)}`,
194
- )
195
- }
196
- const actualSha256 = createHash('sha256').update(bytes).digest('hex')
197
- if (actualSha256 !== descriptor.sha256) {
198
- throw new Error(`DeepSeek tokenizer asset ${name} failed SHA-256 verification`)
199
- }
200
- const parsed: unknown = JSON.parse(bytes.toString('utf8'))
201
- if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
202
- throw new Error(`DeepSeek tokenizer asset ${name} must contain a JSON object`)
203
- }
204
- return parsed as Record<string, unknown>
205
- }
@@ -1,104 +0,0 @@
1
- /**
2
- * Estimator model-catalog projection for the settings card: the live
3
- * provider/model-group catalog from the DSH `llm` service — including
4
- * user-configured custom groups — plus the effective host selection
5
- * (override → agentDefaultModel.currentSelection). The same projection seam
6
- * dsh-perm-gate's receiver-info and dsh-prime-memory's llm-providers view use.
7
- *
8
- * Pure projection: never throws; per-provider failures are reported inline so
9
- * one broken group never blanks the whole list.
10
- */
11
-
12
- /** One model entry as offered by a provider group. */
13
- export interface CatalogModel {
14
- readonly id: string
15
- readonly name: string
16
- }
17
-
18
- /** One provider group and its models (or the reason it failed to enumerate). */
19
- export interface CatalogProvider {
20
- readonly id: string
21
- readonly name: string
22
- readonly models: readonly CatalogModel[]
23
- readonly error?: string
24
- }
25
-
26
- /** What the settings card needs to render the host-route dropdowns. */
27
- export interface EstimatorCatalog {
28
- /** Live provider groups; empty when the `llm` service is unavailable. */
29
- readonly providers: readonly CatalogProvider[]
30
- /** The provider/model the host channel would use right now (undefined when undetermined). */
31
- readonly selection?: { readonly provider: string, readonly model: string }
32
- }
33
-
34
- /** The minimal faces of the host services this projection reads. */
35
- export interface EstimatorCatalogDeps {
36
- llm?: {
37
- listProviders?: () => readonly { id: string, name: string }[]
38
- listModels?: (providerId: string) => Promise<readonly { id: string, name: string }[]>
39
- /** Fallback enumeration source for builds whose `listModels` is absent or dormant. */
40
- listConfigurableProviders?: () => readonly { provider: string, settingsNs: string }[]
41
- /** Discovery for a configured route answers from the adapter's own knowledge — no network call. */
42
- discoverModels?: (settingsNs: string, request: { provider?: string }) => Promise<readonly { id: string, name?: string }[]>
43
- }
44
- /** Live default-model selection (optional `agentDefaultModel` service). */
45
- currentSelection?: () => { provider?: unknown, model?: unknown } | undefined
46
- /** Explicit estimator overrides (empty string = follow the host selection). */
47
- overrideProvider?: string
48
- overrideModel?: string
49
- }
50
-
51
- function str(value: unknown): string {
52
- return typeof value === 'string' ? value : ''
53
- }
54
-
55
- /** Resolve the effective host model route (override → session default). */
56
- export function resolveHostRoute(deps: EstimatorCatalogDeps): { provider: string, model: string } | undefined {
57
- const overrideProvider = str(deps.overrideProvider)
58
- const overrideModel = str(deps.overrideModel)
59
- const selected = deps.currentSelection?.()
60
- const selectedProvider = str(selected?.provider)
61
- const selectedModel = str(selected?.model)
62
- const provider = overrideProvider !== '' ? overrideProvider : selectedProvider
63
- const model = overrideModel !== '' ? overrideModel : selectedModel
64
- if (provider === '' || model === '') return undefined
65
- return { provider, model }
66
- }
67
-
68
- /** Build the catalog projection. Never throws. */
69
- export async function buildEstimatorCatalog(deps: EstimatorCatalogDeps): Promise<EstimatorCatalog> {
70
- if (deps.llm?.listProviders === undefined) {
71
- const selection = resolveHostRoute(deps)
72
- return selection === undefined ? { providers: [] } : { providers: [], selection }
73
- }
74
- const selection = resolveHostRoute(deps)
75
- const raw = deps.llm.listProviders()
76
- const providers = await Promise.all(raw.map(async (p): Promise<CatalogProvider> => {
77
- let models: CatalogModel[] = []
78
- let error: string | undefined
79
- try {
80
- models = (await deps.llm?.listModels?.(p.id) ?? []).map(m => ({ id: m.id, name: m.name }))
81
- } catch (e) {
82
- error = String((e as Error)?.message ?? e)
83
- }
84
- if (models.length === 0) {
85
- // Fallback: route discovery. For an already-configured route the
86
- // adapter answers from its own stored knowledge (no network call).
87
- try {
88
- const entry = deps.llm?.listConfigurableProviders?.().find(c => c.provider === p.id)
89
- if (entry !== undefined && deps.llm?.discoverModels !== undefined) {
90
- const discovered = await deps.llm.discoverModels(entry.settingsNs, { provider: p.id })
91
- if (discovered.length > 0) {
92
- models = discovered.map(m => ({ id: m.id, name: m.name ?? m.id }))
93
- error = undefined
94
- }
95
- }
96
- } catch {
97
- // keep the primary error / empty state
98
- }
99
- }
100
- if (models.length === 0 && error === undefined) error = 'no models advertised'
101
- return { id: p.id, name: p.name, models, ...(error === undefined ? {} : { error }) }
102
- }))
103
- return { providers, ...(selection === undefined ? {} : { selection }) }
104
- }