dsh-compact-pi 0.0.0-stage → 0.2.3-b2

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 (277) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/LICENSE +25 -0
  3. package/README.md +167 -2
  4. package/bin/dcp-session.ts +36 -0
  5. package/bin/dcp.ts +39 -0
  6. package/dist/codec.mjs +30315 -0
  7. package/dist/dcp-session.mjs +30682 -0
  8. package/dist/dcp.mjs +30062 -0
  9. package/dist/index.js +36377 -0
  10. package/docs/compatibility.md +35 -0
  11. package/docs/help.md +34 -0
  12. package/docs/native-session-codec.md +31 -0
  13. package/docs/publishing.md +49 -0
  14. package/docs/testing.md +23 -0
  15. package/docs/upstream-update.md +22 -0
  16. package/package.json +95 -4
  17. package/scripts/build-vendor.mjs +20 -0
  18. package/scripts/check-vendor.mjs +60 -0
  19. package/scripts/dsh-vendor-lib.mjs +197 -0
  20. package/scripts/patch-pi.mjs +126 -0
  21. package/scripts/smoke-package.mjs +179 -0
  22. package/scripts/test-resume.mjs +219 -0
  23. package/scripts/vendor-dsh.mjs +134 -0
  24. package/src/bridge.ts +753 -0
  25. package/src/codec.ts +227 -0
  26. package/src/compaction-info.ts +135 -0
  27. package/src/config.ts +80 -0
  28. package/src/dsh/capabilities.ts +55 -0
  29. package/src/dsh/convert.ts +197 -0
  30. package/src/dsh/engine.ts +173 -0
  31. package/src/dsh/images.ts +231 -0
  32. package/src/dsh/llm.ts +144 -0
  33. package/src/dsh/messages.ts +201 -0
  34. package/src/dsh/meter.ts +9 -0
  35. package/src/dsh/projection.ts +36 -0
  36. package/src/dsh/range.ts +2 -0
  37. package/src/dsh/session.ts +79 -0
  38. package/src/dsh/store.ts +123 -0
  39. package/src/dsh/sync.ts +308 -0
  40. package/src/index.ts +186 -0
  41. package/test/bridge.test.ts +159 -0
  42. package/test/cancellation.test.ts +120 -0
  43. package/test/codec.test.ts +127 -0
  44. package/test/compaction-info.test.ts +143 -0
  45. package/test/config.test.ts +106 -0
  46. package/test/convert.test.ts +78 -0
  47. package/test/differential.test.ts +706 -0
  48. package/test/host.test.ts +672 -0
  49. package/test/images-convert.test.ts +116 -0
  50. package/test/images.test.ts +571 -0
  51. package/test/integration.test.ts +407 -0
  52. package/test/pruner.test.ts +84 -0
  53. package/test/vendor.test.ts +25 -0
  54. package/tsconfig.json +21 -0
  55. package/vendor/LICENSE-DeepSeek +21 -0
  56. package/vendor/LICENSE-pi +21 -0
  57. package/vendor/THIRD-PARTY-NOTICES +94 -0
  58. package/vendor/dsh-runtime.d.mts +189 -0
  59. package/vendor/dsh-runtime.mjs +31001 -0
  60. package/vendor/dsh-source/dependencies/zod@4.6.6/index.js +7 -0
  61. package/vendor/dsh-source/dependencies/zod@4.6.6/package.json +147 -0
  62. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/classic/checks.js +1 -0
  63. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/classic/coerce.js +17 -0
  64. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/classic/compat.js +31 -0
  65. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/classic/deep-partial.js +13 -0
  66. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/classic/errors.js +57 -0
  67. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/classic/external.js +17 -0
  68. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/classic/from-json-schema.js +881 -0
  69. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/classic/in-out.js +36 -0
  70. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/classic/iso.js +15 -0
  71. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/classic/parse.js +16 -0
  72. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/classic/schemas.js +1535 -0
  73. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/core/api.js +1107 -0
  74. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/core/checks.js +516 -0
  75. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/core/compile.js +1866 -0
  76. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/core/core.js +141 -0
  77. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/core/doc.js +38 -0
  78. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/core/errors.js +267 -0
  79. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/core/index.js +19 -0
  80. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/core/json-schema-generator.js +99 -0
  81. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/core/json-schema-processors.js +843 -0
  82. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/core/json-schema.js +1 -0
  83. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/core/memoizer.js +311 -0
  84. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/core/parse.js +175 -0
  85. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/core/regexes.js +156 -0
  86. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/core/registries.js +51 -0
  87. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/core/schemas.js +2636 -0
  88. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/core/to-json-schema.js +651 -0
  89. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/core/util.js +873 -0
  90. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/core/versions.js +5 -0
  91. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/core/visit.js +169 -0
  92. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/ar.js +111 -0
  93. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/az.js +110 -0
  94. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/be.js +168 -0
  95. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/bg.js +125 -0
  96. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/bn.js +113 -0
  97. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/ca.js +112 -0
  98. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/ckb.js +133 -0
  99. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/cs.js +116 -0
  100. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/da.js +120 -0
  101. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/de.js +113 -0
  102. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/el.js +112 -0
  103. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/en.js +125 -0
  104. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/eo.js +114 -0
  105. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/es.js +136 -0
  106. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/fa.js +119 -0
  107. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/fi.js +117 -0
  108. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/fr-CA.js +112 -0
  109. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/fr.js +129 -0
  110. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/gu.js +113 -0
  111. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/he.js +221 -0
  112. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/hi.js +111 -0
  113. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/hr.js +126 -0
  114. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/hu.js +113 -0
  115. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/hy.js +158 -0
  116. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/id.js +111 -0
  117. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/index.js +63 -0
  118. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/is.js +114 -0
  119. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/it.js +113 -0
  120. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/ja.js +112 -0
  121. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/ka.js +117 -0
  122. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/kh.js +5 -0
  123. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/km.js +115 -0
  124. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/kn.js +116 -0
  125. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/ko.js +116 -0
  126. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/lt.js +207 -0
  127. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/mk.js +114 -0
  128. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/ms.js +112 -0
  129. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/ne.js +111 -0
  130. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/nl.js +115 -0
  131. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/nn.js +113 -0
  132. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/no.js +113 -0
  133. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/ota.js +114 -0
  134. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/pl.js +114 -0
  135. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/ps.js +119 -0
  136. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/pt-BR.js +143 -0
  137. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/pt.js +142 -0
  138. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/ro.js +122 -0
  139. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/ru.js +168 -0
  140. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/sk.js +116 -0
  141. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/sl.js +114 -0
  142. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/sv.js +115 -0
  143. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/ta.js +115 -0
  144. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/tg.js +117 -0
  145. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/th.js +115 -0
  146. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/tk.js +107 -0
  147. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/tr.js +110 -0
  148. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/ua.js +5 -0
  149. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/uk.js +113 -0
  150. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/ur.js +115 -0
  151. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/uz.js +113 -0
  152. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/vi.js +113 -0
  153. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/yo.js +112 -0
  154. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/zh-CN.js +114 -0
  155. package/vendor/dsh-source/dependencies/zod@4.6.6/v4/locales/zh-TW.js +112 -0
  156. package/vendor/dsh-source/packages/attachment/attachment/package.json +33 -0
  157. package/vendor/dsh-source/packages/attachment/attachment/src/admission.ts +74 -0
  158. package/vendor/dsh-source/packages/attachment/attachment/src/brand.ts +27 -0
  159. package/vendor/dsh-source/packages/attachment/attachment/src/error.ts +86 -0
  160. package/vendor/dsh-source/packages/attachment/attachment/src/index.ts +293 -0
  161. package/vendor/dsh-source/packages/attachment/attachment/src/request-projection.ts +66 -0
  162. package/vendor/dsh-source/packages/attachment/attachment-local/package.json +50 -0
  163. package/vendor/dsh-source/packages/attachment/attachment-local/src/compression-limiter.ts +52 -0
  164. package/vendor/dsh-source/packages/attachment/attachment-local/src/encoding.ts +83 -0
  165. package/vendor/dsh-source/packages/attachment/attachment-local/src/file-store.ts +183 -0
  166. package/vendor/dsh-source/packages/attachment/attachment-local/src/image.ts +133 -0
  167. package/vendor/dsh-source/packages/attachment/attachment-local/src/index.ts +317 -0
  168. package/vendor/dsh-source/packages/attachment/attachment-local/src/normalization.ts +137 -0
  169. package/vendor/dsh-source/packages/attachment/attachment-local/src/request-image.ts +253 -0
  170. package/vendor/dsh-source/packages/attachment/attachment-local/src/sharp.ts +7 -0
  171. package/vendor/dsh-source/packages/attachment/attachment-local/src/store.ts +457 -0
  172. package/vendor/dsh-source/packages/compaction/compaction/package.json +54 -0
  173. package/vendor/dsh-source/packages/compaction/compaction/src/brand.ts +13 -0
  174. package/vendor/dsh-source/packages/compaction/compaction/src/checkpoint.ts +50 -0
  175. package/vendor/dsh-source/packages/compaction/compaction/src/index.ts +196 -0
  176. package/vendor/dsh-source/packages/compaction/compaction/src/tool-pairing.ts +126 -0
  177. package/vendor/dsh-source/packages/compaction/compaction-basic/package.json +75 -0
  178. package/vendor/dsh-source/packages/compaction/compaction-basic/src/answered-route.ts +27 -0
  179. package/vendor/dsh-source/packages/compaction/compaction-basic/src/config.ts +362 -0
  180. package/vendor/dsh-source/packages/compaction/compaction-basic/src/index.ts +494 -0
  181. package/vendor/dsh-source/packages/compaction/compaction-basic/src/region.ts +606 -0
  182. package/vendor/dsh-source/packages/compaction/compaction-basic/src/summarizer.ts +219 -0
  183. package/vendor/dsh-source/packages/compaction/compaction-image-offload/package.json +63 -0
  184. package/vendor/dsh-source/packages/compaction/compaction-image-offload/src/image-offload.ts +46 -0
  185. package/vendor/dsh-source/packages/compaction/compaction-image-offload/src/index.ts +41 -0
  186. package/vendor/dsh-source/packages/compaction/compaction-image-offload/src/project-message.ts +36 -0
  187. package/vendor/dsh-source/packages/compaction/compaction-image-offload/src/projection.ts +74 -0
  188. package/vendor/dsh-source/packages/compaction/compaction-tool-result-pruner/package.json +57 -0
  189. package/vendor/dsh-source/packages/compaction/compaction-tool-result-pruner/src/config.ts +77 -0
  190. package/vendor/dsh-source/packages/compaction/compaction-tool-result-pruner/src/index.ts +185 -0
  191. package/vendor/dsh-source/packages/core/scope/package.json +38 -0
  192. package/vendor/dsh-source/packages/core/scope/src/index.ts +204 -0
  193. package/vendor/dsh-source/packages/core/scope/src/store.ts +267 -0
  194. package/vendor/dsh-source/packages/core/session/package.json +62 -0
  195. package/vendor/dsh-source/packages/core/session/src/fork-error.ts +22 -0
  196. package/vendor/dsh-source/packages/core/session/src/fork.ts +30 -0
  197. package/vendor/dsh-source/packages/core/session/src/index.ts +1221 -0
  198. package/vendor/dsh-source/packages/core/session/src/known-event-types.ts +93 -0
  199. package/vendor/dsh-source/packages/core/session/src/preparation.ts +49 -0
  200. package/vendor/dsh-source/packages/core/session/src/repair.ts +211 -0
  201. package/vendor/dsh-source/packages/core/session/src/request-header.ts +69 -0
  202. package/vendor/dsh-source/packages/core/session/src/seq-ranges.ts +73 -0
  203. package/vendor/dsh-source/packages/core/session/src/surface.ts +777 -0
  204. package/vendor/dsh-source/packages/core/session/src/tool-history.ts +75 -0
  205. package/vendor/dsh-source/packages/core/session/src/types.ts +581 -0
  206. package/vendor/dsh-source/packages/core/session/src/validation.ts +570 -0
  207. package/vendor/dsh-source/packages/llm/llm/package.json +79 -0
  208. package/vendor/dsh-source/packages/llm/llm/src/adapter-failure.ts +109 -0
  209. package/vendor/dsh-source/packages/llm/llm/src/assembler.ts +208 -0
  210. package/vendor/dsh-source/packages/llm/llm/src/assistant-stream.ts +533 -0
  211. package/vendor/dsh-source/packages/llm/llm/src/attribution.ts +90 -0
  212. package/vendor/dsh-source/packages/llm/llm/src/brand.ts +76 -0
  213. package/vendor/dsh-source/packages/llm/llm/src/call-config.ts +95 -0
  214. package/vendor/dsh-source/packages/llm/llm/src/content.ts +437 -0
  215. package/vendor/dsh-source/packages/llm/llm/src/error.ts +233 -0
  216. package/vendor/dsh-source/packages/llm/llm/src/index.ts +1204 -0
  217. package/vendor/dsh-source/packages/llm/llm/src/message.ts +350 -0
  218. package/vendor/dsh-source/packages/llm/llm/src/request-images.ts +112 -0
  219. package/vendor/dsh-source/packages/llm/llm/src/retry-policy.ts +201 -0
  220. package/vendor/dsh-source/packages/llm/token-meter/package.json +67 -0
  221. package/vendor/dsh-source/packages/llm/token-meter/src/breakdown-projection.ts +184 -0
  222. package/vendor/dsh-source/packages/llm/token-meter/src/estimate.ts +104 -0
  223. package/vendor/dsh-source/packages/llm/token-meter/src/index.ts +296 -0
  224. package/vendor/dsh-source/packages/llm/token-meter/src/measurement-projection.ts +100 -0
  225. package/vendor/dsh-source/packages/llm/token-meter/src/route-pricing.ts +76 -0
  226. package/vendor/dsh-source/packages/llm/token-meter/src/surface-fold.ts +142 -0
  227. package/vendor/dsh-source/packages/llm/token-meter/src/surface-projection.ts +96 -0
  228. package/vendor/dsh-source/packages/llm/token-meter/src/usage-projection.ts +213 -0
  229. package/vendor/dsh-source/packages/session/session-projection/package.json +53 -0
  230. package/vendor/dsh-source/packages/session/session-projection/src/index.ts +958 -0
  231. package/vendor/dsh-source/packages/typert/protocol/package.json +53 -0
  232. package/vendor/dsh-source/packages/typert/protocol/src/index.ts +488 -0
  233. package/vendor/dsh-source/packages/typert/protocol/src/json-value.ts +53 -0
  234. package/vendor/dsh-source/packages/typert/protocol/src/owned-value.ts +39 -0
  235. package/vendor/dsh-source/packages/typert/protocol/src/principal.ts +17 -0
  236. package/vendor/dsh-source/packages/typert/protocol/src/remote-error.ts +51 -0
  237. package/vendor/dsh-source/packages/typert/protocol/src/remote-info.ts +161 -0
  238. package/vendor/dsh-source/packages/util/brand/package.json +38 -0
  239. package/vendor/dsh-source/packages/util/brand/src/index.ts +39 -0
  240. package/vendor/dsh-source/packages/util/crypto/package.json +38 -0
  241. package/vendor/dsh-source/packages/util/crypto/src/index.ts +41 -0
  242. package/vendor/dsh-source/packages/util/error/package.json +38 -0
  243. package/vendor/dsh-source/packages/util/error/src/index.ts +22 -0
  244. package/vendor/dsh-source/packages/util/home-paths/package.json +38 -0
  245. package/vendor/dsh-source/packages/util/home-paths/src/index.ts +238 -0
  246. package/vendor/dsh-source/packages/util/lazy-require/package.json +38 -0
  247. package/vendor/dsh-source/packages/util/lazy-require/src/index.ts +24 -0
  248. package/vendor/dsh-source/packages/util/timeout/package.json +38 -0
  249. package/vendor/dsh-source/packages/util/timeout/src/index.ts +212 -0
  250. package/vendor/dsh-source/packages/util/values/package.json +38 -0
  251. package/vendor/dsh-source/packages/util/values/src/index.ts +293 -0
  252. package/vendor/dsh-source/packages/util/values/src/partial-json.ts +666 -0
  253. package/vendor/dsh-source/vendor/cordis/package.json +51 -0
  254. package/vendor/dsh-source/vendor/cordis/src/context.ts +152 -0
  255. package/vendor/dsh-source/vendor/cordis/src/events.ts +375 -0
  256. package/vendor/dsh-source/vendor/cordis/src/fiber.ts +842 -0
  257. package/vendor/dsh-source/vendor/cordis/src/index.ts +16 -0
  258. package/vendor/dsh-source/vendor/cordis/src/logger.ts +263 -0
  259. package/vendor/dsh-source/vendor/cordis/src/reflect.ts +458 -0
  260. package/vendor/dsh-source/vendor/cordis/src/registry.ts +337 -0
  261. package/vendor/dsh-source/vendor/cordis/src/service.ts +125 -0
  262. package/vendor/dsh-source/vendor/cordis/src/utils.ts +297 -0
  263. package/vendor/dsh-source/vendor/cosmokit/package.json +32 -0
  264. package/vendor/dsh-source/vendor/cosmokit/src/array.ts +42 -0
  265. package/vendor/dsh-source/vendor/cosmokit/src/index.ts +12 -0
  266. package/vendor/dsh-source/vendor/cosmokit/src/misc.ts +78 -0
  267. package/vendor/dsh-source/vendor/cosmokit/src/string.ts +113 -0
  268. package/vendor/dsh-source/vendor/cosmokit/src/time.ts +92 -0
  269. package/vendor/dsh-source/vendor/cosmokit/src/types.ts +168 -0
  270. package/vendor/dsh-source/vendor/cosmokit/src/volatile.ts +86 -0
  271. package/vendor/dsh-source/vendor/schemastery/package.json +39 -0
  272. package/vendor/dsh-source/vendor/schemastery/src/index.ts +962 -0
  273. package/vendor/manifest.json +3914 -0
  274. package/vendor/pi-messages.d.mts +3 -0
  275. package/vendor/pi-messages.mjs +123 -0
  276. package/vendor/pi-session-projection.d.mts +6 -0
  277. package/vendor/pi-session-projection.mjs +169 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,38 @@
