dsh-plugin-dev-kb 1.1.0 → 1.4.0

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 (370) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.en.md +14 -8
  3. package/README.md +15 -9
  4. package/docs/banner.svg +25 -0
  5. package/kb/INDEX.md +23 -19
  6. package/kb/README.md +8 -6
  7. package/kb/extra/AGENTS.md +11 -10
  8. package/kb/extra/cookbook/adding-a-remote-api.md +2 -2
  9. package/kb/extra/cookbook/adding-a-remote-api.zh.md +2 -2
  10. package/kb/extra/cookbook/adding-a-session-format-version.md +151 -0
  11. package/kb/extra/cookbook/adding-a-session-format-version.zh.md +151 -0
  12. package/kb/extra/cookbook/adding-a-vendored-package.md +1 -1
  13. package/kb/extra/cookbook/adding-a-vendored-package.zh.md +1 -1
  14. package/kb/extra/cookbook/responding-to-pr-review-on-a-stack.md +1 -1
  15. package/kb/extra/cookbook/responding-to-pr-review-on-a-stack.zh.md +1 -1
  16. package/kb/extra/cookbook/reviewing-persistence-type-changes.md +120 -0
  17. package/kb/extra/cookbook/reviewing-persistence-type-changes.zh.md +120 -0
  18. package/kb/extra/deepseek-llm-api-wire-extensions.md +19 -20
  19. package/kb/extra/deepseek-llm-api-wire-extensions.zh.md +18 -19
  20. package/kb/extra/development.md +37 -10
  21. package/kb/extra/development.zh.md +37 -10
  22. package/kb/extra/event-producer-consumer.md +90 -67
  23. package/kb/extra/event-producer-consumer.zh.md +91 -68
  24. package/kb/extra/glossary.md +1 -1
  25. package/kb/extra/glossary.zh.md +1 -1
  26. package/kb/extra/i18n/README.md +16 -7
  27. package/kb/extra/i18n/README.zh.md +17 -8
  28. package/kb/extra/i18n/terminology.md +4 -4
  29. package/kb/extra/i18n/translation-prompt.md +3 -3
  30. package/kb/extra/module-graph.md +621 -335
  31. package/kb/extra/module-graph.zh.md +621 -335
  32. package/kb/extra/persistence-changes/2026-09-11-initial.md +280 -0
  33. package/kb/extra/persistence-changes/2026-09-11-initial.zh.md +280 -0
  34. package/kb/extra/persistence-changes/2026-09-12-auto-review-error-metadata.md +52 -0
  35. package/kb/extra/persistence-changes/2026-09-12-auto-review-error-metadata.zh.md +52 -0
  36. package/kb/extra/persistence-changes/2026-09-14-image-offload.md +96 -0
  37. package/kb/extra/persistence-changes/2026-09-14-image-offload.zh.md +96 -0
  38. package/kb/extra/persistence-changes/2026-09-14-workspace-changes-event.md +48 -0
  39. package/kb/extra/persistence-changes/2026-09-14-workspace-changes-event.zh.md +48 -0
  40. package/kb/extra/persistence-changes/2026-09-16-session-format-v4.md +120 -0
  41. package/kb/extra/persistence-changes/2026-09-16-session-format-v4.zh.md +120 -0
  42. package/kb/extra/persistence-changes/2026-09-18-schedule-optional-title.md +48 -0
  43. package/kb/extra/persistence-changes/2026-09-18-schedule-optional-title.zh.md +48 -0
  44. package/kb/extra/persistence-changes/2026-09-20-unknown-child-catalog.md +48 -0
  45. package/kb/extra/persistence-changes/2026-09-20-unknown-child-catalog.zh.md +48 -0
  46. package/kb/extra/persistence-changes/2026-09-21-user-question-reply.md +60 -0
  47. package/kb/extra/persistence-changes/2026-09-21-user-question-reply.zh.md +60 -0
  48. package/kb/extra/persistence-changes/README.md +88 -0
  49. package/kb/extra/persistence-changes/README.zh.md +88 -0
  50. package/kb/extra/persistence-changes/historical-formats/README.md +75 -0
  51. package/kb/extra/persistence-changes/historical-formats/README.zh.md +75 -0
  52. package/kb/extra/persistence-changes/historical-formats/v0.md +5105 -0
  53. package/kb/extra/persistence-changes/historical-formats/v0.zh.md +5105 -0
  54. package/kb/extra/persistence-changes/historical-formats/v1.md +5107 -0
  55. package/kb/extra/persistence-changes/historical-formats/v1.zh.md +5107 -0
  56. package/kb/extra/persistence-changes/historical-formats/v2.md +5362 -0
  57. package/kb/extra/persistence-changes/historical-formats/v2.zh.md +5362 -0
  58. package/kb/extra/persistence-changes/historical-formats/v3.md +5634 -0
  59. package/kb/extra/persistence-changes/historical-formats/v3.zh.md +5634 -0
  60. package/kb/extra/persistence-changes/releases/README.md +103 -0
  61. package/kb/extra/persistence-changes/releases/README.zh.md +103 -0
  62. package/kb/extra/persistence-changes/releases/dsh-v0.0.1-rc.1.md +201 -0
  63. package/kb/extra/persistence-changes/releases/dsh-v0.0.1-rc.1.zh.md +201 -0
  64. package/kb/extra/persistence-changes/releases/dsh-v0.0.1-rc.2.md +261 -0
  65. package/kb/extra/persistence-changes/releases/dsh-v0.0.1-rc.2.zh.md +261 -0
  66. package/kb/extra/persistence-changes/releases/dsh-v0.0.1-rc.3.md +126 -0
  67. package/kb/extra/persistence-changes/releases/dsh-v0.0.1-rc.3.zh.md +126 -0
  68. package/kb/extra/persistence-changes/releases/dsh-v0.0.1-rc.4.md +75 -0
  69. package/kb/extra/persistence-changes/releases/dsh-v0.0.1-rc.4.zh.md +75 -0
  70. package/kb/extra/persistence-changes/releases/dsh-v0.0.1-rc.5.md +75 -0
  71. package/kb/extra/persistence-changes/releases/dsh-v0.0.1-rc.5.zh.md +75 -0
  72. package/kb/extra/persistence-changes/releases/dsh-v0.1.0-rc.1.md +75 -0
  73. package/kb/extra/persistence-changes/releases/dsh-v0.1.0-rc.1.zh.md +75 -0
  74. package/kb/extra/persistence-changes/releases/dsh-v0.1.0-rc.2.md +75 -0
  75. package/kb/extra/persistence-changes/releases/dsh-v0.1.0-rc.2.zh.md +75 -0
  76. package/kb/extra/persistence-changes/releases/dsh-v0.1.0-rc.3.md +75 -0
  77. package/kb/extra/persistence-changes/releases/dsh-v0.1.0-rc.3.zh.md +75 -0
  78. package/kb/extra/persistence-changes/releases/dsh-v0.1.0-rc.5.md +75 -0
  79. package/kb/extra/persistence-changes/releases/dsh-v0.1.0-rc.5.zh.md +75 -0
  80. package/kb/extra/persistence-changes/releases/dsh-v0.1.0-rc.6.md +75 -0
  81. package/kb/extra/persistence-changes/releases/dsh-v0.1.0-rc.6.zh.md +75 -0
  82. package/kb/extra/persistence-changes/releases/dsh-v0.1.0-rc.7.md +82 -0
  83. package/kb/extra/persistence-changes/releases/dsh-v0.1.0-rc.7.zh.md +82 -0
  84. package/kb/extra/persistence-changes/releases/dsh-v0.1.0-rc.8.md +110 -0
  85. package/kb/extra/persistence-changes/releases/dsh-v0.1.0-rc.8.zh.md +110 -0
  86. package/kb/extra/persistence-changes/releases/dsh-v0.1.1-rc.1.md +82 -0
  87. package/kb/extra/persistence-changes/releases/dsh-v0.1.1-rc.1.zh.md +82 -0
  88. package/kb/extra/persistence-changes/releases/dsh-v0.1.1-rc.2.md +119 -0
  89. package/kb/extra/persistence-changes/releases/dsh-v0.1.1-rc.2.zh.md +119 -0
  90. package/kb/extra/persistence-changes/releases/dsh-v0.1.2-alpha.1.md +295 -0
  91. package/kb/extra/persistence-changes/releases/dsh-v0.1.2-alpha.1.zh.md +295 -0
  92. package/kb/extra/persistence-changes/releases/dsh-v0.1.2-alpha.2.md +286 -0
  93. package/kb/extra/persistence-changes/releases/dsh-v0.1.2-alpha.2.zh.md +286 -0
  94. package/kb/extra/persistence-changes/releases/dsh-v0.1.2-alpha.3.md +75 -0
  95. package/kb/extra/persistence-changes/releases/dsh-v0.1.2-alpha.3.zh.md +75 -0
  96. package/kb/extra/persistence-changes/releases/dsh-v0.1.2-alpha.4.md +95 -0
  97. package/kb/extra/persistence-changes/releases/dsh-v0.1.2-alpha.4.zh.md +95 -0
  98. package/kb/extra/persistence-changes/releases/dsh-v0.1.2-alpha.5.md +75 -0
  99. package/kb/extra/persistence-changes/releases/dsh-v0.1.2-alpha.5.zh.md +75 -0
  100. package/kb/extra/persistence-changes/releases/dsh-v0.1.2-rc.1.md +75 -0
  101. package/kb/extra/persistence-changes/releases/dsh-v0.1.2-rc.1.zh.md +75 -0
  102. package/kb/extra/persistence-changes/releases/dsh-v0.1.3-alpha.1.md +154 -0
  103. package/kb/extra/persistence-changes/releases/dsh-v0.1.3-alpha.1.zh.md +154 -0
  104. package/kb/extra/persistence-changes/releases/dsh-v0.1.3-alpha.2.md +86 -0
  105. package/kb/extra/persistence-changes/releases/dsh-v0.1.3-alpha.2.zh.md +86 -0
  106. package/kb/extra/persistence-changes/releases/dsh-v0.1.5-alpha.1.md +139 -0
  107. package/kb/extra/persistence-changes/releases/dsh-v0.1.5-alpha.1.zh.md +139 -0
  108. package/kb/extra/persistence-changes/releases/dsh-v0.1.5-alpha.2.md +95 -0
  109. package/kb/extra/persistence-changes/releases/dsh-v0.1.5-alpha.2.zh.md +95 -0
  110. package/kb/extra/persistence-changes/releases/dsh-v0.1.5-rc.1.md +75 -0
  111. package/kb/extra/persistence-changes/releases/dsh-v0.1.5-rc.1.zh.md +75 -0
  112. package/kb/extra/persistence-changes/releases/dsh-v0.1.5-rc.2.md +75 -0
  113. package/kb/extra/persistence-changes/releases/dsh-v0.1.5-rc.2.zh.md +75 -0
  114. package/kb/extra/rescope.md +2 -2
  115. package/kb/extra/rescope.zh.md +2 -2
  116. package/kb/extra/session-format-status.md +63 -0
  117. package/kb/extra/session-format-status.zh.md +63 -0
  118. package/kb/extra/subsystems/agent-team.md +52 -28
  119. package/kb/extra/subsystems/agent-team.zh.md +52 -28
  120. package/kb/extra/subsystems/attachment.md +19 -9
  121. package/kb/extra/subsystems/attachment.zh.md +19 -9
  122. package/kb/extra/subsystems/boot.md +323 -0
  123. package/kb/extra/subsystems/boot.zh.md +323 -0
  124. package/kb/extra/subsystems/browser-use.md +67 -0
  125. package/kb/extra/subsystems/browser-use.zh.md +67 -0
  126. package/kb/extra/subsystems/claude-code-mods.md +146 -0
  127. package/kb/extra/subsystems/claude-code-mods.zh.md +146 -0
  128. package/kb/extra/subsystems/computer-use.md +56 -0
  129. package/kb/extra/subsystems/computer-use.zh.md +56 -0
  130. package/kb/extra/subsystems/deliverables.md +178 -0
  131. package/kb/extra/subsystems/deliverables.zh.md +178 -0
  132. package/kb/extra/subsystems/extensions.md +6 -4
  133. package/kb/extra/subsystems/extensions.zh.md +6 -4
  134. package/kb/extra/subsystems/feedback.md +165 -31
  135. package/kb/extra/subsystems/feedback.zh.md +165 -31
  136. package/kb/extra/subsystems/mcp.md +139 -0
  137. package/kb/extra/subsystems/mcp.zh.md +139 -0
  138. package/kb/extra/subsystems/office-to-pdf.md +87 -0
  139. package/kb/extra/subsystems/office-to-pdf.zh.md +87 -0
  140. package/kb/extra/subsystems/otel.md +44 -0
  141. package/kb/extra/subsystems/otel.zh.md +44 -0
  142. package/kb/extra/subsystems/product-telemetry.md +79 -0
  143. package/kb/extra/subsystems/product-telemetry.zh.md +79 -0
  144. package/kb/extra/subsystems/ssh.md +135 -0
  145. package/kb/extra/subsystems/ssh.zh.md +135 -0
  146. package/kb/extra/subsystems/todo.md +3 -3
  147. package/kb/extra/subsystems/todo.zh.md +3 -3
  148. package/kb/extra/subsystems/voice-input.md +164 -0
  149. package/kb/extra/subsystems/voice-input.zh.md +164 -0
  150. package/kb/extra/subsystems/webhook.md +3 -3
  151. package/kb/extra/subsystems/webhook.zh.md +1 -1
  152. package/kb/extra/testing.md +5 -4
  153. package/kb/extra/testing.zh.md +5 -4
  154. package/kb/extra/ui-radius.md +115 -0
  155. package/kb/extra/ui-radius.zh.md +115 -0
  156. package/kb/extra/upgrade-guide/v0.1.7-rc.2/schedule-optional-bundle/guide.md +22 -0
  157. package/kb/extra/upgrade-guide/v0.1.7-rc.2/schedule-optional-bundle/guide.zh.md +22 -0
  158. package/kb/extra/upgrade-guide/v0.1.7-rc.2/transcript-view-legacy-normal/guide.md +25 -0
  159. package/kb/extra/upgrade-guide/v0.1.7-rc.2/transcript-view-legacy-normal/guide.zh.md +25 -0
  160. package/kb/extra/upgrade-guide/v0.2.0-rc.2/account-sign-in-errors/guide.md +18 -0
  161. package/kb/extra/upgrade-guide/v0.2.0-rc.2/account-sign-in-errors/guide.zh.md +18 -0
  162. package/kb/extra/upgrade-guide/v0.2.0-rc.2/remove-runtime-invariants/guide.md +23 -0
  163. package/kb/extra/upgrade-guide/v0.2.0-rc.2/remove-runtime-invariants/guide.zh.md +23 -0
  164. package/kb/extra/upgrade-guide/v0.2.0-rc.2/schedule-bundle-retired/guide.md +22 -0
  165. package/kb/extra/upgrade-guide/v0.2.0-rc.2/schedule-bundle-retired/guide.zh.md +22 -0
  166. package/kb/extra/upgrade-guide/v0.2.0-rc.2/subpath-plugin-display-manifest/guide.md +27 -0
  167. package/kb/extra/upgrade-guide/v0.2.0-rc.2/subpath-plugin-display-manifest/guide.zh.md +27 -0
  168. package/kb/extra/web-styling.md +12 -2
  169. package/kb/extra/web-styling.zh.md +12 -2
  170. package/kb/meta/search-index.json +1019 -251
  171. package/kb/meta/site-pages.txt +187 -183
  172. package/kb/meta/source.json +8 -8
  173. package/kb/meta/topics.md +11 -7
  174. package/kb/site/develop/basic/config.md +1 -0
  175. package/kb/site/develop/basic/index.md +1 -0
  176. package/kb/site/develop/basic/publish.md +10 -3
  177. package/kb/site/develop/basic/tool.md +1 -0
  178. package/kb/site/develop/cordis-tutorial/01-first-plugin.md +1 -0
  179. package/kb/site/develop/cordis-tutorial/02-lifecycle-and-effects.md +1 -0
  180. package/kb/site/develop/cordis-tutorial/03-services.md +1 -0
  181. package/kb/site/develop/cordis-tutorial/04-events.md +1 -0
  182. package/kb/site/develop/cordis-tutorial/05-config.md +28 -0
  183. package/kb/site/develop/cordis-tutorial/06-composition-and-hmr.md +3 -2
  184. package/kb/site/develop/cordis-tutorial/07-into-the-harness.md +1 -0
  185. package/kb/site/develop/cordis-tutorial/index.md +1 -0
  186. package/kb/site/develop/framework/events.md +1 -0
  187. package/kb/site/develop/framework/index.md +2 -1
  188. package/kb/site/develop/framework/service.md +1 -0
  189. package/kb/site/develop/practice/dynamic-cordis.md +9 -8
  190. package/kb/site/develop/practice/index.md +1 -0
  191. package/kb/site/develop/practice/llm-adapter.md +2 -1
  192. package/kb/site/en/develop/basic/config.md +1 -0
  193. package/kb/site/en/develop/basic/index.md +1 -0
  194. package/kb/site/en/develop/basic/publish.md +10 -3
  195. package/kb/site/en/develop/basic/tool.md +1 -0
  196. package/kb/site/en/develop/cordis-tutorial/01-first-plugin.md +1 -0
  197. package/kb/site/en/develop/cordis-tutorial/02-lifecycle-and-effects.md +1 -0
  198. package/kb/site/en/develop/cordis-tutorial/03-services.md +1 -0
  199. package/kb/site/en/develop/cordis-tutorial/04-events.md +1 -0
  200. package/kb/site/en/develop/cordis-tutorial/05-config.md +28 -0
  201. package/kb/site/en/develop/cordis-tutorial/06-composition-and-hmr.md +3 -2
  202. package/kb/site/en/develop/cordis-tutorial/07-into-the-harness.md +1 -0
  203. package/kb/site/en/develop/cordis-tutorial/index.md +1 -0
  204. package/kb/site/en/develop/framework/events.md +1 -0
  205. package/kb/site/en/develop/framework/index.md +2 -1
  206. package/kb/site/en/develop/framework/service.md +1 -0
  207. package/kb/site/en/develop/practice/dynamic-cordis.md +9 -8
  208. package/kb/site/en/develop/practice/index.md +1 -0
  209. package/kb/site/en/develop/practice/llm-adapter.md +2 -1
  210. package/kb/site/en/guide/github-review.md +1 -0
  211. package/kb/site/en/guide/mcp-memory.md +1 -0
  212. package/kb/site/en/guide/network-proxy.md +2 -1
  213. package/kb/site/en/guide/providers-custom-form.png +0 -0
  214. package/kb/site/en/guide/providers-models-page.png +0 -0
  215. package/kb/site/en/guide/providers.md +98 -83
  216. package/kb/site/en/guide/public-deployments.md +36 -0
  217. package/kb/site/en/guide/python-sdk.md +60 -23
  218. package/kb/site/en/guide/quickstart.md +2 -0
  219. package/kb/site/en/guide/schedule.md +70 -11
  220. package/kb/site/en/reference/agent-lifecycle.md +13 -5
  221. package/kb/site/en/reference/api-gateway.md +13 -11
  222. package/kb/site/en/reference/capability-seams.md +187 -62
  223. package/kb/site/en/reference/config-catalog.md +1887 -819
  224. package/kb/site/en/reference/cookbook/adding-a-package.md +57 -3
  225. package/kb/site/en/reference/cookbook/adding-a-settings-card.md +35 -64
  226. package/kb/site/en/reference/cookbook/adding-a-tool.md +5 -4
  227. package/kb/site/en/reference/cookbook/adding-an-llm-adapter.md +1 -0
  228. package/kb/site/en/reference/cookbook/extension-cookbook.md +7 -6
  229. package/kb/site/en/reference/cordis-api/context.md +1 -0
  230. package/kb/site/en/reference/cordis-api/events.md +1 -0
  231. package/kb/site/en/reference/cordis-api/fiber.md +4 -3
  232. package/kb/site/en/reference/cordis-api/inherited.md +16 -16
  233. package/kb/site/en/reference/cordis-api/registry.md +1 -0
  234. package/kb/site/en/reference/cordis-api/service.md +1 -0
  235. package/kb/site/en/reference/cordis-primer.md +1 -0
  236. package/kb/site/en/reference/index.md +32 -15
  237. package/kb/site/en/reference/persistence-catalog.md +7787 -81
  238. package/kb/site/en/reference/subsystems/approval.md +3 -2
  239. package/kb/site/en/reference/subsystems/client-modules.md +30 -13
  240. package/kb/site/en/reference/subsystems/client-resources.md +96 -0
  241. package/kb/site/en/reference/subsystems/commands.md +6 -1
  242. package/kb/site/en/reference/subsystems/compaction.md +50 -3
  243. package/kb/site/en/reference/subsystems/conversation.md +36 -6
  244. package/kb/site/en/reference/subsystems/core.md +174 -271
  245. package/kb/site/en/reference/subsystems/credentials.md +169 -5
  246. package/kb/site/en/reference/subsystems/filesystem.md +26 -0
  247. package/kb/site/en/reference/subsystems/goal.md +39 -2
  248. package/kb/site/en/reference/subsystems/index.md +18 -5
  249. package/kb/site/en/reference/subsystems/jobs.md +337 -127
  250. package/kb/site/en/reference/subsystems/llm-streaming.md +93 -43
  251. package/kb/site/en/reference/subsystems/lsp.md +2 -1
  252. package/kb/site/en/reference/subsystems/permission-presets.md +66 -29
  253. package/kb/site/en/reference/subsystems/persistence.md +40 -18
  254. package/kb/site/en/reference/subsystems/plan.md +2 -1
  255. package/kb/site/en/reference/subsystems/ptc-runtime.md +236 -0
  256. package/kb/site/en/reference/subsystems/sandbox.md +7 -5
  257. package/kb/site/en/reference/subsystems/schedule.md +392 -33
  258. package/kb/site/en/reference/subsystems/scope.md +2 -1
  259. package/kb/site/en/reference/subsystems/session-projection.md +22 -19
  260. package/kb/site/en/reference/subsystems/session-query.md +1 -0
  261. package/kb/site/en/reference/subsystems/session-reference.md +12 -6
  262. package/kb/site/en/reference/subsystems/session-telemetry.md +27 -8
  263. package/kb/site/en/reference/subsystems/session-title.md +6 -5
  264. package/kb/site/en/reference/subsystems/session.md +258 -118
  265. package/kb/site/en/reference/subsystems/settings.md +43 -292
  266. package/kb/site/en/reference/subsystems/shell.md +44 -32
  267. package/kb/site/en/reference/subsystems/sidebar-right.md +162 -0
  268. package/kb/site/en/reference/subsystems/skills.md +5 -6
  269. package/kb/site/en/reference/subsystems/slots.md +68 -39
  270. package/kb/site/en/reference/subsystems/spill.md +15 -7
  271. package/kb/site/en/reference/subsystems/storage.md +2 -2
  272. package/kb/site/en/reference/subsystems/subagent.md +65 -72
  273. package/kb/site/en/reference/subsystems/subprocess.md +42 -44
  274. package/kb/site/en/reference/subsystems/system-prompt.md +7 -2
  275. package/kb/site/en/reference/subsystems/terminal.md +1 -0
  276. package/kb/site/en/reference/subsystems/token-meter.md +3 -1
  277. package/kb/site/en/reference/subsystems/tools.md +44 -16
  278. package/kb/site/en/reference/subsystems/typert.md +153 -10
  279. package/kb/site/en/reference/subsystems/user-questions.md +131 -1
  280. package/kb/site/en/reference/subsystems/web-client.md +15 -9
  281. package/kb/site/en/reference/subsystems/web-server.md +74 -1
  282. package/kb/site/en/reference/subsystems/web.md +1 -0
  283. package/kb/site/en/reference/subsystems/workflow.md +10 -9
  284. package/kb/site/en/reference/subsystems/workspace.md +343 -4
  285. package/kb/site/en/reference/tool-catalog.md +806 -311
  286. package/kb/site/en/reference/tool-execution-pipeline.md +9 -5
  287. package/kb/site/guide/github-review.md +1 -0
  288. package/kb/site/guide/mcp-memory.md +1 -0
  289. package/kb/site/guide/network-proxy.md +2 -1
  290. package/kb/site/guide/providers-custom-form.zh.png +0 -0
  291. package/kb/site/guide/providers-models-page.zh.png +0 -0
  292. package/kb/site/guide/providers.md +109 -94
  293. package/kb/site/guide/public-deployments.md +36 -0
  294. package/kb/site/guide/python-sdk.md +60 -23
  295. package/kb/site/guide/quickstart.md +2 -0
  296. package/kb/site/guide/schedule.md +70 -11
  297. package/kb/site/reference/agent-lifecycle.md +13 -5
  298. package/kb/site/reference/api-gateway.md +13 -11
  299. package/kb/site/reference/capability-seams.md +187 -62
  300. package/kb/site/reference/config-catalog.md +1889 -820
  301. package/kb/site/reference/cookbook/adding-a-package.md +55 -3
  302. package/kb/site/reference/cookbook/adding-a-settings-card.md +35 -64
  303. package/kb/site/reference/cookbook/adding-a-tool.md +5 -4
  304. package/kb/site/reference/cookbook/adding-an-llm-adapter.md +1 -0
  305. package/kb/site/reference/cookbook/extension-cookbook.md +7 -6
  306. package/kb/site/reference/cordis-api/context.md +1 -0
  307. package/kb/site/reference/cordis-api/events.md +1 -0
  308. package/kb/site/reference/cordis-api/fiber.md +4 -3
  309. package/kb/site/reference/cordis-api/inherited.md +16 -16
  310. package/kb/site/reference/cordis-api/registry.md +1 -0
  311. package/kb/site/reference/cordis-api/service.md +1 -0
  312. package/kb/site/reference/cordis-primer.md +1 -0
  313. package/kb/site/reference/index.md +32 -15
  314. package/kb/site/reference/persistence-catalog.md +7791 -85
  315. package/kb/site/reference/subsystems/approval.md +3 -2
  316. package/kb/site/reference/subsystems/client-modules.md +30 -13
  317. package/kb/site/reference/subsystems/client-resources.md +96 -0
  318. package/kb/site/reference/subsystems/commands.md +6 -1
  319. package/kb/site/reference/subsystems/compaction.md +50 -3
  320. package/kb/site/reference/subsystems/conversation.md +35 -5
  321. package/kb/site/reference/subsystems/core.md +174 -271
  322. package/kb/site/reference/subsystems/credentials.md +169 -5
  323. package/kb/site/reference/subsystems/filesystem.md +26 -0
  324. package/kb/site/reference/subsystems/goal.md +39 -2
  325. package/kb/site/reference/subsystems/index.md +28 -15
  326. package/kb/site/reference/subsystems/jobs.md +336 -126
  327. package/kb/site/reference/subsystems/llm-streaming.md +93 -43
  328. package/kb/site/reference/subsystems/lsp.md +2 -1
  329. package/kb/site/reference/subsystems/permission-presets.md +66 -29
  330. package/kb/site/reference/subsystems/persistence.md +40 -18
  331. package/kb/site/reference/subsystems/plan.md +2 -1
  332. package/kb/site/reference/subsystems/ptc-runtime.md +236 -0
  333. package/kb/site/reference/subsystems/sandbox.md +7 -5
  334. package/kb/site/reference/subsystems/schedule.md +392 -33
  335. package/kb/site/reference/subsystems/scope.md +2 -1
  336. package/kb/site/reference/subsystems/session-projection.md +22 -19
  337. package/kb/site/reference/subsystems/session-query.md +1 -0
  338. package/kb/site/reference/subsystems/session-reference.md +12 -6
  339. package/kb/site/reference/subsystems/session-telemetry.md +27 -8
  340. package/kb/site/reference/subsystems/session-title.md +6 -5
  341. package/kb/site/reference/subsystems/session.md +258 -118
  342. package/kb/site/reference/subsystems/settings.md +43 -292
  343. package/kb/site/reference/subsystems/shell.md +44 -32
  344. package/kb/site/reference/subsystems/sidebar-right.md +162 -0
  345. package/kb/site/reference/subsystems/skills.md +5 -6
  346. package/kb/site/reference/subsystems/slots.md +68 -39
  347. package/kb/site/reference/subsystems/spill.md +15 -7
  348. package/kb/site/reference/subsystems/storage.md +2 -2
  349. package/kb/site/reference/subsystems/subagent.md +64 -71
  350. package/kb/site/reference/subsystems/subprocess.md +42 -44
  351. package/kb/site/reference/subsystems/system-prompt.md +7 -2
  352. package/kb/site/reference/subsystems/terminal.md +1 -0
  353. package/kb/site/reference/subsystems/token-meter.md +3 -1
  354. package/kb/site/reference/subsystems/tools.md +44 -16
  355. package/kb/site/reference/subsystems/typert.md +153 -10
  356. package/kb/site/reference/subsystems/user-questions.md +132 -2
  357. package/kb/site/reference/subsystems/web-client.md +15 -9
  358. package/kb/site/reference/subsystems/web-server.md +74 -1
  359. package/kb/site/reference/subsystems/web.md +1 -0
  360. package/kb/site/reference/subsystems/workflow.md +10 -9
  361. package/kb/site/reference/subsystems/workspace.md +343 -4
  362. package/kb/site/reference/tool-catalog.md +810 -315
  363. package/kb/site/reference/tool-execution-pipeline.md +9 -5
  364. package/lib/index.js +25 -44
  365. package/package.json +3 -2
  366. package/skills/dsh-plugin-dev-kb.md +6 -5
  367. package/kb/site/en/reference/subsystems/code-runtime.md +0 -198
  368. package/kb/site/en/reference/subsystems/invariants.md +0 -91
  369. package/kb/site/reference/subsystems/code-runtime.md +0 -198
  370. package/kb/site/reference/subsystems/invariants.md +0 -91
