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,1070 @@
1
+ # Core
2
+
3
+ English | [中文](core.zh.md)
4
+
5
+ The **core** subsystem is [`packages/core`](../../packages/core/README.md) — the packages every composition boots: the event-sourced session log, system-prompt assembly, the tool registry, the agent types, and the concrete loop that drives them. This page explains what the `agent`/`agent-loop` pair declares — how an agent is created and owned, and the `Agent` handle's delivery, cancellation, and interception contracts — plus the two type patterns every subsystem follows. The group's dedicated pages and the rest of the folder are indexed in the [subsystems README](README.md).
6
+
7
+ ## The spine, package by package
8
+
9
+ A turn flows through the six packages in one loop: the driver in [`agent-loop`](../../packages/core/agent-loop) claims a queued prompt, opens a turn on the [session log](session.md) (`ctx.sessions`), assembles the request prefix through [system-prompt](system-prompt.md) (`ctx.systemPrompt`) and derives history from the log, streams the model response through the [LLM seam](llm-streaming.md), dispatches tool calls through the [tool registry](tools.md) (`ctx.tools`), and appends every model-visible fact back onto the log before the next step derives from it. The conversation vocabulary the loop moves — `Message`, `ContentBlock`, `StreamChunk`, the model request — is declared by [`packages/llm`](../../packages/llm/README.md) and documented on [llm-streaming.md](llm-streaming.md).
10
+
11
+ | Package | Owns | Page |
12
+ |---|---|---|
13
+ | `session/` | The append-only `SessionEvent` log and in-memory store — the single source of truth (`ctx.sessions`) | [session.md](session.md) |
14
+ | `system-prompt/` | Prompt-section and tool-schema assembly (`ctx.systemPrompt`) | [system-prompt.md](system-prompt.md) |
15
+ | `tools/` | The scoped tool registry and guarded execution pipeline (`ctx.tools`) | [tools.md](tools.md) |
16
+ | `agent/` | The `Agent` interface, live registry, initiator scope, and `agent/*` event vocabulary (`ctx.agents`) | this page |
17
+ | `agent-loop/` | The concrete driver implementing the public `Agent` contract (`ctx.agentLoop`) | this page |
18
+ | `scope/` | The scoped-registration primitive the registries and loop build per-agent scoping on | [scope.md](scope.md) |
19
+
20
+ `scope/` is the one non-service package: a dependency-free library (`createScope`/`scopeOf`/`scopeTarget`) that sits below `session/` and `system-prompt/` in the module graph precisely so they can consume it without a cycle. `agent-loop` is the one concrete implementation of the public `Agent` contract and lives here because it is the harness's default product loop; it runs each driver inside `ctx.agents.withInitiator()`. Extension plugins depend on `agent` — including when they need the initiating Agent — and never on `agent-loop` directly, so the loop stays swappable. The default composition that wires this spine into a runnable agent is [`examples/agent-spine-demo`](../../packages/examples/agent-spine-demo/README.md).
21
+
22
+ ## Creation and ownership
23
+
24
+ Consumers create agents through `ctx.agents` — `create()` builds a fresh session and agent under one caller-supplied `SessionId`, `resume()` loads a persisted session first — or declaratively through the loop's config entries. Programmatic creation returns the owner's handle:
25
+
26
+ Source: [`packages/core/agent/src/index.ts`](../../packages/core/agent/src/index.ts)
27
+
28
+ ```ts type-equiv
29
+ /**
30
+ * An owned agent plus its disposer, returned by {@link AgentRegistry.create} /
31
+ * {@link AgentRegistry.resume}. The disposer is a CAPABILITY: among consumers,
32
+ * only the holder can tear this agent down. The registered factory provider is
33
+ * also a structural owner because the scoped agent depends on that provider's
34
+ * service API; provider unload stops and drains every live handle it made.
35
+ * `dispose()` stops the loop, awaits its exit, unregisters the agent, removes
36
+ * its session from the store, and finally unwinds its scoped world.
37
+ *
38
+ * `ctx.agents.get(id)` still returns a bare {@link Agent} — the handle is
39
+ * exposed only to the consumer owner that created it; the structural provider
40
+ * reaches the same teardown internally. Config-created agents (the loop's own
41
+ * startup) are owned by the loop fiber and never need a handle.
42
+ */
43
+ interface AgentHandle {
44
+ agent: Agent
45
+ dispose(): Promise<void>
46
+ }
47
+ ```
48
+
49
+ `CreateAgentOptions` carries the shared identity and everything a fresh agent needs before publication: session metadata (`meta` — validated `cwd`, fork lineage, seed boundary, origin classification, delegation depth), an optional `seed` replay prefix for forks, per-agent `AgentOptions`, a creation-only cancellation `signal`, and `setup`. `ResumeAgentOptions` is the persisted-identity counterpart: `resumeSessionId`, `agentOptions`, `signal`, and `setup`. The `setup` callback (`AgentSetup`) composes the agent's scoped world while both ids are still unpublished — everything registered through `agentCtx` exists before `agent/created` and the first prompt assembly — and may return a synchronous commit invoked immediately before publication; a setup rejection, commit throw, or owner disposal rolls the transaction back without publishing either id.
50
+
51
+ `AgentFactory` is the creation interface behind the registry: the loop registers its factory via `ctx.agents.setFactory()`, so consumers use `ctx.agents` without depending on the concrete loop package. The exact `create`/`resume` signatures and rollback contracts are in the [generated section](#ctxagents--agentregistry) below.
52
+
53
+ ## The agent handle
54
+
55
+ `Agent` is the surface every plugin (UI, hooks, orchestrators) programs against; `ctx.agents.get(id)` returns it, and the [initiator scope](#initiating-agent) carries it. The concrete implementation is package-internal to dsh-agent-loop; nothing outside the loop depends on it. The unified `send` method exposes target and wakeup routing directly; `followup`, `steer`, and `inject` are fixed-preset aliases.
56
+
57
+ Source: [`packages/core/agent/src/types.ts`](../../packages/core/agent/src/types.ts)
58
+
59
+ ```ts type-equiv
60
+ /** Public live-agent handle. */
61
+ interface Agent {
62
+ /** The single identity shared with {@link session}. */
63
+ readonly id: SessionId
64
+ /** The provider route and model this agent's requests use. */
65
+ readonly options: AgentOptions
66
+ /** The live session this agent drives; its log is the durable source of truth. */
67
+ readonly session: Session
68
+ /** The agent-owned projection of durable pending work. */
69
+ readonly inbox: Inbox
70
+ /** The current lifecycle state, mirrored on every `agent/status` transition. */
71
+ readonly status: AgentStatus
72
+ /** Agent-scoped context; its contributions are agent-local, unwind on disposal, and reject registration afterward. */
73
+ readonly ctx: Context
74
+
75
+ /**
76
+ * Clear queued and steering work — unless `keepInbox` — and abort the active
77
+ * turn or between-turn task. The first cause wins for that activity. With no
78
+ * active activity, cancellation is a no-op and does not arm later work.
79
+ * @param cause - the stable caller intent carried by the active operation signal.
80
+ * @param options - cancellation options; `keepInbox` preserves pending work.
81
+ */
82
+ cancel(cause: AgentCancelCause, options?: CancelOptions): void
83
+
84
+ /**
85
+ * Resolve after the current whole-agent activity reaches quiescence. This
86
+ * follows replacement work started before the observed driver retires,
87
+ * but does not identify the settlement of any particular message.
88
+ * @returns fulfillment after no active driver or maintenance task remains.
89
+ */
90
+ whenIdle(): Promise<void>
91
+
92
+ /**
93
+ * Run one non-turn maintenance task from the true idle phase. The task starts
94
+ * synchronously after claiming that phase; later waking input remains in the
95
+ * inbox until the task settles, while public status stays `idle`.
96
+ * `whenIdle()` follows both the task and any waking work released behind it.
97
+ * @param task - operation whose fulfillment or rejection is preserved, with a signal aborted by {@link cancel}.
98
+ * @throws synchronously when turn-driving or another maintenance task already owns the agent.
99
+ * @returns the task promise.
100
+ */
101
+ runMaintenance<T>(task: (signal: AbortSignal) => Promise<T>): Promise<T>
102
+
103
+ /**
104
+ * Route identified input to an inbox boundary and optionally wake the driver.
105
+ * Waking input submitted after active cancellation is queued for the next
106
+ * turn and runs when the aborted activity converges to idle; a `disposed`
107
+ * cancel leaves it parked. A wake submitted while already idle always opens
108
+ * its turn boundary, even when its message is cleared before the driver
109
+ * claims ([cancel-convergence wake latch](../../../../.agents/notes/implemented/bug-fix/2026-08-07-cancel-convergence-wake-latch.md)).
110
+ * @param message - identified content and the source that supplied it.
111
+ * @param target - the preferred next-turn or next-step inbox boundary.
112
+ * @param wakeup - whether delivery may wake the driver.
113
+ */
114
+ send(message: UserMessage, target: InboxTarget, wakeup: boolean): void
115
+
116
+ /**
117
+ * Queue an ordinary follow-up turn and wake the driver. The item becomes the
118
+ * sole ordinary message of its own turn.
119
+ * @param message - identified prompt content and the source that supplied it.
120
+ */
121
+ followup(message: UserMessage): void
122
+
123
+ /**
124
+ * Submit steering for the nearest step. An idle driver starts a turn;
125
+ * a running driver consumes it at its next step boundary.
126
+ * A rejected step leaves steering parked in the inbox until the next
127
+ * wake; cancellation or disposal may discard pending steering.
128
+ * @param message - identified steering content and the source that supplied it.
129
+ */
130
+ steer(message: UserMessage): void
131
+
132
+ /**
133
+ * Queue model-facing context for the next pre-step without waking the
134
+ * driver. A running driver claims it at the nearest later step boundary;
135
+ * idle drivers leave it pending until follow-up or steering
136
+ * wakes them. It may miss a request whose pre-step already claimed its
137
+ * batch. Cancellation or disposal may discard pending context.
138
+ * @param message - identified injected context and the source that supplied it.
139
+ */
140
+ inject(message: UserMessage): void
141
+ }
142
+ ```
143
+
144
+ ```ts type-equiv
145
+ /**
146
+ * An agent's lifecycle state, emitted on every transition as `agent/status`:
147
+ * `idle` means no driver is active; `running` begins when waking input starts
148
+ * cancellable pre-step processing and lasts while the driver drains,
149
+ * closes, or checkpoints turns. Disposal removes the agent from its registry;
150
+ * it is not a third observable status.
151
+ */
152
+ type AgentStatus = 'idle' | 'running'
153
+ ```
154
+
155
+ `running` describes the driver-wide drain interval and may span consecutive queued turns; it does not prove a turn is still open. Disposal removes the agent from the registry and emits `agent/disposed`; it is not a terminal status value. `followup()` returns no handle: its `MessageId` identifies durable inbox insertion, claim, and discard facts, not a later assistant output or turn ending. `whenIdle()` observes the whole agent, so callers may call a receipt-to-idle interval a run only when they explicitly own that interval ([decision](../../.agents/notes/implemented/architecture/2026-07-30-followup-enqueue-and-owned-runs.md)).
156
+
157
+ ```ts type-equiv
158
+ /** Merge-extensible agent creation options. Persona belongs to system-prompt sections. */
159
+ interface AgentOptions {
160
+ /** Provider route (must have a registered adapter at call time). */
161
+ provider?: string
162
+ /** Model id interpreted by the selected provider adapter. */
163
+ model?: string
164
+ /** Maximum output tokens for each conversation-model request. */
165
+ maxTokens?: number
166
+ }
167
+ ```
168
+
169
+ Dispatch requires `provider` and `model` after `agent/request`. When present, `maxTokens` must be a positive safe integer and caps every conversation-model request; omission allows the exact-model adapter default to materialize before the request header, or otherwise leaves provider behavior unchanged. An agent-scoped `deployment:persona` prompt section may shadow the global default persona.
170
+
171
+ The inbox is the delivery vocabulary — two ordered pending-message lists the agent owns as a durable projection:
172
+
173
+ ```ts type-equiv
174
+ /** One of the two ordered pending-message lists owned by an agent. */
175
+ type InboxTarget = 'next-turn' | 'next-step'
176
+ ```
177
+
178
+ Every pending occurrence is its `UserMessage`; `MessageId` is the sole identity. `Inbox.append`, `prepend`, `replace`, `remove`, `clear`, `splice`, and `claim` record normalized durable `agent/inbox/spliced` mutations and reject duplicate pending ids. `replace(messageId, newMessage)` and `remove(messageId)` locate the pending message across both lists; replacement may change identity and emits the old message as discarded followed by the new message as inserted. Ordinary removals and `clear()` are cancellations. `claim(target)` removes the proposed step batch — all `next-step` input plus, at a turn boundary, one `next-turn` message — through pure deletion splices without emitting discarded notifications, and the loop separately emits per-message claimed notifications. Whole-queue consumers such as UI projections reconstruct `nextTurn` and `nextStep` from the durable splices, while consumers following one message use the exact `agent/inbox/inserted`, `claimed`, and `discarded` notifications.
179
+
180
+ Cancellation:
181
+
182
+ ```ts type-equiv
183
+ /** Options for {@link Agent.cancel}. */
184
+ interface CancelOptions {
185
+ /**
186
+ * Preserve queued and steering inbox items instead of discarding them. The
187
+ * active turn is still aborted, but un-started and pending work survives for a
188
+ * later turn and no canceled inbox splice is logged.
189
+ */
190
+ keepInbox?: boolean | undefined
191
+ }
192
+ ```
193
+
194
+ ```ts type-equiv
195
+ /** Why an active agent driver was cancelled. */
196
+ type AgentCancelCause =
197
+ | { readonly kind: 'user' }
198
+ | { readonly kind: 'parent' }
199
+ | { readonly kind: 'hook'; readonly reason: string }
200
+ | { readonly kind: 'disposed' }
201
+ ```
202
+
203
+ The cause is a TypeScript-enforced same-process input. An active cancellation holder copies it into the runtime-only `AbortSignal.reason`; a signal grants cooperating listeners no classification authority. Durable `turn/end` retains the coarse `{ kind: 'aborted' }` outcome; recording who requested cancellation would require a separate durable event rather than overloading the terminal result.
204
+
205
+ The [event taxonomy](../architecture.md#events) owns the `agent/*` lifecycle, checkpoint, and waterfall contracts. Turn and step boundaries are durable session events rather than agent emits.
206
+
207
+ ## Initiating Agent
208
+
209
+ The process-local initiator carried by `ctx.agents` is the exact `Agent` above, not a separate frame or copied identity. Ambient presence is neither liveness proof nor authorization; the [initiator-scope decision](../../.agents/notes/implemented/architecture/2026-07-15-agent-initiator-scope.md) defines its lifetime and scope rules.
210
+
211
+ ## Interception decisions
212
+
213
+ Pre-step decisions use the same identified `UserMessage` type as durable user-role input. The entered batch is authoritative and preserves every message's `id` and `source`. Hook bridges map their native decision fields onto this typed result.
214
+
215
+ Source: [`packages/core/agent/src/types.ts`](../../packages/core/agent/src/types.ts)
216
+
217
+ `agent/pre-step` receives one payload carrying the exclusive claimed batch (`messages`), the proposed step's coordinates (`turn`, `step`), and the current turn's cancellation `signal`. The initial proposal runs inside an open turn before any step; a tool continuation may submit an empty claimed batch between steps:
218
+
219
+ It returns a `PreStepDecision`. Reject opens no step. Enter supplies the complete message batch appended after `step/start`; claimed messages omitted by the final decision remain removed, while input inserted after the claim stays pending:
220
+
221
+ ```ts type-equiv
222
+ /** Whether and with which messages the loop enters a proposed step. */
223
+ type PreStepDecision =
224
+ | { kind: 'reject' }
225
+ | { kind: 'enter'; messages: UserMessage[] }
226
+ ```
227
+
228
+ `agent/request-error` runs after a failed model step closes and before its turn closes. Listeners can repair durable state or await policy work while the failed turn's signal is still live. A handling listener returns `{ kind: 'retry' }` without calling `next()`; the default `undefined` leaves the failure terminal.
229
+
230
+ ```ts type-equiv
231
+ /** Action returned by a listener that owns model-request recovery. */
232
+ type RequestErrorAction = { kind: 'retry' } | undefined
233
+ ```
234
+
235
+ `agent/pre-step` is the only serial listener chain before request derivation. `agent/turn-stopping` runs when a turn has no tool or steering continuation, before one final steering drain.
236
+
237
+ `agent/session-start` carries a `SessionStartSource` (why the session lifecycle began; a bridge keys its SessionStart matcher on it):
238
+
239
+ ```ts type-equiv
240
+ /** Why a session lifecycle began; seeded creates are `startup`, while persisted loads are `resume`. */
241
+ type SessionStartSource = 'startup' | 'resume' | 'clear' | 'compact'
242
+ ```
243
+
244
+ ## Sessions
245
+
246
+ A `Session` is an **append-only log** of typed `SessionEvent`s — the single source of truth. The LLM message history is *derived* from the log (`deriveMessages()`), not stored separately. Every entry carries a monotonic `seq`, a `time`, and a `type`-discriminated `data` payload; surface variants may also list cited earlier events in `sourceEventSeqs` and carry a `surfaceOp`.
247
+
248
+ The `SessionEvent` envelope's exact conditional fields, the twelve event variants (`turn/start`, `turn/end`, `step/start`, `step/end`, `user/message`, `assistant/chunk`, `assistant/message`, `tool/call`, `tool/result`, `steering/message`, `todo/write`, `request/header`), the `deriveMessages()` projection rules, the `TurnTrigger`/`TurnEndReason` reasons, and the execution-enclosure and standalone-event rules are on **[session.md](session.md)**. How the log is made durable — the `SessionPersistence` interface, JSONL/SQLite backends, the `session/flush` checkpoint, crash recovery, and `SessionHeader` — is on **[persistence.md](persistence.md)**.
249
+
250
+ ## `ToolDefinition`
251
+
252
+ The one pipeline-authoring type that is core: what every registered tool *is* — a model-facing `ToolSchema` plus an `execute` function and optional final-content and UI callbacks. A tool author rarely constructs it by hand (the `defineTool` DSL builds it with typed arguments), but it is the contract the registry holds and the loop dispatches through.
253
+
254
+ Its full fields, the `defineTool`/`ValueSchemaSpec`/`ParameterSchemaSpec` typed schema DSL, the `ToolExecution`/`ToolExecutionResult` waterfall types, and the tool-presentation UI types are on **[tools.md](tools.md)**.
255
+
256
+ ## Repo-wide type patterns
257
+
258
+ Two patterns recur across every subsystem and are documented once, here.
259
+
260
+ <a id="the-map--derived-union-pattern"></a>
261
+
262
+ ### The `…Map → derived-union` pattern
263
+
264
+ Almost every extensible sum type in the harness follows one pattern: an interface keyed by a discriminant tag (the `…Map`), from which the union is derived with `keyof`. Plugins add variants by **declaration merging** — no edit to the owning package.
265
+
266
+ ```ts ignore-check
267
+ // The pattern, schematically:
268
+ interface ThingMap {
269
+ 'a': { kind: 'a'; /* … */ }
270
+ 'b': { kind: 'b'; /* … */ }
271
+ }
272
+ type ThingKind = keyof ThingMap // 'a' | 'b'
273
+ type Thing = ThingMap[keyof ThingMap] // the discriminated union
274
+
275
+ // A plugin extends it without touching the source package:
276
+ declare module '@deepseek-ai/dsh-llm' {
277
+ interface ThingMap {
278
+ 'c': { kind: 'c'; /* … */ }
279
+ }
280
+ }
281
+ ```
282
+
283
+ Six canonical maps use this pattern; a plugin author extends these:
284
+
285
+ | Map | Package | Derives | Catalog |
286
+ |---|---|---|---|
287
+ | `ContentBlockMap` | dsh-llm | `ContentBlock` | [llm-streaming.md](llm-streaming.md#content-blocks-and-messages) |
288
+ | `MessageSourceMap` | dsh-llm | `MessageSource` | [llm-streaming.md](llm-streaming.md#content-blocks-and-messages) |
289
+ | `FinishReasonMap` | dsh-llm | `FinishReason` | [llm-streaming.md](llm-streaming.md#the-model-request-and-result) |
290
+ | `TurnTriggerMap` | dsh-session | `TurnTrigger` | [session.md](session.md) |
291
+ | `TurnEndReasonMap` | dsh-session | `TurnEndReason` | [session.md](session.md) |
292
+ | `SessionEventMap` | dsh-session | `SessionEvent` | [session.md](session.md) |
293
+
294
+ Two large discriminated unions are the ones consumers `switch` over most: **`StreamChunk`** (the streaming protocol) and **`SessionEvent`** (the log entry). Per the repo convention, `switch` on the tag — don't chain `if`s — so each arm narrows and a typo'd tag fails to compile.
295
+
296
+ ### Branded IDs
297
+
298
+ IDs passed between packages are **branded** — structurally strings, but non-interchangeable at the type level (a `SessionId` cannot be passed where a `CallId` is expected). Construction goes through a per-type factory; comparison, logging, and JSON behave as ordinary strings.
299
+
300
+ The `Branded<B>` primitive lives in its own type-only package, [dsh-brand](../../packages/util/brand) (no runtime code, no harness-package dependency), so any package can brand the ids it owns without depending on an unrelated capability package.
301
+
302
+ Source: [`packages/util/brand/src/index.ts`](../../packages/util/brand/src/index.ts)
303
+
304
+ ```ts type-equiv
305
+ /** A string carrying a compile-time-only brand `B`. */
306
+ type Branded<B extends string> = string & { readonly [BRAND]: B }
307
+ ```
308
+
309
+ The two core IDs are `CallId` (correlates a tool call with its result; dsh-llm) and `SessionId` (the shared live agent and durable session identity; dsh-session). Capability packages brand their own ids too, such as `JobId` in [jobs.md](jobs.md).
310
+
311
+ <!-- BEGIN GENERATED cordis-surface (gen-cordis-catalog.ts) — do not edit between markers -->
312
+
313
+ <a id="cordis-surface"></a>
314
+
315
+ ## Cordis API
316
+
317
+ 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).
318
+
319
+ <a id="ctxagentdefaultmodel--agentdefaultmodelconfig"></a>
320
+
321
+ ### `ctx.agentDefaultModel` — `AgentDefaultModelConfig`
322
+
323
+ Owns the default model selection independently of any Host or transport. The composition entry remains usable without a settings provider; when one is mounted, its user layer is read live.
324
+
325
+ ```ts cordis-catalog
326
+ /**
327
+ * Read the current default model selection.
328
+ * @returns a detached provider, model, and optional reasoning selection.
329
+ */
330
+ currentSelection(): ModelSelection
331
+
332
+ /**
333
+ * Save the complete default model selection. A deployment without a settings
334
+ * provider keeps its composition entry.
335
+ * @param next - resolved selection accepted by an entry point.
336
+ * @returns fulfillment after the optional settings write settles.
337
+ */
338
+ async saveSelection(next: ModelSelection): Promise<void>
339
+ ```
340
+
341
+ Source: [`packages/core/agent-default-model/src/index.ts:64`](../../packages/core/agent-default-model/src/index.ts)
342
+
343
+ <a id="ctxagentloop--agentloop"></a>
344
+
345
+ ### `ctx.agentLoop` — `AgentLoop`
346
+
347
+ Concrete agent factory and driver service.
348
+
349
+ ```ts cordis-catalog
350
+ /**
351
+ * Create an agent and session under one caller-supplied identity, owned by
352
+ * the accessing fiber. Constructor-driven config calls mint a fresh combined
353
+ * id before entering this boundary.
354
+ * @param id - shared agent/session identity.
355
+ * @param options - concrete loop options.
356
+ * @param meta - optional fresh-session workspace metadata.
357
+ * @returns the published running agent.
358
+ */
359
+ create(id: SessionId, options: AgentOptions = {}, meta: Pick<SessionHeader, 'cwd'> = {}): Agent
360
+
361
+ /**
362
+ * Create an owned agent on a caller-supplied session id.
363
+ * @param ownerCtx - caller context that structurally owns the lifecycle.
364
+ * @param options - identities, session seed/metadata, loop options, setup, and cancellation.
365
+ * @returns the published handle.
366
+ */
367
+ async createAgent(ownerCtx: Context, options: CreateAgentOptions): Promise<AgentHandle>
368
+
369
+ /**
370
+ * Resume an owned agent from the configured persistence service.
371
+ * @param ownerCtx - caller context that owns load, setup, and the live lifecycle.
372
+ * @param options - persisted identity, loop options, setup, and cancellation.
373
+ * @returns the published handle.
374
+ */
375
+ async resume(ownerCtx: Context, options: ResumeAgentOptions): Promise<AgentHandle>
376
+ ```
377
+
378
+ Types: [SessionHeader](persistence.md)
379
+
380
+ Source: [`packages/core/agent-loop/src/index.ts:296`](../../packages/core/agent-loop/src/index.ts)
381
+
382
+ <a id="ctxagentpresets--agentpresets"></a>
383
+
384
+ ### `ctx.agentPresets` — `AgentPresets`
385
+
386
+ Registry over the deployment's agent presets.
387
+
388
+ Discovery is unmemoized: `list()` and `resolve()` re-read the roots on every call so a preset authored while the process runs is visible immediately, and a preset deleted underneath a picker disappears from the next read.
389
+
390
+ ```ts cordis-catalog
391
+ /**
392
+ * Every preset the configured roots currently supply.
393
+ * @returns the presets, first-root-wins per id.
394
+ */
395
+ async list(): Promise<AgentPreset[]>
396
+
397
+ /**
398
+ * Resolve one preset by id.
399
+ *
400
+ * A broken preset resolves — deleting one, reading one, and reporting one
401
+ * all need the row — and the mounting paths refuse it AFTER resolution
402
+ * through {@link resolveMountable}.
403
+ * @param id - the preset id, or `undefined` for {@link defaultId}.
404
+ * @returns the resolved preset.
405
+ * @throws when no configured root supplies that id.
406
+ */
407
+ async resolve(id?: string): Promise<AgentPreset>
408
+
409
+ /**
410
+ * Compose one agent from a preset: ensure the preset's standing mount, then
411
+ * parent the agent's scope key to it so the mount's registrations and
412
+ * listeners cover this agent.
413
+ *
414
+ * Call from the agent factory's `setup(agentCtx)`; a rejection there rolls
415
+ * the agent creation back, so a broken preset never yields a half-composed
416
+ * session.
417
+ * @param agentCtx - the agent's scope context.
418
+ * @param id - the preset id, or `undefined` for {@link defaultId}.
419
+ * @returns the preset that was composed, for the caller to record.
420
+ * @throws when the preset is unknown or its composition is unusable.
421
+ */
422
+ async mount(agentCtx: Context, id?: string): Promise<AgentPreset>
423
+
424
+ /**
425
+ * Join one agent to the SAME standing composition another already runs on.
426
+ *
427
+ * This is how a child agent inherits its parent's capabilities. It is a bind,
428
+ * not a mount: the parent's generation is already composed, so the child gets
429
+ * that exact instance — the same plugin objects, the same tool registrations,
430
+ * the same prompt sections. Re-resolving the parent's preset by id instead
431
+ * would re-read the roster, and a composition file edited since the parent
432
+ * started would hand the child a DIFFERENT generation than the one its
433
+ * parent's history was produced under (and a preset deleted since would fail
434
+ * the child outright while its parent keeps running).
435
+ *
436
+ * Synchronous, and with no composition failure mode of its own — it reads no
437
+ * roster, mounts nothing, and touches no file — which is what lets a child
438
+ * creation window use it: the two in-process subagent drivers compose their
439
+ * children inside a synchronous `setup`. It still rejects a caller error, as
440
+ * the `@throws` below record.
441
+ *
442
+ * A parent that joined no preset — a rosterless deployment — yields no join
443
+ * and no error: there, the model-facing rows sit in the host composition and
444
+ * the child already sees them through the global layer.
445
+ * @param agentCtx - the joining agent's scope context.
446
+ * @param parentCtx - the scope context of the agent whose composition to join.
447
+ * @returns the preset id joined, or undefined when the parent joined none.
448
+ * @throws when `agentCtx` carries no scope, or has already joined a preset.
449
+ */
450
+ composeFrom(agentCtx: Context, parentCtx: Context): string | undefined
451
+
452
+ /**
453
+ * The preset one live agent runs on.
454
+ *
455
+ * Read from the live scope chain rather than from the session, so it answers
456
+ * for an agent whose session has not recorded a preset yet — a child agent
457
+ * whose durable header is being built from its parent's composition.
458
+ * @param agentCtx - the agent's scope context.
459
+ * @returns the preset id, or undefined when the agent joined none.
460
+ */
461
+ composedPreset(agentCtx: Context): string | undefined
462
+
463
+ /**
464
+ * Read one preset's composition text.
465
+ * @param id - the preset id.
466
+ * @returns the composition exactly as stored.
467
+ * @throws when no configured root supplies that id.
468
+ */
469
+ async read(id: string): Promise<string>
470
+
471
+ /**
472
+ * Create a locally authored preset by copying an existing one whole.
473
+ *
474
+ * Copy is the only authoring write. Composition text never crosses this
475
+ * seam: the source is named by id and its directory is copied as it stands,
476
+ * so the copy is exactly as loadable as its source and authoring grants no
477
+ * capability the roster did not already carry. The copy is NOT mounted to
478
+ * validate — a source that mounts today yields a copy that mounts today.
479
+ * @param from - the preset the copy starts from; shipped presets are the
480
+ * primary source, so any trust is accepted.
481
+ * @param id - the new preset's id, which becomes its directory name.
482
+ * @param name - display name for the copy; absent falls back to the id.
483
+ * @throws when the source is unknown, the id is unusable or already taken,
484
+ * or the deployment configures no writable root.
485
+ */
486
+ async copy(from: string, id: string, name?: string): Promise<void>
487
+
488
+ /**
489
+ * Delete a locally authored preset.
490
+ * @param id - the preset id.
491
+ * @throws when the preset is unknown or ships with the deployment.
492
+ */
493
+ async remove(id: string): Promise<void>
494
+
495
+ /**
496
+ * One agent's instance of a service its preset mounted.
497
+ *
498
+ * A preset publishes services behind `isolate` realms, which are invisible
499
+ * outside the group that declares them — including to the host. This is how a
500
+ * caller holding the agent reads one anyway: a request that is ABOUT a
501
+ * session but arrives from outside it, which is every browser RPC.
502
+ *
503
+ * Read addressing only. A host row that `inject`s a service cannot use this,
504
+ * because injection resolves before any session exists and has no agent to
505
+ * key by; such a service belongs on the host plane instead.
506
+ * @param agent - the agent whose composition to look inside.
507
+ * @param name - the service name as the preset's rows resolve it.
508
+ * @returns the agent's instance, or undefined when its preset mounts none.
509
+ */
510
+ serviceFor<K extends string & keyof Context>(agent: { ctx: Context }, name: K): Context[K] | undefined
511
+
512
+ /**
513
+ * Re-link one agent to a different preset's standing composition.
514
+ *
515
+ * Only valid while the agent has produced nothing: swapping tools mid
516
+ * conversation would leave logged tool calls the new composition cannot
517
+ * make. The CALLER owns that check — this method does not read session
518
+ * history.
519
+ *
520
+ * The swap is a parent re-link, not an unmount: standing mounts are shared
521
+ * and permanent, so the old composition stays for its other agents and the
522
+ * new one is ensured BEFORE the link moves. An unknown or unusable preset
523
+ * therefore throws with the agent exactly as it was — there is no torn-down
524
+ * state to restore. The re-link runs through the binding this roster kept
525
+ * from the agent's mount — dsh-scope's only re-link authority. An agent
526
+ * that never composed one has nothing to re-link: the switch is then the
527
+ * agent's first bind, exactly a mount.
528
+ * @param agentCtx - the agent's scope context.
529
+ * @param id - the preset to compose the agent from instead.
530
+ * @returns the preset now installed.
531
+ * @throws when the preset is unknown or its composition is unusable.
532
+ */
533
+ async recompose(agentCtx: Context, id: string): Promise<AgentPreset>
534
+
535
+ /**
536
+ * The standing scope key of one preset, for a host reader with no agent.
537
+ *
538
+ * A cold transcript read resolves tool presenters against the composition
539
+ * the session recorded, and the standing mount makes that possible without
540
+ * resuming anything: ensuring the mount composes plugins but starts no
541
+ * agent, no session, and no turn.
542
+ * @param id - the preset id, or `undefined` for {@link defaultId}.
543
+ * @returns the standing scope key readers pass as a registry view scope.
544
+ * @throws when the preset is unknown or its composition is unusable.
545
+ */
546
+ async standingKeyFor(id?: string): Promise<ScopeKey>
547
+ ```
548
+
549
+ Types: [ScopeKey](scope.md)
550
+
551
+ Source: [`packages/preset/agent-presets/src/index.ts:82`](../../packages/preset/agent-presets/src/index.ts)
552
+
553
+ <a id="ctxagents--agentregistry"></a>
554
+
555
+ ### `ctx.agents` — `AgentRegistry`
556
+
557
+ Agent service (`ctx.agents`): tracks live agents and carries the initiating Agent through one process-local asynchronous driver chain. Agent *creation* is provided by whichever plugin implements the AgentFactory (`@deepseek-ai/dsh-agent-loop`), registered via setFactory.
558
+
559
+ Initiator methods provide same-process causal attribution only. Ambient presence is neither liveness proof nor authorization; subjects and owners remain explicit, as does identity at worker, process, persistence, and wire boundaries. Returned Promise boundaries drain during teardown, except a nested lineage that starts an owning-fiber unload is excluded from its own drain.
560
+
561
+ ```ts cordis-catalog
562
+ /**
563
+ * Read the Agent that initiated the inherited asynchronous driver chain.
564
+ * Use this optional form for logging, tracing, metrics, or host attribution
565
+ * that also supports agentless calls. When a parent creates a child, setup
566
+ * reports the causal parent while `agentCtx.agent` identifies the child.
567
+ * @returns the inherited Agent, or `undefined` outside an initiator boundary
568
+ * and inside an explicit clearing boundary.
569
+ * @throws when this service instance has been disposed.
570
+ */
571
+ currentInitiator(): Agent | undefined
572
+
573
+ /**
574
+ * Read the initiating Agent and fail when no initiator boundary is active.
575
+ * Use this for private helpers contractually below a driver, or for a
576
+ * deployment-owned outbound request whose contract forbids agentless calls.
577
+ * Generic or direct-call paths use optional lookup or explicit request fields.
578
+ * @returns the inherited Agent.
579
+ * @throws when no initiator is active or this service instance has been disposed.
580
+ */
581
+ requireInitiator(): Agent
582
+
583
+ /**
584
+ * Run an operation with one exact Agent as its process-local initiator. The
585
+ * exact synchronous value or Promise returned by the operation is preserved.
586
+ * Custom drivers and test harnesses wrap their complete returned foreground
587
+ * lifetime.
588
+ * A queue or wire receiver may establish this boundary only after validating
589
+ * explicit identity and resolving the exact live Agent; this method does neither.
590
+ * Detached work remains owned by the subsystem that starts it.
591
+ * @param agent - initiating Agent to inherit; presence is neither liveness proof nor authorization.
592
+ * @param operation - synchronous or asynchronous operation to invoke.
593
+ * @returns the exact value returned by `operation`.
594
+ * @throws when the initiator scope is closing/disposed, or when `operation` throws.
595
+ */
596
+ withInitiator<T>(agent: Agent, operation: () => T): T
597
+
598
+ /**
599
+ * Run an operation inside a boundary that hides any inherited initiating
600
+ * Agent. The exact synchronous value or Promise is preserved.
601
+ * Use this while creating lazy shared timers, queue pumps, pool maintenance,
602
+ * watchers, or exporters so they do not inherit the first Agent that happens
603
+ * to initialize them. It clears only initiator attribution, not explicit
604
+ * fields, and does not own or drain detached resources.
605
+ * @param operation - synchronous or asynchronous operation to invoke without an initiator.
606
+ * @returns the exact value returned by `operation`.
607
+ * @throws when the initiator scope is closing/disposed, or when `operation` throws.
608
+ */
609
+ withoutInitiator<T>(operation: () => T): T
610
+
611
+ /**
612
+ * Register the agent-creation factory (the loop calls this on construction,
613
+ * effect-scoped). A traced Cordis service is canonicalized to its concrete
614
+ * target; each create/resume call is then traced through that caller's
615
+ * context so ownership follows the caller without stacking proxy layers.
616
+ * Throws if a factory is already registered. Returns the disposer; on
617
+ * dispose the factory slot is cleared.
618
+ * @param factory - the loop-owned factory {@link create}/{@link resume} delegate to.
619
+ * @returns the disposer that clears the factory slot. The exact
620
+ * Cordis effect disposer (single-shot): composite (generator) effects may
621
+ * yield it directly — exact identity nests the teardown in order.
622
+ */
623
+ setFactory(factory: AgentFactory): () => void
624
+
625
+ /**
626
+ * Create and publish a new agent through the registered factory.
627
+ * Distinct from {@link register} (which records an already-constructed
628
+ * agent): this constructs the agent and its session. Rejects if no factory is
629
+ * registered or creation/setup fails. The resolved {@link AgentHandle} lets
630
+ * the owner tear down exactly this agent.
631
+ * @param options - shared identity, session seed/metadata, and agent options.
632
+ * @returns the handle after setup, rollback-covered publication, and loop start complete.
633
+ */
634
+ async create(options: CreateAgentOptions): Promise<AgentHandle>
635
+
636
+ /**
637
+ * Load a persisted session and resume an agent on it through the registered
638
+ * factory. Rejects if no factory is registered; the factory rejects if
639
+ * session persistence is not configured or persistence/setup fails.
640
+ * @param options - persisted identity, configuration, and optional setup.
641
+ * @returns the handle after setup, rollback-covered publication, and loop start complete.
642
+ */
643
+ async resume(options: ResumeAgentOptions): Promise<AgentHandle>
644
+
645
+ /**
646
+ * Register a live agent. Throws if an agent with the same id is already
647
+ * registered. Emits `agent/created` on registration and `agent/disposed`
648
+ * when the calling fiber is disposed — both with the agent's scope carrier
649
+ * (`scopeTarget(agent, agent)`): the subject is the agent in hand, so the
650
+ * emits are scope-filtered regardless of which context invoked `register`
651
+ * (calling through `agent.ctx` scopes EFFECTS; dispatch scoping always
652
+ * requires passing the carrier). Returns the disposer.
653
+ * @param agent - the already-constructed agent to record in the store.
654
+ * @returns the EXACT Cordis effect disposer (single-shot; a repeat call
655
+ * returns undefined without awaiting an in-flight teardown). Exact
656
+ * identity is load-bearing: a composite (generator) effect that owns a
657
+ * teardown ORDER — the agent factory's lifecycle chain — must yield THIS
658
+ * function so Cordis nests the unregistration at that yield position;
659
+ * yielding a wrapper would leave it disposing as a concurrent sibling on
660
+ * owner unload, unregistering the agent (and emitting `agent/disposed`)
661
+ * while its final turn is still draining.
662
+ */
663
+ register(agent: Agent): () => void
664
+
665
+ /**
666
+ * Insert an already-constructed agent without announcing it. This is the
667
+ * advanced ordered-lifecycle primitive used by the async agent factory: it
668
+ * first completes setup while the agent is unpublished, then assigns the
669
+ * returned detach closure into its pre-installed composite teardown before
670
+ * calling {@link announce}. Ordinary callers use {@link register}.
671
+ * @param agent - the prepared, unpublished agent.
672
+ * @param owner - live agent whose scoped context created this agent, or
673
+ * undefined for a top-level runtime root. This is runtime ownership, not
674
+ * the resumed session's durable parent lineage.
675
+ * @returns an idempotent closure that removes this exact entry and emits
676
+ * `agent/disposed` with listener failures contained. When called from a
677
+ * synchronous `agent/created` listener, removal and disposal wait until
678
+ * that creation dispatch unwinds.
679
+ */
680
+ enter(agent: Agent, owner: Agent | undefined): () => void
681
+
682
+ /**
683
+ * Announce an agent previously inserted with {@link enter}.
684
+ * @param agent - the live inserted agent to announce.
685
+ * @throws if `agent` is not the exact live registry entry for its id, or its
686
+ * creation announcement already began (including a reentrant call from a
687
+ * creation listener).
688
+ */
689
+ announce(agent: Agent): void
690
+
691
+ /**
692
+ * Look up a live agent.
693
+ * @param id - the shared agent/session id to look up.
694
+ * @returns the agent, or undefined when no live agent has that id.
695
+ */
696
+ get(id: SessionId): Agent | undefined
697
+
698
+ /**
699
+ * Test whether a live agent was created through one exact parent agent's
700
+ * scoped context. Runtime ownership is independent of durable session
701
+ * lineage and remains unambiguous when unrelated providers reuse an id.
702
+ * @param id - the candidate child agent's shared agent/session id.
703
+ * @param owner - the expected runtime creator agent.
704
+ * @returns true only while the exact child entry is live under that owner.
705
+ */
706
+ isOwnedBy(id: SessionId, owner: Agent): boolean
707
+
708
+ /**
709
+ * All live agents, in registration order.
710
+ * @returns a fresh array; mutating it does not affect the registry.
711
+ */
712
+ list(): Agent[]
713
+
714
+ /**
715
+ * All live top-level agents in registration order. A top-level agent was
716
+ * created without an owning agent context; durable session lineage does not
717
+ * affect this runtime relation, so a resumed fork may still be a root.
718
+ * @returns a fresh array; mutating it does not affect the registry.
719
+ */
720
+ roots(): Agent[]
721
+ ```
722
+
723
+ Source: [`packages/core/agent/src/index.ts:256`](../../packages/core/agent/src/index.ts)
724
+
725
+ <a id="agent-events"></a>
726
+
727
+ ### `agent/*` events
728
+
729
+ <a id="agentcreated--emit"></a>
730
+
731
+ #### `agent/created` — emit
732
+
733
+ A fully configured agent and live session were published. Setup is composition-only; `agent/session-start` is the first startup-driving extension point. Synchronous listener failure vetoes publication, while returned-promise rejection is reported. Detach requested during dispatch waits until every creation listener has observed the stable entry.
734
+
735
+ ```ts cordis-catalog
736
+ /**
737
+ * A fully configured agent and live session were published. Setup is
738
+ * composition-only; `agent/session-start` is the first startup-driving extension point.
739
+ * Synchronous listener failure vetoes publication, while returned-promise
740
+ * rejection is reported. Detach requested during dispatch waits until every
741
+ * creation listener has observed the stable entry.
742
+ * @param payload.agent - the newly registered agent with its live session and completed setup.
743
+ * Scope-filtered dispatch (`@deepseek-ai/dsh-scope`): agent-scoped listeners receive only that agent.
744
+ * @mode emit
745
+ */
746
+ 'agent/created'(this: Scoped<Agent>, payload: { agent: Agent }): void
747
+ ```
748
+
749
+ Types: [Scoped](scope.md)
750
+
751
+ Source: [`packages/core/agent/src/runtime-types.ts:159`](../../packages/core/agent/src/runtime-types.ts)
752
+
753
+ <a id="agentdisposed--emit"></a>
754
+
755
+ #### `agent/disposed` — emit
756
+
757
+ An agent left the registry; AgentLoop emits this after driver quiescence and scoped-registration unwind, but before session detachment. Custom registry users own their driver-ordering contract.
758
+
759
+ ```ts cordis-catalog
760
+ /**
761
+ * An agent left the registry; AgentLoop emits this after driver quiescence
762
+ * and scoped-registration unwind, but before session detachment. Custom
763
+ * registry users own their driver-ordering contract.
764
+ * @param payload.agent - the exact agent removed from the registry.
765
+ * Scope-filtered dispatch (`@deepseek-ai/dsh-scope`): agent-scoped listeners receive only that agent.
766
+ * @mode emit
767
+ */
768
+ 'agent/disposed'(this: Scoped<Agent>, payload: { agent: Agent }): void
769
+ ```
770
+
771
+ Types: [Scoped](scope.md)
772
+
773
+ Source: [`packages/core/agent/src/runtime-types.ts:168`](../../packages/core/agent/src/runtime-types.ts)
774
+
775
+ <a id="agenterror--emit"></a>
776
+
777
+ #### `agent/error` — emit
778
+
779
+ A step or turn errored. The machine reports a failure here even when the error has no in-turn position for a durable record.
780
+
781
+ ```ts cordis-catalog
782
+ /**
783
+ * A step or turn errored. The machine reports a failure here even when
784
+ * the error has no in-turn position for a durable record.
785
+ * @param payload.agent - the agent whose turn errored.
786
+ * @param payload.turn - the turn in which the failure surfaced.
787
+ * @param payload.step - the step at which the failure surfaced.
788
+ * @param payload.error - the failure, verbatim.
789
+ * Scope-filtered dispatch (`@deepseek-ai/dsh-scope`): agent-scoped listeners receive only that agent.
790
+ * @mode emit
791
+ */
792
+ 'agent/error'(this: Scoped<Agent>, payload: { agent: Agent; turn: number; step: number; error: unknown }): void
793
+ ```
794
+
795
+ Types: [Scoped](scope.md)
796
+
797
+ Source: [`packages/core/agent/src/runtime-types.ts:290`](../../packages/core/agent/src/runtime-types.ts)
798
+
799
+ <a id="agentinboxclaimed--emit"></a>
800
+
801
+ #### `agent/inbox/claimed` — emit
802
+
803
+ One message left the inbox inside its open turn. If the proposed step is rejected, the claimed message ends here: it is neither discarded nor re-emitted as a user/message, and the turn closes without a step.
804
+
805
+ ```ts cordis-catalog
806
+ /**
807
+ * One message left the inbox inside its open turn. If the proposed step
808
+ * is rejected, the claimed message ends here: it is neither discarded nor
809
+ * re-emitted as a user/message, and the turn closes without a step.
810
+ * @param payload.agent - the agent whose inbox changed.
811
+ * @param payload.message - the claimed message.
812
+ * @param payload.turn - the owning turn.
813
+ * Scope-filtered dispatch (`@deepseek-ai/dsh-scope`): agent-scoped listeners receive only that agent.
814
+ * @mode emit
815
+ */
816
+ 'agent/inbox/claimed'(this: Scoped<Agent>, payload: { agent: Agent; message: UserMessage; turn: number }): void
817
+ ```
818
+
819
+ Types: [Scoped](scope.md) · [UserMessage](session.md)
820
+
821
+ Source: [`packages/core/agent/src/runtime-types.ts:197`](../../packages/core/agent/src/runtime-types.ts)
822
+
823
+ <a id="agentinboxdiscarded--emit"></a>
824
+
825
+ #### `agent/inbox/discarded` — emit
826
+
827
+ One message was discarded from the live inbox.
828
+
829
+ ```ts cordis-catalog
830
+ /**
831
+ * One message was discarded from the live inbox.
832
+ * @param payload.agent - the agent whose inbox changed.
833
+ * @param payload.message - the discarded message.
834
+ * Scope-filtered dispatch (`@deepseek-ai/dsh-scope`): agent-scoped listeners receive only that agent.
835
+ * @mode emit
836
+ */
837
+ 'agent/inbox/discarded'(this: Scoped<Agent>, payload: { agent: Agent; message: UserMessage }): void
838
+ ```
839
+
840
+ Types: [Scoped](scope.md) · [UserMessage](session.md)
841
+
842
+ Source: [`packages/core/agent/src/runtime-types.ts:205`](../../packages/core/agent/src/runtime-types.ts)
843
+
844
+ <a id="agentinboxinserted--emit"></a>
845
+
846
+ #### `agent/inbox/inserted` — emit
847
+
848
+ One message entered the live inbox.
849
+
850
+ ```ts cordis-catalog
851
+ /**
852
+ * One message entered the live inbox.
853
+ * @param payload.agent - the agent whose inbox changed.
854
+ * @param payload.message - the inserted message.
855
+ * Scope-filtered dispatch (`@deepseek-ai/dsh-scope`): agent-scoped listeners receive only that agent.
856
+ * @mode emit
857
+ */
858
+ 'agent/inbox/inserted'(this: Scoped<Agent>, payload: { agent: Agent; message: UserMessage }): void
859
+ ```
860
+
861
+ Types: [Scoped](scope.md) · [UserMessage](session.md)
862
+
863
+ Source: [`packages/core/agent/src/runtime-types.ts:186`](../../packages/core/agent/src/runtime-types.ts)
864
+
865
+ <a id="agentpre-step--waterfall"></a>
866
+
867
+ #### `agent/pre-step` — waterfall
868
+
869
+ Reject a proposed step or replace the messages that enter it. Calling `next()` preserves the current messages.
870
+
871
+ ```ts cordis-catalog
872
+ /**
873
+ * Reject a proposed step or replace the messages that enter it. Calling
874
+ * `next()` preserves the current messages.
875
+ * @param payload.agent - the agent proposing the step.
876
+ * @param payload.messages - messages removed from the inbox for this step.
877
+ * @param payload.turn - the turn that will own the step.
878
+ * @param payload.step - the step proposed by the loop.
879
+ * @param payload.signal - the current turn's cancellation signal.
880
+ * Scope-filtered dispatch (`@deepseek-ai/dsh-scope`): agent-scoped listeners receive only that agent.
881
+ * @mode waterfall
882
+ */
883
+ 'agent/pre-step'(this: Scoped<Agent>, payload: { agent: Agent; messages: UserMessage[]; turn: number; step: number; signal: AbortSignal }, next: () => Promise<PreStepDecision>): Promise<PreStepDecision>
884
+ ```
885
+
886
+ Types: [Scoped](scope.md) · [UserMessage](session.md)
887
+
888
+ Source: [`packages/core/agent/src/runtime-types.ts:231`](../../packages/core/agent/src/runtime-types.ts)
889
+
890
+ <a id="agentrequest--waterfall"></a>
891
+
892
+ #### `agent/request` — waterfall
893
+
894
+ Replace the frozen call configuration. `await next()` yields the config the machine would use (agent options on the first request, the logged header afterwards); return a replacement to switch. Model-visible content must use logged channels; this waterfall cannot mutate messages.
895
+
896
+ ```ts cordis-catalog
897
+ /**
898
+ * Replace the frozen call configuration. `await next()` yields the config
899
+ * the machine would use (agent options on the first request, the logged
900
+ * header afterwards); return a replacement to switch. Model-visible
901
+ * content must use logged channels; this waterfall cannot mutate messages.
902
+ * @param payload.agent - the agent making the model call.
903
+ * @param payload.turn - the open turn number.
904
+ * @param payload.step - the step whose request this is.
905
+ * @param payload.signal - the current turn's explicit abort signal.
906
+ * Scope-filtered dispatch (`@deepseek-ai/dsh-scope`): agent-scoped listeners receive only that agent.
907
+ * @mode waterfall
908
+ */
909
+ 'agent/request'(this: Scoped<Agent>, payload: { agent: Agent; turn: number; step: number; signal: AbortSignal }, next: () => Promise<LlmCallConfig>): Promise<LlmCallConfig>
910
+ ```
911
+
912
+ Types: [LlmCallConfig](llm-streaming.md) · [Scoped](scope.md)
913
+
914
+ Source: [`packages/core/agent/src/runtime-types.ts:244`](../../packages/core/agent/src/runtime-types.ts)
915
+
916
+ <a id="agentrequest-error--waterfall"></a>
917
+
918
+ #### `agent/request-error` — waterfall
919
+
920
+ Handle one failed model-request attempt before the loop retries or closes its step. A listener returns `{ kind: 'retry' }` without calling `next()` when it owns recovery, or calls `next()` to delegate. The default `undefined` leaves the failure terminal.
921
+
922
+ ```ts cordis-catalog
923
+ /**
924
+ * Handle one failed model-request attempt before the loop retries or closes
925
+ * its step. A listener returns `{ kind: 'retry' }` without calling `next()`
926
+ * when it owns recovery, or calls `next()` to delegate. The default
927
+ * `undefined` leaves the failure terminal.
928
+ * @param payload.agent - the agent whose request failed.
929
+ * @param payload.turn - the turn containing the failed request.
930
+ * @param payload.step - the step containing the failed request attempt.
931
+ * @param payload.provider - the provider selected for the failed request.
932
+ * @param payload.failure - serializable facts normalized at the final adapter boundary.
933
+ * @param payload.retryPolicy - the policy of the adapter registration that served the failed request.
934
+ * @param payload.signal - the turn abort signal.
935
+ * Scope-filtered dispatch (`@deepseek-ai/dsh-scope`): agent-scoped listeners receive only that agent.
936
+ * @mode waterfall
937
+ */
938
+ 'agent/request-error'(this: Scoped<Agent>, payload: { agent: Agent; turn: number; step: number; provider: string; failure: LlmFailure; retryPolicy: ResolvedRetryPolicy | undefined; signal: AbortSignal }, next: () => Promise<RequestErrorAction>): Promise<RequestErrorAction>
939
+ ```
940
+
941
+ Types: [LlmFailure](llm-streaming.md) · [ResolvedRetryPolicy](llm-streaming.md) · [Scoped](scope.md)
942
+
943
+ Source: [`packages/core/agent/src/runtime-types.ts:260`](../../packages/core/agent/src/runtime-types.ts)
944
+
945
+ <a id="agentsession-start--emit"></a>
946
+
947
+ #### `agent/session-start` — emit
948
+
949
+ The session lifecycle began, once before the first turn. Use `agent.inject()` to seed model-facing context. This is a notification, not a veto; disposal requested by a lifecycle owner is rechecked before the driver starts.
950
+
951
+ ```ts cordis-catalog
952
+ /**
953
+ * The session lifecycle began, once before the first turn. Use
954
+ * `agent.inject()` to seed model-facing context. This is a notification, not
955
+ * a veto; disposal requested by a lifecycle owner is rechecked before the
956
+ * driver starts.
957
+ * @param payload.agent - the agent whose session lifecycle began.
958
+ * @param payload.source - why the session started (fresh startup, resume, …).
959
+ * Scope-filtered dispatch (`@deepseek-ai/dsh-scope`): agent-scoped listeners receive only that agent.
960
+ * @mode emit
961
+ */
962
+ 'agent/session-start'(this: Scoped<Agent>, payload: { agent: Agent; source: SessionStartSource }): void
963
+ ```
964
+
965
+ Types: [Scoped](scope.md)
966
+
967
+ Source: [`packages/core/agent/src/runtime-types.ts:217`](../../packages/core/agent/src/runtime-types.ts)
968
+
969
+ <a id="agentstatus--emit"></a>
970
+
971
+ #### `agent/status` — emit
972
+
973
+ Agent status changed (`idle` ⇄ `running`). A waking delivery enters `running` synchronously after reserving cancellation; `idle` means no driver remains scheduled or active.
974
+
975
+ ```ts cordis-catalog
976
+ /**
977
+ * Agent status changed (`idle` ⇄ `running`). A waking delivery enters
978
+ * `running` synchronously after reserving cancellation; `idle` means no
979
+ * driver remains scheduled or active.
980
+ * @param payload.agent - the agent whose status flipped.
981
+ * @param payload.status - the status just entered (the transition's destination).
982
+ * Scope-filtered dispatch (`@deepseek-ai/dsh-scope`): agent-scoped listeners receive only that agent.
983
+ * @mode emit
984
+ */
985
+ 'agent/status'(this: Scoped<Agent>, payload: { agent: Agent; status: AgentStatus }): void
986
+ ```
987
+
988
+ Types: [Scoped](scope.md)
989
+
990
+ Source: [`packages/core/agent/src/runtime-types.ts:178`](../../packages/core/agent/src/runtime-types.ts)
991
+
992
+ <a id="agentturn-stopping--serial"></a>
993
+
994
+ #### `agent/turn-stopping` — serial
995
+
996
+ The turn is about to close: the model owes no response (no live tool calls, no fresh steering). Awaited before the boundary commits — a listener that objects steers (`agent.steer(...)`) and the machine re-reads its inbox: fresh steering runs another step, none closes the turn. Data decides, so listener order cannot change the outcome. The inverse control (stop a tool loop early) is data too: a tool result carrying `concludesTurn` ends the turn at its step. The conclusion never short-circuits already-submitted next-step work: same-step `additionalContexts` or racing steering still runs, and the turn closes only when that inbox drains.
997
+
998
+ ```ts cordis-catalog
999
+ /**
1000
+ * The turn is about to close: the model owes no response (no live tool
1001
+ * calls, no fresh steering). Awaited before the boundary commits — a
1002
+ * listener that objects steers (`agent.steer(...)`) and the machine
1003
+ * re-reads its inbox: fresh steering runs another step, none closes the
1004
+ * turn. Data decides, so listener order cannot change the outcome. The
1005
+ * inverse control (stop a tool loop early) is data too: a tool result
1006
+ * carrying `concludesTurn` ends the turn at its step. The conclusion
1007
+ * never short-circuits already-submitted next-step work: same-step
1008
+ * `additionalContexts` or racing steering still runs, and the turn
1009
+ * closes only when that inbox drains.
1010
+ * @param payload.agent - the agent whose turn is at its stop boundary.
1011
+ * @param payload.turn - the turn about to close.
1012
+ * @param payload.signal - the current turn's explicit abort signal.
1013
+ * Scope-filtered dispatch (`@deepseek-ai/dsh-scope`): agent-scoped listeners receive only that agent.
1014
+ * @mode serial
1015
+ */
1016
+ 'agent/turn-stopping'(this: Scoped<Agent>, payload: { agent: Agent; turn: number; signal: AbortSignal }): Promise<void> | void
1017
+ ```
1018
+
1019
+ Types: [Scoped](scope.md)
1020
+
1021
+ Source: [`packages/core/agent/src/runtime-types.ts:278`](../../packages/core/agent/src/runtime-types.ts)
1022
+
1023
+ <a id="agent-loop-events"></a>
1024
+
1025
+ ### `agent-loop/*` events
1026
+
1027
+ <a id="agent-loopconfig-start-failed--emit"></a>
1028
+
1029
+ #### `agent-loop/config-start-failed` — emit
1030
+
1031
+ A declarative agent entry failed before it could publish a live agent. Consumers that buffer work for the configured identity use this transient signal to reject that work instead of waiting forever. Normal factory teardown suppresses failures from the cancelled startup attempt.
1032
+
1033
+ ```ts cordis-catalog
1034
+ /**
1035
+ * A declarative agent entry failed before it could publish a live agent.
1036
+ * Consumers that buffer work for the configured identity use this
1037
+ * transient signal to reject that work instead of waiting forever. Normal
1038
+ * factory teardown suppresses failures from the cancelled startup attempt.
1039
+ * @param payload.sessionId - exact shared agent/session identity that failed startup.
1040
+ * @param payload.error - persistence, setup, or publication failure.
1041
+ * @mode emit
1042
+ */
1043
+ 'agent-loop/config-start-failed'(payload: { sessionId: SessionId; error: unknown }): void
1044
+ ```
1045
+
1046
+ Source: [`packages/core/agent-loop/src/index.ts:183`](../../packages/core/agent-loop/src/index.ts)
1047
+
1048
+ <a id="agent-preset-events"></a>
1049
+
1050
+ ### `agent-preset/*` events
1051
+
1052
+ <a id="agent-presetselected--emit"></a>
1053
+
1054
+ #### `agent-preset/selected` — emit
1055
+
1056
+ One session committed a different agent preset to its durable log. Consumers invalidate only state derived from that session's composition.
1057
+
1058
+ ```ts cordis-catalog
1059
+ /**
1060
+ * One session committed a different agent preset to its durable log.
1061
+ * Consumers invalidate only state derived from that session's composition.
1062
+ * @mode emit
1063
+ * @param sessionId - the session whose composition changed.
1064
+ * @param agentPreset - the preset recorded by the committed selection.
1065
+ */
1066
+ 'agent-preset/selected'(sessionId: SessionId, agentPreset: string): void
1067
+ ```
1068
+
1069
+ Source: [`packages/preset/agent-presets/src/types.ts:13`](../../packages/preset/agent-presets/src/types.ts)
1070
+ <!-- END GENERATED cordis-surface -->