1
+ # Changelog
2
+
3
+ ## [0.2.3-b2]
4
+
5
+ - Correct the lockfile integrity for `@aws/lambda-invoke-store@0.2.2` so a clean `npm ci` can install the development dependencies.
6
+ - Includes the summary model picker, bidirectional session migration, and pi compatibility tests introduced in 0.2.3b1.
7
+
8
+ ## [0.2.3-b1]
9
+
10
+ - Export the active pi branch and its effective compressed context to DSH. Keep the original pi entries for unchanged round trips and import the live DSH surface after a session continues there.
11
+ - Add `/dcp-summary-model` to choose or reset the project default summary model and show the setting in `/dcp-status`.
12
+ - Sync the unmodified DeepSeek Harness `0.2.3-alpha.2` source snapshot (`4b399c39`).
13
+ - Adapt pi image limits to the upstream attachment encoder's separate hard byte limit and preferred size. Both use the same pi limit or the existing 1 MiB default.
14
+ - Use the upstream summary route projection, which prefers the last model that answered when no summary model is configured.
15
+ - Match the upstream Node.js requirement: `^24.22.3 || >=26.13.1`.
16
+ - Add an automated pi 1.5.2 and 1.6.0 resume and migration matrix, along with CLI help and maintenance documentation.
17
+
18
+ ## [0.2.2-b3]
19
+
20
+ - Update the upstream DeepSeek Harness source snapshot to `0.2.2-rc.5` (`9c2670d3`), including shared error handling and session updates.
21
+ - Bundle the upstream-pinned Zod `4.6.6`. The existing pi adapter works with the new snapshot without source patches.
22
+
23
+ ## [0.2.2-b2]
24
+
25
+ - Fix Esc during an ordinary tool call being reported as a DCP extension error even when no compaction occurred. Pi can invoke the context hook with an already-aborted signal after a tool returns; DCP now skips maintenance in that hook.
26
+ - Handle cancellation during a running context transform without rethrowing it as an extension failure, while preserving committed context changes.
27
+ - Add real pi SDK regression tests for tool and summary cancellation, no automatic retry after cancellation, and a subsequent user request.
28
+ - Keep automatic compaction and continuation policy unchanged; the upstream source snapshot is unchanged.
29
+
30
+ ## [0.2.2-b1]
31
+
32
+ - Host the unmodified DeepSeek Harness compaction engine, token meter and tool-result pruner in Cordis through a pi extension.
33
+ - Support automatic, manual and overflow compaction, durable session checkpoints and branch-aware replay.
34
+ - Support user and tool-result images, upstream image offloading and attachment-aware session conversion.
35
+ - Add `/dcp-status`, `/dcp-compact` and Ctrl+O provenance and compaction statistics.
36
+ - Include the pinned upstream source closure and licenses; installation does not require a DeepSeek Harness checkout.
37
+
38
+ The displayed DCP version is `0.2.2b1`; the npm version is `0.2.2-b1`.
package/LICENSE ADDED
@@ -0,0 +1,25 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 dcp contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ Portions of this project import code from DeepSeek Harness, licensed under
24
+ MIT; see vendor/LICENSE-DeepSeek. Additional bundled dependencies retain their
25
+ respective licenses; see vendor/THIRD-PARTY-NOTICES and vendor/LICENSE-pi.
package/README.md CHANGED
@@ -1,3 +1,168 @@
1
- # Temporary Holding Version
1
+ # dsh-compact-pi (dcp)
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ An installable pi extension hosting **unmodified DeepSeek Harness compaction plugins in real Cordis**. DCP adapts a defined common subset of pi and DSH; its source updater copies upstream files without rewriting imports or patching the compression algorithm.
4
+
5
+ Tested with pi 1.5.2 and 1.6.0. Node.js must satisfy `^24.22.3 || >=26.13.1`. DCP **0.2.3b2** uses DeepSeek Harness **0.2.3-alpha.2**. `/dcp-status` shows both versions and the upstream commit recorded in [vendor/manifest.json](vendor/manifest.json). The Git tag and npm version use the SemVer spelling `0.2.3-b2`. The source snapshot is included in the package.
6
+
7
+ ## Install and use
8
+
9
+ ```bash
10
+ pi install git:github.com/HanqingTony/dsh-compact-pi@v0.2.3-b2
11
+ ```
12
+
13
+ Restart pi or `/reload`, then `/dcp-status`. The Git tag pins this release. To follow future releases on the default branch, use `pi install git:github.com/HanqingTony/dsh-compact-pi`. Before switching from a local DCP installation, use `pi list` and `pi remove <old-source>` to remove the old package entry and avoid loading DCP twice. To install a development checkout, use `pi install /absolute/path/to/dsh-compact-pi`. For one run:
14
+
15
+ ```bash
16
+ pi --no-extensions -e /absolute/path/to/dsh-compact-pi/dist/index.js
17
+ ```
18
+
19
+ | Command | Behavior |
20
+ |---|---|
21
+ | `/dcp-status` | Loaded versions, policy budgets and compatibility scope |
22
+ | `/dcp-summary-model` | Choose the project default DCP summary model from available pi models |
23
+ | `/dcp-summary-model reset` | Restore automatic selection for the project default |
24
+ | `/dcp-compact` | Manual upstream `compactNow()` through pi's compaction controller; idle only, no arguments |
25
+ | `/compact` | Pi's standard command intercepted by DCP; use while idle, without instructions |
26
+
27
+ Automatic pressure checks use DSH's `agent/pre-step` listener. Overflow decisions and budgets belong to DSH's `agent/request-error` listener. Manual compaction uses DSH's `compactNow()`, including its persistence checkpoint. DCP does not add manual pre-pruning, an emergency pressure fallback, a fixed 8K summary cap, or adaptive headroom.
28
+
29
+ Do not load bcp/bcp-lean or another context-rewriting extension alongside DCP. The project configuration in this checkout disables those packages locally.
30
+
31
+ ## Updating an existing installation
32
+
33
+ In pi 1.5.2, `pi update` alone updates **pi itself**. Use `pi update --extensions` to update installed packages, or `pi update <source>` to update one package.
34
+
35
+ | Installed source | Update behavior |
36
+ |---|---|
37
+ | `git:github.com/HanqingTony/dsh-compact-pi@v0.2.3-b2` | Stays on this tag until you install a different tag |
38
+ | `git:github.com/HanqingTony/dsh-compact-pi` | Follows the default branch (`main`), including changes between tagged releases |
39
+ | Local checkout | Uses local files; pi does not fetch a new release for that path |
40
+
41
+ To upgrade a pinned 0.2.2 installation, install the new tag on the machine where pi runs.
42
+
43
+ ```bash
44
+ pi install git:github.com/HanqingTony/dsh-compact-pi@v0.2.3-b2
45
+ ```
46
+
47
+ To follow `main` instead, replace the pinned source once, then update packages as needed:
48
+
49
+ ```bash
50
+ pi install git:github.com/HanqingTony/dsh-compact-pi
51
+ pi update --extensions
52
+ # Or update only DCP:
53
+ pi update git:github.com/HanqingTony/dsh-compact-pi
54
+ ```
55
+
56
+ After changing or updating the installed package, restart pi or run `/reload` while idle, then `/dcp-status` to verify the loaded version. Updating files on disk does not replace code already loaded by a running session. Keep only one DCP source in `pi list`; remove a previous local registration with `pi remove <old-source>` when switching to GitHub. Global and project-local package settings can both load extensions, so check both if commands or handlers appear twice.
57
+
58
+ See [CHANGELOG.md](CHANGELOG.md) for fixes in each build and [the publishing guide](docs/publishing.md) for maintainer release steps.
59
+
60
+ ## Compatibility scope
61
+
62
+ The supported comparison scenario is a **fixed physical model, text, user/tool-result images and ordinary tool messages, and no user input during compaction**. Submitted input is rejected with a retry-later notice rather than queued by DCP. PNG/JPEG/WebP/GIF images participate in upstream summarization and image offloading. General file attachments, assistant image output and virtual routing remain outside this scope: DCP preserves the original context and explicitly reports the unsupported capability. It never silently replaces DSH with pi's default summarizer.
63
+
64
+ Pi retains its own session format, branches, names, labels and extension state. DCP records request changes through `pi.appendEntry` before using them; at a safe boundary it also emits native `context_edit`/`compaction` entries. Pi is the sole writer of that session file. Existing `dcp`/`zcp` checkpoint records remain readable.
65
+
66
+ The adapter compares the finalized model-visible context, not original streaming timings or byte-identical provider payloads. Pi's native manual-compaction admission check still runs before the extension hook. Advanced routing, general file-attachment offload, input queuing and exact provider cache behavior are not emulated. See the precise contract in [docs/compatibility.md](docs/compatibility.md).
67
+
68
+ ## Ctrl+O diagnostics
69
+
70
+ Expand a `[compaction]` card with `Ctrl+O`. Its display identifies DCP, pi native, or another extension. New DCP cards show plugin/DSH version, trigger, summary model, token estimates, message counts, summary/prune/image-offload counts and duration. The renderer adds this information only to the display, not to the saved summary or model context. Historical records without these fields are identified as historical rather than attributed to the currently loaded version.
71
+
72
+ ## Images
73
+
74
+ User images and tool screenshots no longer disable compaction. The unmodified DSH local attachment backend validates and normalizes them into durable references; the summary request reads those references as real images. Images in the retained tail remain available. Text pruning preserves accompanying pictures.
75
+
76
+ The unmodified `compaction-image-offload` plugin handles image-count/encoded-byte admission failures in both the main request and summary request. It omits the oldest image occurrences and records permanent `image/offload` decisions. Placeholders name the attachment and its normalized read-only path. The decision survives cancellation after commit, restart and native pi context edits; a later read can introduce a fresh image occurrence.
77
+
78
+ The compatibility adapter uses pi's declared `inputLimits.images.maxPerRequest` / `maxPerMessage`; absent a request count limit it uses the upstream pi-ai default of 50, with a 20 MiB base64-image budget. Summary request versions follow the upstream 4-megapixel / 1 MiB defaults, further constrained by pi's declared resize dimensions/byte cap. Unstructured remote provider errors are not guessed into image-offload counts. A text-only summary model is rejected when its selected prefix still contains retained images.
79
+
80
+ The upstream pi-ai adapter does not declare exact image-token pricing. DCP likewise uses upstream attachment-reference heuristics and provider usage anchors; it never charges the base64 string as text tokens. Before a usable provider sample, this can underestimate visual pressure.
81
+
82
+ For persistent pi sessions, normalized objects live under `.dcp-assets/` beside the session file; in-memory sessions use the configured pi agent directory (default `~/.pi/agent`). The backend writes its request cache under that same attachment home. Keep those objects if you need the read-only recovery paths. No automatic asset garbage collection is provided. `sharp` is a production dependency and uses its platform-specific native binaries.
83
+
84
+ `dcp-session pi2dsh` writes valid attachment references to `DSH_HOME` (default `~/.dsh`) and keeps the byte-exact pi archive. Foreign DSH imports read that same attachment store and replay offloads before embedding retained images into pi; missing assets fail explicitly. The legacy synchronous core codec has no automatic attachment resolution; use the CLI for image sessions.
85
+
86
+ ## Configuration
87
+
88
+ Use `/dcp-summary-model` while pi is idle to see the current default and pick a model. The command saves `summarizationProvider` and `summarizationModel` in the project's `.pi/dcp.json` and reloads pi. The active conversation model continues to handle the conversation. Choose **Auto** or run `/dcp-summary-model reset` to let DSH prefer the last model that answered, then the current request model. Exact `modelPolicies` overrides take precedence and are preserved when changing or resetting the project default. `/dcp-status` shows the default and whether such overrides exist.
89
+
90
+ Optional `.pi/dcp.json`:
91
+
92
+ ```json
93
+ {
94
+ "policy": {
95
+ "thresholdRatio": 0.8,
96
+ "retainRatio": 0.16,
97
+ "compactionRetries": 1,
98
+ "maxOverflowRetries": 1
99
+ },
100
+ "audit": true
101
+ }
102
+ ```
103
+
104
+ `policy` is passed to upstream without extra DCP policy defaults. DSH's default headroom is **65,536** tokens, and omitted `maxTokens` inherits headroom. These are output upper bounds, not target summary lengths. Exact `modelPolicies`, paired summarization model/provider overrides, and `retainTokens` instead of `retainRatio` use upstream validation. `auto: false` leaves only manual compaction enabled. `.pi/zcp.json` is accepted if the new filename is absent.
105
+
106
+ Small-window models need an explicit policy that fits their model budget. For example, for a 32K context model reserving 8K output:
107
+
108
+ ```json
109
+ {
110
+ "policy": {
111
+ "headroomTokens": 2048,
112
+ "maxTokens": 4096,
113
+ "retainTokens": 4096
114
+ }
115
+ }
116
+ ```
117
+
118
+ Retention settings apply to automatic pressure. Manual compaction follows upstream's zero-retention-budget selection, preserving only the last balanced tail. `audit: false` omits detailed DSH events but retains checkpoint replay/provenance. Reload after configuration changes.
119
+
120
+ ## Updating upstream
121
+
122
+ ```bash
123
+ npm ci
124
+ npm run vendor:dsh -- /path/to/deepseek-harness
125
+ npm run vendor:verify -- /path/to/deepseek-harness
126
+ npm run check
127
+ npm run test:package
128
+ ```
129
+
130
+ The updater traverses **source** imports, copies the required TS/JS and dependency files byte-for-byte into `vendor/dsh-source/`, records import resolutions and SHA-256 hashes, and builds from that local copy. It does not use DSH's `lib/` artifacts and does not modify source imports. Normal builds verify the copied files and rebuild the kernel without consulting the upstream checkout.
131
+
132
+ The pi compatibility layer lives in `src/dsh/engine.ts`, `src/dsh/llm.ts`, `src/dsh/sync.ts` and `src/bridge.ts`. It supplies model I/O, maps pi operations to Cordis events and translates persisted projections. Compatible upstream changes require no compression-source edits. A changed service/export contract can still require adapter/resolver updates; failed checks must be resolved before shipping. Details: [docs/upstream-update.md](docs/upstream-update.md).
133
+
134
+ ## Validation and packaging
135
+
136
+ ```bash
137
+ npm run check # strict typecheck, source rebuild, tests and real pi SDK integration
138
+ npm run test:package # package, isolated install, copied-source rebuild, pi install/load
139
+ ```
140
+
141
+ Differential tests compare the adapter with direct upstream Cordis plugin execution: summary input/budget, logical selected spans, prune/replace events, final surfaces, no-op/failure results, flush checkpoints and retry decisions. Runtime IDs/timestamps and host-specific seed offsets are excluded. Other tests cover real TypeBox tool schemas, usage pricing, durability, branches, Ctrl+O, cancellation, scope rejection and input rejection. Provider replies are deterministic stubs; paid live-model fidelity benchmarks are not implied.
142
+
143
+ The distributable is `dsh-compact-pi-0.2.3-b2.tgz`. It can be installed with `npm install ./dsh-compact-pi-0.2.3-b2.tgz`, followed by `pi install /absolute/path/to/node_modules/dsh-compact-pi`. It contains the copied source closure and built extension.
144
+
145
+ See [testing](docs/testing.md), [publishing](docs/publishing.md), and [release notes](CHANGELOG.md).
146
+
147
+ ## Session conversion
148
+
149
+ See [usage and troubleshooting](docs/help.md) for configuration examples, migration steps and recovery checks. Run `dcp-session --help` for the CLI synopsis.
150
+
151
+ ```bash
152
+ dcp-session dsh2pi old.dsh.jsonl imported.pi.jsonl
153
+ pi --session imported.pi.jsonl
154
+ dcp-session pi2dsh session.pi.jsonl exported.dsh.jsonl
155
+ dcp --session old.dsh.jsonl
156
+ ```
157
+
158
+ The converter uses the DSH session format of the pinned upstream snapshot in `vendor/manifest.json`. Its pi-to-DSH export gives DSH the active branch after native context edits, compaction and DCP journal replay. The export also archives the original pi entries, including other branches and metadata, in ignorable `plugin:dcp/pi-header` and `plugin:dcp/pi-entry` records.
159
+
160
+ Importing an unchanged export restores the original pi entries. For a native DSH session, or an export whose context has since changed in DSH, the converter imports the live DSH context as a new linear pi session. Keep the source files if you want access to the original branch tree, plugin state or full event history. Pass a separate output path. Reading compressed DSH logs requires the `zstd` command.
161
+
162
+ `npm run test:resume -- <pi-version>` checks both directions through the CLI, including resuming in pi after adding a message in DSH. The full test suite also exercises a checkpoint created by the upstream DSH engine and retained or offloaded image attachments.
163
+
164
+ If an old v0.1 core codec patch is installed, export needed sessions and restore it with `node scripts/patch-pi.mjs --restore` before using the normal extension. See [migration details](docs/native-session-codec.md).
165
+
166
+ ## License
167
+
168
+ MIT. Upstream licenses and source provenance are in `vendor/LICENSE-DeepSeek`, `vendor/LICENSE-pi`, `vendor/THIRD-PARTY-NOTICES` and `vendor/manifest.json`.
@@ -0,0 +1,36 @@
1
+ /** CLI: convert pi and DSH session JSONL files. */
2
+
3
+ import { dshToPi, piToDsh } from '../src/dsh/convert.ts'
4
+
5
+ const help = `Usage:
6
+ dcp-session pi2dsh <pi-session.jsonl> <out.dsh.jsonl>
7
+ dcp-session dsh2pi <dsh-session.jsonl> <out.pi.jsonl>
8
+ dcp-session --help
9
+
10
+ pi2dsh exports the active pi context and archives the original pi entries.
11
+ dsh2pi restores those entries from an unchanged export. For a native or
12
+ continued DSH session it imports the active DSH context.
13
+
14
+ Use a separate output path. DSH input may be .jsonl or .zstd (requires zstd).
15
+ Image references are resolved under DSH_HOME (default ~/.dsh).`
16
+
17
+ const [command, input, output, ...extra] = process.argv.slice(2)
18
+ if (command === '--help' || command === '-h') {
19
+ console.log(help)
20
+ process.exit(0)
21
+ }
22
+ if ((command !== 'pi2dsh' && command !== 'dsh2pi') || !input || !output || extra.length) {
23
+ console.error(help)
24
+ process.exit(2)
25
+ }
26
+
27
+ try {
28
+ const report =
29
+ command === 'pi2dsh'
30
+ ? await piToDsh(input, output)
31
+ : await dshToPi(input, output)
32
+ console.log(JSON.stringify(report, null, 2))
33
+ } catch (error) {
34
+ console.error(error instanceof Error ? error.message : String(error))
35
+ process.exit(1)
36
+ }
package/bin/dcp.ts ADDED
@@ -0,0 +1,39 @@
1
+ /** Launch pi with dcp. DSH input is imported into a new pi session, never overwritten. */
2
+ import { spawn } from 'node:child_process'
3
+ import path from 'node:path'
4
+ import { existsSync } from 'node:fs'
5
+ import { dshToPi } from '../src/dsh/convert.ts'
6
+ import { isDshFile } from '../src/codec.ts'
7
+ const args = process.argv.slice(2)
8
+ const plugin = path.join(import.meta.dirname, 'index.js')
9
+ async function main() {
10
+ for (let index = 0; index < args.length; index++) {
11
+ const equals = args[index]!.startsWith('--session=')
12
+ if (args[index] !== '--session' && !equals) continue
13
+ const file = equals ? args[index]!.slice(10) : args[index + 1]
14
+ if (file && (isDshFile(file) || file.endsWith('.zstd'))) {
15
+ const output = `${file}.${Date.now()}.pi.jsonl`
16
+ if (existsSync(output))
17
+ throw new Error(`Import destination exists: ${output}`)
18
+ await dshToPi(file, output)
19
+ if (equals) args[index] = `--session=${output}`
20
+ else args[index + 1] = output
21
+ console.error(`dcp: imported DSH session into ${output}`)
22
+ }
23
+ break
24
+ }
25
+ // Explicit extension loading is reliable for one-shot use outside an installed package.
26
+ args.push('-e', plugin)
27
+ const child = spawn(process.env.PI_BIN ?? 'pi', args, { stdio: 'inherit' })
28
+ child.on('error', (error) => {
29
+ console.error(`dcp: ${error.message}`)
30
+ process.exitCode = 1
31
+ })
32
+ child.on('exit', (code) => {
33
+ process.exitCode = code ?? 1
34
+ })
35
+ }
36
+ main().catch((error) => {
37
+ console.error(`dcp: ${error.message}`)
38
+ process.exitCode = 1
39
+ })