dsh-plugin-guide 0.1.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 (374) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE.md +26 -0
  3. package/README.es.md +139 -0
  4. package/README.hi.md +138 -0
  5. package/README.md +165 -0
  6. package/README.pt.md +139 -0
  7. package/README.zh-CN.md +164 -0
  8. package/SKILL.md +69 -0
  9. package/cordis.patch.yml +4 -0
  10. package/guide/links.md +92 -0
  11. package/guide/plugin-dev-guide.md +429 -0
  12. package/guide/quick-reference.es.md +176 -0
  13. package/guide/quick-reference.hi.md +176 -0
  14. package/guide/quick-reference.md +176 -0
  15. package/guide/quick-reference.pt.md +176 -0
  16. package/guide/quick-reference.zh-CN.md +175 -0
  17. package/index.js +58 -0
  18. package/package.json +83 -0
  19. package/references/community-ecosystem.md +201 -0
  20. package/references/community-repo-deep-dive.md +695 -0
  21. package/references/cordis-paper-and-community.md +326 -0
  22. package/references/harness-repo.md +654 -0
  23. package/references/official-docs/AGENTS.md +149 -0
  24. package/references/official-docs/BENCHMARK.md +3 -0
  25. package/references/official-docs/CLAUDE.md +1 -0
  26. package/references/official-docs/CONTRIBUTING.i18n.yaml +6 -0
  27. package/references/official-docs/CONTRIBUTING.md +23 -0
  28. package/references/official-docs/CONTRIBUTING.zh.md +23 -0
  29. package/references/official-docs/LICENSE +21 -0
  30. package/references/official-docs/README.i18n.yaml +6 -0
  31. package/references/official-docs/README.md +35 -0
  32. package/references/official-docs/README.zh.md +74 -0
  33. package/references/official-docs/SNAPSHOT.md +16 -0
  34. package/references/official-docs/THIRD_PARTY_NOTICES.md +192 -0
  35. package/references/official-docs/docs/AGENTS.md +75 -0
  36. package/references/official-docs/docs/agent-lifecycle.i18n.yaml +6 -0
  37. package/references/official-docs/docs/agent-lifecycle.md +82 -0
  38. package/references/official-docs/docs/agent-lifecycle.zh.md +84 -0
  39. package/references/official-docs/docs/api-gateway.i18n.yaml +6 -0
  40. package/references/official-docs/docs/api-gateway.md +164 -0
  41. package/references/official-docs/docs/api-gateway.zh.md +164 -0
  42. package/references/official-docs/docs/architecture.i18n.yaml +6 -0
  43. package/references/official-docs/docs/architecture.md +129 -0
  44. package/references/official-docs/docs/architecture.zh.md +133 -0
  45. package/references/official-docs/docs/capability-seams.i18n.yaml +6 -0
  46. package/references/official-docs/docs/capability-seams.md +471 -0
  47. package/references/official-docs/docs/capability-seams.zh.md +473 -0
  48. package/references/official-docs/docs/config-catalog.i18n.yaml +6 -0
  49. package/references/official-docs/docs/config-catalog.md +3151 -0
  50. package/references/official-docs/docs/config-catalog.zh.md +3152 -0
  51. package/references/official-docs/docs/cookbook/adding-a-conversation-node.i18n.yaml +6 -0
  52. package/references/official-docs/docs/cookbook/adding-a-conversation-node.md +233 -0
  53. package/references/official-docs/docs/cookbook/adding-a-conversation-node.zh.md +233 -0
  54. package/references/official-docs/docs/cookbook/adding-a-package.i18n.yaml +6 -0
  55. package/references/official-docs/docs/cookbook/adding-a-package.md +118 -0
  56. package/references/official-docs/docs/cookbook/adding-a-package.zh.md +118 -0
  57. package/references/official-docs/docs/cookbook/adding-a-tool.i18n.yaml +6 -0
  58. package/references/official-docs/docs/cookbook/adding-a-tool.md +94 -0
  59. package/references/official-docs/docs/cookbook/adding-a-tool.zh.md +96 -0
  60. package/references/official-docs/docs/cookbook/adding-a-vendored-package.i18n.yaml +6 -0
  61. package/references/official-docs/docs/cookbook/adding-a-vendored-package.md +59 -0
  62. package/references/official-docs/docs/cookbook/adding-a-vendored-package.zh.md +59 -0
  63. package/references/official-docs/docs/cookbook/adding-an-llm-adapter.i18n.yaml +6 -0
  64. package/references/official-docs/docs/cookbook/adding-an-llm-adapter.md +43 -0
  65. package/references/official-docs/docs/cookbook/adding-an-llm-adapter.zh.md +43 -0
  66. package/references/official-docs/docs/cookbook/extension-cookbook.i18n.yaml +6 -0
  67. package/references/official-docs/docs/cookbook/extension-cookbook.md +129 -0
  68. package/references/official-docs/docs/cookbook/extension-cookbook.zh.md +131 -0
  69. package/references/official-docs/docs/cookbook/maintaining-dsh-code-review.i18n.yaml +6 -0
  70. package/references/official-docs/docs/cookbook/maintaining-dsh-code-review.md +64 -0
  71. package/references/official-docs/docs/cookbook/maintaining-dsh-code-review.zh.md +64 -0
  72. package/references/official-docs/docs/cookbook/responding-to-pr-review-on-a-stack.i18n.yaml +6 -0
  73. package/references/official-docs/docs/cookbook/responding-to-pr-review-on-a-stack.md +32 -0
  74. package/references/official-docs/docs/cookbook/responding-to-pr-review-on-a-stack.zh.md +32 -0
  75. package/references/official-docs/docs/cordis-api/context.i18n.yaml +6 -0
  76. package/references/official-docs/docs/cordis-api/context.md +364 -0
  77. package/references/official-docs/docs/cordis-api/context.zh.md +366 -0
  78. package/references/official-docs/docs/cordis-api/events.i18n.yaml +6 -0
  79. package/references/official-docs/docs/cordis-api/events.md +207 -0
  80. package/references/official-docs/docs/cordis-api/events.zh.md +209 -0
  81. package/references/official-docs/docs/cordis-api/fiber.i18n.yaml +6 -0
  82. package/references/official-docs/docs/cordis-api/fiber.md +375 -0
  83. package/references/official-docs/docs/cordis-api/fiber.zh.md +377 -0
  84. package/references/official-docs/docs/cordis-api/inherited.md +39 -0
  85. package/references/official-docs/docs/cordis-api/registry.i18n.yaml +6 -0
  86. package/references/official-docs/docs/cordis-api/registry.md +152 -0
  87. package/references/official-docs/docs/cordis-api/registry.zh.md +154 -0
  88. package/references/official-docs/docs/cordis-api/service.i18n.yaml +6 -0
  89. package/references/official-docs/docs/cordis-api/service.md +102 -0
  90. package/references/official-docs/docs/cordis-api/service.zh.md +104 -0
  91. package/references/official-docs/docs/cordis-primer.i18n.yaml +6 -0
  92. package/references/official-docs/docs/cordis-primer.md +44 -0
  93. package/references/official-docs/docs/cordis-primer.zh.md +50 -0
  94. package/references/official-docs/docs/cordis-tutorial/01-first-plugin.i18n.yaml +6 -0
  95. package/references/official-docs/docs/cordis-tutorial/01-first-plugin.md +95 -0
  96. package/references/official-docs/docs/cordis-tutorial/01-first-plugin.zh.md +95 -0
  97. package/references/official-docs/docs/cordis-tutorial/02-lifecycle-and-effects.i18n.yaml +6 -0
  98. package/references/official-docs/docs/cordis-tutorial/02-lifecycle-and-effects.md +98 -0
  99. package/references/official-docs/docs/cordis-tutorial/02-lifecycle-and-effects.zh.md +98 -0
  100. package/references/official-docs/docs/cordis-tutorial/03-services.i18n.yaml +6 -0
  101. package/references/official-docs/docs/cordis-tutorial/03-services.md +98 -0
  102. package/references/official-docs/docs/cordis-tutorial/03-services.zh.md +98 -0
  103. package/references/official-docs/docs/cordis-tutorial/04-events.i18n.yaml +6 -0
  104. package/references/official-docs/docs/cordis-tutorial/04-events.md +144 -0
  105. package/references/official-docs/docs/cordis-tutorial/04-events.zh.md +144 -0
  106. package/references/official-docs/docs/cordis-tutorial/05-config.i18n.yaml +6 -0
  107. package/references/official-docs/docs/cordis-tutorial/05-config.md +84 -0
  108. package/references/official-docs/docs/cordis-tutorial/05-config.zh.md +84 -0
  109. package/references/official-docs/docs/cordis-tutorial/06-composition-and-hmr.i18n.yaml +6 -0
  110. package/references/official-docs/docs/cordis-tutorial/06-composition-and-hmr.md +113 -0
  111. package/references/official-docs/docs/cordis-tutorial/06-composition-and-hmr.zh.md +113 -0
  112. package/references/official-docs/docs/cordis-tutorial/07-into-the-harness.i18n.yaml +6 -0
  113. package/references/official-docs/docs/cordis-tutorial/07-into-the-harness.md +107 -0
  114. package/references/official-docs/docs/cordis-tutorial/07-into-the-harness.zh.md +107 -0
  115. package/references/official-docs/docs/cordis-tutorial/index.i18n.yaml +6 -0
  116. package/references/official-docs/docs/cordis-tutorial/index.md +60 -0
  117. package/references/official-docs/docs/cordis-tutorial/index.zh.md +62 -0
  118. package/references/official-docs/docs/defensive-patterns.i18n.yaml +6 -0
  119. package/references/official-docs/docs/defensive-patterns.md +33 -0
  120. package/references/official-docs/docs/defensive-patterns.zh.md +33 -0
  121. package/references/official-docs/docs/development.i18n.yaml +6 -0
  122. package/references/official-docs/docs/development.md +171 -0
  123. package/references/official-docs/docs/development.zh.md +171 -0
  124. package/references/official-docs/docs/event-producer-consumer.i18n.yaml +6 -0
  125. package/references/official-docs/docs/event-producer-consumer.md +76 -0
  126. package/references/official-docs/docs/event-producer-consumer.zh.md +78 -0
  127. package/references/official-docs/docs/glossary.i18n.yaml +6 -0
  128. package/references/official-docs/docs/glossary.md +45 -0
  129. package/references/official-docs/docs/glossary.zh.md +45 -0
  130. package/references/official-docs/docs/graph-atlas.i18n.yaml +6 -0
  131. package/references/official-docs/docs/graph-atlas.md +24 -0
  132. package/references/official-docs/docs/graph-atlas.zh.md +26 -0
  133. package/references/official-docs/docs/i18n/README.i18n.yaml +6 -0
  134. package/references/official-docs/docs/i18n/README.md +60 -0
  135. package/references/official-docs/docs/i18n/README.zh.md +60 -0
  136. package/references/official-docs/docs/i18n/style-samples.md +87 -0
  137. package/references/official-docs/docs/i18n/terminology.md +214 -0
  138. package/references/official-docs/docs/i18n/translation-prompt.md +263 -0
  139. package/references/official-docs/docs/i18n/translation-rules.i18n.yaml +6 -0
  140. package/references/official-docs/docs/i18n/translation-rules.md +69 -0
  141. package/references/official-docs/docs/i18n/translation-rules.zh.md +69 -0
  142. package/references/official-docs/docs/module-graph.i18n.yaml +6 -0
  143. package/references/official-docs/docs/module-graph.md +1638 -0
  144. package/references/official-docs/docs/module-graph.zh.md +1640 -0
  145. package/references/official-docs/docs/persistence-catalog.i18n.yaml +6 -0
  146. package/references/official-docs/docs/persistence-catalog.md +944 -0
  147. package/references/official-docs/docs/persistence-catalog.zh.md +946 -0
  148. package/references/official-docs/docs/postmortem/0001-acp-default-export-drops-inject.i18n.yaml +6 -0
  149. package/references/official-docs/docs/postmortem/0001-acp-default-export-drops-inject.md +113 -0
  150. package/references/official-docs/docs/postmortem/0001-acp-default-export-drops-inject.zh.md +113 -0
  151. package/references/official-docs/docs/postmortem/0002-js-expression-disabled-filesystem-tools.i18n.yaml +6 -0
  152. package/references/official-docs/docs/postmortem/0002-js-expression-disabled-filesystem-tools.md +47 -0
  153. package/references/official-docs/docs/postmortem/0002-js-expression-disabled-filesystem-tools.zh.md +47 -0
  154. package/references/official-docs/docs/postmortem/0003-web-agent-gui-feedback-loop.i18n.yaml +6 -0
  155. package/references/official-docs/docs/postmortem/0003-web-agent-gui-feedback-loop.md +53 -0
  156. package/references/official-docs/docs/postmortem/0003-web-agent-gui-feedback-loop.zh.md +53 -0
  157. package/references/official-docs/docs/postmortem/0004-landlock-partial-notice-misclassified-child-failures.i18n.yaml +6 -0
  158. package/references/official-docs/docs/postmortem/0004-landlock-partial-notice-misclassified-child-failures.md +55 -0
  159. package/references/official-docs/docs/postmortem/0004-landlock-partial-notice-misclassified-child-failures.zh.md +55 -0
  160. package/references/official-docs/docs/postmortem/README.i18n.yaml +6 -0
  161. package/references/official-docs/docs/postmortem/README.md +18 -0
  162. package/references/official-docs/docs/postmortem/README.zh.md +18 -0
  163. package/references/official-docs/docs/rescope.i18n.yaml +6 -0
  164. package/references/official-docs/docs/rescope.md +53 -0
  165. package/references/official-docs/docs/rescope.zh.md +53 -0
  166. package/references/official-docs/docs/subsystems/README.i18n.yaml +6 -0
  167. package/references/official-docs/docs/subsystems/README.md +55 -0
  168. package/references/official-docs/docs/subsystems/README.zh.md +55 -0
  169. package/references/official-docs/docs/subsystems/approval.i18n.yaml +6 -0
  170. package/references/official-docs/docs/subsystems/approval.md +170 -0
  171. package/references/official-docs/docs/subsystems/approval.zh.md +170 -0
  172. package/references/official-docs/docs/subsystems/attachment.i18n.yaml +6 -0
  173. package/references/official-docs/docs/subsystems/attachment.md +115 -0
  174. package/references/official-docs/docs/subsystems/attachment.zh.md +115 -0
  175. package/references/official-docs/docs/subsystems/client-modules.i18n.yaml +6 -0
  176. package/references/official-docs/docs/subsystems/client-modules.md +118 -0
  177. package/references/official-docs/docs/subsystems/client-modules.zh.md +118 -0
  178. package/references/official-docs/docs/subsystems/code-runtime.i18n.yaml +6 -0
  179. package/references/official-docs/docs/subsystems/code-runtime.md +191 -0
  180. package/references/official-docs/docs/subsystems/code-runtime.zh.md +191 -0
  181. package/references/official-docs/docs/subsystems/commands.i18n.yaml +6 -0
  182. package/references/official-docs/docs/subsystems/commands.md +187 -0
  183. package/references/official-docs/docs/subsystems/commands.zh.md +187 -0
  184. package/references/official-docs/docs/subsystems/compaction.i18n.yaml +6 -0
  185. package/references/official-docs/docs/subsystems/compaction.md +238 -0
  186. package/references/official-docs/docs/subsystems/compaction.zh.md +238 -0
  187. package/references/official-docs/docs/subsystems/core.i18n.yaml +6 -0
  188. package/references/official-docs/docs/subsystems/core.md +1070 -0
  189. package/references/official-docs/docs/subsystems/core.zh.md +1078 -0
  190. package/references/official-docs/docs/subsystems/credentials.i18n.yaml +6 -0
  191. package/references/official-docs/docs/subsystems/credentials.md +133 -0
  192. package/references/official-docs/docs/subsystems/credentials.zh.md +133 -0
  193. package/references/official-docs/docs/subsystems/extensions.i18n.yaml +6 -0
  194. package/references/official-docs/docs/subsystems/extensions.md +364 -0
  195. package/references/official-docs/docs/subsystems/extensions.zh.md +364 -0
  196. package/references/official-docs/docs/subsystems/feedback.i18n.yaml +6 -0
  197. package/references/official-docs/docs/subsystems/feedback.md +266 -0
  198. package/references/official-docs/docs/subsystems/feedback.zh.md +266 -0
  199. package/references/official-docs/docs/subsystems/filesystem.i18n.yaml +6 -0
  200. package/references/official-docs/docs/subsystems/filesystem.md +495 -0
  201. package/references/official-docs/docs/subsystems/filesystem.zh.md +495 -0
  202. package/references/official-docs/docs/subsystems/goal.i18n.yaml +6 -0
  203. package/references/official-docs/docs/subsystems/goal.md +277 -0
  204. package/references/official-docs/docs/subsystems/goal.zh.md +277 -0
  205. package/references/official-docs/docs/subsystems/invariants.i18n.yaml +6 -0
  206. package/references/official-docs/docs/subsystems/invariants.md +88 -0
  207. package/references/official-docs/docs/subsystems/invariants.zh.md +88 -0
  208. package/references/official-docs/docs/subsystems/jobs.i18n.yaml +6 -0
  209. package/references/official-docs/docs/subsystems/jobs.md +290 -0
  210. package/references/official-docs/docs/subsystems/jobs.zh.md +290 -0
  211. package/references/official-docs/docs/subsystems/llm-streaming.i18n.yaml +6 -0
  212. package/references/official-docs/docs/subsystems/llm-streaming.md +888 -0
  213. package/references/official-docs/docs/subsystems/llm-streaming.zh.md +894 -0
  214. package/references/official-docs/docs/subsystems/lsp.i18n.yaml +6 -0
  215. package/references/official-docs/docs/subsystems/lsp.md +202 -0
  216. package/references/official-docs/docs/subsystems/lsp.zh.md +202 -0
  217. package/references/official-docs/docs/subsystems/permission-presets.i18n.yaml +6 -0
  218. package/references/official-docs/docs/subsystems/permission-presets.md +131 -0
  219. package/references/official-docs/docs/subsystems/permission-presets.zh.md +131 -0
  220. package/references/official-docs/docs/subsystems/persistence.i18n.yaml +6 -0
  221. package/references/official-docs/docs/subsystems/persistence.md +385 -0
  222. package/references/official-docs/docs/subsystems/persistence.zh.md +385 -0
  223. package/references/official-docs/docs/subsystems/plan.i18n.yaml +6 -0
  224. package/references/official-docs/docs/subsystems/plan.md +87 -0
  225. package/references/official-docs/docs/subsystems/plan.zh.md +87 -0
  226. package/references/official-docs/docs/subsystems/sandbox.i18n.yaml +6 -0
  227. package/references/official-docs/docs/subsystems/sandbox.md +218 -0
  228. package/references/official-docs/docs/subsystems/sandbox.zh.md +218 -0
  229. package/references/official-docs/docs/subsystems/schedule.i18n.yaml +6 -0
  230. package/references/official-docs/docs/subsystems/schedule.md +186 -0
  231. package/references/official-docs/docs/subsystems/schedule.zh.md +186 -0
  232. package/references/official-docs/docs/subsystems/scope.i18n.yaml +6 -0
  233. package/references/official-docs/docs/subsystems/scope.md +59 -0
  234. package/references/official-docs/docs/subsystems/scope.zh.md +59 -0
  235. package/references/official-docs/docs/subsystems/session-projection.i18n.yaml +6 -0
  236. package/references/official-docs/docs/subsystems/session-projection.md +262 -0
  237. package/references/official-docs/docs/subsystems/session-projection.zh.md +262 -0
  238. package/references/official-docs/docs/subsystems/session-query.i18n.yaml +6 -0
  239. package/references/official-docs/docs/subsystems/session-query.md +495 -0
  240. package/references/official-docs/docs/subsystems/session-query.zh.md +495 -0
  241. package/references/official-docs/docs/subsystems/session-reference.i18n.yaml +6 -0
  242. package/references/official-docs/docs/subsystems/session-reference.md +108 -0
  243. package/references/official-docs/docs/subsystems/session-reference.zh.md +108 -0
  244. package/references/official-docs/docs/subsystems/session-telemetry.i18n.yaml +6 -0
  245. package/references/official-docs/docs/subsystems/session-telemetry.md +194 -0
  246. package/references/official-docs/docs/subsystems/session-telemetry.zh.md +194 -0
  247. package/references/official-docs/docs/subsystems/session-title.i18n.yaml +6 -0
  248. package/references/official-docs/docs/subsystems/session-title.md +204 -0
  249. package/references/official-docs/docs/subsystems/session-title.zh.md +204 -0
  250. package/references/official-docs/docs/subsystems/session.i18n.yaml +6 -0
  251. package/references/official-docs/docs/subsystems/session.md +849 -0
  252. package/references/official-docs/docs/subsystems/session.zh.md +851 -0
  253. package/references/official-docs/docs/subsystems/settings.i18n.yaml +6 -0
  254. package/references/official-docs/docs/subsystems/settings.md +310 -0
  255. package/references/official-docs/docs/subsystems/settings.zh.md +310 -0
  256. package/references/official-docs/docs/subsystems/shell.i18n.yaml +6 -0
  257. package/references/official-docs/docs/subsystems/shell.md +303 -0
  258. package/references/official-docs/docs/subsystems/shell.zh.md +303 -0
  259. package/references/official-docs/docs/subsystems/skills.i18n.yaml +6 -0
  260. package/references/official-docs/docs/subsystems/skills.md +331 -0
  261. package/references/official-docs/docs/subsystems/skills.zh.md +331 -0
  262. package/references/official-docs/docs/subsystems/spill.i18n.yaml +6 -0
  263. package/references/official-docs/docs/subsystems/spill.md +117 -0
  264. package/references/official-docs/docs/subsystems/spill.zh.md +117 -0
  265. package/references/official-docs/docs/subsystems/storage.i18n.yaml +6 -0
  266. package/references/official-docs/docs/subsystems/storage.md +229 -0
  267. package/references/official-docs/docs/subsystems/storage.zh.md +229 -0
  268. package/references/official-docs/docs/subsystems/subagent.i18n.yaml +6 -0
  269. package/references/official-docs/docs/subsystems/subagent.md +734 -0
  270. package/references/official-docs/docs/subsystems/subagent.zh.md +736 -0
  271. package/references/official-docs/docs/subsystems/subprocess.i18n.yaml +6 -0
  272. package/references/official-docs/docs/subsystems/subprocess.md +324 -0
  273. package/references/official-docs/docs/subsystems/subprocess.zh.md +324 -0
  274. package/references/official-docs/docs/subsystems/system-prompt.i18n.yaml +6 -0
  275. package/references/official-docs/docs/subsystems/system-prompt.md +207 -0
  276. package/references/official-docs/docs/subsystems/system-prompt.zh.md +207 -0
  277. package/references/official-docs/docs/subsystems/terminal.i18n.yaml +6 -0
  278. package/references/official-docs/docs/subsystems/terminal.md +184 -0
  279. package/references/official-docs/docs/subsystems/terminal.zh.md +184 -0
  280. package/references/official-docs/docs/subsystems/token-meter.i18n.yaml +6 -0
  281. package/references/official-docs/docs/subsystems/token-meter.md +90 -0
  282. package/references/official-docs/docs/subsystems/token-meter.zh.md +90 -0
  283. package/references/official-docs/docs/subsystems/tools.i18n.yaml +6 -0
  284. package/references/official-docs/docs/subsystems/tools.md +720 -0
  285. package/references/official-docs/docs/subsystems/tools.zh.md +720 -0
  286. package/references/official-docs/docs/subsystems/typert.i18n.yaml +6 -0
  287. package/references/official-docs/docs/subsystems/typert.md +336 -0
  288. package/references/official-docs/docs/subsystems/typert.zh.md +336 -0
  289. package/references/official-docs/docs/subsystems/user-questions.i18n.yaml +6 -0
  290. package/references/official-docs/docs/subsystems/user-questions.md +178 -0
  291. package/references/official-docs/docs/subsystems/user-questions.zh.md +178 -0
  292. package/references/official-docs/docs/subsystems/web-server.i18n.yaml +6 -0
  293. package/references/official-docs/docs/subsystems/web-server.md +108 -0
  294. package/references/official-docs/docs/subsystems/web-server.zh.md +108 -0
  295. package/references/official-docs/docs/subsystems/web.i18n.yaml +6 -0
  296. package/references/official-docs/docs/subsystems/web.md +199 -0
  297. package/references/official-docs/docs/subsystems/web.zh.md +199 -0
  298. package/references/official-docs/docs/subsystems/workflow.i18n.yaml +6 -0
  299. package/references/official-docs/docs/subsystems/workflow.md +278 -0
  300. package/references/official-docs/docs/subsystems/workflow.zh.md +278 -0
  301. package/references/official-docs/docs/subsystems/workspace.i18n.yaml +6 -0
  302. package/references/official-docs/docs/subsystems/workspace.md +228 -0
  303. package/references/official-docs/docs/subsystems/workspace.zh.md +228 -0
  304. package/references/official-docs/docs/testing.i18n.yaml +6 -0
  305. package/references/official-docs/docs/testing.md +49 -0
  306. package/references/official-docs/docs/testing.zh.md +49 -0
  307. package/references/official-docs/docs/tool-catalog.i18n.yaml +6 -0
  308. package/references/official-docs/docs/tool-catalog.md +1873 -0
  309. package/references/official-docs/docs/tool-catalog.zh.md +1878 -0
  310. package/references/official-docs/docs/tool-execution-pipeline.i18n.yaml +6 -0
  311. package/references/official-docs/docs/tool-execution-pipeline.md +62 -0
  312. package/references/official-docs/docs/tool-execution-pipeline.zh.md +64 -0
  313. package/references/official-docs/docs/user/develop/basic/config.i18n.yaml +6 -0
  314. package/references/official-docs/docs/user/develop/basic/config.md +106 -0
  315. package/references/official-docs/docs/user/develop/basic/config.zh.md +106 -0
  316. package/references/official-docs/docs/user/develop/basic/index.i18n.yaml +6 -0
  317. package/references/official-docs/docs/user/develop/basic/index.md +144 -0
  318. package/references/official-docs/docs/user/develop/basic/index.zh.md +144 -0
  319. package/references/official-docs/docs/user/develop/basic/publish.i18n.yaml +6 -0
  320. package/references/official-docs/docs/user/develop/basic/publish.md +183 -0
  321. package/references/official-docs/docs/user/develop/basic/publish.zh.md +183 -0
  322. package/references/official-docs/docs/user/develop/basic/tool.i18n.yaml +6 -0
  323. package/references/official-docs/docs/user/develop/basic/tool.md +52 -0
  324. package/references/official-docs/docs/user/develop/basic/tool.zh.md +52 -0
  325. package/references/official-docs/docs/user/develop/framework/events.i18n.yaml +6 -0
  326. package/references/official-docs/docs/user/develop/framework/events.md +143 -0
  327. package/references/official-docs/docs/user/develop/framework/events.zh.md +143 -0
  328. package/references/official-docs/docs/user/develop/framework/index.i18n.yaml +6 -0
  329. package/references/official-docs/docs/user/develop/framework/index.md +137 -0
  330. package/references/official-docs/docs/user/develop/framework/index.zh.md +137 -0
  331. package/references/official-docs/docs/user/develop/framework/service.i18n.yaml +6 -0
  332. package/references/official-docs/docs/user/develop/framework/service.md +148 -0
  333. package/references/official-docs/docs/user/develop/framework/service.zh.md +150 -0
  334. package/references/official-docs/docs/user/develop/practice/index.i18n.yaml +6 -0
  335. package/references/official-docs/docs/user/develop/practice/index.md +155 -0
  336. package/references/official-docs/docs/user/develop/practice/index.zh.md +155 -0
  337. package/references/official-docs/docs/user/develop/practice/llm-adapter.i18n.yaml +6 -0
  338. package/references/official-docs/docs/user/develop/practice/llm-adapter.md +188 -0
  339. package/references/official-docs/docs/user/develop/practice/llm-adapter.zh.md +188 -0
  340. package/references/official-docs/docs/user/guide/index.i18n.yaml +6 -0
  341. package/references/official-docs/docs/user/guide/index.md +30 -0
  342. package/references/official-docs/docs/user/guide/index.zh.md +30 -0
  343. package/references/official-docs/docs/user/guide/providers-custom-form.png +0 -0
  344. package/references/official-docs/docs/user/guide/providers-custom-form.zh.png +0 -0
  345. package/references/official-docs/docs/user/guide/providers-models-page.png +0 -0
  346. package/references/official-docs/docs/user/guide/providers-models-page.zh.png +0 -0
  347. package/references/official-docs/docs/user/guide/providers.i18n.yaml +6 -0
  348. package/references/official-docs/docs/user/guide/providers.md +98 -0
  349. package/references/official-docs/docs/user/guide/providers.zh.md +98 -0
  350. package/references/official-docs/docs/user/guide/python-sdk.i18n.yaml +6 -0
  351. package/references/official-docs/docs/user/guide/python-sdk.md +104 -0
  352. package/references/official-docs/docs/user/guide/python-sdk.zh.md +104 -0
  353. package/references/official-docs/docs/user/index.i18n.yaml +6 -0
  354. package/references/official-docs/docs/user/index.md +11 -0
  355. package/references/official-docs/docs/user/index.zh.md +11 -0
  356. package/references/official-docs/docs/web-styling.i18n.yaml +6 -0
  357. package/references/official-docs/docs/web-styling.md +25 -0
  358. package/references/official-docs/docs/web-styling.zh.md +25 -0
  359. package/references/official-docs/examples/AGENTS.md +20 -0
  360. package/references/official-docs/packages/AGENTS.md +27 -0
  361. package/references/official-docs/packages/README.md +69 -0
  362. package/references/official-docs/vendor/README.md +60 -0
  363. package/references/official-docs/website-docs.ts +524 -0
  364. package/references/sources.md +137 -0
  365. package/references/upstream-cordis.md +594 -0
  366. package/references/website-pages.md +668 -0
  367. package/scripts/archive-discussions.ps1 +154 -0
  368. package/scripts/download-community-articles.ps1 +188 -0
  369. package/scripts/download-community-repos.ps1 +232 -0
  370. package/scripts/download-sources.ps1 +195 -0
  371. package/scripts/gen-topic-snapshot.ps1 +91 -0
  372. package/scripts/install-skill.ps1 +63 -0
  373. package/scripts/sync-official-docs.ps1 +130 -0
  374. package/scripts/verify-kit.ps1 +191 -0
