@chatcode/chatcode-cli 3.0.3 → 3.0.4-rc.2

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 (243) hide show
  1. package/README.i18n.yaml +10 -10
  2. package/README.md +16 -1
  3. package/README.zh.md +16 -1
  4. package/lib/bin.js +62 -11
  5. package/lib/{command-errors-CBJRI2gy.js → command-errors-CScdshCl.js} +12 -12
  6. package/lib/{command-trees-Dvq4C7a4.js → command-trees-Dc17MYfV.js} +2 -2
  7. package/lib/{component-identity-DPdJglJO.js → component-identity-DFJD_d-P.js} +3 -3
  8. package/lib/{dump-config-CauO75nE.js → dump-config-BcH-VYuv.js} +5 -5
  9. package/lib/dump-config-CyopmD85.js +2 -0
  10. package/lib/{dump-config-schema-CObLWWaW.js → dump-config-schema-DM0fb6Ns.js} +2 -2
  11. package/lib/{extension-events-Be9LWvHD.js → extension-events-qXmhzmHo.js} +20 -20
  12. package/lib/{frames-7PAg0Q9b.js → frames-B89znn_0.js} +4 -4
  13. package/lib/headless-compat.js +2 -2
  14. package/lib/{host-access-DeCjoRQP.js → host-access-B0CRAwsX.js} +1 -1
  15. package/lib/{keymap-CRUxM_qn.js → keymap-CIoVICBI.js} +17 -16
  16. package/lib/{plugin-CDFSDE_y.js → plugin-BKQsL2xn.js} +3264 -2301
  17. package/lib/{plugin-Cn-hyYY8.js → plugin-eJjD6r12.js} +1 -1
  18. package/lib/{profile-boot-SJGbpLgN.js → profile-boot-BNQry1NM.js} +97 -14
  19. package/lib/profile-boot.js +2 -2
  20. package/lib/{scenes-D6jV1EEi.js → scenes-BRf-zMpF.js} +3 -3
  21. package/lib/{settings-sections-DJQRNBo9.js → settings-sections-4gMhveN_.js} +7 -3
  22. package/lib/statusBarSettings-CnmdSHkO.js +382 -0
  23. package/lib/{themes-BCly4_y9.js → themes-Ce97Zsri.js} +13 -13
  24. package/lib/tui-compat-command-trees.js +1 -1
  25. package/lib/tui-compat-extensions.js +3 -3
  26. package/lib/tui-compat-plugin-host.js +5 -5
  27. package/lib/tui-compat-scenes.js +1 -1
  28. package/lib/tui-compat-settings-sections.js +1 -1
  29. package/lib/tui-compat-working-activity.js +4 -4
  30. package/lib/tui-compat-workspaces.js +1 -1
  31. package/lib/tui-compat.js +9 -26
  32. package/lib/types/args.d.ts +2 -0
  33. package/lib/types/permission-bypass.d.ts +16 -0
  34. package/lib/types/profile-boot.d.ts +12 -0
  35. package/lib/types/tui-compat.d.ts +4 -0
  36. package/lib/types/web-browser.d.ts +6 -0
  37. package/lib/types/web-instance.d.ts +42 -0
  38. package/lib/web-browser-Vcgfdsv_.js +46 -0
  39. package/lib/web-instance-B0jec7cq.js +2 -0
  40. package/lib/web-instance-DbP7IHPv.js +280 -0
  41. package/lib/{workspaces-Bb3kCAFb.js → workspaces-1xrm-e3V.js} +2 -2
  42. package/package.json +36 -33
  43. package/runtime/manifest.json +4 -2
  44. package/runtime/node_modules/@deepseek-ai/dsh-agent-default-model/lib/index.js +137 -11
  45. package/runtime/node_modules/@deepseek-ai/dsh-agent-default-model/lib/types/index.d.ts +27 -1
  46. package/runtime/node_modules/@deepseek-ai/dsh-agent-preset/skills/cordis-composition-reference/references/packages.md +2 -1
  47. package/runtime/node_modules/@deepseek-ai/dsh-api-gateway/lib/client.js +2 -0
  48. package/runtime/node_modules/@deepseek-ai/dsh-api-gateway/lib/types/client/remote-stream.js +4 -0
  49. package/runtime/node_modules/@deepseek-ai/dsh-api-remotes/lib/client.js +152 -39
  50. package/runtime/node_modules/@deepseek-ai/dsh-api-remotes/lib/index.js +4 -0
  51. package/runtime/node_modules/@deepseek-ai/dsh-api-remotes/lib/types/remote-events.d.ts +3 -0
  52. package/runtime/node_modules/@deepseek-ai/dsh-api-remotes/lib/types/remote-events.js +1 -0
  53. package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/index.js +179 -35
  54. package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/typert.host.js +57 -30
  55. package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/typert.remote-client.js +31 -19
  56. package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/types/agent.d.ts +9 -1
  57. package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/types/agent.js +36 -6
  58. package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/types/archived-session-gate.js +1 -1
  59. package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/types/catalog.js +12 -2
  60. package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/types/client/sessions/service.d.ts +1 -1
  61. package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/types/commands.d.ts +2 -2
  62. package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/types/commands.js +24 -8
  63. package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/types/index.d.ts +4 -3
  64. package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/types/index.js +31 -14
  65. package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/types/list.d.ts +6 -0
  66. package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/types/list.js +89 -4
  67. package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/types/remote-events.d.ts +1 -1
  68. package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/types/types.d.ts +27 -0
  69. package/runtime/node_modules/@deepseek-ai/dsh-api-settings-controller/lib/index.js +28 -1
  70. package/runtime/node_modules/@deepseek-ai/dsh-api-settings-controller/lib/typert.host.js +39 -0
  71. package/runtime/node_modules/@deepseek-ai/dsh-api-settings-controller/lib/typert.remote-client.d.ts +2 -0
  72. package/runtime/node_modules/@deepseek-ai/dsh-api-settings-controller/lib/typert.remote-client.js +32 -0
  73. package/runtime/node_modules/@deepseek-ai/dsh-api-settings-controller/lib/types/index.d.ts +8 -0
  74. package/runtime/node_modules/@deepseek-ai/dsh-api-settings-controller/lib/types/index.js +19 -1
  75. package/runtime/node_modules/@deepseek-ai/dsh-api-workspace-controller/lib/client.js +30 -0
  76. package/runtime/node_modules/@deepseek-ai/dsh-api-workspace-controller/lib/index.js +111 -2
  77. package/runtime/node_modules/@deepseek-ai/dsh-api-workspace-controller/lib/typert.host.js +104 -11
  78. package/runtime/node_modules/@deepseek-ai/dsh-api-workspace-controller/lib/typert.remote-client.d.ts +5 -1
  79. package/runtime/node_modules/@deepseek-ai/dsh-api-workspace-controller/lib/typert.remote-client.js +78 -11
  80. package/runtime/node_modules/@deepseek-ai/dsh-api-workspace-controller/lib/types/client/model.d.ts +14 -1
  81. package/runtime/node_modules/@deepseek-ai/dsh-api-workspace-controller/lib/types/client/model.js +17 -0
  82. package/runtime/node_modules/@deepseek-ai/dsh-api-workspace-controller/lib/types/client/service.d.ts +15 -0
  83. package/runtime/node_modules/@deepseek-ai/dsh-api-workspace-controller/lib/types/client/service.js +12 -0
  84. package/runtime/node_modules/@deepseek-ai/dsh-api-workspace-controller/lib/types/commands.d.ts +13 -1
  85. package/runtime/node_modules/@deepseek-ai/dsh-api-workspace-controller/lib/types/commands.js +44 -2
  86. package/runtime/node_modules/@deepseek-ai/dsh-api-workspace-controller/lib/types/feed.js +17 -0
  87. package/runtime/node_modules/@deepseek-ai/dsh-api-workspace-controller/lib/types/index.d.ts +13 -1
  88. package/runtime/node_modules/@deepseek-ai/dsh-api-workspace-controller/lib/types/index.js +22 -0
  89. package/runtime/node_modules/@deepseek-ai/dsh-api-workspace-controller/lib/types/types.d.ts +17 -0
  90. package/runtime/node_modules/@deepseek-ai/dsh-app-boot/lib/index.js +67 -19
  91. package/runtime/node_modules/@deepseek-ai/dsh-app-boot/lib/types/index.d.ts +1 -1
  92. package/runtime/node_modules/@deepseek-ai/dsh-app-boot/lib/types/profile-context.d.ts +11 -1
  93. package/runtime/node_modules/@deepseek-ai/dsh-app-boot/lib/worker/profile-resolution-bootstrap.js +22 -3
  94. package/runtime/node_modules/@deepseek-ai/dsh-base/cordis.patch.yml +9 -3
  95. package/runtime/node_modules/@deepseek-ai/dsh-base/package.json +2 -1
  96. package/runtime/node_modules/@deepseek-ai/dsh-client-hmr/lib/client.js +931 -7
  97. package/runtime/node_modules/@deepseek-ai/dsh-client-hmr/lib/index.js +57 -19
  98. package/runtime/node_modules/@deepseek-ai/dsh-client-hmr/lib/types/client/index.d.ts +5 -2
  99. package/runtime/node_modules/@deepseek-ai/dsh-client-hmr/lib/types/config.d.ts +12 -0
  100. package/runtime/node_modules/@deepseek-ai/dsh-client-hmr/lib/types/events.d.ts +4 -4
  101. package/runtime/node_modules/@deepseek-ai/dsh-client-hmr/lib/types/index.d.ts +3 -8
  102. package/runtime/node_modules/@deepseek-ai/dsh-client-hmr/package.json +6 -2
  103. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-chat/lib/client.js +3 -2
  104. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-chat/lib/types/index.d.ts +2 -2
  105. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-commands/lib/client.js +10 -0
  106. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-conversation/lib/client.js +1 -1
  107. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-deliverables/lib/types/client/present-open.d.ts +1 -1
  108. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-goal/lib/client.js +1 -1
  109. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-model-selection/lib/client.js +68 -16
  110. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-model-selection/lib/types/client/directory.d.ts +3 -1
  111. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-model-selection/lib/types/client/locales.d.ts +6 -0
  112. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-primitives/lib/markdown/CodeBlock.module.css +3 -5
  113. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-primitives/lib/markdown/MarkdownText.module.css +23 -27
  114. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-settings/lib/types/client/contract/slots.d.ts +3 -1
  115. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-settings-account/lib/client.js +2 -2
  116. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-settings-account/lib/types/index.d.ts +2 -2
  117. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-settings-general/lib/client.js +8 -7
  118. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-settings-general/lib/types/client/SettingsDocumentAction.d.ts +1 -1
  119. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-settings-general/lib/types/client/settings-document-store.d.ts +2 -1
  120. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-settings-models/lib/client.js +33 -12
  121. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-settings-models/lib/types/client/locales.d.ts +2 -0
  122. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-settings-plugin-inventory/lib/client.js +1 -1
  123. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-sidebar/lib/client.js +3 -1
  124. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-theme/lib/client.js +1 -1
  125. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-workspace/lib/client.js +1925 -207
  126. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-workspace/lib/types/client/ArchivedSessions.d.ts +13 -0
  127. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-workspace/lib/types/client/contract/slots.d.ts +4 -0
  128. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-workspace/lib/types/client/locales.d.ts +42 -0
  129. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-workspace/lib/types/client/recent.d.ts +11 -0
  130. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-workspace/lib/types/client/rows/RecentList.d.ts +15 -0
  131. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-workspace/lib/types/client/rows/Rows.d.ts +6 -1
  132. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-workspace/lib/types/client/session-actions/DeleteSession.d.ts +24 -0
  133. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-workspace/lib/types/client/stores.d.ts +2 -2
  134. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-workspace/lib/types/client/tree.d.ts +15 -13
  135. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-workspace/package.json +3 -1
  136. package/runtime/node_modules/@deepseek-ai/dsh-commands/lib/index.js +16 -0
  137. package/runtime/node_modules/@deepseek-ai/dsh-commands/lib/typert.host.js +7 -3
  138. package/runtime/node_modules/@deepseek-ai/dsh-commands/lib/typert.remote-client.js +6 -2
  139. package/runtime/node_modules/@deepseek-ai/dsh-commands/lib/types/index.js +20 -0
  140. package/runtime/node_modules/@deepseek-ai/dsh-commands/lib/types/types.d.ts +5 -0
  141. package/runtime/node_modules/@deepseek-ai/dsh-computer-use/lib/index.js +35 -0
  142. package/runtime/node_modules/@deepseek-ai/dsh-computer-use/lib/types/brand.d.ts +11 -0
  143. package/runtime/node_modules/@deepseek-ai/dsh-computer-use/lib/types/brand.js +10 -0
  144. package/runtime/node_modules/@deepseek-ai/dsh-computer-use/lib/types/index.d.ts +28 -0
  145. package/runtime/node_modules/@deepseek-ai/dsh-computer-use/lib/types/index.js +36 -0
  146. package/runtime/node_modules/@deepseek-ai/dsh-computer-use/package.json +42 -0
  147. package/runtime/node_modules/@deepseek-ai/dsh-config-editor/lib/index.js +102 -14
  148. package/runtime/node_modules/@deepseek-ai/dsh-config-editor/lib/types/index.d.ts +34 -4
  149. package/runtime/node_modules/@deepseek-ai/dsh-config-editor/package.json +1 -0
  150. package/runtime/node_modules/@deepseek-ai/dsh-cordis-client-runner/lib/client.js +5 -2
  151. package/runtime/node_modules/@deepseek-ai/dsh-host-webserver/lib/index.js +2 -1
  152. package/runtime/node_modules/@deepseek-ai/dsh-native-command/lib/index.js +21 -8
  153. package/runtime/node_modules/@deepseek-ai/dsh-native-command/lib/types/path-opener.d.ts +4 -6
  154. package/runtime/node_modules/@deepseek-ai/dsh-native-command/lib/types/path-opener.js +18 -7
  155. package/runtime/node_modules/@deepseek-ai/dsh-schedule/lib/index.js +4 -0
  156. package/runtime/node_modules/@deepseek-ai/dsh-schedule/lib/typert.host.js +5 -5
  157. package/runtime/node_modules/@deepseek-ai/dsh-schedule/lib/typert.remote-client.js +5 -5
  158. package/runtime/node_modules/@deepseek-ai/dsh-schedule/lib/types/index.js +5 -0
  159. package/runtime/node_modules/@deepseek-ai/dsh-session/lib/types/index.d.ts +21 -0
  160. package/runtime/node_modules/@deepseek-ai/dsh-session-persistence/lib/index.js +12 -0
  161. package/runtime/node_modules/@deepseek-ai/dsh-session-persistence/lib/types/index.d.ts +15 -0
  162. package/runtime/node_modules/@deepseek-ai/dsh-session-persistence-jsonl/lib/index.js +95 -2
  163. package/runtime/node_modules/@deepseek-ai/dsh-session-persistence-jsonl/lib/types/index.d.ts +3 -1
  164. package/runtime/node_modules/@deepseek-ai/dsh-session-projection-cache/lib/index.js +25 -1
  165. package/runtime/node_modules/@deepseek-ai/dsh-session-projection-cache/lib/types/index.d.ts +1 -0
  166. package/runtime/node_modules/@deepseek-ai/dsh-session-projection-cache/package.json +2 -1
  167. package/runtime/node_modules/@deepseek-ai/dsh-session-query/lib/index.js +13 -0
  168. package/runtime/node_modules/@deepseek-ai/dsh-session-query/lib/types/observation.d.ts +5 -0
  169. package/runtime/node_modules/@deepseek-ai/dsh-session-query-sqlite/lib/index.js +26 -0
  170. package/runtime/node_modules/@deepseek-ai/dsh-session-query-sqlite/package.json +2 -1
  171. package/runtime/node_modules/@deepseek-ai/dsh-settings/lib/index.js +5 -4
  172. package/runtime/node_modules/@deepseek-ai/dsh-settings/lib/types/index.d.ts +4 -3
  173. package/runtime/node_modules/@deepseek-ai/dsh-settings/lib/types/index.js +4 -3
  174. package/runtime/node_modules/@deepseek-ai/dsh-storage/lib/types/backend.d.ts +4 -0
  175. package/runtime/node_modules/@deepseek-ai/dsh-storage-domain/lib/index.js +65 -1
  176. package/runtime/node_modules/@deepseek-ai/dsh-storage-domain/lib/types/domain.d.ts +17 -2
  177. package/runtime/node_modules/@deepseek-ai/dsh-storage-json/lib/index.js +25 -0
  178. package/runtime/node_modules/@deepseek-ai/dsh-storage-json/package.json +1 -0
  179. package/runtime/node_modules/@deepseek-ai/dsh-subagent/lib/types/control.d.ts +1 -1
  180. package/runtime/node_modules/@deepseek-ai/dsh-tianti/lib/index.js +5522 -0
  181. package/runtime/node_modules/@deepseek-ai/dsh-tianti/lib/types/command-args.d.ts +17 -0
  182. package/runtime/node_modules/@deepseek-ai/dsh-tianti/lib/types/commands/tianti/cicd.d.ts +8 -0
  183. package/runtime/node_modules/@deepseek-ai/dsh-tianti/lib/types/commands/tianti/tianti.d.ts +7 -0
  184. package/runtime/node_modules/@deepseek-ai/dsh-tianti/lib/types/commands/tianti-deliver/tianti-deliver.d.ts +8 -0
  185. package/runtime/node_modules/@deepseek-ai/dsh-tianti/lib/types/config.d.ts +27 -0
  186. package/runtime/node_modules/@deepseek-ai/dsh-tianti/lib/types/index.d.ts +13 -0
  187. package/runtime/node_modules/@deepseek-ai/dsh-tianti/lib/types/memory-config.d.ts +10 -0
  188. package/runtime/node_modules/@deepseek-ai/dsh-tianti/lib/types/runtime.d.ts +105 -0
  189. package/runtime/node_modules/@deepseek-ai/dsh-tianti/lib/types/services/tianti/aliases.d.ts +11 -0
  190. package/runtime/node_modules/@deepseek-ai/dsh-tianti/lib/types/services/tianti/auth.d.ts +20 -0
  191. package/runtime/node_modules/@deepseek-ai/dsh-tianti/lib/types/services/tianti/client.d.ts +206 -0
  192. package/runtime/node_modules/@deepseek-ai/dsh-tianti/lib/types/services/tianti/config.d.ts +22 -0
  193. package/runtime/node_modules/@deepseek-ai/dsh-tianti/lib/types/services/tianti/index.d.ts +6 -0
  194. package/runtime/node_modules/@deepseek-ai/dsh-tianti/lib/types/services/tianti/log.d.ts +16 -0
  195. package/runtime/node_modules/@deepseek-ai/dsh-tianti/lib/types/services/tianti/types.d.ts +136 -0
  196. package/runtime/node_modules/@deepseek-ai/dsh-tianti/lib/types/services/wanmaDevelopmentWorkflow/codebase.d.ts +19 -0
  197. package/runtime/node_modules/@deepseek-ai/dsh-tianti/lib/types/services/wanmaDevelopmentWorkflow/dynamicWorkflow.d.ts +10 -0
  198. package/runtime/node_modules/@deepseek-ai/dsh-tianti/lib/types/services/wanmaDevelopmentWorkflow/engine.d.ts +8 -0
  199. package/runtime/node_modules/@deepseek-ai/dsh-tianti/lib/types/services/wanmaDevelopmentWorkflow/executor.d.ts +11 -0
  200. package/runtime/node_modules/@deepseek-ai/dsh-tianti/lib/types/services/wanmaDevelopmentWorkflow/executors.d.ts +15 -0
  201. package/runtime/node_modules/@deepseek-ai/dsh-tianti/lib/types/services/wanmaDevelopmentWorkflow/index.d.ts +23 -0
  202. package/runtime/node_modules/@deepseek-ai/dsh-tianti/lib/types/services/wanmaDevelopmentWorkflow/memorySuggestions.d.ts +12 -0
  203. package/runtime/node_modules/@deepseek-ai/dsh-tianti/lib/types/services/wanmaDevelopmentWorkflow/openspec.d.ts +31 -0
  204. package/runtime/node_modules/@deepseek-ai/dsh-tianti/lib/types/services/wanmaDevelopmentWorkflow/recommend.d.ts +8 -0
  205. package/runtime/node_modules/@deepseek-ai/dsh-tianti/lib/types/services/wanmaDevelopmentWorkflow/render.d.ts +8 -0
  206. package/runtime/node_modules/@deepseek-ai/dsh-tianti/lib/types/services/wanmaDevelopmentWorkflow/requirementContext.d.ts +12 -0
  207. package/runtime/node_modules/@deepseek-ai/dsh-tianti/lib/types/services/wanmaDevelopmentWorkflow/scenarioUpgrade.d.ts +24 -0
  208. package/runtime/node_modules/@deepseek-ai/dsh-tianti/lib/types/services/wanmaDevelopmentWorkflow/state.d.ts +16 -0
  209. package/runtime/node_modules/@deepseek-ai/dsh-tianti/lib/types/services/wanmaDevelopmentWorkflow/store.d.ts +33 -0
  210. package/runtime/node_modules/@deepseek-ai/dsh-tianti/lib/types/services/wanmaDevelopmentWorkflow/templates.d.ts +8 -0
  211. package/runtime/node_modules/@deepseek-ai/dsh-tianti/lib/types/services/wanmaDevelopmentWorkflow/types.d.ts +385 -0
  212. package/runtime/node_modules/@deepseek-ai/dsh-tianti/lib/types/services/wanmaDevelopmentWorkflow/writeReviewSync.d.ts +6 -0
  213. package/runtime/node_modules/@deepseek-ai/dsh-tianti/lib/types/services/writeReview/index.d.ts +29 -0
  214. package/runtime/node_modules/@deepseek-ai/dsh-tianti/lib/types/services/writeReview/store.d.ts +20 -0
  215. package/runtime/node_modules/@deepseek-ai/dsh-tianti/lib/types/services/writeReview/types.d.ts +49 -0
  216. package/runtime/node_modules/@deepseek-ai/dsh-tianti/lib/types/tools.d.ts +12 -0
  217. package/runtime/node_modules/@deepseek-ai/dsh-tianti/package.json +57 -0
  218. package/runtime/node_modules/@deepseek-ai/dsh-tool-cordis/lib/types/api-catalog.js +157 -22
  219. package/runtime/node_modules/@deepseek-ai/dsh-web-frontend/dist/assets/index-D5kpKf--.css +1 -0
  220. package/runtime/node_modules/@deepseek-ai/dsh-web-frontend/dist/assets/index-Dz_cDcce.js +133 -0
  221. package/runtime/node_modules/@deepseek-ai/dsh-web-frontend/dist/assets/index-Dz_cDcce.js.map +1 -0
  222. package/runtime/node_modules/@deepseek-ai/dsh-web-frontend/dist/chatcode-apple-touch-icon.png +0 -0
  223. package/runtime/node_modules/@deepseek-ai/dsh-web-frontend/dist/chatcode-icon-32.png +0 -0
  224. package/runtime/node_modules/@deepseek-ai/dsh-web-frontend/dist/chatcode-mask-icon.svg +1 -0
  225. package/runtime/node_modules/@deepseek-ai/dsh-web-frontend/dist/favicon-dark.svg +1 -3
  226. package/runtime/node_modules/@deepseek-ai/dsh-web-frontend/dist/favicon.ico +0 -0
  227. package/runtime/node_modules/@deepseek-ai/dsh-web-frontend/dist/favicon.svg +1 -3
  228. package/runtime/node_modules/@deepseek-ai/dsh-web-frontend/dist/index.html +8 -4
  229. package/runtime/node_modules/@deepseek-ai/dsh-web-frontend/dist/preview.html +8 -4
  230. package/runtime/node_modules/@deepseek-ai/dsh-web-frontend/package.json +2 -1
  231. package/runtime/node_modules/@deepseek-ai/dsh-workspace/lib/index.js +325 -37
  232. package/runtime/node_modules/@deepseek-ai/dsh-workspace/lib/invariant.js +6 -1
  233. package/runtime/node_modules/@deepseek-ai/dsh-workspace/lib/types/entity.d.ts +6 -0
  234. package/runtime/node_modules/@deepseek-ai/dsh-workspace/lib/types/entity.js +23 -17
  235. package/runtime/node_modules/@deepseek-ai/dsh-workspace/lib/types/index.d.ts +41 -0
  236. package/runtime/node_modules/@deepseek-ai/dsh-workspace/lib/types/index.js +314 -23
  237. package/runtime/node_modules/@deepseek-ai/dsh-workspace/lib/types/spec.d.ts +4 -0
  238. package/runtime/node_modules/@deepseek-ai/dsh-workspace/lib/types/spec.js +4 -0
  239. package/lib/dump-config-CijLv_kn.js +0 -2
  240. package/lib/tuiDisplayPrefs-Dm_fULiR.js +0 -204
  241. package/runtime/node_modules/@deepseek-ai/dsh-web-frontend/dist/assets/index-DUvMhLle.css +0 -1
  242. package/runtime/node_modules/@deepseek-ai/dsh-web-frontend/dist/assets/index-Q6zc2uHV.js +0 -127
  243. package/runtime/node_modules/@deepseek-ai/dsh-web-frontend/dist/assets/index-Q6zc2uHV.js.map +0 -1