@@ -1,5 +1,6 @@
1
1
  ---
2
2
  editSource: "docs/subsystems/session.zh.md"
3
+ rawMarkdownPath: "reference/subsystems/session.md"
3
4
  outline: [2,3]
4
5
  ---
5
6
 
@@ -14,8 +15,8 @@ outline: [2,3]
14
15
  仅追加的事件类型。可通过声明合并扩展:插件通过 declaration merging 声明额外的事件类型。例如[压缩(compaction) seam](./compaction.md) 添加了 `compaction/start` / `compaction/summary` / `compaction/end`,`@deepseek-ai/dsh-hook-protocol` 为钩子桥接添加了仅记录日志的 `hook/invoked` / `hook/result` 记录。与 `compaction/*` 一样,这些都不是 `SurfaceEventType`(没有 `surfaceOp`)。生成的[持久化日志事件目录](../persistence-catalog.md)列举了所有成员(核心与合并扩展的),包含其 payload、surface 标记与声明位置。
15
16
 
16
17
  ```ts type-equiv
17
- /** A user-role specialization of the one shared message representation. */
18
- interface UserMessage extends Message {
18
+ /** A user-role specialization of the shared message representation. */
19
+ interface UserMessage extends MessageBase {
19
20
  readonly role: 'user'
20
21
  }
21
22
  ```