@@ -0,0 +1,849 @@
1
+ # Sessions
2
+
3
+ English | [中文](session.zh.md)
4
+
5
+ The in-memory, event-sourced model of [dsh-session](../../packages/core/session). A `Session` is an **append-only log** of typed `SessionEvent`s — the single source of truth for an agent's whole interaction history. The LLM message history is *derived* from the log, never stored separately; replay is re-derivation from the same events. How the log is made **durable** (the persistence seam, backends, crash recovery) is the sibling concern on [persistence.md](persistence.md).
6
+
7
+ Source: [`packages/core/session/src/types.ts`](../../packages/core/session/src/types.ts)
8
+
9
+ ## `SessionEventMap` — the event vocabulary
10
+
11
+ The append-only event types. Merge-extensible: a plugin declares extra event types via declaration merging — e.g. the [compaction seam](compaction.md) adds `compaction/start` / `compaction/summary` / `compaction/end`, and `@deepseek-ai/dsh-hook-protocol` adds log-only `hook/invoked` / `hook/result` records for a hook bridge. Like `compaction/*`, these are NOT `SurfaceEventType`s (no `surfaceOp`). The generated [persistence log event catalog](../persistence-catalog.md) enumerates every member — core and merged — with its payload, surface badge, and declaration site.
12
+
13
+ ```ts type-equiv
14
+ /** A user-role specialization of the one shared message representation. */
15
+ interface UserMessage extends Message {
16
+ readonly role: 'user'
17
+ }
18
+ ```
19
+
20
+ ```ts type-equiv
21
+ /**
22
+ * The merge-extensible, append-only source of truth for an agent interaction.
23
+ * Message history is derived from this log. Every event is lossless JSON and
24
+ * sequence numbers stay contiguous, including raw chunks, so persistence can
25
+ * store the canonical log verbatim.
26
+ */
27
+ interface SessionEventMap {
28
+ /**
29
+ * Opens turn `turn` before the loop claims queued input or runs pre-step.
30
+ * Rejection, empty input, cancellation, or failure may close it with no
31
+ * step; otherwise the following identified `user/message` event or batch
32
+ * records the messages entering the step.
33
+ */
34
+ 'turn/start': { turn: number }
35
+ /**
36
+ * Closes turn `turn` with the {@link TurnEndReason} that ended it. A turn
37
+ * with no entered step has no `step/start` or `step/end`. The loop does not await a
38
+ * flush at turn boundaries: `dsh-session-checkpoint-policy` owns the
39
+ * per-request durability checkpoint, and consumers that read storage after
40
+ * `whenIdle()` flush themselves. Success commits the turn; rejection is
41
+ * reported live and does not prevent later work.
42
+ */
43
+ 'turn/end': { turn: number; reason: TurnEndReason }
44
+ /** Opens step `step` of turn `turn` — one model call plus the tool executions it requested. */
45
+ 'step/start': { turn: number; step: number }
46
+ /** Closes step `step` of turn `turn`. */
47
+ 'step/end': { turn: number; step: number }
48
+ /**
49
+ * A user-role message on the model-visible surface: a direct human prompt
50
+ * (the queued message claimed for this turn), a synthetic `agent.inject()`
51
+ * context (file-change notices, subdir AGENTS.md, skill content, cron
52
+ * notifications, …), or an entered goal continuation round. All three
53
+ * project their `content` verbatim; `source` tells them apart.
54
+ */
55
+ 'user/message': UserMessage
56
+ /** Raw stream chunk — token-level replay fidelity. */
57
+ 'assistant/chunk': { turn: number; step: number; chunk: StreamChunk }
58
+ /**
59
+ * Assembled assistant message for one step (derived history uses this).
60
+ * Carries the step's `usage` when the adapter reported token accounting, so
61
+ * the model output and its accounting travel together (there is no separate
62
+ * usage record). `usage` is absent when the adapter reported none.
63
+ */
64
+ 'assistant/message': { turn: number; step: number; message: AssistantMessage; usage?: TokenUsage }
65
+ /**
66
+ * The model requested one tool invocation: `name` with the raw `arguments`
67
+ * JSON string exactly as the model produced it (unparsed). `callId` pairs the
68
+ * call with its `tool/result`.
69
+ */
70
+ 'tool/call': { turn: number; step: number; callId: CallId; name: string; arguments: string }
71
+ /**
72
+ * A completed tool call's model-facing result, optional internal failure
73
+ * identity, and optional tool-private `meta` presentation payload. `meta` is
74
+ * opaque to the core (the producing tool owns its shape and reads it back in
75
+ * `presentResult`) but MUST be JSON-serializable: `Session.append`
76
+ * runtime-validates all event data with `isJsonValue`, so a non-serializable
77
+ * `meta` is rejected at the source, and the durable log reproduces the
78
+ * identical card on replay. Absent
79
+ * unless the tool attaches one (e.g. `dsh-tool-fs` carries its result-time
80
+ * contextual diff here).
81
+ */
82
+ 'tool/result': {
83
+ turn: number
84
+ step: number
85
+ message: ToolResultMessage
86
+ error?: { name: string; code: string }
87
+ meta?: JsonValue
88
+ }
89
+ /** Whole-list snapshot; latest write wins on replay. Log-only UI state; never derived history. */
90
+ 'todo/write': { todos: TodoItem[] }
91
+ /**
92
+ * Full header for the next request, appended inside its step before dispatch.
93
+ * It is log-only; the latest snapshot reconstructs the request header.
94
+ */
95
+ 'request/header': { header: EpochHeader; reason: RequestHeaderReason }
96
+ /**
97
+ * Route metadata for the next request, logged only when the route or capacity
98
+ * changes. It does not participate in request reconstruction or header equality.
99
+ */
100
+ 'request/context': RequestContext
101
+ /**
102
+ * Marks the end of a constructor seed. Events before it have smaller seq
103
+ * values and came from the seed (resume, fork, or replay); this lifecycle
104
+ * produced none of them. This log-only event is the durable projection of
105
+ * {@link Session.firstLiveSeq}. Its payload is empty — position and `time`
106
+ * carry the meaning.
107
+ *
108
+ * Locate the LAST one in stored history. A seed already ending in one is not
109
+ * re-marked, so reopening an untouched session does not grow its log per
110
+ * pickup and the event need not be at the current `firstLiveSeq`.
111
+ *
112
+ * `Session`'s constructor is the only legitimate writer. The invariant
113
+ * companion deliberately constrains nothing here, so a plugin appending one
114
+ * would silently classify every live bracket before it as seed history.
115
+ *
116
+ * An owner of a standalone open/close bracket (`compaction/start` …
117
+ * `compaction/end`) reads it because seed history and live work are otherwise
118
+ * byte-identical: an unmatched opening marker before this event belongs to
119
+ * an ended lifecycle, whatever ended it. NOT a liveness signal about other
120
+ * writers — a concurrently live session holds its own boundary elsewhere,
121
+ * so tolerating concurrent writers needs a signal beyond the log.
122
+ */
123
+ 'session/end-seed': Record<string, never>
124
+ }
125
+ ```
126
+
127
+ `UserMessage` is the identified, frozen user-role value shared by ordinary prompts, injected context, steering, and live inbox events. Event wrappers add only event-local position or outcome facts; the loop adds only driver-owned routing state while an item remains pending.
128
+
129
+ ### `TodoItem` — one todo-list entry
130
+
131
+ The unit of the `todo/write` event's whole-list snapshot. Deliberately minimal — a `content` line and a three-state `status` (no id, priority, or `activeForm`): the list is replaced wholesale on every write, so entries need no stable identity. See the [todo_write Agent Note](../../.agents/notes/implemented/feature/2026-06-29-todo-write-tool.md).
132
+
133
+ ```ts type-equiv
134
+ /**
135
+ * One entry in an agent's todo list — the unit of the `todo/write`
136
+ * {@link SessionEventMap} event's whole-list snapshot.
137
+ *
138
+ * Deliberately minimal: a human-readable `content` line and a three-state
139
+ * `status`. No id, priority, or `activeForm` — the list is replaced wholesale
140
+ * on every write (last-write-wins), so entries need no stable identity. The
141
+ * three statuses describe the complete portable lifecycle needed by model and
142
+ * UI consumers.
143
+ */
144
+ interface TodoItem {
145
+ /** What this task is — a short imperative line shown in the UI. */
146
+ content: string
147
+ /** Lifecycle state. `in_progress` marks a task being worked now; parallel work may mark several. */
148
+ status: 'pending' | 'in_progress' | 'completed'
149
+ }
150
+ ```
151
+
152
+ <a id="the-request-header-event-requestheader"></a>
153
+
154
+ ### The request header event: `request/header`
155
+
156
+ The request envelope — the `EpochHeader` (call config + markers for adapter-supplied defaults + rendered system prompt + assembled tool schemas) — is logged session state, so every conversation request is a pure function of the log (the reconstructability Agent Note). A full `request/header` snapshot with reason `'initial'` or `'resume'` records each loop-instance boundary; a later changed request records another full snapshot with reason `'change'`. `foldRequestHeader(events)` reconstructs the header by selecting the latest snapshot. The event is not a `SurfaceEventType`: it produces no LLM message.
157
+
158
+ ```ts type-equiv
159
+ /**
160
+ * Logged request state outside derived history: call config, system prompt, and
161
+ * tools. The latest full `request/header` snapshot reconstructs it; canonical
162
+ * empty optional fields are absent.
163
+ */
164
+ interface EpochHeader {
165
+ /** The conversation's call configuration (provider, model, reasoning effort, and sampling scalars). */
166
+ config: LlmCallConfig
167
+ /** Effective config fields materialized from the exact adapter rather than proposed by a caller. */
168
+ adapterDefaults?: LlmCallConfigAdapterDefaults
169
+ /** Rendered system prompt text; absent for a system-less request. */
170
+ system?: string
171
+ /** Assembled tool schemas; absent for a tool-less request. */
172
+ tools?: ToolSchema[]
173
+ }
174
+ ```
175
+
176
+ Canonical form represents an empty system prompt or tool list as an absent field, matching how requests are built. Legacy v0 logs containing the legacy `request/header-delta` event or its full-snapshot `fallback` reason are rejected at seed, append, and persistence-load boundaries rather than replayed incompletely.
177
+
178
+ ### The route capacity event: `request/context`
179
+
180
+ The context metadata of the route a request resolved to is separate logged state, appended beside `request/header` inside the same step and only when the provider, model, or capacity differs from the previous record. It stays outside `EpochHeader` because that type is the reconstruction contract compared field-wise by `headerEquals`: capacity describes a route, not a request input, so folding it in would let a capacity change register as a request-envelope `change` and would pull adapter metadata into the loop's reconstruction invariant. Like `request/header`, it is not a `SurfaceEventType` and produces no LLM message. `session.requestContext()` folds the latest record incrementally. A route whose adapter advertises no capacity is recorded with `contextWindow` absent, so the new record clears an older route's capacity.
181
+
182
+ ```ts type-equiv
183
+ /** Registration-bound metadata for one resolved model route. */
184
+ interface RequestContext {
185
+ /** Registered provider route the metadata belongs to. */
186
+ provider: string
187
+ /** Provider-owned model id the metadata belongs to. */
188
+ model: string
189
+ /** Maximum combined request and response context in tokens, when advertised. */
190
+ contextWindow?: number
191
+ }
192
+ ```
193
+
194
+ ## `SessionEvent<T>` — one log entry
195
+
196
+ A proper discriminated union over `type` (not independent `type`/`data` unions), so `switch (event.type)` narrows `event.data` without casts. `seq` is the monotonic position in the log (`seq = log.length`); `time` is epoch ms.
197
+
198
+ ```ts type-equiv
199
+ /**
200
+ * One immutable entry in the session log.
201
+ *
202
+ * A proper discriminated union over `type` (not independent `type`/`data`
203
+ * unions), so `switch (event.type)` narrows `event.data` without casts.
204
+ *
205
+ * The {@link sourceEventSeqs} and {@link surfaceOp} fields are conditional:
206
+ * they only exist on {@link SurfaceEventType} variants (`user/message`,
207
+ * `assistant/message`, `tool/result`).
208
+ * Non-surface events (boundary markers, chunks, usage, errors) never carry
209
+ * surface metadata — the compiler enforces this at `Session.append()`
210
+ * call sites.
211
+ */
212
+ type SessionEvent<T extends SessionEventType = SessionEventType> = {
213
+ [K in SessionEventType]: {
214
+ type: K
215
+ /** Monotonic sequence number within the session. */
216
+ seq: number
217
+ /** Unix epoch milliseconds. */
218
+ time: number
219
+ data: SessionEventMap[K]
220
+ /**
221
+ * Marks an event a reader may safely skip when it does not recognize
222
+ * `type`. Absent means required: a reader meeting an unrecognized type
223
+ * without this marker MUST refuse to reconstruct the session instead of
224
+ * silently dropping the event, because an unrecognized required event may
225
+ * change how the rest of the log is interpreted. A writer sets `true` only
226
+ * on purely informational records whose loss cannot affect reconstruction;
227
+ * defaulting to required means a forgotten marker over-refuses (an
228
+ * inconvenience) rather than silently resuming a gutted session.
229
+ */
230
+ ignorable?: true
231
+ } & (K extends SurfaceEventType ? {
232
+ /**
233
+ * Seq numbers of earlier events that this event cites as sources
234
+ * (e.g. the `assistant/chunk` seqs that built an `assistant/message`,
235
+ * or the surface nodes shadowed by a compaction replace node). An
236
+ * `assistant/message` may carry a present empty array for a known empty
237
+ * provider stream; when the field is absent, the event does not record which
238
+ * earlier events produced the message.
239
+ */
240
+ sourceEventSeqs?: number[]
241
+ /** How this event entered the surface; absent for non-surface events. */
242
+ surfaceOp?: SurfaceOp
243
+ } : object)
244
+ }[T]
245
+ ```
246
+
247
+ `SessionEventType = keyof SessionEventMap`. Because `SessionEventMap` is merge-extensible, switches over `SessionEvent` must NOT use `assertNever` — a plugin-added variant is a valid unknown value; handle the known cases and fall through `default`.
248
+
249
+ For `assistant/message`, a present `sourceEventSeqs: []` is a complete known-empty provider stream, while a legacy or foreign event with no field does not record which earlier events produced the message. The loop writes the field for every successful model call; every other surface event requires a non-empty list when the field is present.
250
+
251
+ ## Surface types
252
+
253
+ The three message-producing types (`SurfaceEventType` — `user/message`, `assistant/message`, `tool/result`) carry surface metadata declaring how they join the ordered derived surface. See the [session surface Agent Note](../../.agents/notes/implemented/architecture/2026-06-18-session-surface.md).
254
+
255
+ ### `SurfaceEventType` — the message-producing subset of event types
256
+
257
+ ```ts type-equiv
258
+ /**
259
+ * The subset of {@link SessionEventType} values whose events produce LLM
260
+ * messages and are eligible to appear on the ordered surface. Only these
261
+ * event types may carry {@link SurfaceOp} and {@link SessionEvent.sourceEventSeqs}.
262
+ */
263
+ type SurfaceEventType =
264
+ | 'user/message'
265
+ | 'assistant/message'
266
+ | 'tool/result'
267
+ ```
268
+
269
+ ### `SurfaceOp` — how an event entered the surface
270
+
271
+ ```ts type-equiv
272
+ /**
273
+ * How a session event entered the ordered surface. Only valid on
274
+ * {@link SurfaceEventType} events.
275
+ *
276
+ * - `'append'`: added to the tail — normal path for user/assistant/tool
277
+ * messages.
278
+ * - `{ op: 'replace', start, end }`: replaces surface nodes from `start`
279
+ * (inclusive) through `end` (inclusive) with this node. Both must exist as
280
+ * surface nodes in the current surface. `start === end` replaces a single
281
+ * node. The node's {@link SessionEvent.sourceEventSeqs} must include every
282
+ * shadowed surface node. Used by compaction; any surface-replacing producer
283
+ * may use it.
284
+ */
285
+ type SurfaceOp =
286
+ | 'append'
287
+ | { op: 'replace'; start: number; end: number }
288
+ ```
289
+
290
+ `'append'` is the normal tail-append path. `replace` shadows surface entries from `start` through `end` inclusive (both must be valid surface seqs; `start === end` replaces a single entry) and inserts the new event in their place.
291
+
292
+ ### `SurfaceIntent` — the parameter to `session.append()`
293
+
294
+ ```ts type-equiv
295
+ /**
296
+ * Surface placement and cited source-event seqs for {@link Session.append}. Required on
297
+ * message-producing events and forbidden on log-only events.
298
+ */
299
+ interface SurfaceIntent {
300
+ surfaceOp: SurfaceOp
301
+ /**
302
+ * Complete set of known source-event seqs. `assistant/message` may use a
303
+ * present empty array for a known empty provider stream; when the field is
304
+ * absent, the event does not record which earlier events produced the message.
305
+ * Other surface events require a non-empty set when this field is present.
306
+ */
307
+ sourceEventSeqs?: number[]
308
+ }
309
+ ```
310
+
311
+ Required for `SurfaceEventType` events — every message-producing event must declare how it joins the surface, the sole source of derived model history. A human-facing transcript is the other projection and reads the log's append-origin events instead, because the surface deliberately shadows the ranges a replacement summarizes (`isAppendSurfaceEvent` in [dsh-session](../../packages/core/session/README.md)). Non-surface types reject it at compile time.
312
+
313
+ Only `assistant/message` may carry a present empty `sourceEventSeqs`; when the field is absent, the event does not record which earlier events produced the message, and the provider may still have emitted chunks.
314
+
315
+ ### `SessionSurface` — the live readonly surface projection
316
+
317
+ `Session.surface` returns the session's stable `SessionSurface` view. The same incremental manager validates append candidates before commit and advances this projection from committed events; callers can observe membership and replacement generation but cannot invoke validation.
318
+
319
+ `SurfaceManager(log, baseSeq?)` can instead fold a contiguous loaded window whose first event has the absolute sequence `baseSeq`. Every event remains contiguous in that absolute sequence space, and a replacement that crosses the window head fails because its declared range is absent.
320
+
321
+ ```ts type-equiv
322
+ /** Readonly live projection of the message-producing session events. */
323
+ interface SessionSurface {
324
+ /** Current surface event sequences in model-visible order. */
325
+ readonly nodes: readonly number[]
326
+ /** Monotonic count of committed positional replacements. */
327
+ readonly replaceGeneration: number
328
+ }
329
+ ```
330
+
331
+ ### `SurfaceFoldReplacement` and `SurfaceFoldResult` — a complete surface replay
332
+
333
+ `foldSurface(events)` returns detached current event sequences together with the actual sequences shadowed by each declared replacement range. The live manager uses the same transitions without retaining replacement history. Its `replaceGeneration` increments for each committed replacement so incremental consumers can distinguish pure tail growth from a rewrite.
334
+
335
+ ```ts type-equiv
336
+ /** One replacement operation observed while folding a session surface. */
337
+ interface SurfaceFoldReplacement {
338
+ /** Seq of the event that replaced the prior surface range. */
339
+ seq: number
340
+ /** Declared inclusive start seq of the replaced surface range. */
341
+ start: number
342
+ /** Declared inclusive end seq of the replaced surface range. */
343
+ end: number
344
+ /** Actual surface entries removed by the operation, in surface order. */
345
+ shadowedSeqs: number[]
346
+ }
347
+ ```
348
+
349
+ ```ts type-equiv
350
+ /** Complete result of replaying the surface operations in a session log. */
351
+ interface SurfaceFoldResult {
352
+ /** Current surface event sequences in model-visible order. */
353
+ nodes: number[]
354
+ /** Replacement operations in event order. */
355
+ replacements: SurfaceFoldReplacement[]
356
+ }
357
+ ```
358
+
359
+ ## `Session` public API
360
+
361
+ The body-stripped declaration keeps the plain class's detached factory, state accessors, append method, and history projections synchronized with source. Store operations remain in the generated [`ctx.sessions` section](#ctxsessions--sessionstore).
362
+
363
+ ```ts public-api
364
+ /**
365
+ * An event-sourced session: an append-only log of {@link SessionEvent}s.
366
+ *
367
+ * Plain class (not a Service) — create live instances via
368
+ * `ctx.sessions.create()` and detached instances via {@link create}.
369
+ * Seeding with an existing event log replays/forks a session.
370
+ * @typert object
371
+ */
372
+ declare class Session {
373
+ /** The ordered surface over this session's event log. */
374
+ get surface(): SessionSurface;
375
+ /**
376
+ * Detached, deep-frozen creation metadata (format version, cwd, lineage,
377
+ * seed boundary). Supplied by the store via `ctx.sessions.create()`. When a
378
+ * `Session` is created without a store-owned header, a minimal header is
379
+ * synthesized (stamped with the current {@link SESSION_FORMAT_VERSION}) so
380
+ * `session.header` is always present. Kept out of the event log — it is a
381
+ * storage concern, not replayable conversation state.
382
+ */
383
+ readonly header: SessionHeader;
384
+ /** The session identity, derived from its durable header's single copy. */
385
+ get id(): SessionId;
386
+ /**
387
+ * The first seq appended IN THIS PROCESS: the length of the constructor
388
+ * seed (0 without one). Events with smaller seq values entered through
389
+ * construction — replay, fork, or resume — and were never published on the
390
+ * `session/event` firehose (constructor seeds do not emit), so consumers
391
+ * that replay the log as a publication substitute (telemetry adoption)
392
+ * start here. Distinct from `header.seedLength`, the DURABLE fork-lineage
393
+ * boundary: a resumed session's constructor seed is its full stored log,
394
+ * while its header keeps the original fork value — this field is the
395
+ * in-process construction fact.
396
+ *
397
+ * Not persisted itself: a seeded session projects it into the log as the
398
+ * `session/end-seed` event, which is what a consumer reading STORED history
399
+ * reads. Locate the LAST such event, not necessarily one at this seq — a
400
+ * seed already ending in one is not re-marked, so reopening an untouched
401
+ * session leaves that event at a smaller seq than `firstLiveSeq`. Prefer
402
+ * this field in-process: it is exact before the marker reaches storage.
403
+ *
404
+ * When this lifecycle appends the marker, it occupies this seq before the
405
+ * store attaches and therefore does not publish either. Otherwise this seq
406
+ * holds an ordinary published write.
407
+ */
408
+ readonly firstLiveSeq: number;
409
+ /**
410
+ * Create a detached session by validating and snapshotting borrowed seed
411
+ * events and storage metadata.
412
+ * @param id - session identity.
413
+ * @param seed - optional borrowed replay or fork events.
414
+ * @param header - optional borrowed storage metadata.
415
+ * @returns a detached session.
416
+ */
417
+ static create(id: SessionId, seed?: readonly SessionEvent[], header?: SessionHeader): Session;
418
+ /**
419
+ * Restore a detached session by taking ownership of fresh persistence values.
420
+ * The storage format, event envelopes, sequence continuity, surface transitions,
421
+ * and header fields are validated before the restored objects are frozen.
422
+ * @param id - restored session identity.
423
+ * @param seed - fresh detached events whose ownership is transferred.
424
+ * @param header - fresh detached metadata whose ownership is transferred.
425
+ * @returns a restored detached session.
426
+ */
427
+ static fromRestore(id: SessionId, seed: readonly SessionEvent[], header: SessionHeader): Session;
428
+ /**
429
+ * An immutable snapshot of the append-only event log. The snapshot is reused
430
+ * until the next append; a previously returned array does not grow later.
431
+ * Events and their nested data are deep-frozen at acceptance, so neither a
432
+ * cast nor ordinary JavaScript can rewrite durable history.
433
+ */
434
+ get events(): readonly SessionEvent[];
435
+ /** The next event's sequence number — always the log length (the `seq = log.length` contiguity contract). */
436
+ get seq(): number;
437
+ /**
438
+ * Append one typed event to the log and synchronously notify observers via
439
+ * the store-owned, module-private publication hooks. The hot path never blocks
440
+ * on I/O — persistence plugins buffer asynchronously. Once the event enters
441
+ * the log, the append is committed: observer failures are logged and
442
+ * contained per listener, so they do not change the return value or prevent
443
+ * later listeners from observing the same accepted event.
444
+ *
445
+ * @param type - The event type (key of {@link SessionEventMap}).
446
+ * @param data - The event payload; must be JSON-serializable.
447
+ * @param opts - Surface metadata: `surfaceOp` controls how the event enters
448
+ * the ordered surface; `sourceEventSeqs` lists the seq numbers of earlier
449
+ * events this one derives from. REQUIRED for
450
+ * {@link SurfaceEventType} events (every message-producing event must
451
+ * declare how it joins the surface, the sole source of derived model
452
+ * history) and
453
+ * rejected by the compiler for non-surface types like `turn/start` or
454
+ * `assistant/chunk`.
455
+ * @returns the logged event — its assigned `seq`/`time` plus the SNAPSHOT of
456
+ * `data` that entered the log, so reading `event.data` back sees the logged
457
+ * value, never the caller's still-mutable input.
458
+ * @throws if `data` or surface metadata is not losslessly JSON-serializable
459
+ * (BigInt, function, symbol, undefined, negative zero, non-finite number,
460
+ * circular reference, sparse array, or an exotic object such as
461
+ * Map/Set/Date/class instance), or when the candidate violates the
462
+ * canonical surface contract (marker shape and eligibility, unique
463
+ * earlier source-event references, positional replacement validity, and complete
464
+ * shadowed-node coverage). One recursive pass reads, validates, and
465
+ * copies each nested value once, so a stateful getter cannot supply one value
466
+ * to validation and another to storage. The event log is the durable source
467
+ * of truth, so a bad event fails at the append site rather than later during
468
+ * a backend flush. A synchronous internal dispatch validation failure or an
469
+ * append reentered while this acceptance/publication boundary is open also
470
+ * rejects before the log changes.
471
+ */
472
+ append<T extends SessionEventType>(
473
+ type: T,
474
+ data: SessionEventMap[T],
475
+ ...opts: T extends SurfaceEventType ? [opts: SurfaceIntent] : []
476
+ ): SessionEvent<T>;
477
+ /**
478
+ * The {@link EpochHeader} in force after the log's last header event — the
479
+ * header the NEXT request will be compared against — or undefined before
480
+ * the first `request/header` snapshot. The live, incrementally-maintained
481
+ * form of `foldRequestHeader(session.events)`: each header event is folded
482
+ * once, when first seen, so a per-step read costs O(new events).
483
+ * @returns the folded header, or undefined when no header event exists yet.
484
+ */
485
+ requestHeader(): EpochHeader | undefined;
486
+ /**
487
+ * Return the latest resolved route metadata, or `undefined` before the first
488
+ * `request/context` event. Each event is folded once.
489
+ * @returns the latest immutable route metadata.
490
+ */
491
+ requestContext(): RequestContext | undefined;
492
+ /**
493
+ * Derive the LLM message history by walking the ordered sequences of
494
+ * message-producing events maintained by `surfaceOp` markers. The
495
+ * surface is the single source of derived history: every message-producing
496
+ * append records its `surfaceOp`, so a raw event with no marker (a chunk, a
497
+ * turn boundary) is correctly absent, and a compaction `replace` deletes the
498
+ * shadowed nodes from the derivation. The projection rules are
499
+ * {@link deriveEventMessage}, folded per node.
500
+ *
501
+ * CACHED: each surface node is projected exactly once, when first seen — a
502
+ * call costs O(new nodes), and a surface rewrite (a `replace`;
503
+ * {@link SessionSurface.replaceGeneration}) rebuilds. The returned array is
504
+ * a fresh snapshot per call (later appends never grow an array a caller
505
+ * already holds); the `Message` objects in it are SHARED and **deep-frozen**.
506
+ * Their content reuses the already frozen durable event data, so the cache
507
+ * needs no second deep clone and consumers still cannot mutate the log.
508
+ * @returns a fresh array of the shared, frozen derived history.
509
+ */
510
+ deriveMessages(): Message[];
511
+ /**
512
+ * Instance face of the pure per-node `deriveEventMessage` export from
513
+ * `surface.ts`.
514
+ * @param event - the event to project.
515
+ * @returns the derived message, or null when the event produces none.
516
+ */
517
+ deriveEventMessage(event: SessionEvent): Message | null;
518
+ }
519
+ ```
520
+
521
+ ## Derived history: `deriveMessages()` and `deriveEventMessage()`
522
+
523
+ `Session.deriveMessages()` projects the event log into the `Message[]` the model sees — cached (each surface node projected once, when first seen; a surface rewrite rebuilds) and frozen (a fresh array per call over shared, deep-frozen messages, so mutating logged history through a projection is unrepresentable). `deriveEventMessage(event)` is the per-node pure function the fold applies — public so external reconstructors and the dev invariant project a log prefix with exactly the same rules and cannot disagree with the cache. The projection rules:
524
+
525
+ - `user/message` → a user message carrying exact `content`; an optional envelope remains log-only display metadata.
526
+ - `assistant/message` → an assistant message with the provider and model that produced it plus optional adapter-private replay state. Raw `assistant/chunk` events are replay/UI data and are **skipped** in derivation (the assembled message is authoritative). An **empty-content** `assistant/message` is also skipped — a max-tokens step cut off with no content still records an `assistant/message` to hold its usage, provider, and model, but a content-less assistant turn must not enter the provider transcript.
527
+ - `tool/result` → a user message carrying a `tool-result` block.
528
+ - `user/message` (injected context, i.e. non-`user` source) → a user-role message carrying its `content` verbatim at its chronological position; its typed source names the producer and carries any producer-specific data.
529
+
530
+ Everything else (`turn/*`, `step/*`, plugin-owned `llm/retry`) is structural and does not project into a message. Token accounting reads per-step `assistant/chunk { type: 'usage' }` records and treats `assistant/message.usage` as the committed-step fallback when no usage chunk exists; failed model-request attempts have no assistant message, so their usage chunk is the durable accounting record. Because this unreleased format intentionally has no compatibility promise, seed/load validation rejects request headers and assistant messages that omit provider/model instead of guessing a route for historical data.
531
+
532
+ ## Live-session fork API
533
+
534
+ `ctx.sessions.create(id, { seed, meta })` is the low-level replay/fork primitive. For ordinary live-session forks, `SessionStore` exposes one policy API:
535
+
536
+ - `fork(source, boundary?, childSessionId?)` accepts a live `Session` object or live `SessionId`, selects source events through the inclusive `boundary` seq (default: current last event), requires the selected prefix to end outside an open turn, then creates a live child session with deep-cloned seed events plus child metadata (`parentSession`, `seedLength`, and inherited `cwd`).
537
+
538
+ An explicit `boundary` lets callers fork from any stable between-turn position, including a previous `turn/end` or a later standalone log-only event, even if the source has newer events or an open current turn. The API rejects a prefix that ends inside an open turn instead of clipping silently. Broader execution-relation sanity stays in the existing `dsh-invariants` plugin and persistence repair path rather than being duplicated in `fork()`. `dsh-subagent-fork-in-process` keeps its completed-prefix clipping because tool-time delegation usually starts while the parent turn is open; ordinary session branching should make the requested boundary explicit.
539
+
540
+ ## Why a turn ended: `TurnEndReasonMap`
541
+
542
+ `turn/start` has no trigger field. The entered `user/message` batch records what entered each step, `llm/retry` records request recovery, and idle injection remains pending until a waking delivery reaches a later pre-step. Live turns retain the typed [`AgentCancelCause`](core.md#the-agent-handle) that stopped the driver; persistence uses the additional `{ kind: 'legacy' }` cause only when importing a supported coarse cancellation record that did not store its caller.
543
+
544
+ ```ts type-equiv
545
+ /** Durable cancellation cause, including imports whose original coarse record carried no cause. */
546
+ type TurnEndCancelCause = AgentCancelCause | { readonly kind: 'legacy' }
547
+ ```
548
+
549
+ ```ts type-equiv
550
+ /**
551
+ * Why a turn ended. Merge-extensible sum type.
552
+ */
553
+ interface TurnEndReasonMap {
554
+ completed: { kind: 'completed' }
555
+ /** A cancellation request interrupted the live turn. */
556
+ aborted: { kind: 'aborted'; reason: TurnEndCancelCause }
557
+
558
+ blocked: { kind: 'blocked' }
559
+ /**
560
+ * The turn failed. `error` is always a structured failure: the `LlmError`
561
+ * facts verbatim, or `{ message: errorChain(error), code: 'UNKNOWN' }`
562
+ * flattened from any other error.
563
+ */
564
+ error: { kind: 'error'; error: LlmFailure }
565
+ /** At least one step reached its output-token ceiling, even if a plugin continued the turn. */
566
+ 'max-tokens': { kind: 'max-tokens' }
567
+ /**
568
+ * A persistence backend closed a crash-orphaned turn on reload. The loop never
569
+ * emits this marker, and the events recorded before the crash remain intact.
570
+ */
571
+ interrupted: { kind: 'interrupted' }
572
+ }
573
+ ```
574
+
575
+ `max-tokens` mirrors the model-call `FinishReason` of the same name: any `max-tokens` step in a turn makes the whole turn end `max-tokens` rather than `completed` (the cut-short fact wins over a later continuation), so a consumer can tell a clean stop from a truncated one. Cancellation and errors remain distinct outcomes. `interrupted` is the one reason no loop emits—it is synthesized by crash recovery (see [persistence.md](persistence.md)). The map is merge-extensible.
576
+
577
+ ## Execution enclosure and standalone events
578
+
579
+ A turn encloses one model-loop execution, not the whole session log. AgentLoop records injected `user/message` events only from entering pre-step batches inside a turn; plugin-owned log-only events may still appear between `turn/end` and the next `turn/start`, consuming event seqs without incrementing turn numbers. Persistence admits every contiguous accepted event into a bounded durable batch, while crash repair closes only a genuinely open trailing turn. A producer that needs an immediate durability barrier explicitly awaits `ctx.sessions.flush(session)`.
580
+
581
+ The optional `dsh-session/invariant` companion enforces the relations owned by core: turn and step numbering, execution-event enclosure, and same-step tool call/result pairing. Merge-extensible event relations belong to the plugin that declares them, so core does not reject an unknown event merely because no turn is open. See [the standalone-event decision](../../.agents/notes/implemented/simplification/2026-07-28-remove-synthetic-log-only-turns.md).
582
+
583
+ ## The end-seed boundary: `session/end-seed`
584
+
585
+ A seeded session — resume, fork, or replay — appends this log-only event immediately after its constructor seed, as its first live write. Events before it have smaller seq values and came from the seed. It is the durable projection of `firstLiveSeq`: that field answers where this lifecycle's writes start for a consumer holding the object, while the event answers the same question for one holding only stored bytes. The payload is empty, so position and `time` carry the whole meaning, and it produces no message. `Session`'s constructor is the only legitimate writer.
586
+
587
+ An explicitly supplied empty seed writes `session/end-seed` at seq 0, which distinguishes an empty resumed session from a fresh one. A seed already ending in `session/end-seed` is not re-marked, so reopening an untouched session does not grow its log per pickup. Locate the LAST `session/end-seed` in stored history rather than assuming one exists at `firstLiveSeq`: after a pickup with no work, the event has a smaller seq than the next lifecycle's `firstLiveSeq`.
588
+
589
+ It exists because seed history and live work are otherwise byte-identical, which defeats any plugin owning a standalone open/close bracket: an unmatched `compaction/start` reads the same whether the writer crashed mid-compaction or is compacting right now. An opening marker before `session/end-seed` came from the constructor seed and belongs to an ended lifecycle, whatever ended it (a crash, a succeeding process, or a fork out of a still-running parent), so its owner may treat it as dead. That covers only brackets *this* session inherited: a concurrently live session holding an open bracket over the same history has its own boundary elsewhere, so tolerating concurrent writers needs a liveness signal beyond the log. Core writes the boundary and reads nothing from it — a bracket's vocabulary stays with its owning plugin, which is why crash repair closes turn/step/tool boundaries and never `compaction/*`.
590
+
591
+ Consumers that order Sessions by human activity exclude this boundary: picking a Session up is not work, so ordering by the log tail would float every opened Session to the top.
592
+
593
+ ## Plugin-contributed log-only events
594
+
595
+ A plugin may declaration-merge extra `SessionEventMap` types. These are **log-only**: NOT `SurfaceEventType`s (they carry no `surfaceOp` and contribute nothing to derived history). Their owner decides whether they belong to an open execution turn or may stand between turns, and enforces any relation in its own invariant companion. The generated [persistence log event catalog](../persistence-catalog.md) enumerates every core and plugin-contributed event with its payload, surface badge, and declaration site; the compaction seam's `compaction/*` semantics are discussed on [compaction.md](compaction.md).
596
+
597
+ When several events in one plugin-owned family assemble into one Web Client Conversation Node, every start, update, result, resource, or interruption event in that family carries or independently derives the same stable business id. This requirement applies to correlated Node families, not to every Session event; it lets the client group each event without guessing from adjacency or scanning history. See the [Conversation Node cookbook](../cookbook/adding-a-conversation-node.md).
598
+
599
+ The hook bridges' `hook/invoked` / `hook/result` pairs (from `@deepseek-ai/dsh-hook-protocol`) correlate by `handlerId`. `UserPromptSubmit`, `PreToolUse`, `PostToolUse`, and `Stop` fire inside the loop's open turn, so their `hook/*` records are turn-enclosed by construction. `SessionStart` gets no `hook/*` record because it runs before turn 1; its context remains pending in the inbox until a waking delivery opens a turn (see [the hook-bridges Agent Note](../../.agents/notes/implemented/feature/2026-06-30-hook-bridges.md)).
600
+
601
+ ## Durability contract
602
+
603
+ What a persistence backend relies on: the durable log persists every event losslessly, **including** `assistant/chunk` — `seq` must stay contiguous, so chunks cannot be filtered out of the canonical log. A backend may choose its own storage encoding for an event batch as long as `load` returns the exact appended events (the JSONL backend's default packed chunk rows are such an encoding — see [persistence.md](persistence.md)). All `event.data` must be JSON-serializable; `Session.append` enforces this at the source (throwing on non-serializable data), so a bad event never enters the log and `session.events` always equals what a backend can persist. Adding an event type that carries non-serializable data, corrupts core execution nesting, or violates its owner's declared relation is a breaking change to the on-disk format.
604
+
605
+ The backends that consume this contract are on [persistence.md](persistence.md).
606
+
607
+ <!-- BEGIN GENERATED cordis-surface (gen-cordis-catalog.ts) — do not edit between markers -->
608
+
609
+ <a id="cordis-surface"></a>
610
+
611
+ ## Cordis API
612
+
613
+ Generated from source by `scripts/gen-cordis-catalog.ts` (verified fresh by `pnpm run verify-cordis-catalog` in doc-sync; regenerate with `pnpm run gen-cordis-catalog`) — this section is byte-identical in both language sides of the page. Signature blocks use a `ts cordis-catalog` fence and keep the original source JSDoc; dispatch modes are defined in the [primer](../cordis-primer.md#dispatch-modes), and the framework-inherited `ctx` API lives in [cordis-api/inherited.md](../cordis-api/inherited.md).
614
+
615
+ <a id="ctxsessions--sessionstore"></a>
616
+
617
+ ### `ctx.sessions` — `SessionStore`
618
+
619
+ In-memory session store (`ctx.sessions`).
620
+
621
+ Persistence is intentionally not implemented here — persistence plugins subscribe to `session/event` and flush on `session/flush` / dispose.
622
+
623
+ ```ts cordis-catalog
624
+ /**
625
+ * Create a session owned by the calling fiber: disposing that fiber stops
626
+ * event notification and removes the session from the store. `options.seed`
627
+ * populates the session with a copy of those events (replay/fork);
628
+ * `options.meta` attaches creation metadata (validated absolute `cwd`, seed
629
+ * and parent lineage, and delegation depth) as the immutable
630
+ * {@link SessionHeader} (the store fills `version`/`id`/`createdAt`).
631
+ *
632
+ * For an agent whose session must be torn down IN ORDER with its loop (so the
633
+ * loop's final events are published before the store attachment ends), do NOT use this
634
+ * — fold the session lifecycle into the agent's own effect via
635
+ * {@link prepare} + {@link enter} + {@link announce} (see
636
+ * `dsh-agent-loop`'s creation transaction).
637
+ *
638
+ * @param id - the session id; omitted, the store mints `session-<n>`.
639
+ * @param options - seed events and/or creation metadata for the header.
640
+ * @returns the live session, already entered and announced.
641
+ * @throws if a session with `id` already exists, metadata is not a plain
642
+ * lossless-JSON record with valid scalar fields, or `meta.cwd` is a
643
+ * non-absolute path (storage backends key directories off it).
644
+ */
645
+ create(id?: SessionId, options?: CreateSessionOptions): Session
646
+
647
+ /**
648
+ * Build a session WITHOUT entering it into the store — validate the id/cwd and
649
+ * construct the {@link Session} (with its immutable {@link SessionHeader}).
650
+ * Pairs with {@link enter} + {@link announce}: a caller that owns a composite
651
+ * `ctx.effect` (the agent factory) folds the session lifecycle into that ONE
652
+ * effect so a fiber unload tears the session + agent down as a single ORDERED
653
+ * chain rather than as racing sibling effects — which would remove the publication hooks
654
+ * before the driver's closing events commit, dropping them.
655
+ *
656
+ * @param id - the session id; omitted, the store mints `session-<n>`.
657
+ * @param options - seed events and/or creation metadata for the header. With
658
+ * `seedSource: 'persistence'`, metadata and events must be fresh detached
659
+ * graphs whose ownership transfers to this call: they are validated and
660
+ * frozen in place through {@link Session.fromRestore}, so the caller must
661
+ * retain no mutable aliases.
662
+ * @returns the constructed session, NOT yet in the store.
663
+ * @throws if a session with `id` already exists, metadata is not a plain
664
+ * lossless-JSON record with valid scalar fields, or `meta.cwd` is a
665
+ * non-absolute path.
666
+ */
667
+ prepare(id?: SessionId, options?: PrepareSessionOptions): Session
668
+
669
+ /**
670
+ * Enter a {@link prepare}d session into the store: install the module-private
671
+ * append publication hooks and add it to the store. Returns the DETACH
672
+ * disposer (hooks + store removal). Does NOT emit `session/created` —
673
+ * the caller yields this disposer inside its effect and THEN calls
674
+ * {@link announce}, so a throwing `session/created` listener rolls the attach
675
+ * back instead of leaking it.
676
+ *
677
+ * Re-checks the id for a duplicate: `prepare` and `enter` are public
678
+ * cross-package primitives and a caller may interleave arbitrary work (or
679
+ * another create) between them, so a stale prepared session must NOT overwrite
680
+ * a live store entry of the same id — its detach disposer would later delete
681
+ * the REAL session. The {@link create} convenience and the agent factory call
682
+ * the two back-to-back so they never trip this, but the public API cannot
683
+ * assume that.
684
+ *
685
+ * @param session - a {@link prepare}d session not yet in the store.
686
+ * @returns the detach disposer (publication hooks + store removal). When called from
687
+ * a synchronous `session/created` listener, removal and disposal wait until
688
+ * that creation dispatch unwinds.
689
+ * @throws if a session with this id is already in the store.
690
+ */
691
+ enter(session: Session): () => void
692
+
693
+ /** Emit `session/created` exactly once for an {@link enter}ed session (with
694
+ * the carrier {@link enter} captured). Separate from {@link enter} so the
695
+ * caller can yield the detach disposer first (rollback safety — see
696
+ * {@link enter}).
697
+ * @param session - the entered session to announce to listeners.
698
+ * @throws if the session is not live or its announcement already began,
699
+ * including a reentrant call from a creation listener. */
700
+ announce(session: Session): void
701
+
702
+ /**
703
+ * Dispatch the awaited `session/flush` durability checkpoint for `session`,
704
+ * with the carrier captured at {@link enter}. THE flush entry point: the
705
+ * store owns the carrier, so callers (the checkpoint policy's per-request
706
+ * barrier, goal-round-driver's idle checkpoint, teardown drains, and consumers
707
+ * that flush themselves before reading storage) must come through here
708
+ * rather than dispatch a raw `ctx.parallel('session/flush', …)` — one owner,
709
+ * one spelling, and the scoped-dispatch invariant can pin it.
710
+ * @param session - the session whose buffered events must reach durable storage.
711
+ * @returns whether at least one durability listener participated, after every
712
+ * listener has settled successfully.
713
+ * @throws the first registered listener failure after every listener settles.
714
+ */
715
+ async flush(session: Session): Promise<boolean>
716
+
717
+ /**
718
+ * Look up a live session.
719
+ * @param id - the session id to look up.
720
+ * @returns the session, or undefined when no live session has that id.
721
+ */
722
+ get(id: SessionId): Session | undefined
723
+
724
+ /**
725
+ * All live sessions, in creation order.
726
+ * @returns a fresh array; mutating it does not affect the store.
727
+ */
728
+ list(): Session[]
729
+
730
+ /**
731
+ * Create a live child session from a stable prefix of a live source.
732
+ * `boundary` is an inclusive source event seq; omitted means the source's
733
+ * current last event. The selected slice may end with a between-turn event
734
+ * but must not end inside an open turn.
735
+ *
736
+ * @param source - Live source session object or id.
737
+ * @param boundary - Inclusive source event seq to fork through; omitted means
738
+ * the source's current last event, and omitted on an empty source forks an
739
+ * empty child.
740
+ * @param childSessionId - Optional child session id; omitted delegates to
741
+ * `SessionStore`'s id policy.
742
+ * @returns The created live child session.
743
+ */
744
+ fork(source: SessionForkSource, boundary?: number, childSessionId?: SessionId): Session
745
+ ```
746
+
747
+ Types: [CreateSessionOptions](persistence.md) · [PrepareSessionOptions](persistence.md) · [SessionId](core.md)
748
+
749
+ Source: [`packages/core/session/src/index.ts:792`](../../packages/core/session/src/index.ts)
750
+
751
+ <a id="session-events"></a>
752
+
753
+ ### `session/*` events
754
+
755
+ <a id="sessioncreated--emit"></a>
756
+
757
+ #### `session/created` — emit
758
+
759
+ Creation announcement during session publication. A synchronous throw vetoes and rolls back with a paired disposal; detach requested during dispatch is deferred. A returned-promise rejection is logged but cannot retroactively veto this synchronous boundary. Scope-filtered dispatch (`@deepseek-ai/dsh-scope`): agent-scoped listeners receive only sessions entered through that agent's context.
760
+
761
+ ```ts cordis-catalog
762
+ /**
763
+ * Creation announcement during session publication. A synchronous throw vetoes and rolls
764
+ * back with a paired disposal; detach requested during dispatch is deferred.
765
+ * A returned-promise rejection is logged but cannot retroactively veto this
766
+ * synchronous boundary.
767
+ * Scope-filtered dispatch (`@deepseek-ai/dsh-scope`): agent-scoped listeners
768
+ * receive only sessions entered through that agent's context.
769
+ * @param session - the session just entered and announced.
770
+ * @dshScopeScan unsupported
771
+ * @mode emit
772
+ */
773
+ 'session/created'(this: Scoped<Session>, session: Session): void
774
+ ```
775
+
776
+ Types: [Scoped](scope.md)
777
+
778
+ Source: [`packages/core/session/src/index.ts:54`](../../packages/core/session/src/index.ts)
779
+
780
+ <a id="sessiondisposed--emit"></a>
781
+
782
+ #### `session/disposed` — emit
783
+
784
+ Emitted once when an announced session leaves the store, including publication rollback, but never for an entry whose creation announcement did not begin. Listener failures are logged and contained. Scope-filtered dispatch (`@deepseek-ai/dsh-scope`) reuses the owner scope.
785
+
786
+ ```ts cordis-catalog
787
+ /**
788
+ * Emitted once when an announced session leaves the store, including
789
+ * publication rollback, but never for an entry whose creation announcement
790
+ * did not begin. Listener failures are logged and contained.
791
+ * Scope-filtered dispatch (`@deepseek-ai/dsh-scope`) reuses the owner scope.
792
+ * @param session - the session that is no longer live in the store.
793
+ * @dshScopeScan unsupported
794
+ * @mode emit
795
+ */
796
+ 'session/disposed'(this: Scoped<Session>, session: Session): void
797
+ ```
798
+
799
+ Types: [Scoped](scope.md)
800
+
801
+ Source: [`packages/core/session/src/index.ts:64`](../../packages/core/session/src/index.ts)
802
+
803
+ <a id="sessionevent--emit"></a>
804
+
805
+ #### `session/event` — emit
806
+
807
+ Post-commit, fire-and-forget append feed. The listener snapshot resolves before the log push, but callbacks run after it; observer failures are logged and contained without making the committed append fail. Scope-filtered dispatch (`@deepseek-ai/dsh-scope`): agent-scoped listeners receive only events from sessions entered through that agent's context.
808
+
809
+ ```ts cordis-catalog
810
+ /**
811
+ * Post-commit, fire-and-forget append feed. The listener snapshot resolves
812
+ * before the log push, but callbacks run after it; observer failures are
813
+ * logged and contained without making the committed append fail.
814
+ * Scope-filtered dispatch (`@deepseek-ai/dsh-scope`): agent-scoped listeners
815
+ * receive only events from sessions entered through that agent's context.
816
+ * @param session - the session whose log grew.
817
+ * @param event - the appended event, exactly as recorded.
818
+ * @dshScopeScan unsupported
819
+ * @mode emit
820
+ */
821
+ 'session/event'(this: Scoped<Session>, session: Session, event: SessionEvent): void
822
+ ```
823
+
824
+ Types: [Scoped](scope.md)
825
+
826
+ Source: [`packages/core/session/src/index.ts:76`](../../packages/core/session/src/index.ts)
827
+
828
+ <a id="sessionflush--parallel"></a>
829
+
830
+ #### `session/flush` — parallel
831
+
832
+ Awaited parallel durability checkpoint: every listener runs and the caller awaits all of them, with no waterfall veto. Scope-filtered dispatch (`@deepseek-ai/dsh-scope`) reuses the session's owner scope.
833
+
834
+ ```ts cordis-catalog
835
+ /**
836
+ * Awaited parallel durability checkpoint: every listener runs and the
837
+ * caller awaits all of them, with no waterfall veto. Scope-filtered dispatch
838
+ * (`@deepseek-ai/dsh-scope`) reuses the session's owner scope.
839
+ * @param session - the session whose buffered events must reach durable storage.
840
+ * @dshScopeScan unsupported
841
+ * @mode parallel
842
+ */
843
+ 'session/flush'(this: Scoped<Session>, session: Session): Promise<void> | void
844
+ ```
845
+
846
+ Types: [Scoped](scope.md)
847
+
848
+ Source: [`packages/core/session/src/index.ts:85`](../../packages/core/session/src/index.ts)
849
+ <!-- END GENERATED cordis-surface -->