@@ -2,7 +2,7 @@ import z from "@deepseek-ai/schemastery";
2
2
  import { SessionFormatUnsupportedMigrationError, createSessionFormatCatalogWithChildren, historicalSessionFormatCatalog, sessionFormatCatalog } from "@deepseek-ai/dsh-session-format-catalog";
3
3
  import { readdirSync } from "node:fs";
4
4
  import { link, lstat, mkdir, mkdtemp, open, readFile, readdir, realpath, rm, stat, truncate } from "node:fs/promises";
5
- import { basename, dirname, isAbsolute, join, parse, resolve, toNamespacedPath } from "node:path";
5
+ import { basename, dirname, isAbsolute, join, parse, resolve, sep, toNamespacedPath } from "node:path";
6
6
  import { performance } from "node:perf_hooks";
7
7
  import { scheduler } from "node:timers/promises";
8
8
  import { createHash, randomBytes } from "node:crypto";
@@ -2282,6 +2282,8 @@ async function prepareCatalogFacts(parentId, sources, compression, signal) {
2282
2282
  * log, so the memo only needs the sessions in flight between those steps.
2283
2283
  */
2284
2284
  const COLD_LOG_MEMO_MAX_ENTRIES = 2;
2285
+ /** Retained with the stable lock inode after payload deletion. Contains no conversation data. */
2286
+ const DELETED_FILENAME = ".deleted";
2285
2287
  const DEFAULT_COMPRESSION = "zstd";
2286
2288
  /**
2287
2289
  * Internal scheduling constant, not deployment configuration: balance
@@ -2434,6 +2436,7 @@ var JsonlSessionPersistence = class extends SessionPersistence {
2434
2436
  toHeaderLine(snapshot, options?.inheritedEventCount);
2435
2437
  const inheritedEventCount = SessionLogOffset(options?.inheritedEventCount ?? 0);
2436
2438
  await this.ensureRootEncoding();
2439
+ if (await this.wasDeleted(header.id)) throw new SessionAlreadyExistsError(header.id);
2437
2440
  options?.signal?.throwIfAborted();
2438
2441
  if (this.tracker.hasPending(snapshot.id) || await this.findLog(snapshot.id, options?.signal) !== void 0) throw new SessionAlreadyExistsError(snapshot.id);
2439
2442
  options?.signal?.throwIfAborted();
@@ -2596,6 +2599,88 @@ var JsonlSessionPersistence = class extends SessionPersistence {
2596
2599
  signal?.throwIfAborted();
2597
2600
  return snapshots;
2598
2601
  }
2602
+ async prepareDeletion(sessionIds) {
2603
+ const claimed = [];
2604
+ const held = [];
2605
+ let closed = false;
2606
+ const release = async () => {
2607
+ if (closed) return;
2608
+ closed = true;
2609
+ try {
2610
+ const failures = (await Promise.allSettled(held.map((item) => item.lease.release()))).flatMap((result) => result.status === "rejected" ? [result.reason] : []);
2611
+ if (failures.length > 0) throw new AggregateError(failures, "Session deletion lock release failed");
2612
+ } finally {
2613
+ for (const id of claimed) this.tracker.releaseClaim(id);
2614
+ }
2615
+ };
2616
+ try {
2617
+ await this.ensureRootEncoding();
2618
+ const root = await realpath(this.root).catch((error) => {
2619
+ if (isENOENT(error)) return this.root;
2620
+ throw error;
2621
+ });
2622
+ for (const id of [...new Set(sessionIds)].sort()) {
2623
+ this.tracker.claimWrite(id);
2624
+ claimed.push(id);
2625
+ await this.stat(id);
2626
+ for (const project of await this.listProjectDirs()) {
2627
+ const dir = join(project, encodeSegment(id));
2628
+ const info = await lstat(dir).catch((error) => {
2629
+ if (isENOENT(error)) return void 0;
2630
+ throw error;
2631
+ });
2632
+ if (info === void 0) continue;
2633
+ if (!info.isDirectory()) throw new Error("Session deletion requires an owned directory");
2634
+ const resolved = await realpath(dir).catch((error) => {
2635
+ if (isENOENT(error)) return void 0;
2636
+ throw error;
2637
+ });
2638
+ if (resolved === void 0) continue;
2639
+ if (!resolved.startsWith(root + sep)) throw new Error("Session deletion path escapes its storage root");
2640
+ held.push({
2641
+ dir,
2642
+ lease: await SessionWriteLease.acquire(dir, id)
2643
+ });
2644
+ }
2645
+ }
2646
+ return {
2647
+ commit: async () => {
2648
+ if (closed) throw new Error("Session deletion reservation is closed");
2649
+ for (const { dir } of held) {
2650
+ const marker = await open(join(dir, DELETED_FILENAME), "a", 384);
2651
+ try {
2652
+ await marker.sync();
2653
+ } finally {
2654
+ await marker.close();
2655
+ }
2656
+ await this.syncDirPosix(dir);
2657
+ for (const entry of await readdir(dir)) if (entry !== "session.lock" && entry !== DELETED_FILENAME) await rm(join(dir, entry), {
2658
+ recursive: true,
2659
+ force: true
2660
+ });
2661
+ await this.syncDirPosix(dir);
2662
+ }
2663
+ for (const id of claimed) {
2664
+ this.coldLogMemo.delete(id);
2665
+ this.migrationPreparations.delete(id);
2666
+ }
2667
+ },
2668
+ [Symbol.asyncDispose]: release
2669
+ };
2670
+ } catch (error) {
2671
+ await release();
2672
+ throw error;
2673
+ }
2674
+ }
2675
+ async wasDeleted(id) {
2676
+ for (const project of await this.listProjectDirs()) try {
2677
+ await stat(join(project, encodeSegment(id), DELETED_FILENAME));
2678
+ return true;
2679
+ } catch (error) {
2680
+ if (!isENOENT(error)) throw error;
2681
+ }
2682
+ return false;
2683
+ }
2599
2684
  /** Resolve and read one stored log, refusing loudly when the artifact is absent. */
2600
2685
  async requireStoredLog(id, signal) {
2601
2686
  const selected = await this.findLog(id, signal);
@@ -2931,7 +3016,14 @@ var JsonlSessionPersistence = class extends SessionPersistence {
2931
3016
  */
2932
3017
  async acquireWriteLease(header) {
2933
3018
  await this.rejectOppositeArtifact(header.cwd, header.id);
2934
- return this.acquireLease(header.id, header.cwd);
3019
+ const lease = await this.acquireLease(header.id, header.cwd);
3020
+ try {
3021
+ if (await this.wasDeleted(header.id)) throw new SessionAlreadyExistsError(header.id);
3022
+ return lease;
3023
+ } catch (error) {
3024
+ await lease.release();
3025
+ throw error;
3026
+ }
2935
3027
  }
2936
3028
  /** Decode complete frames and retain complete JSONL records from a torn final frame. */
2937
3029
  async readZstdPrefix(buffer, signal) {
@@ -3334,6 +3426,7 @@ var JsonlSessionPersistence = class extends SessionPersistence {
3334
3426
  throw error;
3335
3427
  }
3336
3428
  signal?.throwIfAborted();
3429
+ if (entries.some((entry) => entry.name === DELETED_FILENAME)) return void 0;
3337
3430
  const generations = [];
3338
3431
  const opposite = [];
3339
3432
  for (const entry of entries) {
@@ -7,7 +7,7 @@
7
7
  */
8
8
  import { Context } from '@deepseek-ai/cordis';
9
9
  import z from '@deepseek-ai/schemastery';
10
- import { SessionPersistence, type SessionAccess, type SessionHandle, type SessionHandleReadResult, type SessionPersistenceCreateOptions, type SessionPersistenceListOptions, type SessionPersistenceOpenOptions, type SessionPersistenceSnapshot, type SessionPersistenceStatOptions, type SessionPersistenceRevision as PersistenceRevision } from '@deepseek-ai/dsh-session-persistence';
10
+ import { SessionPersistence, type SessionAccess, type SessionHandle, type SessionDeletion, type SessionHandleReadResult, type SessionPersistenceCreateOptions, type SessionPersistenceListOptions, type SessionPersistenceOpenOptions, type SessionPersistenceSnapshot, type SessionPersistenceStatOptions, type SessionPersistenceRevision as PersistenceRevision } from '@deepseek-ai/dsh-session-persistence';
11
11
  import { JsonlSessionHandle } from './storage.ts';
12
12
  import { SessionWriteLease } from './lease.ts';
13
13
  import type { SessionEvent, SessionId, SessionHeader, SessionLogOffset as SessionLogOffsetType } from '@deepseek-ai/dsh-session';
@@ -118,6 +118,8 @@ declare class JsonlSessionPersistence extends SessionPersistence {
118
118
  * @returns one snapshot per session, in no promised order.
119
119
  */
120
120
  list(options?: SessionPersistenceListOptions): Promise<readonly SessionPersistenceSnapshot[]>;
121
+ prepareDeletion(sessionIds: readonly SessionId[]): Promise<SessionDeletion>;
122
+ private wasDeleted;
121
123
  /** Resolve and read one stored log, refusing loudly when the artifact is absent. */
122
124
  private requireStoredLog;
123
125
  /** Probe the memo and otherwise decode one historical generation under backend cancellation. */
@@ -155,6 +155,7 @@ var SessionProjectionCache = class extends Service {
155
155
  listingTable;
156
156
  writes = Promise.resolve();
157
157
  closed = false;
158
+ deleted = /* @__PURE__ */ new Set();
158
159
  dirty = /* @__PURE__ */ new Map();
159
160
  constructor(ctx, config) {
160
161
  super(ctx, "sessionProjectionCache");
@@ -173,6 +174,24 @@ var SessionProjectionCache = class extends Service {
173
174
  await this.writes;
174
175
  }, "sessionProjectionCache.writeDrain");
175
176
  this.installWritePath();
177
+ const cleanup = (ids) => {
178
+ for (const id of ids) this.deleted.add(id);
179
+ return this.enqueueWrite(async () => {
180
+ for (const id of ids) {
181
+ await this.requireTable().delete(id);
182
+ await this.requireListingTable().delete(id);
183
+ }
184
+ });
185
+ };
186
+ this.ctx.on("session/deleting", ({ sessionIds }) => cleanup(sessionIds));
187
+ this.ctx.on("session/deleted", (ids) => {
188
+ cleanup(ids).catch((error) => {
189
+ this.ctx.logger.warn(`session projection cache: deletion cleanup failed: ${String(error)}`);
190
+ });
191
+ });
192
+ this.ctx.inject(["workspaceRegistry"], async (ctx) => {
193
+ await cleanup(ctx.workspaceRegistry.deletedSessionIds);
194
+ });
176
195
  }
177
196
  /**
178
197
  * The stored record for one session, accepted only when its bound log
@@ -185,6 +204,7 @@ var SessionProjectionCache = class extends Service {
185
204
  * @returns the identity-matching record, or `undefined` (absent or unrelated).
186
205
  */
187
206
  async recordFor(id, expected) {
207
+ if (this.deleted.has(id)) return void 0;
188
208
  const record = await this.requireTable().read(id);
189
209
  if (record === void 0) return void 0;
190
210
  return identityMatches(record.identity, expected) ? record : void 0;
@@ -240,14 +260,17 @@ var SessionProjectionCache = class extends Service {
240
260
  /** Read a small listing record, deriving it once from an older full checkpoint when needed. */
241
261
  async listingRecord(id) {
242
262
  await this.writes;
263
+ if (this.deleted.has(id)) return void 0;
243
264
  const signature = this.ctx.sessionProjections.checkpointViewSignature();
244
265
  const stored = await this.requireListingTable().read(id);
245
266
  if (stored?.signature === signature) return stored.checkpoint;
267
+ if (this.deleted.has(id)) return void 0;
246
268
  const record = await this.requireTable().read(id);
247
269
  if (record === void 0) return void 0;
248
270
  const listing = this.listingOf(record, signature);
249
271
  await this.enqueueWrite(async () => {
250
- if (await this.requireTable().read(id) === record) await this.requireListingTable().put(id, listing);
272
+ const current = await this.requireTable().read(id);
273
+ if (!this.deleted.has(id) && current === record) await this.requireListingTable().put(id, listing);
251
274
  }).catch((error) => {
252
275
  this.ctx.logger.warn(`session projection cache: listing write-back for "${id}" failed: ${String(error)}`);
253
276
  });
@@ -402,6 +425,7 @@ var SessionProjectionCache = class extends Service {
402
425
  rows: detached
403
426
  };
404
427
  await this.enqueueWrite(async () => {
428
+ if (this.deleted.has(id)) return;
405
429
  await this.requireTable().put(id, record);
406
430
  const listing = this.listingOf(record, this.ctx.sessionProjections.checkpointViewSignature());
407
431
  await this.requireListingTable().put(id, listing);
@@ -57,6 +57,7 @@ export declare class SessionProjectionCache extends Service {
57
57
  private listingTable?;
58
58
  private writes;
59
59
  private closed;
60
+ private readonly deleted;
60
61
  private readonly dirty;
61
62
  constructor(ctx: Context, config: Config);
62
63
  /** Open both on-demand domains and install the write-behind listeners. */
@@ -45,6 +45,7 @@
45
45
  "@deepseek-ai/dsh-session-projection": "workspace:*",
46
46
  "@deepseek-ai/dsh-storage": "workspace:*",
47
47
  "@deepseek-ai/dsh-storage-domain": "workspace:*",
48
- "@deepseek-ai/dsh-storage-json": "workspace:*"
48
+ "@deepseek-ai/dsh-storage-json": "workspace:*",
49
+ "@deepseek-ai/dsh-workspace": "workspace:*"
49
50
  }
50
51
  }
@@ -331,6 +331,13 @@ var SessionObservationReader = class {
331
331
  cacheCapacity;
332
332
  cache = /* @__PURE__ */ new Map();
333
333
  /**
334
+ * Drop deleted identities while existing observation leases settle independently.
335
+ * @param ids - permanently deleted Session identities.
336
+ */
337
+ forget(ids) {
338
+ for (const id of ids) this.cache.delete(id);
339
+ }
340
+ /**
334
341
  * @param ctx - context carrying Session and optional persistence/projection services.
335
342
  * @param cacheCapacity - maximum unpinned cold observations retained for reuse.
336
343
  */
@@ -1055,6 +1062,12 @@ var SessionQueryEngine = class extends Service {
1055
1062
  if (!Number.isSafeInteger(preparedSessionCacheSize) || preparedSessionCacheSize < 1) throw new SessionQueryError("session-query: preparedSessionCacheSize must be a positive safe integer", "SESSION_QUERY_INVALID_CONFIG");
1056
1063
  this._corpus = new SessionCorpus(ctx, persistedReadConcurrency);
1057
1064
  this._observations = new SessionObservationReader(ctx, preparedSessionCacheSize);
1065
+ ctx.on("session/deleting", ({ sessionIds }) => {
1066
+ this._observations.forget(sessionIds);
1067
+ });
1068
+ ctx.on("session/deleted", (ids) => {
1069
+ this._observations.forget(ids);
1070
+ });
1058
1071
  }
1059
1072
  /**
1060
1073
  * Observe one exact live or prepared Session without a persistence listing preflight.
@@ -50,6 +50,11 @@ export declare class SessionObservationReader {
50
50
  private readonly ctx;
51
51
  private readonly cacheCapacity;
52
52
  private readonly cache;
53
+ /**
54
+ * Drop deleted identities while existing observation leases settle independently.
55
+ * @param ids - permanently deleted Session identities.
56
+ */
57
+ forget(ids: readonly SessionId[]): void;
53
58
  /**
54
59
  * @param ctx - context carrying Session and optional persistence/projection services.
55
60
  * @param cacheCapacity - maximum unpinned cold observations retained for reuse.
@@ -529,6 +529,32 @@ var SqliteSessionQueryEngine = class extends SessionQueryEngine {
529
529
  return () => this._optionalPersistenceFiber.dispose();
530
530
  }, "sessionQuerySqlite.optionalPersistence");
531
531
  ctx.effect(() => async () => this.close(), "sessionQuerySqlite.close");
532
+ const cleanup = (ids) => this._serialized(void 0, async () => {
533
+ if (ids.length === 0 || this.config.openAt === "never") return;
534
+ await this._ensureReady(void 0);
535
+ const db = this._requireDb();
536
+ db.exec("BEGIN IMMEDIATE");
537
+ try {
538
+ for (const id of ids) {
539
+ this._deleteSession("persisted", id);
540
+ this._deleteSession("live", id);
541
+ }
542
+ db.exec("COMMIT");
543
+ } catch (error) {
544
+ db.exec("ROLLBACK");
545
+ throw error;
546
+ }
547
+ this._globalGeneration += 1;
548
+ });
549
+ ctx.on("session/deleting", ({ sessionIds }) => cleanup(sessionIds));
550
+ ctx.on("session/deleted", (ids) => {
551
+ cleanup(ids).catch((error) => {
552
+ ctx.logger.warn(`session query: deletion cleanup failed: ${String(error)}`);
553
+ });
554
+ });
555
+ ctx.inject(["workspaceRegistry"], async (ctx) => {
556
+ await cleanup(ctx.workspaceRegistry.deletedSessionIds);
557
+ });
532
558
  }
533
559
  /** Open eagerly only when activation owns the configured readiness boundary. */
534
560
  async [Service.init]() {
@@ -47,6 +47,7 @@
47
47
  "@deepseek-ai/dsh-session-persistence-jsonl": "workspace:*",
48
48
  "@deepseek-ai/dsh-session-query": "workspace:*",
49
49
  "@deepseek-ai/cordis": "workspace:~",
50
- "@deepseek-ai/dsh-session-projection": "workspace:*"
50
+ "@deepseek-ai/dsh-session-projection": "workspace:*",
51
+ "@deepseek-ai/dsh-workspace": "workspace:*"
51
52
  }
52
53
  }
@@ -402,11 +402,12 @@ var SettingsForms = class extends Service {
402
402
  get documentPath() {
403
403
  return this.ownerContext.configEditor.documentPath;
404
404
  }
405
- /** Locate the profile patch for native editing.
406
- * @returns The existing profile patch path.
405
+ /** Locate and materialize the owning patch for native editing.
406
+ * @param namespace Optional namespace; shared entries resolve to the home-level document.
407
+ * @returns The existing owning patch path.
407
408
  */
408
- prepareDocument() {
409
- return Promise.resolve(this.documentPath);
409
+ prepareDocument(namespace) {
410
+ return this.ownerContext.configEditor.prepareDocument(namespace);
410
411
  }
411
412
  /** Read active plugin schemas and their live values.
412
413
  * @param options Redaction required for remote callers.
@@ -85,10 +85,11 @@ export declare class SettingsForms extends Service {
85
85
  get writable(): boolean;
86
86
  /** Current profile patch shown by the native configuration editor. */
87
87
  get documentPath(): string;
88
- /** Locate the profile patch for native editing.
89
- * @returns The existing profile patch path.
88
+ /** Locate and materialize the owning patch for native editing.
89
+ * @param namespace Optional namespace; shared entries resolve to the home-level document.
90
+ * @returns The existing owning patch path.
90
91
  */
91
- prepareDocument(): Promise<string>;
92
+ prepareDocument(namespace?: string): Promise<string>;
92
93
  /** Read active plugin schemas and their live values.
93
94
  * @param options Redaction required for remote callers.
94
95
  * @returns Forms keyed by unique profile entry ids.
@@ -261,10 +261,11 @@ export class SettingsForms extends Service {
261
261
  get writable() { return true; }
262
262
  /** Current profile patch shown by the native configuration editor. */
263
263
  get documentPath() { return this.ownerContext.configEditor.documentPath; }
264
- /** Locate the profile patch for native editing.
265
- * @returns The existing profile patch path.
264
+ /** Locate and materialize the owning patch for native editing.
265
+ * @param namespace Optional namespace; shared entries resolve to the home-level document.
266
+ * @returns The existing owning patch path.
266
267
  */
267
- prepareDocument() { return Promise.resolve(this.documentPath); }
268
+ prepareDocument(namespace) { return this.ownerContext.configEditor.prepareDocument(namespace); }
268
269
  /** Read active plugin schemas and their live values.
269
270
  * @param options Redaction required for remote callers.
270
271
  * @returns Forms keyed by unique profile entry ids.
@@ -86,6 +86,10 @@ export interface KvUnit {
86
86
  tables: Record<string, Record<string, unknown>>;
87
87
  global: unknown;
88
88
  }>;
89
+ /** Reload committed medium state before a domain refresh. Unsupported backends retain their snapshot. */
90
+ refresh?(): Promise<void>;
91
+ /** Hold a cross-process writer lock across a complete logical operation, including all its writes. */
92
+ exclusive?<T>(operation: () => Promise<T>): Promise<T>;
89
93
  /**
90
94
  * Read one record without loading other records. Backends without keyed
91
95
  * reads omit this member; on-demand domains require it.
@@ -1,5 +1,7 @@
1
1
  import z from "@deepseek-ai/schemastery";
2
2
  import { UNIT_NAME_RE, storageBackendServiceKey } from "@deepseek-ai/dsh-storage";
3
+ import { AsyncLocalStorage } from "node:async_hooks";
4
+ import { isDeepStrictEqual } from "node:util";
3
5
  //#region lib/types/error.js
4
6
  /**
5
7
  * Error vocabulary of the domain data form.
@@ -109,6 +111,7 @@ const noop = () => {};
109
111
  */
110
112
  var DomainImpl = class {
111
113
  ctx;
114
+ spec;
112
115
  unit;
113
116
  onClosed;
114
117
  /** Domain name from the spec. */
@@ -123,6 +126,7 @@ var DomainImpl = class {
123
126
  /** Set when close finishes (chain drained, unit closed): reads reject from here on. */
124
127
  closed = false;
125
128
  disposal;
129
+ operationScope = new AsyncLocalStorage();
126
130
  /**
127
131
  * @param ctx - Context that carries `domain/changed` emissions.
128
132
  * @param spec - The domain declaration.
@@ -138,6 +142,7 @@ var DomainImpl = class {
138
142
  */
139
143
  constructor(ctx, spec, unit, records, globalValue, onClosed, readStored) {
140
144
  this.ctx = ctx;
145
+ this.spec = spec;
141
146
  this.unit = unit;
142
147
  this.onClosed = onClosed;
143
148
  this.name = spec.name;
@@ -191,6 +196,53 @@ var DomainImpl = class {
191
196
  if (table === void 0) throw new Error(`domain '${this.name}' declares no table '${name}'`);
192
197
  return table;
193
198
  }
199
+ /** Reload eager records atomically in memory; a malformed record leaves the previous projection untouched.
200
+ * @returns Whether persisted records or global values changed the in-memory projection.
201
+ */
202
+ refresh() {
203
+ return this.enqueue(async () => {
204
+ await this.unit.refresh?.();
205
+ const snapshot = await this.unit.loadAll();
206
+ const records = /* @__PURE__ */ new Map();
207
+ let global;
208
+ try {
209
+ for (const [name, tableSpec] of Object.entries(this.spec.tables)) {
210
+ const parsed = /* @__PURE__ */ new Map();
211
+ for (const [key, raw] of Object.entries(snapshot.tables[name] ?? {})) parsed.set(key, tableSpec.valueSchema.parse(raw));
212
+ records.set(name, parsed);
213
+ }
214
+ global = this.spec.global === void 0 ? void 0 : snapshot.global === null ? this.spec.global.initial : this.spec.global.schema.parse(snapshot.global);
215
+ } catch (error) {
216
+ throw new DomainError("invalid-record", `domain '${this.name}': refreshed snapshot failed validation`, { cause: error });
217
+ }
218
+ let changed = !isDeepStrictEqual(this.globalValue, global);
219
+ for (const [name, next] of records) {
220
+ const table = this.tables.get(name);
221
+ if (table === void 0) throw new Error(`domain '${this.name}' declares no table '${name}'`);
222
+ changed = table.replace(next) || changed;
223
+ }
224
+ this.globalValue = global;
225
+ return changed;
226
+ });
227
+ }
228
+ /** Nested table/global operations run on this queue slot, not behind their own awaiting parent.
229
+ * @param operation Work executed under the domain queue and backend writer lock.
230
+ * @returns The operation result after the locked work settles.
231
+ */
232
+ exclusive(operation) {
233
+ if (this.operationScope.getStore()?.active) return operation();
234
+ return this.enqueue(async () => {
235
+ const run = async () => {
236
+ const scope = { active: true };
237
+ try {
238
+ return await this.operationScope.run(scope, operation);
239
+ } finally {
240
+ scope.active = false;
241
+ }
242
+ };
243
+ return await (this.unit.exclusive === void 0 ? run() : this.unit.exclusive(run));
244
+ });
245
+ }
194
246
  /**
195
247
  * Close this domain: reject new writes immediately, drain already-queued
196
248
  * writes (their events still emit), close the unit, then free the name via
@@ -221,6 +273,7 @@ var DomainImpl = class {
221
273
  }
222
274
  }
223
275
  enqueue(job) {
276
+ if (this.operationScope.getStore()?.active) return job();
224
277
  if (this.disposing) return Promise.reject(new DomainError("closed", `domain '${this.name}' is closed`));
225
278
  const result = this.chain.then(job);
226
279
  this.chain = result.then(noop, noop);
@@ -241,6 +294,13 @@ var KvTableImpl = class {
241
294
  this.tableName = tableName;
242
295
  this.records = records;
243
296
  }
297
+ replace(next) {
298
+ if (isDeepStrictEqual(this.records, next)) return false;
299
+ this.records.clear();
300
+ for (const [key, value] of next) this.records.set(key, value);
301
+ this.loaded.clear();
302
+ return true;
303
+ }
244
304
  read(key) {
245
305
  return this.host.enqueue(async () => {
246
306
  if (this.host.readStored !== void 0 && !this.loaded.has(key)) {
@@ -277,9 +337,13 @@ var KvTableImpl = class {
277
337
  }
278
338
  delete(key) {
279
339
  return this.host.enqueue(async () => {
280
- if (!this.records.has(key)) return false;
340
+ if (!(this.records.has(key) || this.host.readStored !== void 0 && await this.host.unit.readRecord(this.tableName, key) !== void 0)) {
341
+ this.loaded.add(key);
342
+ return false;
343
+ }
281
344
  await this.host.unit.deleteRecord(this.tableName, key);
282
345
  this.records.delete(key);
346
+ this.loaded.add(key);
283
347
  this.host.emitChanged({
284
348
  domain: this.host.domainName,
285
349
  table: this.tableName,
@@ -94,6 +94,10 @@ export interface Domain<S extends DomainSpec> {
94
94
  readonly name: string;
95
95
  /** Global singleton handle; a spec without `global` has no usable handle (`never`). */
96
96
  readonly global: DomainGlobalHandleOf<S>;
97
+ /** Reload and validate the complete medium snapshot. No events emit; the owner publishes its refreshed projection. */
98
+ refresh(): Promise<boolean>;
99
+ /** Serialize a logical operation locally and, where supported, across processes. Refresh inside the operation before writing. */
100
+ exclusive<T>(operation: () => Promise<T>): Promise<T>;
97
101
  /**
98
102
  * Resolve one declared table handle. Handles are stable — repeated calls
99
103
  * return the same instance.
@@ -111,8 +115,8 @@ export interface Domain<S extends DomainSpec> {
111
115
  */
112
116
  close(): Promise<void>;
113
117
  }
114
- /** Keyed reads and complete replacements without whole-table enumeration. */
115
- export type RecordTable<K extends string, V> = Pick<KvTable<K, V>, 'read' | 'put'>;
118
+ /** Keyed reads, complete replacements, and removals without whole-table enumeration. */
119
+ export type RecordTable<K extends string, V> = Pick<KvTable<K, V>, 'read' | 'put' | 'delete'>;
116
120
  /** Per-record domain opened without loading its records. No global slot is exposed. */
117
121
  export interface RecordDomain<S extends DomainSpec> {
118
122
  /** Domain name from the spec. */
@@ -135,6 +139,7 @@ export interface RecordDomain<S extends DomainSpec> {
135
139
  */
136
140
  export declare class DomainImpl {
137
141
  private readonly ctx;
142
+ private readonly spec;
138
143
  private readonly unit;
139
144
  private readonly onClosed;
140
145
  /** Domain name from the spec. */
@@ -149,6 +154,7 @@ export declare class DomainImpl {
149
154
  /** Set when close finishes (chain drained, unit closed): reads reject from here on. */
150
155
  private closed;
151
156
  private disposal?;
157
+ private readonly operationScope;
152
158
  /**
153
159
  * @param ctx - Context that carries `domain/changed` emissions.
154
160
  * @param spec - The domain declaration.
@@ -172,6 +178,15 @@ export declare class DomainImpl {
172
178
  * @returns the stable table handle.
173
179
  */
174
180
  table(name: string): KvTable<string, unknown>;
181
+ /** Reload eager records atomically in memory; a malformed record leaves the previous projection untouched.
182
+ * @returns Whether persisted records or global values changed the in-memory projection.
183
+ */
184
+ refresh(): Promise<boolean>;
185
+ /** Nested table/global operations run on this queue slot, not behind their own awaiting parent.
186
+ * @param operation Work executed under the domain queue and backend writer lock.
187
+ * @returns The operation result after the locked work settles.
188
+ */
189
+ exclusive<T>(operation: () => Promise<T>): Promise<T>;
175
190
  /**
176
191
  * Close this domain: reject new writes immediately, drain already-queued
177
192
  * writes (their events still emit), close the unit, then free the name via
@@ -3,6 +3,7 @@ import z from "@deepseek-ai/schemastery";
3
3
  import { StorageError, UNIT_NAME_RE, storageBackendServiceKey } from "@deepseek-ai/dsh-storage";
4
4
  import { dirname, join } from "node:path";
5
5
  import { randomUUID } from "node:crypto";
6
+ import { withFileLock } from "@deepseek-ai/dsh-atomic-write";
6
7
  //#region lib/types/atomic.js
7
8
  /**
8
9
  * Atomic whole-file replacement for the JSON backend.
@@ -203,6 +204,30 @@ var SingleJsonUnit = class {
203
204
  this.state = state;
204
205
  this.onClose = onClose;
205
206
  }
207
+ async refresh() {
208
+ this.assertOpen();
209
+ let text;
210
+ try {
211
+ text = await readFile(this.path, "utf8");
212
+ } catch (error) {
213
+ if (error.code !== "ENOENT") throw error;
214
+ }
215
+ this.state = text === void 0 ? {
216
+ version: this.descriptor.version,
217
+ global: null,
218
+ tables: new Map(this.descriptor.tables.map((table) => [table, /* @__PURE__ */ new Map()]))
219
+ } : parse(text, this.descriptor);
220
+ }
221
+ async exclusive(operation) {
222
+ this.assertOpen();
223
+ const pending = withFileLock(this.path, operation, { waitMs: 1e4 });
224
+ this.inFlight.add(pending);
225
+ try {
226
+ return await pending;
227
+ } finally {
228
+ this.inFlight.delete(pending);
229
+ }
230
+ }
206
231
  async loadAll() {
207
232
  this.assertOpen();
208
233
  const tables = {};
@@ -31,6 +31,7 @@
31
31
  "@deepseek-ai/cordis": "workspace:~"
32
32
  },
33
33
  "dependencies": {
34
+ "@deepseek-ai/dsh-atomic-write": "workspace:*",
34
35
  "@deepseek-ai/schemastery": "workspace:~"
35
36
  },
36
37
  "devDependencies": {
@@ -12,8 +12,8 @@ declare const CONTROL_ID_SCHEMAS: {
12
12
  childSessionId: z.ZodString;
13
13
  mode: z.ZodLiteral<"continuable">;
14
14
  delivery: z.ZodEnum<{
15
- steer: "steer";
16
15
  queue: "queue";
16
+ steer: "steer";
17
17
  }>;
18
18
  }, z.core.$strip>;
19
19
  readonly 'subagent.interrupt': z.ZodObject<{