@@ -56,6 +57,27 @@ interface SessionEventMap {
56
57
  * project their `content` verbatim; `source` tells them apart.
57
58
  */
58
59
  'user/message': UserMessage
60
+ /** An incremental agent session change admitted at the named turn and step. */
61
+ 'developer/message': {
62
+ turn: number
63
+ step: number
64
+ message: DeveloperMessage
65
+ /** Earlier request/header defining every tool addition; required exactly when additions are present. */
66
+ headerSeq?: SessionSeq
67
+ }
68
+ /**
69
+ * The rendered system prompt on the model-visible surface. The loop appends
70
+ * the first one as surface node 0 before the step's first `user/message`.
71
+ * A prepared in-history route can append nonempty changes in a continuing
72
+ * series. An incapable route or new series normalizes text to the first system
73
+ * node. Normalization empties nonempty later nodes, then rewrites the head if
74
+ * needed, through logged per-node replacements. An empty rendering always
75
+ * clears all active system nodes, leaving no older instructions model-visible.
76
+ * Empty later nodes are dormant and project to no message; an empty head with
77
+ * no active later node records "no system prompt". Restored nonempty text follows
78
+ * the same route and series rule; empty nodes never restore older text.
79
+ */
80
+ 'system/message': { turn: number; step: number; message: SystemMessage }
59
81
  /**
60
82
  * Assembled assistant message for one step (derived history uses this).
61
83
  * Carries the step's `usage` when the adapter reported token accounting, so
@@ -89,7 +111,9 @@ interface SessionEventMap {
89
111
  'tool/call': { turn: number; step: number; callId: ToolCallId; name: string; arguments: string }
90
112
  /**
91
113
  * A completed tool call's model-facing result, optional internal failure
92
- * identity, and optional tool-private `meta` presentation payload. `meta` is
114
+ * identity and user-facing reason, and optional tool-private `meta`
115
+ * presentation payload. The reason remains outside the model-facing message.
116
+ * `meta` is
93
117
  * opaque to the core (the producing tool owns its shape and reads it back in
94
118
  * `presentResult`) but MUST be JSON-serializable: `Session.append`
95
119
  * runtime-validates all event data with `isJsonValue`, so a non-serializable
@@ -102,7 +126,11 @@ interface SessionEventMap {
102
126
  turn: number
103
127
  step: number
104
128
  message: ToolResultMessage
105
- error?: { name: string; code: string }
129
+ /**
130
+ * Optional failure identity and raw user-facing reason, outside model content;
131
+ * allowed only when the message has `isError: true`.
132
+ */
133
+ error?: { name: string; code: string; reason?: string }
106
134
  meta?: JsonValue
107
135
  }
108
136
  /**
@@ -112,27 +140,31 @@ interface SessionEventMap {
112
140
  'request/header': {
113
141
  header: EpochHeader
114
142
  reason: RequestHeaderReason
115
- /** A changed header also begins a distinct model-message series. */
143
+ /** This request begins a distinct model-message series, independently of the header reason. */
116
144
  startsSeries?: true
117
145
  }
118
146
  /**
119
- * Route metadata for the next request, logged only when the route or capacity
120
- * changes. It does not participate in request reconstruction or header equality.
147
+ * Route metadata for the next request, logged only when the route, capacity,
148
+ * or system prompt update mode changes. It does not participate in request
149
+ * reconstruction or header equality. Prompt admission uses the bound prepared
150
+ * call's capability, not this snapshot from an earlier request.
121
151
  */
122
152
  'request/context': RequestContext
123
153
  /**
124
- * Marks the end of a constructor seed. Events before it have smaller seq
125
- * values and came from the seed (resume, fork, or replay); this lifecycle
126
- * produced none of them. This log-only event is the durable projection of
127
- * {@link Session.firstLiveSeq}.
154
+ * Separates inherited or restored history from later lifecycle-owned work.
155
+ * This log-only marker need not be at {@link Session.firstLiveSeq}: a fork
156
+ * seed can already contain its tagged marker and child-owned synthetic
157
+ * closers before construction.
128
158
  *
129
159
  * A fresh fork child owns one `{ inherited: true }` marker at its exact
130
160
  * inherited-prefix cut, even when that prefix ends in an ancestor marker.
131
- * The last tagged marker is the current Session's cut; untagged markers keep
132
- * ordinary restore and replay lifecycle boundaries.
161
+ * `buildForkSeed` appends that marker before any synthetic closers; the
162
+ * `Session` constructor supplies it when given only the inherited prefix.
163
+ * The last tagged marker is the current Session's cut; untagged markers
164
+ * keep ordinary restore and replay lifecycle boundaries.
133
165
  *
134
- * `Session`'s constructor is the only legitimate writer. The invariant
135
- * companion deliberately constrains nothing here, so a plugin appending one
166
+ * Only the `Session` constructor and `buildForkSeed` may create this marker.
167
+ * Session append does not reject other writers, so a plugin appending one
136
168
  * would silently classify every live bracket before it as seed history.
137
169
  *
138
170
  * An owner of a standalone open/close bracket (`compaction/start` …
@@ -152,12 +184,13 @@ interface SessionEventMap {
152
184
 
153
185
  ### 请求头事件:`request/header`
154
186
 
155
- 请求信封(即 `EpochHeader`:调用配置 + 适配器所提供默认值的标记 + 渲染后的系统提示词 + 已组装的工具 schema)会作为会话状态写入日志,因此每个对话请求都是日志的纯函数(见可重建性 Agent Note)。带有 reason `'initial'` 或 `'resume'` 的完整 `request/header` 快照记录每个 agent loop 实例的边界;请求变化时会追加 reason 为 `'change'` 的快照;未变的信封显式开启消息序列或跟随 surface 替换时,会追加 reason 为 `'series'` 的快照。如果发生变化的快照所属请求同时开启序列,它会携带 `startsSeries: true`。普通的仅追加后续 Turn,以及同一模型消息序列内的后续 Step 与重试沿用最新快照。`foldRequestHeader(events)` 通过选择最新快照重建请求头。该事件不是 `SurfaceEventType`,不产生 LLM 消息。
187
+ 请求信封(即 `EpochHeader`:调用配置 + 适配器所提供默认值的标记 + 已组装的工具 schema)会作为会话状态写入日志,因此每个对话请求都是日志的纯函数(见可重建性 Agent Note)。渲染后的系统提示词不属于请求头:它是派生历史,即 surface 第 0 号节点上的 `system/message` 事件以及任何后续的历史内系统节点([决策](https://github.com/deepseek-ai/deepseek-harness/blob/master/.agents/notes/implemented/architecture/2026-09-02-system-prompt-as-surface-node.zh.md)),因此提示词变更替换或追加一个系统节点,而请求头保持不变。带有 reason `'initial'` 或 `'resume'` 的完整 `request/header` 快照记录每个 agent loop 实例的边界;请求变化时会追加 reason 为 `'change'` 的快照;未变的信封显式开启消息序列或跟随 surface 替换时,会追加 reason 为 `'series'` 的快照。如果 `'initial'`、`'resume'` 或 `'change'` 快照所属请求同时开启序列,它会携带 `startsSeries: true`;reason `'series'` 已记录这一事实。普通的仅追加后续 Turn,以及同一模型消息序列内的后续 Step 与重试沿用最新快照。`foldRequestHeader(events)` 通过选择最新快照重建请求头。该事件不是 `SurfaceEventType`,不产生 LLM 消息。
156
188
 
157
189
  ```ts type-equiv
158
190
  /**
159
- * Logged request state outside derived history: call config, system prompt, and
160
- * tools. The latest full `request/header` snapshot reconstructs it; canonical
191
+ * Logged request state outside derived history: call config and tools. The
192
+ * system prompt is derived history — surface node 0, a `system/message` event.
193
+ * The latest full `request/header` snapshot reconstructs the header; canonical
161
194
  * empty optional fields are absent.
162
195
  */
163
196
  interface EpochHeader {
@@ -165,18 +198,20 @@ interface EpochHeader {
165
198
  config: LlmCallConfig
166
199
  /** Effective config fields materialized from the exact adapter rather than proposed by a caller. */
167
200
  adapterDefaults?: LlmCallConfigAdapterDefaults
168
- /** Rendered system prompt text; absent for a system-less request. */
169
- system?: string
170
201
  /** Assembled tool schemas; absent for a tool-less request. */
171
202
  tools?: ToolSchema[]
203
+ /** Retired request text; system prompts belong to system/message events.
204
+ * @persistenceReserved
205
+ */
206
+ system?: never
172
207
  }
173
208
  ```
174
209
 
175
- 规范形式:空系统提示词和空工具列表都表示为字段缺失,与请求构建方式一致。包含旧版 `request/header-delta` 事件或完整快照原因为 `fallback` 的旧版 v0 日志,会在 seed、append 和持久化加载边界被拒绝,而不会以不完整方式回放。
210
+ 当前事件接纳要求 `request/header.header` 为规范形式:禁止任何 `system` 字段,必须省略 `tools: []` 与 `adapterDefaults: {}`。仅含空白的系统消息内容、`config.stop: []` 与嵌套扩展保持不变。seed、append 与当前持久化读取拒绝非规范 header,而不会静默规范化;[V3 信封决策](https://github.com/deepseek-ai/deepseek-harness/blob/master/.agents/notes/implemented/architecture/2026-09-06-v3-canonical-session-envelopes.zh.md)负责历史转换。包含旧版 `request/header-delta` 事件或完整快照原因为 `fallback` 的旧版 v0 日志,会被拒绝,而不会以不完整方式回放。
176
211
 
177
212
  ### 路由容量事件:`request/context`
178
213
 
179
- 请求所解析到的路由的上下文元数据是独立的已记录状态,在同一步骤内紧随 `request/header` 追加,且仅在提供方、模型或容量与上一条记录不同时追加。它保持在 `EpochHeader` 之外,因为该类型是 `headerEquals` 逐字段比较的重建约定。容量描述的是路由,不是请求输入,把它折叠进去会让一次容量变化被登记为请求信封的 `change`,也会把适配器元数据拉进 loop 的重建不变式。与 `request/header` 一样,它不是 `SurfaceEventType`,也不产生 LLM 消息。`session.requestContext()` 以增量方式归并最新一条记录。适配器不公布容量的路由会以缺失 `contextWindow` 的形式记录,因此新记录可以清除较早路由的容量。
214
+ 请求所解析到的路由的上下文元数据是独立的已记录状态,在同一步骤内紧随 `request/header` 追加,且仅在提供方、模型、容量或 `systemPromptUpdate` 模式与上一条记录不同时追加。它保持在 `EpochHeader` 之外,因为该类型是 `headerEquals` 逐字段比较的重建约定。容量与更新模式描述的是路由,不是请求输入,把它们折叠进去会让一次路由变化被登记为请求信封的 `change`,也会把适配器元数据拉进 loop 的请求重建。与 `request/header` 一样,它不是 `SurfaceEventType`,也不产生 LLM 消息。`session.requestContext()` 以增量方式归并最新一条记录;agent loop 在决定变化后的系统提示词是替换最新的系统节点还是追加到已缓存历史之后时,读取该记录的 `systemPromptUpdate`([决策规则](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/core/agent-loop/README.zh.md#understand-the-implementation))。适配器不公布容量的路由会以缺失 `contextWindow` 的形式记录,因此新记录可以清除较早路由的容量;未声明更新模式的路由同样会清除较早路由的 `systemPromptUpdate`。
180
215
 
181
216
  ```ts type-equiv
182
217
  /** Registration-bound metadata for one resolved model route. */
@@ -187,6 +222,8 @@ interface RequestContext {
187
222
  model: string
188
223
  /** Maximum combined request and response context in tokens, when advertised. */
189
224
  contextWindow?: number
225
+ /** `'in-history'` when the route reads the latest `system` message at any position as the effective system prompt. */
226
+ systemPromptUpdate?: SystemPromptUpdate
190
227
  }
191
228
  ```
192
229
 
@@ -224,7 +261,7 @@ type OptionalSessionSeq = SessionSeq | null
224
261
  * unions), so `switch (event.type)` narrows `event.data` without casts.
225
262
  *
226
263
  * The {@link sourceEventSeqs} and {@link surfaceOp} fields are conditional:
227
- * they only exist on {@link SurfaceEventType} variants (`user/message`,
264
+ * they only exist on {@link SurfaceEventType} variants (`system/message`, `user/message`,
228
265
  * `assistant/message`, `tool/result`).
229
266
  * Non-surface events (boundary markers, attempts, errors) never carry
230
267
  * surface metadata — the compiler enforces this at `Session.append()`
@@ -249,28 +286,22 @@ type SessionEvent<T extends SessionEventType = SessionEventType> = {
249
286
  * inconvenience) rather than silently resuming a gutted session.
250
287
  */
251
288
  ignorable?: true
252
- } & (K extends SurfaceEventType ? {
253
- /**
254
- * Seq numbers of earlier events that this event cites as sources, such as
255
- * the surface nodes shadowed by a compaction replacement. A v2
256
- * `assistant/message` embeds its provider stream and cannot carry this field.
257
- */
258
- sourceEventSeqs?: SessionSeq[]
259
- /** How this event entered the surface; absent for non-surface events. */
260
- surfaceOp?: SurfaceOp
261
- } : object)
289
+ } & (K extends SurfaceEventType ? SurfaceIntent<K> : {
290
+ surfaceOp?: never
291
+ sourceEventSeqs?: never
292
+ })
262
293
  }[T]
263
294
  ```
264
295
 
265
296
  `SessionEventType = keyof SessionEventMap`。由于 `SessionEventMap` 可通过合并扩展,对 `SessionEvent` 的 switch 语句禁止使用 `assertNever`:插件添加的变体是合法的未知值;处理已知 case 后在 `default` 中放行。
266
297
 
267
- V2 `assistant/message` 嵌入 provider stream,不能携带 `sourceEventSeqs`。User 与 tool surface event 可以在 provenance 或 replacement operation 需要时引用完整且非空的唯一较早 event 集合。
298
+ 每个 surface 事件都要求 `surfaceOp`;已知仅日志事件禁止两个 surface 元数据字段。原生未知或已退役的可忽略信封保持不透明。`assistant/message` 嵌入其提供方 stream,并禁止 `sourceEventSeqs`。System、user 与 tool surface 事件可以在来源归属或替换覆盖需要时引用完整、非空且唯一的较早事件集合。`tool/result` 仅在消息带有 `isError: true` 时可以携带 `data.error`;失败结果的失败身份仍可省略。
268
299
 
269
300
  <a id="surface-types"></a>
270
301
 
271
302
  ## Surface 类型
272
303
 
273
- 三种产生消息的类型(`SurfaceEventType`:`user/message`、`assistant/message`、`tool/result`)携带 surface 元数据,用来声明它们如何加入有序的派生 surface。见 [session surface Agent Note](https://github.com/deepseek-ai/deepseek-harness/blob/master/.agents/notes/implemented/architecture/2026-06-18-session-surface.zh.md)。
304
+ 产生消息的类型(`SurfaceEventType`:`system/message`、`developer/message`、`user/message`、`assistant/message`、`tool/result`)携带 surface 元数据,用来声明它们如何加入有序的派生 surface。`system/message` 承载渲染后的系统提示词:循环把第一条追加为 surface 第 0 号节点,并在提示词变化时恰好替换最新的系统节点,或在历史内路由上追加一条新的;surface 折叠拒绝任何其他覆盖第 0 号节点 `system/message` 的替换,而后续系统节点是普通历史,压缩替换可以遮蔽它。见 [session surface Agent Note](https://github.com/deepseek-ai/deepseek-harness/blob/master/.agents/notes/implemented/architecture/2026-06-18-session-surface.zh.md)。
274
305
 
275
306
  ### `SurfaceEventType`:事件类型中产生消息的子集
276
307
 
@@ -278,10 +309,12 @@ V2 `assistant/message` 嵌入 provider stream,不能携带 `sourceEventSeqs`
278
309
  /**
279
310
  * The subset of {@link SessionEventType} values whose events produce LLM
280
311
  * messages and are eligible to appear on the ordered surface. Only these
281
- * event types may carry {@link SurfaceOp}; user and tool events may also cite
312
+ * event types may carry {@link SurfaceOp}; system, user, and tool events may also cite
282
313
  * earlier sources through {@link SessionEvent.sourceEventSeqs}.
283
314
  */
284
315
  type SurfaceEventType =
316
+ | 'system/message'
317
+ | 'developer/message'
285
318
  | 'user/message'
286
319
  | 'assistant/message'
287
320
  | 'tool/result'
@@ -296,19 +329,19 @@ type SurfaceEventType =
296
329
  *
297
330
  * - `'append'`: added to the tail — normal path for user/assistant/tool
298
331
  * messages.
299
- * - `{ op: 'replace', start, end }`: replaces surface nodes from `start`
300
- * (inclusive) through `end` (inclusive) with this node. Both must exist as
301
- * surface nodes in the current surface. `start === end` replaces a single
332
+ * - `{ op: 'replace', startSeq, endSeq }`: replaces surface nodes from `startSeq`
333
+ * (inclusive) through `endSeq` (inclusive) with this node. Both must exist as
334
+ * surface nodes in the current surface. `startSeq === endSeq` replaces a single
302
335
  * node. The node's {@link SessionEvent.sourceEventSeqs} must include every
303
336
  * shadowed surface node. Used by compaction; any surface-replacing producer
304
337
  * may use it.
305
338
  */
306
339
  type SurfaceOp =
307
340
  | 'append'
308
- | { op: 'replace'; start: SessionSeq; end: SessionSeq }
341
+ | { op: 'replace'; startSeq: SessionSeq; endSeq: SessionSeq }
309
342
  ```
310
343
 
311
- `'append'` 是常规的尾部追加路径。`replace` 会遮蔽从 `start` 到 `end`(含两端)的 surface 条目(两者都必须是有效的 surface seq;`start === end` 时仅替换单个条目),并在原位置插入新事件。
344
+ `'append'` 是常规的尾部追加路径。`replace` 恰好包含 `op`、`startSeq` 和 `endSeq`,不接受别名或额外键。它遮蔽这两个当前 surface 事件序号之间的闭区间,并在原位置插入新事件;相同端点仅替换一个条目。端点必须早于替换事件,但它们的相对顺序按 surface 顺序而非数值序号顺序确定。
312
345
 
313
346
  ### `SurfaceIntent`:`session.append()` 的参数
314
347
 
@@ -320,7 +353,7 @@ type SurfaceOp =
320
353
  type SurfaceIntent<T extends SurfaceEventType = SurfaceEventType> = {
321
354
  surfaceOp: SurfaceOp
322
355
  } & (T extends 'assistant/message' ? {
323
- /** V2 Assistant messages embed their provider stream instead of citing source events. */
356
+ /** Assistant messages embed their provider stream instead of citing source events. */
324
357
  sourceEventSeqs?: never
325
358
  } : {
326
359
  /** Complete non-empty set of known earlier source-event seqs. */
@@ -332,11 +365,47 @@ type SurfaceIntent<T extends SurfaceEventType = SurfaceEventType> = {
332
365
 
333
366
  `assistant/message` 不能携带 `sourceEventSeqs`;它的 `stream` 拥有精确 provider 证据。其他 surface event 不引用较早 event 时省略该字段,需要引用时使用完整非空 list。
334
367
 
368
+ <a id="plugin-owned-message-projections"></a>
369
+ ### 插件拥有的消息投影
370
+
371
+ 修改内容的插件用 `@messageProjection` 标记事件声明,并通过 `ctx.sessions.registerMessageProjection()` 注册纯处理器。Session 在提交前通过处理器校验完整决策,应用其不可变消息更新,并推进 `contentGeneration`。缺少处理器时拒绝操作,包括恢复和独立折叠,卸载已经使用的处理器后也会拒绝读取缓存。独立读取器将处理器显式传给 `foldSurface(events, projections)`,并通过 `deriveEventMessage()` 应用 `projectedMessages`。当前格式目录为离线读取器装配第一方处理器。[图片省略插件](./compaction.md#image-offload)拥有图片专用的事件及解释逻辑。
372
+
373
+ ```ts type-equiv
374
+ /** Readonly history immediately before a message-projection event. */
375
+ interface SessionMessageProjectionContext {
376
+ /** Current message-producing event sequences in model-visible order. */
377
+ nodes: readonly SessionSeq[]
378
+ /** Contiguous event window; entries at or beyond the candidate seq are not committed inputs. */
379
+ events: readonly SessionEvent[]
380
+ /** Absolute sequence of the window's first event. */
381
+ baseSeq: SessionLogOffset
382
+ /** Previously projected messages keyed by their original event sequences. */
383
+ messages: ReadonlyMap<SessionSeq, Message>
384
+ }
385
+ ```
386
+
387
+ ```ts type-equiv
388
+ /** Pure interpretation of one plugin-owned event that changes existing message content. */
389
+ interface SessionMessageProjection<T extends SessionEventType = SessionEventType> {
390
+ /** Event interpreted by this definition; declare it with `@messageProjection` in SessionEventMap. */
391
+ type: T
392
+ /**
393
+ * Validate the complete durable decision before returning any updates. Preserve
394
+ * message identities and publish immutable copies without mutating the input.
395
+ * @param event - candidate event, not yet applied to the supplied history.
396
+ * @param context - history preceding this decision.
397
+ * @returns changed current messages keyed by their original sequences.
398
+ * @throws when the durable decision cannot be applied to this history.
399
+ */
400
+ project(event: SessionEvent<T>, context: SessionMessageProjectionContext): ReadonlyMap<SessionSeq, Message>
401
+ }
402
+ ```
403
+
335
404
  ### `SessionSurface`:实时只读 surface 投影
336
405
 
337
406
  `Session.surface` 返回会话稳定的 `SessionSurface` 视图。同一个增量管理器在提交前校验追加候选事件,并根据已提交事件推进该投影;调用方可以观察成员关系和替换代次,但不能调用校验。
338
407
 
339
- `SurfaceManager(log, baseSeq?)` 也可以折叠一个连续的已加载窗口,其第一个事件的绝对序号为 `baseSeq`。每个事件在该绝对序号空间中仍保持连续;如果替换跨过窗口头部,由于其声明的范围并不存在,该替换会失败。
408
+ `SurfaceManager(log, baseSeq?, projections?)` 也可以折叠一个连续的已加载窗口,其第一个事件的绝对序号为 `baseSeq`。每个事件在该绝对序号空间中仍保持连续;如果替换跨过窗口头部,由于其声明的范围并不存在,该替换会失败。
340
409
 
341
410
  ```ts type-equiv
342
411
  /** Readonly live projection of the message-producing session events. */
@@ -345,12 +414,14 @@ interface SessionSurface {
345
414
  readonly nodes: readonly SessionSeq[]
346
415
  /** Monotonic count of committed positional replacements. */
347
416
  readonly replaceGeneration: number
417
+ /** Monotonic count of committed replacements and plugin-owned message changes. */
418
+ readonly contentGeneration: number
348
419
  }
349
420
  ```
350
421
 
351
422
  ### `SurfaceFoldReplacement` 与 `SurfaceFoldResult`:完整的 surface 回放
352
423
 
353
- `foldSurface(events)` 返回一份独立的当前事件 seq 列表,以及每个声明的替换范围实际遮蔽的 seq。实时管理器复用同一套状态转换,但不保留替换历史。每提交一次替换,其 `replaceGeneration` 就递增一次,使增量消费方能够区分纯尾部增长与重写。
424
+ `foldSurface(events, projections)` 返回一份独立的当前事件 seq 列表,以及每个声明的替换范围实际遮蔽的 seq。实时管理器复用同一套状态转换,但不保留替换历史。每提交一次替换,其 `replaceGeneration` 就递增一次,使增量消费方能够区分纯尾部增长与重写。
354
425
 
355
426
  ```ts type-equiv
356
427
  /** One replacement operation observed while folding a session surface. */
@@ -373,6 +444,8 @@ interface SurfaceFoldResult {
373
444
  nodes: SessionSeq[]
374
445
  /** Replacement operations in event order. */
375
446
  replacements: SurfaceFoldReplacement[]
447
+ /** Immutable projected messages, keyed by their original event sequences. */
448
+ projectedMessages: ReadonlyMap<SessionSeq, Message>
376
449
  }
377
450
  ```
378
451
 
@@ -406,29 +479,26 @@ declare class Session {
406
479
  /** The session identity, derived from its durable header's single copy. */
407
480
  get id(): SessionId;
408
481
  /**
409
- * The first seq appended IN THIS PROCESS: the length of the constructor
410
- * seed (0 without one). Events with smaller seq values entered through
411
- * construction — replay, fork, or resume — and were never published on the
412
- * `session/event` firehose (constructor seeds do not emit). This offset marks
413
- * the constructor-input boundary for lifecycle ownership and persistence
414
- * adoption; consumers that need complete canonical history still start at
415
- * seq 0. Distinct from {@link inheritedEventCount}, the DURABLE
416
- * fork-lineage cut: a resumed session's constructor seed is its full stored
417
- * log, while the inherited count keeps the original fork value — this field is the
418
- * in-process construction fact.
419
- *
420
- * Not persisted itself: a seeded session projects it into the log as the
421
- * `session/end-seed` event, which is what a consumer reading STORED history
422
- * reads. Locate the LAST such event, not necessarily one at this seq — a
423
- * seed already ending in one is not re-marked, so reopening an untouched
424
- * session leaves that event at a smaller seq than `firstLiveSeq`. Prefer
425
- * this field in-process: it is exact before the marker reaches storage.
482
+ * The constructor seed length (0 without one), before any marker appended
483
+ * during construction. Seed events never publish on `session/event`. A
484
+ * marker appended before the store attaches occupies this seq without
485
+ * publishing either; otherwise this seq is available for the next append.
426
486
  *
427
- * When this lifecycle appends the marker, it occupies this seq before the
428
- * store attaches and therefore does not publish either. Otherwise this seq
429
- * holds an ordinary published write.
430
- */
487
+ * This in-process offset is not persisted. A fork seed can already contain
488
+ * the child's inherited marker and synthetic closers, so its child-owned
489
+ * history starts at {@link inheritedEventCount}, before this offset. A
490
+ * resumed Session's seed contains its full stored log, while its inherited
491
+ * count keeps the durable fork cut. Consumers needing complete canonical
492
+ * history start at seq 0.
493
+ */
431
494
  readonly firstLiveSeq: SessionLogOffset;
495
+ /**
496
+ * First event produced for this object lifecycle. A new fork includes its
497
+ * child-owned seed marker and closers; a restored Session starts after its
498
+ * complete stored prefix. This in-process capture offset is not persisted.
499
+ */
500
+ readonly firstLifecycleSeq: SessionLogOffset;
501
+
432
502
  /**
433
503
  * Create a detached session by validating and snapshotting borrowed seed
434
504
  * events and storage metadata.
@@ -436,32 +506,44 @@ declare class Session {
436
506
  * @param seed - optional borrowed replay or fork events.
437
507
  * @param header - optional borrowed storage metadata.
438
508
  * @param inheritedEventCount - exact fork-inherited prefix length for a seeded header.
509
+ * @param projections - pure interpreters for plugin-owned message changes.
439
510
  * @returns a detached session.
511
+ * @throws when a seed event requires a missing message interpreter or fails validation.
440
512
  */
441
513
  static create(
442
514
  id: SessionId,
443
515
  seed?: readonly SessionEvent[],
444
516
  header?: SessionHeader,
445
517
  inheritedEventCount?: SessionLogOffset,
446
- ): Session;
518
+ projections?: readonly SessionMessageProjection[],
519
+ ): Session;
447
520
  /**
448
- * Restore a detached session by taking ownership of fresh persistence values.
449
- * The storage format, event envelopes, sequence continuity, surface transitions,
450
- * and header fields are validated before the restored objects are frozen.
521
+ * Restore a detached session by adopting an independently owned or deeply frozen seed.
522
+ * Runtime-required event fields, event envelopes, sequence continuity, surface
523
+ * transitions, and header fields are validated without copying or freezing events.
524
+ * Embedded Assistant streams remain opaque until a stream consumer or storage
525
+ * verifier reads them.
451
526
  * @param id - restored session identity.
452
- * @param seed - fresh detached events whose ownership is transferred.
453
- * @param header - fresh detached metadata whose ownership is transferred.
527
+ * @param seed - independently owned or deeply frozen events.
528
+ * @param header - independently owned storage metadata.
454
529
  * @param inheritedEventCount - exact fork-inherited prefix length decoded from storage.
530
+ * @param eventState - aliasing state carried from the operation that produced the seed.
531
+ * @param projections - pure interpreters for plugin-owned message changes.
455
532
  * @returns a restored detached session.
533
+ * @throws when a seed event requires a missing message interpreter or fails validation.
456
534
  */
457
535
  static fromRestore(
458
536
  id: SessionId,
459
537
  seed: readonly SessionEvent[],
460
538
  header: SessionHeader,
461
539
  inheritedEventCount: SessionLogOffset,
462
- ): Session;
540
+ eventState: SessionSeedEventState,
541
+ projections?: readonly SessionMessageProjection[],
542
+ ): Session;
463
543
  /**
464
544
  * Return the immutable event stored at one exact sequence number.
545
+ * @deprecated Existing logic may remain unmigrated for now, but new calls are prohibited.
546
+ * See the [Agent Note](../../../../.agents/notes/implemented/architecture/2026-09-09-deprecate-synchronous-session-event-reads.md).
465
547
  * @param seq - event sequence number.
466
548
  * @returns the accepted event, or undefined when the log does not contain it.
467
549
  */
@@ -470,6 +552,8 @@ declare class Session {
470
552
  * Materialize an immutable snapshot of a half-open event sequence range.
471
553
  * A full current snapshot is reused until the next append; every previously
472
554
  * returned snapshot remains stable after later appends.
555
+ * @deprecated Existing logic may remain unmigrated for now, but new calls are prohibited.
556
+ * See the [Agent Note](../../../../.agents/notes/implemented/architecture/2026-09-09-deprecate-synchronous-session-event-reads.md).
473
557
  * @param fromSeq - non-negative inclusive sequence number; defaults to the log start.
474
558
  * @param toSeqExclusive - non-negative exclusive sequence number; defaults to the current end.
475
559
  * @returns a frozen array of the selected deeply frozen events.
@@ -477,9 +561,11 @@ declare class Session {
477
561
  snapshotEvents(
478
562
  fromSeq: SessionLogOffset = SessionLogOffset(0),
479
563
  toSeqExclusive: SessionLogOffset = this.seq,
480
- ): readonly SessionEvent[];
564
+ ): readonly SessionEvent[];
481
565
  /**
482
566
  * Return this Session's events after its fork-inherited prefix.
567
+ * @deprecated Existing logic may remain unmigrated for now, but new calls are prohibited.
568
+ * See the [Agent Note](../../../../.agents/notes/implemented/architecture/2026-09-09-deprecate-synchronous-session-event-reads.md).
483
569
  * @returns a fresh array containing child-owned events in log order.
484
570
  */
485
571
  ownEvents(): readonly SessionEvent[];
@@ -517,6 +603,7 @@ declare class Session {
517
603
  * (BigInt, function, symbol, undefined, negative zero, non-finite number,
518
604
  * circular reference, sparse array, or an exotic object such as
519
605
  * Map/Set/Date/class instance), or when the candidate violates the
606
+ * request-header empty-field or tool-error consistency rules, or the
520
607
  * canonical surface contract (marker shape and eligibility, unique
521
608
  * earlier source-event references, positional replacement validity, and complete
522
609
  * shadowed-node coverage). One iterative pass reads, validates, and
@@ -531,7 +618,7 @@ declare class Session {
531
618
  type: T,
532
619
  data: SessionEventMap[T],
533
620
  ...opts: T extends SurfaceEventType ? [opts: SurfaceIntent<T>] : []
534
- ): SessionEvent<T>;
621
+ ): SessionEvent<T>;
535
622
  /**
536
623
  * The {@link EpochHeader} in force after the log's last header event — the
537
624
  * header the NEXT request will be compared against — or undefined before
@@ -547,6 +634,12 @@ declare class Session {
547
634
  * @returns the latest immutable route metadata.
548
635
  */
549
636
  requestContext(): RequestContext | undefined;
637
+ /**
638
+ * Fold unseen committed events into capability-independent tool history.
639
+ * Initial access reconstructs inherited history; later reads consume only new events.
640
+ * @returns an immutable snapshot for LLM request projection, including historical addition definitions.
641
+ */
642
+ toolHistory(): ToolHistory;
550
643
  /**
551
644
  * Derive the LLM message history by walking the ordered sequences of
552
645
  * message-producing events maintained by `surfaceOp` markers. The
@@ -554,21 +647,21 @@ declare class Session {
554
647
  * append records its `surfaceOp`, so a raw event with no marker (a chunk, a
555
648
  * turn boundary) is correctly absent, and a compaction `replace` deletes the
556
649
  * shadowed nodes from the derivation. The projection rules are
557
- * {@link deriveEventMessage}, folded per node.
650
+ * {@link deriveEventMessage}, with logged message projections applied
651
+ * without changing node membership or message identity.
558
652
  *
559
- * CACHED: each surface node is projected exactly once, when first seen — a
560
- * call costs O(new nodes), and a surface rewrite (a `replace`;
561
- * {@link SessionSurface.replaceGeneration}) rebuilds. The returned array is
653
+ * CACHED: pure tail growth costs O(new nodes); a replacement or message projection
654
+ * ({@link SessionSurface.contentGeneration}) rebuilds. The returned array is
562
655
  * a fresh snapshot per call (later appends never grow an array a caller
563
656
  * already holds); the `Message` objects in it are SHARED and **deep-frozen**.
564
- * Their content reuses the already frozen durable event data, so the cache
565
- * needs no second deep clone and consumers still cannot mutate the log.
657
+ * Unchanged content reuses frozen event data; projected blocks are frozen
658
+ * derived copies. Consumers cannot mutate the log through either form.
566
659
  * @returns a fresh array of the shared, frozen derived history.
567
660
  */
568
661
  deriveMessages(): Message[];
569
662
  /**
570
- * Instance face of the pure per-node `deriveEventMessage` export from
571
- * `surface.ts`.
663
+ * Project one event with all committed message projections applied.
664
+ * The original durable event remains unchanged.
572
665
  * @param event - the event to project.
573
666
  * @returns the derived message, or null when the event produces none.
574
667
  */
@@ -578,11 +671,11 @@ declare class Session {
578
671
 
579
672
  ## 派生历史:`deriveMessages()` 与 `deriveEventMessage()`
580
673
 
581
- `Session.deriveMessages()` 将事件日志投影为模型看到的 `Message[]`。它是缓存的(每个 surface 节点在首次出现时投影一次;surface 重写触发重建)且冻结的(每次调用返回一个新数组,引用共享的深冻结消息,因此通过投影修改已记录的历史在类型上不可表达)。`deriveEventMessage(event)` 是折叠所应用的逐节点纯函数,公开暴露以便外部重建器和开发不变式检查能以完全相同的规则投影日志前缀,不会与缓存产生分歧。投影规则:
674
+ `Session.deriveMessages()` 将事件日志投影为模型看到的 `Message[]`。它是缓存的(每个 surface 节点在首次出现时投影一次;surface 重写触发重建)且冻结的(每次调用返回一个新数组,引用共享的深冻结消息,因此通过投影修改已记录的历史在类型上不可表达)。`deriveEventMessage(event)` 是折叠所应用的逐节点纯函数,公开暴露以便外部重建器能以完全相同的规则投影日志前缀,不会与缓存产生分歧。投影规则:
582
675
 
583
676
  - `user/message` → 一条携带确切 `content` 的 user 消息;可选 envelope 仅作为日志中的展示元数据保留。
584
677
  - `assistant/message` → 一条 assistant 消息,包含生成它的提供方和模型,以及可选的适配器私有回放状态。其嵌入式紧凑 stream 是回放、usage 与 UI 证据,而不是第二条 message。**内容为空的** `assistant/message` 也会跳过:因 max-tokens 而截断且无内容的步骤仍会记录一条 `assistant/message` 来保存 stream、usage、提供方和模型,但无内容的 assistant 轮次不得进入提供方 transcript(文本记录)。
585
- - `tool/result` → 一条携带 `tool-result` 块的 user 消息。
678
+ - `tool/result` → 一条一等 tool-role 消息,携带结果内容与工具调用标识。
586
679
  - `user/message`(注入上下文,即非 `user` 来源)→ 按时间顺序在相应位置生成一条 user-role 消息,并原样承载其 `content`;其类型化 source 标明生产方,并携带所有生产方专用数据。
587
680
 
588
681
  其余所有事件(`turn/*`、`step/*`、`assistant/attempt`、插件所属的 `llm/retry`)均为结构信息,不会投影为消息。token 记账会展开每个 `assistant/message` 或 `assistant/attempt` 的嵌入式 stream,message 顶层 `usage` 存在时仍是已提交 message 的权威。失败的模型请求 attempt 因此可以保留提供方 usage,而无需虚构 assistant message。当前逻辑校验会拒绝没有提供方/模型的 request header 和 assistant 消息,而不会猜测路由;受支持的历史表示会在当前 Session 存在前,由其相邻格式迁移边归一化并校验。
@@ -593,7 +686,7 @@ declare class Session {
593
686
 
594
687
  - `fork(source, boundary?, childSessionId?)` 接受一个活跃的 `Session` 对象或活跃的 `SessionId`,选取到 `SessionSeq` boundary(含)为止的源事件(默认为当前最后一个事件),要求所选前缀结束时没有开放轮次,然后创建一个活跃的子会话,包含深克隆的 seed event、`parentSession`、`isSeeded: true`、精确 `inheritedEventCount` 及继承的 `cwd`。
595
688
 
596
- 显式 `boundary` 允许调用者从任意稳定的轮次间位置 fork,包括之前的 `turn/end` 或更晚的独立纯日志事件,即使源会话有更新的事件或正在进行的轮次。API 拒绝结束于开放轮次内的前缀,而不是静默截断。更广泛的执行关系健全性检查留在既有的 `dsh-invariants` 插件和持久化修复路径中,不在 `fork()` 中重复。`dsh-subagent-fork-in-process` 保留其已完成前缀截断逻辑,因为工具调用时的委托通常在父轮次仍然打开时启动;普通的会话分支应显式指定请求的 boundary。
689
+ 显式 `boundary` 允许调用者从任意稳定的轮次间位置 fork,包括之前的 `turn/end` 或更晚的独立纯日志事件,即使源会话有更新的事件或正在进行的轮次。API 拒绝结束于开放轮次内的前缀,而不是静默截断。`dsh-subagent-fork-in-process` 保留其已完成前缀截断逻辑,因为工具调用时的委托通常在父轮次仍然打开时启动;普通的会话分支应显式指定请求的 boundary。
597
690
 
598
691
  <a id="why-a-turn-ended-turnendreasonmap"></a>
599
692
 
@@ -631,22 +724,29 @@ interface TurnEndReasonMap {
631
724
  * the events recorded before the crash remain intact.
632
725
  */
633
726
  interrupted: { kind: 'interrupted' }
727
+ /**
728
+ * Fork-seed construction closed a turn that was still open at the fork
729
+ * boundary in the source session. Only fork seeds carry this marker — the
730
+ * loop never emits it — and the source events before the boundary remain
731
+ * intact in the child.
732
+ */
733
+ forked: { kind: 'forked' }
634
734
  }
635
735
  ```
636
736
 
637
- `max-tokens` 与模型调用中同名的 `FinishReason` 对应:只要轮次内有任何步骤以 `max-tokens` 结束,整个轮次就以 `max-tokens` 而不是 `completed` 结束(即使之后继续执行,截断事实仍优先),让消费方能够区分正常停止和截断停止。取消和错误仍是不同的结果。`interrupted` 是唯一不会由任何 loop 发出的原因:它由崩溃恢复合成(见 [persistence.md](./persistence.md))。该 map 可通过合并扩展。
737
+ `max-tokens` 与模型调用中同名的 `FinishReason` 对应:只要轮次内有任何步骤以 `max-tokens` 结束,整个轮次就以 `max-tokens` 而不是 `completed` 结束(即使之后继续执行,截断事实仍优先),让消费方能够区分正常停止和截断停止。取消和错误仍是不同的结果。loop 不会实时发出 `interrupted` 或 `forked`:崩溃恢复合成 `interrupted`(见 [persistence.md](./persistence.md)),而 fork 种子构造合成 `forked`。该 map 可通过合并扩展。
638
738
 
639
739
  ## 执行封闭与独立事件
640
740
 
641
741
  一个轮次包围一次模型循环执行,而不是整个会话日志。AgentLoop 只会在轮次内进入 pre-step 批次时记录注入的 `user/message` 事件;插件所属的纯日志事件仍可出现在 `turn/end` 与下一个 `turn/start` 之间,占用事件 seq 但不递增轮次编号。持久化会将每个连续且已接受的事件纳入有界持久化批次,而崩溃修复只关闭确实仍处于开放状态的尾部轮次。需要即时持久性屏障的生产方会显式等待 `ctx.sessions.flush(session)`。
642
742
 
643
- 可选的 `dsh-session/invariant` 配套插件会强制核心拥有的关系:轮次与步骤编号、执行事件封闭,以及同一步骤内的工具调用/结果配对。可合并扩展事件的关系由声明它的插件拥有,因此核心不会仅因没有开放轮次就拒绝未知事件。见[独立事件决策](https://github.com/deepseek-ai/deepseek-harness/blob/master/.agents/notes/implemented/simplification/2026-07-28-remove-synthetic-log-only-turns.zh.md)。
743
+ 可合并扩展事件的关系由声明它的插件拥有,因此核心不会仅因没有开放轮次就拒绝未知事件。见[独立事件决策](https://github.com/deepseek-ai/deepseek-harness/blob/master/.agents/notes/implemented/simplification/2026-07-28-remove-synthetic-log-only-turns.zh.md)。
644
744
 
645
745
  ## 种子结束边界:`session/end-seed`
646
746
 
647
- 新 fork constructor 要求 seed 等于 inherited prefix,并在精确持久 cut 追加 `session/end-seed { inherited: true }`。restore 会保留该 tagged marker,并且只在完整 stored seed 尚未以 marker 结尾时追加普通 `session/end-seed {}`。两种形式都只进入 log 且不产生 message;`Session` constructor 是唯一合法 writer。
747
+ `buildForkSeed` 在精确的 inherited-prefix cut 追加 `session/end-seed { inherited: true }`,然后添加合成的 fork 结束事件。`Session` constructor 保留该预先构造的 marker,或在 seed 仅含 inherited prefix 时追加 marker。restore 保留 tagged marker,并且只在完整 stored seed 尚未以 marker 结尾时追加普通 `session/end-seed {}`。两种形式都只进入 log 且不产生 message;只有 constructor 和 `buildForkSeed` 可以创建它们。
648
748
 
649
- 对于 fork lineage,定位 payload 携带 `inherited: true` 的最后一个 marker;v2 decoding 只在 `SessionHeader.isSeeded` 为 true 时要求该 marker,并从其 seq 推导 `inheritedEventCount`。对于 lifecycle ownership,定位任一形式的最后一个 `session/end-seed`。重新打开已经以任一 marker 结尾的 seed 时,不会再追加普通 marker。
749
+ 对于 fork lineage,定位 payload 携带 `inherited: true` 的最后一个 marker;当前格式 decoding 只在 `SessionHeader.isSeeded` 为 true 时要求该 marker,并从其 seq 推导 `inheritedEventCount`。对于 lifecycle ownership,定位任一形式的最后一个 `session/end-seed`。重新打开已经以任一 marker 结尾的 seed 时,不会再追加普通 marker。
650
750
 
651
751
  它之所以必要,是因为种子历史与实时工作在字节层面完全相同,这会让任何拥有独立开/闭括号的插件失效:一个未配对的 `compaction/start`,无论写入方是在压缩中途崩溃、还是此刻正在压缩,读起来都一样。在 `session/end-seed` 之前的开启标记来自构造种子,并且属于一个已结束的生命周期,无论结束原因为何(崩溃、进程接替,或从仍在运行的父会话 fork 出来),因此其所有方可以视之为已死。这只覆盖*本*会话继承的括号:另一个并发存活的会话可能在同一段历史上持有开放括号,而它自己的边界在别处,因此容忍并发写入方还需要日志之外的存活信号。核心写入该边界但不从中读取任何内容——括号的词汇表仍归其所属插件,这也正是崩溃修复只关闭轮次/步骤/工具边界而从不处理 `compaction/*` 的原因。
652
752
 
@@ -654,15 +754,15 @@ interface TurnEndReasonMap {
654
754
 
655
755
  ## 插件贡献的仅日志事件
656
756
 
657
- 插件可以通过 declaration merging 添加额外的 `SessionEventMap` 类型。这些是**仅日志**事件:不是 `SurfaceEventType`(不携带 `surfaceOp`,不参与派生历史)。事件所有方决定它们属于一个开放的执行轮次,还是可以独立位于轮次之间,并在自己的不变量配套插件中强制所需关系。生成的[持久化日志事件目录](../persistence-catalog.md)会列出每个核心或插件贡献的事件;压缩 seam 的 `compaction/*` 语义在 [compaction.md](./compaction.md) 中讨论。
757
+ 插件可以通过 declaration merging 添加额外的 `SessionEventMap` 类型。这些是**仅日志**事件:不是 `SurfaceEventType`(不携带 `surfaceOp`,不参与派生历史)。事件所有方决定它们属于一个开放的执行轮次,还是可以独立位于轮次之间。生成的[持久化日志事件目录](../persistence-catalog.md)会列出每个核心或插件贡献的事件;压缩 seam 的 `compaction/*` 语义在 [compaction.md](./compaction.md) 中讨论。
658
758
 
659
759
  如果同一个插件事件族中的多条事件要组装成一个 Web Client Conversation Node,该事件族中的每条 start、update、result、resource 或 interruption 事件都必须携带或独立推导出同一个稳定业务 id。此要求只约束需要关联的 Node 事件族,并不要求每条 Session 事件都有业务 id;Client 因此无须根据相邻关系猜测归属,也无须扫描历史。参见 [Conversation 子系统](./conversation.md)。
660
760
 
661
- 钩子桥接层的 `hook/invoked` / `hook/result` 对(来自 `@deepseek-ai/dsh-hook-protocol`)通过 `handlerId` 关联。`UserPromptSubmit`、`PreToolUse`、`PostToolUse` 与 `Stop` 在 loop 已打开的轮次内触发,因此其 `hook/*` 记录天然位于轮次之内。`SessionStart` 不生成 `hook/*` 记录,因为它在轮次 1 之前运行;其上下文会在 inbox 中保持待处理,直到唤醒交付打开一个轮次(见[钩子桥接 Agent Note](https://github.com/deepseek-ai/deepseek-harness/blob/master/.agents/notes/implemented/feature/2026-06-30-hook-bridges.zh.md))。
761
+ 钩子桥接层的 `hook/invoked` / `hook/result` 对(来自 `@deepseek-ai/dsh-hook-protocol`)通过 `handlerId` 关联。`UserPromptSubmit`、`PreToolUse`、`PostToolUse` 与 `Stop` 在 loop 已打开的轮次内触发,因此其 `hook/*` 记录天然位于轮次之内。`SessionStart` 不生成 `hook/*` 记录,因为它在轮次 1 之前运行;其上下文会在 inbox 中保持待处理,直到唤醒交付打开一个轮次。
662
762
 
663
763
  ## 持久性约定
664
764
 
665
- 持久化后端依赖的约定如下:持久日志无损保存每个事件,每个 Assistant attempt 都是一个 `assistant/message` 或 `assistant/attempt`,其嵌入式紧凑 stream 会保留原始带时间 chunk。`seq` 在这些 settlement 与所有交错事件之间保持连续。后端可以为事件批次选择自己的存储 framing,只要句柄的 `read()` 返回与追加时完全一致的事件即可;当前 JSONL v2 每个事件写一行(见 [persistence.md](./persistence.md))。所有 `event.data` 都必须可序列化为 JSON;`Session.append` 会从源头强制这一要求(遇到不可序列化数据时抛出),因此错误事件绝不会进入日志,`session.snapshotEvents()` 始终与后端可持久化的内容一致。新增会携带不可序列化数据、破坏核心执行嵌套或违反事件所有方声明关系的事件类型,都会构成磁盘格式的破坏性变更。
765
+ 持久化后端依赖的约定如下:持久日志无损保存每个事件,每个 Assistant attempt 都是一个 `assistant/message` 或 `assistant/attempt`,其嵌入式紧凑 stream 会保留原始带时间 chunk。`seq` 在这些 settlement 与所有交错事件之间保持连续。后端可以为事件批次选择自己的存储 framing,只要句柄的 `read()` 返回与追加时完全一致的事件即可;当前 JSONL 每个事件写一行(见 [persistence.md](./persistence.md))。所有 `event.data` 都必须可序列化为 JSON;`Session.append` 会从源头强制这一要求(遇到不可序列化数据时抛出),因此错误事件绝不会进入日志,`session.snapshotEvents()` 始终与后端可持久化的内容一致。新增会携带不可序列化数据、破坏核心执行嵌套或违反事件所有方声明关系的事件类型,都会构成磁盘格式的破坏性变更。
666
766
 
667
767
  消费此约定的后端见 [persistence.md](./persistence.md)。
668
768
 
@@ -670,7 +770,9 @@ interface TurnEndReasonMap {
670
770
 
671
771
  `ModelCatalog` 是 `session/modelCatalog` 返回的 Host generation 模型目录:它携带部署默认值、可路由 provider id、成功的 provider 分组与相互隔离的 provider 失败。它不由某个 Session 派生,因此与 Session projection 分开保存。
672
772
 
673
- `SessionOpenWorkspacePathRequest` 携带绝对路径或已按 workspace 解析的 `path`。`SessionOpenWorkspacePathValue` 确认 Host 已接受原生交接。Session-aware Client 会在已知当前 Session cwd 时据此解析相对路径;controller 将路径原样交给打开器,并通过 Session Remote 错误词汇表报告无效请求、取消与打开器失败。
773
+ `SessionOpenWorkspacePathRequest` 携带绝对路径或已按 workspace 解析的 `path`。`SessionOpenWorkspacePathValue` 确认 Host 已接受原生交接。Session-aware Client 会在已知当前 Session cwd 时据此解析相对路径;controller 将路径原样交给打开器,并通过 Session Remote 错误词汇表报告无效请求、取消与打开器失败。 可选的 `action: "reveal"` 选择文件管理器导航;省略时使用默认应用打开。
774
+
775
+ 可选的 `application` 指定文件关联应用,不修改系统默认值;`workspacePathApplications({ path })` 在校验 Host 路径后返回当前关联应用、名称、图标和默认项。
674
776
 
675
777
  <!-- BEGIN GENERATED cordis-surface (gen-cordis-catalog.ts) — do not edit between markers -->
676
778
 
@@ -705,7 +807,7 @@ inspect( sessionId: SessionId, signal?: AbortSignal, ): Promise<SessionInspectio
705
807
  /**
706
808
  * Read all visible Session rows without resuming an Agent.
707
809
  * @param _request - reserved empty list request.
708
- * @param signal - cancellation for persistence reads.
810
+ * @param signal - cancellation for persistence reads and summary generation.
709
811
  * @returns visible Session summaries ordered by activity.
710
812
  */
711
813
  @Remote('list') async list(_request: SessionListRequest, signal: AbortSignal): Promise<SessionListValue>
@@ -726,12 +828,18 @@ inspect( sessionId: SessionId, signal?: AbortSignal, ): Promise<SessionInspectio
726
828
  @Remote('create') create(request: SessionCreateRequest): Promise<SessionCreateValue>
727
829
 
728
830
  /**
729
- * Select one Session-local model after explicitly resuming the Session.
831
+ * Select one Session-local model after explicitly resuming the Session; save the default in the background.
730
832
  * @param request - Session identity and requested model selection.
731
- * @returns the normalized selection installed for the Session.
833
+ * @returns the normalized selection installed for the Session, without waiting for default persistence.
732
834
  */
733
835
  @Remote('selectModel') selectModel(request: SessionSelectModelRequest): Promise<SessionSelectModelValue>
734
836
 
837
+ /**
838
+ * Select the first available account model after login when no provider API key is configured.
839
+ * @returns after saving the first available model or retaining the existing default.
840
+ */
841
+ @Remote async initializeDefaultModel(): Promise<void>
842
+
735
843
  /**
736
844
  * Describe every currently routable model for Host-generation selectors.
737
845
  * @returns provider-grouped models, the deployment default, and isolated provider failures.
@@ -745,14 +853,29 @@ inspect( sessionId: SessionId, signal?: AbortSignal, ): Promise<SessionInspectio
745
853
  @Remote canOpenWorkspacePath(): boolean
746
854
 
747
855
  /**
748
- * Open one path prepared by a Session-aware caller on the Host desktop.
856
+ * Describe the serving desktop for authenticated file-action routes.
857
+ * @returns Host name, configured availability, and platform-specific file-manager behavior.
858
+ */
859
+ workspaceDesktop(): { name: string; available: boolean; fileManager: 'finder' | 'explorer' | 'directory' | null }
860
+
861
+ /**
862
+ * Verify one path through the composed filesystem and open it on the Host desktop.
749
863
  * @param request - path after best-effort Session workspace resolution.
750
864
  * @param signal - caller lifetime; abort terminates the native command.
751
865
  * @returns confirmation after the native opener accepts the path.
752
- * @throws RemoteError when the request is invalid, cancelled, or the opener fails.
866
+ * @throws RemoteError when the request is invalid, has no verified Host mapping, is cancelled, or the opener fails.
753
867
  */
754
868
  @Remote('openWorkspacePath') async openWorkspacePath( request: SessionOpenWorkspacePathRequest, signal: AbortSignal, ): Promise<SessionOpenWorkspacePathValue>
755
869
 
870
+ /**
871
+ * Query current file handlers on the serving desktop without activating an Agent.
872
+ * @param request - file path in Host filesystem syntax.
873
+ * @param signal - caller lifetime, propagated to filesystem and desktop queries.
874
+ * @returns OS application names, icons, and default selection; empty when desktop opening is unavailable.
875
+ * @throws RemoteError when the path is invalid, the query is cancelled, or native discovery fails.
876
+ */
877
+ @Remote('workspacePathApplications') async workspacePathApplications( request: { readonly path: string }, signal: AbortSignal, ): Promise<readonly SessionWorkspacePathApplication[]>
878
+
756
879
  /**
757
880
  * Rename one Session after explicitly resuming it.
758
881
  * @param request - Session identity and proposed title.
@@ -761,8 +884,10 @@ inspect( sessionId: SessionId, signal?: AbortSignal, ): Promise<SessionInspectio
761
884
  @Remote('rename') rename(request: SessionRenameRequest): Promise<SessionRenameValue>
762
885
 
763
886
  /**
764
- * Fork one cold-readable completed-turn prefix into a new Session.
765
- * @param request - source Session and optional event anchor.
887
+ * Fork one cold-readable exact event prefix into a new Session. An omitted
888
+ * boundary selects the latest completed-turn prefix; an open cut receives
889
+ * synthetic fork closers.
890
+ * @param request - source Session and optional exact inclusive event boundary.
766
891
  * @returns the new Session identity.
767
892
  */
768
893
  @Remote('fork') fork(request: SessionForkRequest): Promise<SessionForkValue>
@@ -783,11 +908,11 @@ inspect( sessionId: SessionId, signal?: AbortSignal, ): Promise<SessionInspectio
783
908
  @Remote('attachment') attachment(request: SessionAttachmentRequest): Promise<SessionAttachmentValue>
784
909
 
785
910
  /**
786
- * Mutate one still-pending queue occurrence on a live Agent.
911
+ * Mutate one still-pending queue occurrence, resuming a cold Agent first.
787
912
  * @param request - Session, queue item, and requested mutation.
788
913
  * @returns acknowledgement that the queue mutation was applied.
789
914
  */
790
- @Remote('updateQueue') updateQueue(request: SessionUpdateQueueRequest): SessionUpdateQueueValue
915
+ @Remote('updateQueue') updateQueue(request: SessionUpdateQueueRequest): Promise<SessionUpdateQueueValue>
791
916
 
792
917
  /**
793
918
  * Cancel one active Agent turn without dropping its pending inbox.
@@ -813,6 +938,14 @@ inspect( sessionId: SessionId, signal?: AbortSignal, ): Promise<SessionInspectio
813
938
  */
814
939
  @Remote({ mode: 'stream' }) follow(request: SessionFollowRequest, signal: AbortSignal): AsyncIterable<SessionFollowFrame>
815
940
 
941
+ /**
942
+ * Read all registered projections without activating an Agent.
943
+ * @param request - Session whose current values are required.
944
+ * @param signal - cancellation for the Session observation.
945
+ * @returns complete baseline, or null when the Session does not exist.
946
+ */
947
+ @Remote('projections') async projections(request: SessionProjectionsRequest, signal: AbortSignal): Promise<SessionProjectionsValue>
948
+
816
949
  /**
817
950
  * Stream a complete live-control baseline followed by replacement frames.
818
951
  * @param signal - cancellation owned by the Remote stream carrier.
@@ -834,6 +967,15 @@ In-memory session store (`ctx.sessions`).
834
967
  Persistence is intentionally not implemented here — the agent lifecycle attaches a session-log writer to each published session's write handle; a session published outside that lifecycle persists nothing.
835
968
 
836
969
  ```ts cordis-catalog
970
+ /**
971
+ * Register one event interpreter for live creation, restore, and fork.
972
+ * Disposing the contribution makes sessions that used it refuse further derivation.
973
+ * @param projection - pure definition owned by the event's plugin.
974
+ * @returns the fiber-owned disposer.
975
+ * @throws when another definition already owns this event type.
976
+ */
977
+ registerMessageProjection(projection: SessionMessageProjection): () => Promise<void>
978
+
837
979
  /**
838
980
  * Create a session owned by the calling fiber: disposing that fiber stops
839
981
  * event notification and removes the session from the store. `options.seed`
@@ -868,10 +1010,9 @@ create(id?: SessionId, options?: CreateSessionOptions): Session
868
1010
  *
869
1011
  * @param id - the session id; omitted, the store mints `session-<n>`.
870
1012
  * @param options - seed events and/or creation metadata for the header. With
871
- * `seedSource: 'persistence'`, metadata and events must be fresh detached
872
- * graphs whose ownership transfers to this call: they are validated and
873
- * frozen in place through {@link Session.fromRestore}, so the caller must
874
- * retain no mutable aliases.
1013
+ * `eventState`, every seed event is either independently owned or any
1014
+ * shared value is deeply frozen; {@link Session.fromRestore} validates and
1015
+ * adopts those values without copying or freezing them.
875
1016
  * @returns the constructed session, NOT yet in the store.
876
1017
  * @throws if a session with `id` already exists, metadata is not a plain
877
1018
  * lossless-JSON record with valid scalar fields, or `meta.cwd` is a
@@ -918,8 +1059,8 @@ announce(session: Session): void
918
1059
  * store owns the carrier, so callers (the checkpoint policy's per-request
919
1060
  * barrier, goal-round-driver's idle checkpoint, teardown drains, and consumers
920
1061
  * that flush themselves before reading storage) must come through here
921
- * rather than dispatch a raw `ctx.parallel('session/flush', …)` — one owner,
922
- * one spelling, and the scoped-dispatch invariant can pin it.
1062
+ * rather than dispatch a raw `ctx.parallel('session/flush', …)` — one owner
1063
+ * and one spelling.
923
1064
  * @param session - the session whose buffered events must reach durable storage.
924
1065
  * @returns whether at least one durability listener participated, after every
925
1066
  * listener has settled successfully.
@@ -941,10 +1082,12 @@ get(id: SessionId): Session | undefined
941
1082
  list(): Session[]
942
1083
 
943
1084
  /**
944
- * Create a live child session from a stable prefix of a live source.
1085
+ * Create a live child session from an exact prefix of a live source.
945
1086
  * `boundary` is an inclusive source event seq; omitted means the source's
946
- * current last event. The selected slice may end with a between-turn event
947
- * but must not end inside an open turn.
1087
+ * current last event. An open tail receives synthetic tool results and
1088
+ * step/turn closers with the forked cause. Closed steps and turns remain
1089
+ * unchanged, including any failed tool calls already missing results.
1090
+ * `inheritedEventCount` counts only copied source events, excluding these closers.
948
1091
  *
949
1092
  * @param source - Live source session object or id.
950
1093
  * @param boundary - Inclusive source event seq to fork through; omitted means
@@ -989,13 +1132,14 @@ Source: [`packages/api/session-controller/src/types.ts`](https://github.com/deep
989
1132
 
990
1133
  #### `api-session/added` — emit
991
1134
 
992
- A Session became visible to Session list consumers.
1135
+ A Session became visible or its Agent was created or disposed. Consumers upsert the summary and replace its current running and availability state.
993
1136
 
994
1137
  ```ts cordis-catalog
995
1138
  /**
996
- * A Session became visible to Session list consumers.
1139
+ * A Session became visible or its Agent was created or disposed.
1140
+ * Consumers upsert the summary and replace its current running and availability state.
997
1141
  * @mode emit
998
- * @param summary - initial list row for the Session.
1142
+ * @param summary - current list row for the Session.
999
1143
  */
1000
1144
  'api-session/added'(summary: SessionSummary): void
1001
1145
  ```
@@ -1080,7 +1224,6 @@ Creation announcement during session publication. A synchronous throw vetoes and
1080
1224
  * Scope-filtered dispatch (`@deepseek-ai/dsh-scope`): agent-scoped listeners
1081
1225
  * receive only sessions entered through that agent's context.
1082
1226
  * @param session - the session just entered and announced.
1083
- * @dshScopeScan unsupported
1084
1227
  * @mode emit
1085
1228
  */
1086
1229
  'session/created'(this: Scoped<Session>, session: Session): void
@@ -1103,7 +1246,6 @@ Emitted once when an announced session leaves the store, including publication r
1103
1246
  * did not begin. Listener failures are logged and contained.
1104
1247
  * Scope-filtered dispatch (`@deepseek-ai/dsh-scope`) reuses the owner scope.
1105
1248
  * @param session - the session that is no longer live in the store.
1106
- * @dshScopeScan unsupported
1107
1249
  * @mode emit
1108
1250
  */
1109
1251
  'session/disposed'(this: Scoped<Session>, session: Session): void
@@ -1128,7 +1270,6 @@ Post-commit, fire-and-forget append feed. The listener snapshot resolves before
1128
1270
  * receive only events from sessions entered through that agent's context.
1129
1271
  * @param session - the session whose log grew.
1130
1272
  * @param event - the appended event, exactly as recorded.
1131
- * @dshScopeScan unsupported
1132
1273
  * @mode emit
1133
1274
  */
1134
1275
  'session/event'(this: Scoped<Session>, session: Session, event: SessionEvent): void
@@ -1150,7 +1291,6 @@ Awaited parallel durability checkpoint: every listener runs and the caller await
1150
1291
  * caller awaits all of them, with no waterfall veto. Scope-filtered dispatch
1151
1292
  * (`@deepseek-ai/dsh-scope`) reuses the session's owner scope.
1152
1293
  * @param session - the session whose buffered events must reach durable storage.
1153
- * @dshScopeScan unsupported
1154
1294
  * @mode parallel
1155
1295
  */
1156
1296
  'session/flush'(this: Scoped<Session>, session: Session): Promise<void> | void