dsh-plugin-dev-kb 1.5.2 → 1.8.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 (501) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/README.en.md +31 -9
  3. package/README.md +42 -14
  4. package/kb/INDEX.md +3 -3
  5. package/kb/README.md +9 -4
  6. package/kb/extra/AGENTS.md +1 -1
  7. package/kb/extra/cli-help.md +15 -7
  8. package/kb/extra/cli-help.zh.md +15 -7
  9. package/kb/extra/cookbook/adding-a-plugin-preview.md +18 -25
  10. package/kb/extra/cookbook/adding-a-plugin-preview.zh.md +18 -25
  11. package/kb/extra/cookbook/reviewing-persistence-type-changes.md +1 -1
  12. package/kb/extra/cookbook/reviewing-persistence-type-changes.zh.md +1 -1
  13. package/kb/extra/cookbook/reviewing-ui-design.md +166 -0
  14. package/kb/extra/cookbook/reviewing-ui-design.zh.md +166 -0
  15. package/kb/extra/deepseek-llm-api-wire-extensions.md +2 -2
  16. package/kb/extra/deepseek-llm-api-wire-extensions.zh.md +2 -2
  17. package/kb/extra/defensive-patterns/conversation-and-session.md +2 -2
  18. package/kb/extra/defensive-patterns/conversation-and-session.zh.md +2 -2
  19. package/kb/extra/defensive-patterns/general.md +2 -0
  20. package/kb/extra/defensive-patterns/general.zh.md +2 -0
  21. package/kb/extra/defensive-patterns/package-surface.md +1 -0
  22. package/kb/extra/defensive-patterns/package-surface.zh.md +1 -0
  23. package/kb/extra/defensive-patterns/remote-and-api.md +5 -3
  24. package/kb/extra/defensive-patterns/remote-and-api.zh.md +5 -3
  25. package/kb/extra/development.md +16 -9
  26. package/kb/extra/development.zh.md +16 -9
  27. package/kb/extra/event-producer-consumer.md +64 -51
  28. package/kb/extra/event-producer-consumer.zh.md +64 -51
  29. package/kb/extra/i18n/README.md +2 -0
  30. package/kb/extra/i18n/README.zh.md +2 -0
  31. package/kb/extra/module-graph.md +204 -92
  32. package/kb/extra/module-graph.zh.md +204 -92
  33. package/kb/extra/persistence-changes/2026-10-13-liveshare-share-viewer-principal.md +60 -0
  34. package/kb/extra/persistence-changes/2026-10-13-liveshare-share-viewer-principal.zh.md +60 -0
  35. package/kb/extra/persistence-changes/2026-10-19-session-team-mode.md +48 -0
  36. package/kb/extra/persistence-changes/2026-10-19-session-team-mode.zh.md +48 -0
  37. package/kb/extra/persistence-changes/2026-10-22-action-card-status.md +60 -0
  38. package/kb/extra/persistence-changes/2026-10-22-action-card-status.zh.md +60 -0
  39. package/kb/extra/persistence-changes/2026-10-25-skill-catalog-incomplete.md +60 -0
  40. package/kb/extra/persistence-changes/2026-10-25-skill-catalog-incomplete.zh.md +60 -0
  41. package/kb/extra/persistence-changes/2026-10-27-retry-control-input.md +60 -0
  42. package/kb/extra/persistence-changes/2026-10-27-retry-control-input.zh.md +60 -0
  43. package/kb/extra/persistence-changes/2026-10-27-subagent-settlement-attribution.md +60 -0
  44. package/kb/extra/persistence-changes/2026-10-27-subagent-settlement-attribution.zh.md +60 -0
  45. package/kb/extra/persistence-changes/2026-11-02-subagent-catalog-names.md +48 -0
  46. package/kb/extra/persistence-changes/2026-11-02-subagent-catalog-names.zh.md +48 -0
  47. package/kb/extra/persistence-changes/2026-11-02-team-task-owner-names.md +48 -0
  48. package/kb/extra/persistence-changes/2026-11-02-team-task-owner-names.zh.md +48 -0
  49. package/kb/extra/persistence-changes/README.md +2 -0
  50. package/kb/extra/persistence-changes/README.zh.md +2 -0
  51. package/kb/extra/persistence-changes/historical-formats/README.md +1 -1
  52. package/kb/extra/persistence-changes/historical-formats/README.zh.md +1 -1
  53. package/kb/extra/rescope.md +7 -5
  54. package/kb/extra/rescope.zh.md +7 -5
  55. package/kb/extra/subsystems/agent-team.md +38 -75
  56. package/kb/extra/subsystems/agent-team.zh.md +38 -75
  57. package/kb/extra/subsystems/attachment.md +36 -13
  58. package/kb/extra/subsystems/attachment.zh.md +36 -13
  59. package/kb/extra/subsystems/boot.md +179 -5
  60. package/kb/extra/subsystems/boot.zh.md +179 -5
  61. package/kb/extra/subsystems/computer-use.md +78 -0
  62. package/kb/extra/subsystems/computer-use.zh.md +78 -0
  63. package/kb/extra/subsystems/deliverables.md +2 -0
  64. package/kb/extra/subsystems/deliverables.zh.md +2 -0
  65. package/kb/extra/subsystems/forge.md +1226 -0
  66. package/kb/extra/subsystems/forge.zh.md +1226 -0
  67. package/kb/extra/subsystems/liveshare.md +158 -0
  68. package/kb/extra/subsystems/liveshare.zh.md +158 -0
  69. package/kb/extra/subsystems/mcp.md +96 -1
  70. package/kb/extra/subsystems/mcp.zh.md +96 -1
  71. package/kb/extra/subsystems/worktrees.md +54 -3
  72. package/kb/extra/subsystems/worktrees.zh.md +54 -3
  73. package/kb/extra/testing.md +1 -1
  74. package/kb/extra/testing.zh.md +1 -1
  75. package/kb/extra/ui-design-review-cases.md +445 -0
  76. package/kb/extra/ui-design-review-cases.zh.md +445 -0
  77. package/kb/extra/ui-radius.md +3 -1
  78. package/kb/extra/ui-radius.zh.md +3 -1
  79. package/kb/extra/upgrade-guide/v0.2.1-alpha.1/team-direct-inbox/guide.md +1 -1
  80. package/kb/extra/upgrade-guide/v0.2.1-alpha.1/team-direct-inbox/guide.zh.md +1 -1
  81. package/kb/extra/upgrade-guide/v0.2.1-alpha.2/cordis-timer-wrappers/guide.md +24 -0
  82. package/kb/extra/upgrade-guide/v0.2.1-alpha.2/cordis-timer-wrappers/guide.zh.md +24 -0
  83. package/kb/extra/upgrade-guide/v0.2.1-alpha.2/plugin-manager-view-fields/guide.md +25 -0
  84. package/kb/extra/upgrade-guide/v0.2.1-alpha.2/plugin-manager-view-fields/guide.zh.md +25 -0
  85. package/kb/extra/upgrade-guide/v0.2.1-alpha.4/model-switch-compaction/guide.md +30 -0
  86. package/kb/extra/upgrade-guide/v0.2.1-alpha.4/model-switch-compaction/guide.zh.md +30 -0
  87. package/kb/extra/upgrade-guide/v0.2.1-alpha.4/session-model-selection/guide.md +28 -0
  88. package/kb/extra/upgrade-guide/v0.2.1-alpha.4/session-model-selection/guide.zh.md +28 -0
  89. package/kb/extra/upgrade-guide/v0.2.1-rc.1/agent-instructions-chain-budgets/guide.md +24 -0
  90. package/kb/extra/upgrade-guide/v0.2.1-rc.1/agent-instructions-chain-budgets/guide.zh.md +24 -0
  91. package/kb/extra/upgrade-guide/v0.2.1-rc.1/subagent-control-tools/guide.md +23 -0
  92. package/kb/extra/upgrade-guide/v0.2.1-rc.1/subagent-control-tools/guide.zh.md +23 -0
  93. package/kb/extra/upgrade-guide/v0.2.1-rc.2/agent-runtime-owner/guide.md +20 -0
  94. package/kb/extra/upgrade-guide/v0.2.1-rc.2/agent-runtime-owner/guide.zh.md +20 -0
  95. package/kb/extra/upgrade-guide/v0.2.1-rc.2/agent-team-subagents/guide.md +31 -0
  96. package/kb/extra/upgrade-guide/v0.2.1-rc.2/agent-team-subagents/guide.zh.md +31 -0
  97. package/kb/extra/upgrade-guide/v0.2.1-rc.2/approval-projection-dependency/guide.md +34 -0
  98. package/kb/extra/upgrade-guide/v0.2.1-rc.2/approval-projection-dependency/guide.zh.md +34 -0
  99. package/kb/extra/upgrade-guide/v0.2.1-rc.2/auto-review-shutdown/guide.md +20 -0
  100. package/kb/extra/upgrade-guide/v0.2.1-rc.2/auto-review-shutdown/guide.zh.md +20 -0
  101. package/kb/extra/upgrade-guide/v0.2.1-rc.2/auto-review-user-sources/guide.md +18 -0
  102. package/kb/extra/upgrade-guide/v0.2.1-rc.2/auto-review-user-sources/guide.zh.md +18 -0
  103. package/kb/extra/upgrade-guide/v0.2.1-rc.2/built-in-japanese/guide.md +18 -0
  104. package/kb/extra/upgrade-guide/v0.2.1-rc.2/built-in-japanese/guide.zh.md +18 -0
  105. package/kb/extra/upgrade-guide/v0.2.1-rc.2/conditional-tools/guide.md +25 -0
  106. package/kb/extra/upgrade-guide/v0.2.1-rc.2/conditional-tools/guide.zh.md +25 -0
  107. package/kb/extra/upgrade-guide/v0.2.1-rc.2/context-menu-services/guide.md +23 -0
  108. package/kb/extra/upgrade-guide/v0.2.1-rc.2/context-menu-services/guide.zh.md +23 -0
  109. package/kb/extra/upgrade-guide/v0.2.1-rc.2/cua-consent-storage/guide.md +22 -0
  110. package/kb/extra/upgrade-guide/v0.2.1-rc.2/cua-consent-storage/guide.zh.md +22 -0
  111. package/kb/extra/upgrade-guide/v0.2.1-rc.2/cua-preset-scope/guide.md +18 -0
  112. package/kb/extra/upgrade-guide/v0.2.1-rc.2/cua-preset-scope/guide.zh.md +18 -0
  113. package/kb/extra/upgrade-guide/v0.2.1-rc.2/cua-relative-coordinates/guide.md +17 -0
  114. package/kb/extra/upgrade-guide/v0.2.1-rc.2/cua-relative-coordinates/guide.zh.md +17 -0
  115. package/kb/extra/upgrade-guide/v0.2.1-rc.2/file-drag-callbacks/guide.md +19 -0
  116. package/kb/extra/upgrade-guide/v0.2.1-rc.2/file-drag-callbacks/guide.zh.md +19 -0
  117. package/kb/extra/upgrade-guide/v0.2.1-rc.2/headless-policy-composition/guide.md +27 -0
  118. package/kb/extra/upgrade-guide/v0.2.1-rc.2/headless-policy-composition/guide.zh.md +27 -0
  119. package/kb/extra/upgrade-guide/v0.2.1-rc.2/model-badge-package-removal/guide.md +18 -0
  120. package/kb/extra/upgrade-guide/v0.2.1-rc.2/model-badge-package-removal/guide.zh.md +18 -0
  121. package/kb/extra/upgrade-guide/v0.2.1-rc.2/new-session-blank-reuse/guide.md +22 -0
  122. package/kb/extra/upgrade-guide/v0.2.1-rc.2/new-session-blank-reuse/guide.zh.md +22 -0
  123. package/kb/extra/upgrade-guide/v0.2.1-rc.2/node-24/guide.md +17 -0
  124. package/kb/extra/upgrade-guide/v0.2.1-rc.2/node-24/guide.zh.md +17 -0
  125. package/kb/extra/upgrade-guide/v0.2.1-rc.2/official-bundle-lists/guide.md +18 -0
  126. package/kb/extra/upgrade-guide/v0.2.1-rc.2/official-bundle-lists/guide.zh.md +18 -0
  127. package/kb/extra/upgrade-guide/v0.2.1-rc.2/persistent-terminal-controls/guide.md +18 -0
  128. package/kb/extra/upgrade-guide/v0.2.1-rc.2/persistent-terminal-controls/guide.zh.md +18 -0
  129. package/kb/extra/upgrade-guide/v0.2.1-rc.2/pi-ai-default-capacities/guide.md +18 -0
  130. package/kb/extra/upgrade-guide/v0.2.1-rc.2/pi-ai-default-capacities/guide.zh.md +18 -0
  131. package/kb/extra/upgrade-guide/v0.2.1-rc.2/pi-ai-model-catalog/guide.md +53 -0
  132. package/kb/extra/upgrade-guide/v0.2.1-rc.2/pi-ai-model-catalog/guide.zh.md +53 -0
  133. package/kb/extra/upgrade-guide/v0.2.1-rc.2/pi-ai-protocol-replay/guide.md +30 -0
  134. package/kb/extra/upgrade-guide/v0.2.1-rc.2/pi-ai-protocol-replay/guide.zh.md +30 -0
  135. package/kb/extra/upgrade-guide/v0.2.1-rc.2/ptc-script-format/guide.md +20 -0
  136. package/kb/extra/upgrade-guide/v0.2.1-rc.2/ptc-script-format/guide.zh.md +20 -0
  137. package/kb/extra/upgrade-guide/v0.2.1-rc.2/sdk-desktop-context/guide.md +18 -0
  138. package/kb/extra/upgrade-guide/v0.2.1-rc.2/sdk-desktop-context/guide.zh.md +18 -0
  139. package/kb/extra/upgrade-guide/v0.2.1-rc.2/sdk-minimal-checkpoints/guide.md +18 -0
  140. package/kb/extra/upgrade-guide/v0.2.1-rc.2/sdk-minimal-checkpoints/guide.zh.md +18 -0
  141. package/kb/extra/upgrade-guide/v0.2.1-rc.2/session-projection-handles/guide.md +24 -0
  142. package/kb/extra/upgrade-guide/v0.2.1-rc.2/session-projection-handles/guide.zh.md +24 -0
  143. package/kb/extra/upgrade-guide/v0.2.1-rc.2/session-store-writes/guide.md +25 -0
  144. package/kb/extra/upgrade-guide/v0.2.1-rc.2/session-store-writes/guide.zh.md +25 -0
  145. package/kb/extra/upgrade-guide/v0.2.1-rc.2/session-team-mode/guide.md +22 -0
  146. package/kb/extra/upgrade-guide/v0.2.1-rc.2/session-team-mode/guide.zh.md +22 -0
  147. package/kb/extra/upgrade-guide/v0.2.1-rc.2/subagent-activation-options/guide.md +18 -0
  148. package/kb/extra/upgrade-guide/v0.2.1-rc.2/subagent-activation-options/guide.zh.md +18 -0
  149. package/kb/extra/upgrade-guide/v0.2.1-rc.2/subagent-service-methods/guide.md +19 -0
  150. package/kb/extra/upgrade-guide/v0.2.1-rc.2/subagent-service-methods/guide.zh.md +19 -0
  151. package/kb/extra/upgrade-guide/v0.2.1-rc.2/subagent-user-controls/guide.md +26 -0
  152. package/kb/extra/upgrade-guide/v0.2.1-rc.2/subagent-user-controls/guide.zh.md +26 -0
  153. package/kb/extra/upgrade-guide/v0.2.1-rc.2/tool-executor-plugins/guide.md +35 -0
  154. package/kb/extra/upgrade-guide/v0.2.1-rc.2/tool-executor-plugins/guide.zh.md +35 -0
  155. package/kb/extra/upgrade-guide/v0.2.1-rc.2/web-fetch-private-destinations/guide.md +21 -0
  156. package/kb/extra/upgrade-guide/v0.2.1-rc.2/web-fetch-private-destinations/guide.zh.md +21 -0
  157. package/kb/extra/upgrade-guide/v0.2.1-rc.2/webserver-index-peer/guide.md +17 -0
  158. package/kb/extra/upgrade-guide/v0.2.1-rc.2/webserver-index-peer/guide.zh.md +17 -0
  159. package/kb/extra/upgrade-guide/v0.2.1-rc.3/attachment-read-access/guide.md +23 -0
  160. package/kb/extra/upgrade-guide/v0.2.1-rc.3/attachment-read-access/guide.zh.md +23 -0
  161. package/kb/extra/upgrade-guide/v0.2.1-rc.3/computer-use-helper-permissions/guide.md +21 -0
  162. package/kb/extra/upgrade-guide/v0.2.1-rc.3/computer-use-helper-permissions/guide.zh.md +21 -0
  163. package/kb/extra/upgrade-guide/v0.2.1-rc.3/cua-bundle-id-consent/guide.md +20 -0
  164. package/kb/extra/upgrade-guide/v0.2.1-rc.3/cua-bundle-id-consent/guide.zh.md +20 -0
  165. package/kb/extra/upgrade-guide/v0.2.1-rc.3/generated-worktree-names/guide.md +20 -0
  166. package/kb/extra/upgrade-guide/v0.2.1-rc.3/generated-worktree-names/guide.zh.md +20 -0
  167. package/kb/extra/upgrade-guide/v0.2.1-rc.3/inbox-only-agent-wait/guide.md +19 -0
  168. package/kb/extra/upgrade-guide/v0.2.1-rc.3/inbox-only-agent-wait/guide.zh.md +19 -0
  169. package/kb/extra/upgrade-guide/v0.2.1-rc.3/independent-session-forks/guide.md +23 -0
  170. package/kb/extra/upgrade-guide/v0.2.1-rc.3/independent-session-forks/guide.zh.md +23 -0
  171. package/kb/extra/upgrade-guide/v0.2.1-rc.3/ptc-caller-cancellation/guide.md +20 -0
  172. package/kb/extra/upgrade-guide/v0.2.1-rc.3/ptc-caller-cancellation/guide.zh.md +20 -0
  173. package/kb/extra/upgrade-guide/v0.2.1-rc.3/session-follow-activation/guide.md +21 -0
  174. package/kb/extra/upgrade-guide/v0.2.1-rc.3/session-follow-activation/guide.zh.md +21 -0
  175. package/kb/extra/upgrade-guide/v0.2.1-rc.3/subagent-runtime-ownership/guide.md +21 -0
  176. package/kb/extra/upgrade-guide/v0.2.1-rc.3/subagent-runtime-ownership/guide.zh.md +21 -0
  177. package/kb/extra/upgrade-guide/v0.2.1-rc.3/team-mode-menu/guide.md +18 -0
  178. package/kb/extra/upgrade-guide/v0.2.1-rc.3/team-mode-menu/guide.zh.md +18 -0
  179. package/kb/extra/upgrade-guide/v0.2.1-rc.3/team-projection/guide.md +20 -0
  180. package/kb/extra/upgrade-guide/v0.2.1-rc.3/team-projection/guide.zh.md +20 -0
  181. package/kb/extra/upgrade-guide/v0.2.1-rc.3/web-file-downloads/guide.md +19 -0
  182. package/kb/extra/upgrade-guide/v0.2.1-rc.3/web-file-downloads/guide.zh.md +19 -0
  183. package/kb/extra/upgrade-guide/v0.2.1-rc.3/web-search-defaults/guide.md +18 -0
  184. package/kb/extra/upgrade-guide/v0.2.1-rc.3/web-search-defaults/guide.zh.md +18 -0
  185. package/kb/extra/upgrade-guide/v0.2.1-rc.4/model-listing-refresh/guide.md +22 -0
  186. package/kb/extra/upgrade-guide/v0.2.1-rc.4/model-listing-refresh/guide.zh.md +22 -0
  187. package/kb/extra/upgrade-guide/v0.2.1-rc.4/reasoning-body-props/guide.md +20 -0
  188. package/kb/extra/upgrade-guide/v0.2.1-rc.4/reasoning-body-props/guide.zh.md +20 -0
  189. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/context-menu-target/guide.md +19 -0
  190. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/context-menu-target/guide.zh.md +19 -0
  191. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/cordis-loader-entry-trees/guide.md +24 -0
  192. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/cordis-loader-entry-trees/guide.zh.md +24 -0
  193. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/css-anchored-menus/guide.md +21 -0
  194. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/css-anchored-menus/guide.zh.md +21 -0
  195. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/cua-source-dev-helper/guide.md +19 -0
  196. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/cua-source-dev-helper/guide.zh.md +19 -0
  197. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/desktop-stable-channel/guide.md +18 -0
  198. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/desktop-stable-channel/guide.zh.md +18 -0
  199. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/forge-git-permissions/guide.md +21 -0
  200. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/forge-git-permissions/guide.zh.md +21 -0
  201. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/forge-worktree-entry/guide.md +29 -0
  202. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/forge-worktree-entry/guide.zh.md +29 -0
  203. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/fs-observation-policy-default-off/guide.md +29 -0
  204. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/fs-observation-policy-default-off/guide.zh.md +29 -0
  205. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/llm-request-purpose-declarations/guide.md +29 -0
  206. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/llm-request-purpose-declarations/guide.zh.md +29 -0
  207. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/pi-ai-request-image-count/guide.md +18 -0
  208. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/pi-ai-request-image-count/guide.zh.md +18 -0
  209. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/projection-event-frames/guide.md +32 -0
  210. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/projection-event-frames/guide.zh.md +32 -0
  211. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/projection-released-checkpoint/guide.md +30 -0
  212. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/projection-released-checkpoint/guide.zh.md +30 -0
  213. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/projection-snapshot-scope/guide.md +19 -0
  214. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/projection-snapshot-scope/guide.zh.md +19 -0
  215. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/retained-ptc-timeout/guide.md +21 -0
  216. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/retained-ptc-timeout/guide.zh.md +21 -0
  217. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/schedule-agent-tools/guide.md +37 -0
  218. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/schedule-agent-tools/guide.zh.md +37 -0
  219. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/schedule-remote-host-tasks/guide.md +22 -0
  220. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/schedule-remote-host-tasks/guide.zh.md +22 -0
  221. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/sdk-run-commands/guide.md +24 -0
  222. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/sdk-run-commands/guide.zh.md +24 -0
  223. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/session-header-menu/guide.md +20 -0
  224. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/session-header-menu/guide.zh.md +20 -0
  225. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/subagent-explicit-reasoning/guide.md +20 -0
  226. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/subagent-explicit-reasoning/guide.zh.md +20 -0
  227. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/web-search-credential-modes/guide.md +17 -0
  228. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/web-search-credential-modes/guide.zh.md +17 -0
  229. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/web-search-default-provider/guide.md +19 -0
  230. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/web-search-default-provider/guide.zh.md +19 -0
  231. package/kb/extra/upgrade-guide/v0.2.2-alpha.3/chat-process-activity-context/guide.md +18 -0
  232. package/kb/extra/upgrade-guide/v0.2.2-alpha.3/chat-process-activity-context/guide.zh.md +18 -0
  233. package/kb/extra/upgrade-guide/v0.2.2-alpha.3/subagent-names/guide.md +29 -0
  234. package/kb/extra/upgrade-guide/v0.2.2-alpha.3/subagent-names/guide.zh.md +29 -0
  235. package/kb/extra/web-styling.md +19 -1
  236. package/kb/extra/web-styling.zh.md +19 -1
  237. package/kb/meta/search-index.json +1272 -1098
  238. package/kb/meta/source.json +8 -4
  239. package/kb/site/develop/cordis-tutorial/04-events.md +1 -1
  240. package/kb/site/develop/cordis-tutorial/07-into-the-harness.md +5 -4
  241. package/kb/site/develop/framework/events.md +1 -1
  242. package/kb/site/develop/practice/dynamic-cordis.md +1 -1
  243. package/kb/site/en/develop/cordis-tutorial/04-events.md +1 -1
  244. package/kb/site/en/develop/cordis-tutorial/07-into-the-harness.md +5 -4
  245. package/kb/site/en/develop/framework/events.md +1 -1
  246. package/kb/site/en/develop/practice/dynamic-cordis.md +1 -1
  247. package/kb/site/en/guide/network-proxy.md +1 -1
  248. package/kb/site/en/guide/plugin-market.md +10 -10
  249. package/kb/site/en/guide/providers.md +5 -1
  250. package/kb/site/en/guide/python-sdk.md +17 -2
  251. package/kb/site/en/guide/schedule.md +45 -26
  252. package/kb/site/en/reference/agent-lifecycle.md +3 -1
  253. package/kb/site/en/reference/api-gateway.md +4 -4
  254. package/kb/site/en/reference/capability-seams.md +65 -17
  255. package/kb/site/en/reference/config-catalog.md +560 -238
  256. package/kb/site/en/reference/cookbook/adding-a-package.md +4 -2
  257. package/kb/site/en/reference/cookbook/extension-cookbook.md +1 -1
  258. package/kb/site/en/reference/cordis-api/context.md +1 -1
  259. package/kb/site/en/reference/cordis-api/events.md +9 -9
  260. package/kb/site/en/reference/cordis-api/fiber.md +85 -32
  261. package/kb/site/en/reference/cordis-api/inherited.md +10 -9
  262. package/kb/site/en/reference/experimental-persistence-catalog.md +3 -0
  263. package/kb/site/en/reference/index.md +14 -8
  264. package/kb/site/en/reference/persistence-catalog.md +532 -246
  265. package/kb/site/en/reference/subsystems/client-modules.md +19 -11
  266. package/kb/site/en/reference/subsystems/compaction.md +1 -1
  267. package/kb/site/en/reference/subsystems/conversation.md +2 -0
  268. package/kb/site/en/reference/subsystems/core.md +119 -65
  269. package/kb/site/en/reference/subsystems/filesystem.md +202 -28
  270. package/kb/site/en/reference/subsystems/index.md +3 -1
  271. package/kb/site/en/reference/subsystems/llm-streaming.md +92 -4
  272. package/kb/site/en/reference/subsystems/persistence.md +17 -7
  273. package/kb/site/en/reference/subsystems/plan.md +4 -4
  274. package/kb/site/en/reference/subsystems/ptc-runtime.md +12 -5
  275. package/kb/site/en/reference/subsystems/sandbox.md +11 -4
  276. package/kb/site/en/reference/subsystems/schedule.md +194 -430
  277. package/kb/site/en/reference/subsystems/session-projection.md +186 -44
  278. package/kb/site/en/reference/subsystems/session-reference.md +4 -3
  279. package/kb/site/en/reference/subsystems/session.md +119 -31
  280. package/kb/site/en/reference/subsystems/sidebar-right.md +12 -11
  281. package/kb/site/en/reference/subsystems/skills.md +4 -4
  282. package/kb/site/en/reference/subsystems/slots.md +30 -3
  283. package/kb/site/en/reference/subsystems/storage.md +26 -9
  284. package/kb/site/en/reference/subsystems/subagent.md +119 -102
  285. package/kb/site/en/reference/subsystems/system-prompt.md +13 -11
  286. package/kb/site/en/reference/subsystems/token-meter.md +45 -0
  287. package/kb/site/en/reference/subsystems/tools.md +222 -82
  288. package/kb/site/en/reference/subsystems/typert.md +21 -11
  289. package/kb/site/en/reference/subsystems/user-questions.md +22 -6
  290. package/kb/site/en/reference/subsystems/web-client.md +1 -1
  291. package/kb/site/en/reference/subsystems/web-server.md +68 -23
  292. package/kb/site/en/reference/subsystems/web.md +79 -21
  293. package/kb/site/en/reference/tool-catalog.md +270 -395
  294. package/kb/site/en/reference/tool-execution-pipeline.md +5 -4
  295. package/kb/site/guide/network-proxy.md +1 -1
  296. package/kb/site/guide/plugin-market.md +10 -10
  297. package/kb/site/guide/providers.md +5 -1
  298. package/kb/site/guide/python-sdk.md +17 -2
  299. package/kb/site/guide/schedule.md +45 -26
  300. package/kb/site/reference/agent-lifecycle.md +3 -1
  301. package/kb/site/reference/api-gateway.md +4 -4
  302. package/kb/site/reference/capability-seams.md +65 -17
  303. package/kb/site/reference/config-catalog.md +560 -238
  304. package/kb/site/reference/cookbook/adding-a-package.md +4 -2
  305. package/kb/site/reference/cookbook/extension-cookbook.md +1 -1
  306. package/kb/site/reference/cordis-api/context.md +1 -1
  307. package/kb/site/reference/cordis-api/events.md +9 -9
  308. package/kb/site/reference/cordis-api/fiber.md +87 -32
  309. package/kb/site/reference/cordis-api/inherited.md +10 -9
  310. package/kb/site/reference/experimental-persistence-catalog.md +3 -0
  311. package/kb/site/reference/index.md +14 -8
  312. package/kb/site/reference/persistence-catalog.md +532 -246
  313. package/kb/site/reference/subsystems/client-modules.md +19 -11
  314. package/kb/site/reference/subsystems/compaction.md +1 -1
  315. package/kb/site/reference/subsystems/conversation.md +4 -0
  316. package/kb/site/reference/subsystems/core.md +119 -65
  317. package/kb/site/reference/subsystems/filesystem.md +202 -28
  318. package/kb/site/reference/subsystems/index.md +3 -1
  319. package/kb/site/reference/subsystems/llm-streaming.md +92 -4
  320. package/kb/site/reference/subsystems/persistence.md +17 -7
  321. package/kb/site/reference/subsystems/plan.md +4 -4
  322. package/kb/site/reference/subsystems/ptc-runtime.md +12 -5
  323. package/kb/site/reference/subsystems/sandbox.md +11 -4
  324. package/kb/site/reference/subsystems/schedule.md +197 -433
  325. package/kb/site/reference/subsystems/session-projection.md +186 -44
  326. package/kb/site/reference/subsystems/session-reference.md +4 -3
  327. package/kb/site/reference/subsystems/session.md +119 -31
  328. package/kb/site/reference/subsystems/sidebar-right.md +12 -11
  329. package/kb/site/reference/subsystems/skills.md +4 -4
  330. package/kb/site/reference/subsystems/slots.md +30 -3
  331. package/kb/site/reference/subsystems/storage.md +26 -9
  332. package/kb/site/reference/subsystems/subagent.md +119 -102
  333. package/kb/site/reference/subsystems/system-prompt.md +13 -11
  334. package/kb/site/reference/subsystems/token-meter.md +45 -0
  335. package/kb/site/reference/subsystems/tools.md +222 -82
  336. package/kb/site/reference/subsystems/typert.md +21 -11
  337. package/kb/site/reference/subsystems/user-questions.md +22 -6
  338. package/kb/site/reference/subsystems/web-client.md +1 -1
  339. package/kb/site/reference/subsystems/web-server.md +68 -23
  340. package/kb/site/reference/subsystems/web.md +79 -21
  341. package/kb/site/reference/tool-catalog.md +273 -399
  342. package/kb/site/reference/tool-execution-pipeline.md +4 -3
  343. package/lib/index.js +268 -11
  344. package/lib/kb-search.js +261 -0
  345. package/lib/kb-version.js +118 -0
  346. package/package.json +5 -3
  347. package/scripts/refresh-kb.mjs +153 -0
  348. package/scripts/selfcheck.mjs +28 -0
  349. package/scripts/smoke.mjs +77 -0
  350. package/skills/dsh-plugin-dev-kb.md +8 -7
  351. package/skills/dsh-plugin-starter.md +65 -0
  352. package/skills/dsh-upgrade-assistant.md +62 -0
  353. package/kb/extra/agent-lifecycle.md +0 -91
  354. package/kb/extra/agent-lifecycle.zh.md +0 -93
  355. package/kb/extra/api-gateway.md +0 -172
  356. package/kb/extra/api-gateway.zh.md +0 -178
  357. package/kb/extra/architecture.md +0 -165
  358. package/kb/extra/architecture.zh.md +0 -169
  359. package/kb/extra/capability-seams.md +0 -714
  360. package/kb/extra/capability-seams.zh.md +0 -716
  361. package/kb/extra/config-catalog.md +0 -4801
  362. package/kb/extra/config-catalog.zh.md +0 -4803
  363. package/kb/extra/cookbook/adding-a-package.md +0 -170
  364. package/kb/extra/cookbook/adding-a-package.zh.md +0 -170
  365. package/kb/extra/cookbook/adding-a-settings-card.md +0 -72
  366. package/kb/extra/cookbook/adding-a-settings-card.zh.md +0 -72
  367. package/kb/extra/cookbook/adding-a-tool.md +0 -101
  368. package/kb/extra/cookbook/adding-a-tool.zh.md +0 -103
  369. package/kb/extra/cookbook/adding-an-llm-adapter.md +0 -43
  370. package/kb/extra/cookbook/adding-an-llm-adapter.zh.md +0 -43
  371. package/kb/extra/cookbook/extension-cookbook.md +0 -132
  372. package/kb/extra/cookbook/extension-cookbook.zh.md +0 -136
  373. package/kb/extra/cordis-api/context.md +0 -364
  374. package/kb/extra/cordis-api/context.zh.md +0 -366
  375. package/kb/extra/cordis-api/events.md +0 -207
  376. package/kb/extra/cordis-api/events.zh.md +0 -209
  377. package/kb/extra/cordis-api/fiber.md +0 -375
  378. package/kb/extra/cordis-api/fiber.zh.md +0 -377
  379. package/kb/extra/cordis-api/inherited.md +0 -38
  380. package/kb/extra/cordis-api/registry.md +0 -152
  381. package/kb/extra/cordis-api/registry.zh.md +0 -154
  382. package/kb/extra/cordis-api/service.md +0 -102
  383. package/kb/extra/cordis-api/service.zh.md +0 -104
  384. package/kb/extra/cordis-tutorial/01-first-plugin.md +0 -95
  385. package/kb/extra/cordis-tutorial/01-first-plugin.zh.md +0 -95
  386. package/kb/extra/cordis-tutorial/02-lifecycle-and-effects.md +0 -98
  387. package/kb/extra/cordis-tutorial/02-lifecycle-and-effects.zh.md +0 -98
  388. package/kb/extra/cordis-tutorial/03-services.md +0 -98
  389. package/kb/extra/cordis-tutorial/03-services.zh.md +0 -98
  390. package/kb/extra/cordis-tutorial/04-events.md +0 -144
  391. package/kb/extra/cordis-tutorial/04-events.zh.md +0 -144
  392. package/kb/extra/cordis-tutorial/05-config.md +0 -111
  393. package/kb/extra/cordis-tutorial/05-config.zh.md +0 -111
  394. package/kb/extra/cordis-tutorial/06-composition-and-hmr.md +0 -113
  395. package/kb/extra/cordis-tutorial/06-composition-and-hmr.zh.md +0 -113
  396. package/kb/extra/cordis-tutorial/07-into-the-harness.md +0 -108
  397. package/kb/extra/cordis-tutorial/07-into-the-harness.zh.md +0 -108
  398. package/kb/extra/cordis-tutorial/index.md +0 -60
  399. package/kb/extra/cordis-tutorial/index.zh.md +0 -62
  400. package/kb/extra/experimental-persistence-catalog.md +0 -17
  401. package/kb/extra/experimental-persistence-catalog.zh.md +0 -17
  402. package/kb/extra/persistence-catalog.md +0 -9140
  403. package/kb/extra/persistence-catalog.zh.md +0 -9142
  404. package/kb/extra/subsystems/README.md +0 -76
  405. package/kb/extra/subsystems/README.zh.md +0 -76
  406. package/kb/extra/subsystems/approval.md +0 -170
  407. package/kb/extra/subsystems/approval.zh.md +0 -170
  408. package/kb/extra/subsystems/client-modules.md +0 -198
  409. package/kb/extra/subsystems/client-modules.zh.md +0 -198
  410. package/kb/extra/subsystems/client-resources.md +0 -92
  411. package/kb/extra/subsystems/client-resources.zh.md +0 -92
  412. package/kb/extra/subsystems/commands.md +0 -223
  413. package/kb/extra/subsystems/commands.zh.md +0 -223
  414. package/kb/extra/subsystems/compaction.md +0 -284
  415. package/kb/extra/subsystems/compaction.zh.md +0 -284
  416. package/kb/extra/subsystems/conversation.md +0 -301
  417. package/kb/extra/subsystems/conversation.zh.md +0 -303
  418. package/kb/extra/subsystems/core.md +0 -1113
  419. package/kb/extra/subsystems/core.zh.md +0 -1125
  420. package/kb/extra/subsystems/credentials.md +0 -493
  421. package/kb/extra/subsystems/credentials.zh.md +0 -493
  422. package/kb/extra/subsystems/filesystem.md +0 -530
  423. package/kb/extra/subsystems/filesystem.zh.md +0 -530
  424. package/kb/extra/subsystems/goal.md +0 -313
  425. package/kb/extra/subsystems/goal.zh.md +0 -313
  426. package/kb/extra/subsystems/jobs.md +0 -554
  427. package/kb/extra/subsystems/jobs.zh.md +0 -554
  428. package/kb/extra/subsystems/llm-streaming.md +0 -1196
  429. package/kb/extra/subsystems/llm-streaming.zh.md +0 -1202
  430. package/kb/extra/subsystems/lsp.md +0 -202
  431. package/kb/extra/subsystems/lsp.zh.md +0 -202
  432. package/kb/extra/subsystems/permission-presets.md +0 -167
  433. package/kb/extra/subsystems/permission-presets.zh.md +0 -167
  434. package/kb/extra/subsystems/persistence.md +0 -418
  435. package/kb/extra/subsystems/persistence.zh.md +0 -418
  436. package/kb/extra/subsystems/plan.md +0 -87
  437. package/kb/extra/subsystems/plan.zh.md +0 -87
  438. package/kb/extra/subsystems/ptc-runtime.md +0 -250
  439. package/kb/extra/subsystems/ptc-runtime.zh.md +0 -250
  440. package/kb/extra/subsystems/sandbox.md +0 -221
  441. package/kb/extra/subsystems/sandbox.zh.md +0 -221
  442. package/kb/extra/subsystems/schedule.md +0 -550
  443. package/kb/extra/subsystems/schedule.zh.md +0 -550
  444. package/kb/extra/subsystems/scope.md +0 -59
  445. package/kb/extra/subsystems/scope.zh.md +0 -61
  446. package/kb/extra/subsystems/session-projection.md +0 -356
  447. package/kb/extra/subsystems/session-projection.zh.md +0 -356
  448. package/kb/extra/subsystems/session-query.md +0 -511
  449. package/kb/extra/subsystems/session-query.zh.md +0 -511
  450. package/kb/extra/subsystems/session-reference.md +0 -224
  451. package/kb/extra/subsystems/session-reference.zh.md +0 -224
  452. package/kb/extra/subsystems/session-telemetry.md +0 -212
  453. package/kb/extra/subsystems/session-telemetry.zh.md +0 -212
  454. package/kb/extra/subsystems/session-title.md +0 -213
  455. package/kb/extra/subsystems/session-title.zh.md +0 -213
  456. package/kb/extra/subsystems/session.md +0 -1339
  457. package/kb/extra/subsystems/session.zh.md +0 -1343
  458. package/kb/extra/subsystems/settings.md +0 -155
  459. package/kb/extra/subsystems/settings.zh.md +0 -155
  460. package/kb/extra/subsystems/shell.md +0 -314
  461. package/kb/extra/subsystems/shell.zh.md +0 -314
  462. package/kb/extra/subsystems/sidebar-right.md +0 -160
  463. package/kb/extra/subsystems/sidebar-right.zh.md +0 -160
  464. package/kb/extra/subsystems/skills.md +0 -352
  465. package/kb/extra/subsystems/skills.zh.md +0 -352
  466. package/kb/extra/subsystems/slots.md +0 -200
  467. package/kb/extra/subsystems/slots.zh.md +0 -204
  468. package/kb/extra/subsystems/spill.md +0 -124
  469. package/kb/extra/subsystems/spill.zh.md +0 -124
  470. package/kb/extra/subsystems/storage.md +0 -259
  471. package/kb/extra/subsystems/storage.zh.md +0 -259
  472. package/kb/extra/subsystems/subagent.md +0 -686
  473. package/kb/extra/subsystems/subagent.zh.md +0 -688
  474. package/kb/extra/subsystems/subprocess.md +0 -321
  475. package/kb/extra/subsystems/subprocess.zh.md +0 -321
  476. package/kb/extra/subsystems/system-prompt.md +0 -254
  477. package/kb/extra/subsystems/system-prompt.zh.md +0 -254
  478. package/kb/extra/subsystems/terminal.md +0 -184
  479. package/kb/extra/subsystems/terminal.zh.md +0 -184
  480. package/kb/extra/subsystems/token-meter.md +0 -106
  481. package/kb/extra/subsystems/token-meter.zh.md +0 -106
  482. package/kb/extra/subsystems/tools.md +0 -747
  483. package/kb/extra/subsystems/tools.zh.md +0 -747
  484. package/kb/extra/subsystems/typert.md +0 -690
  485. package/kb/extra/subsystems/typert.zh.md +0 -690
  486. package/kb/extra/subsystems/user-questions.md +0 -307
  487. package/kb/extra/subsystems/user-questions.zh.md +0 -307
  488. package/kb/extra/subsystems/web-client.md +0 -100
  489. package/kb/extra/subsystems/web-client.zh.md +0 -100
  490. package/kb/extra/subsystems/web-server.md +0 -302
  491. package/kb/extra/subsystems/web-server.zh.md +0 -302
  492. package/kb/extra/subsystems/web.md +0 -206
  493. package/kb/extra/subsystems/web.zh.md +0 -206
  494. package/kb/extra/subsystems/workflow.md +0 -278
  495. package/kb/extra/subsystems/workflow.zh.md +0 -278
  496. package/kb/extra/subsystems/workspace.md +0 -647
  497. package/kb/extra/subsystems/workspace.zh.md +0 -647
  498. package/kb/extra/tool-catalog.md +0 -2824
  499. package/kb/extra/tool-catalog.zh.md +0 -2832
  500. package/kb/extra/tool-execution-pipeline.md +0 -65
  501. package/kb/extra/tool-execution-pipeline.zh.md +0 -67
@@ -1,91 +0,0 @@
1
- <!-- Generated by scripts/gen-doc-graphs.ts - do not edit by hand.
2
- Run `pnpm run gen-doc-graphs` to regenerate. -->
3
-
4
- # Agent Turn And Step Lifecycle
5
-
6
- This sequence is the visual companion to [architecture.md](architecture.md#turn-flow). It keeps durable replay facts on `session/event` and live control/status on `agent/*`.
7
-
8
- ```mermaid
9
- sequenceDiagram
10
- participant User
11
- participant Agent
12
- participant Driver
13
- participant Hooks as hook listeners
14
- participant Prompt as ctx.systemPrompt
15
- participant LLM as ctx.llm
16
- participant Tools as ctx.tools
17
- participant Session
18
- participant SDK as UI or SDK listener
19
- User->>Agent: followup(content)
20
- Agent-->>SDK: <code>agent/inbox/spliced</code>
21
- Agent-->>SDK: <code>agent/inbox/inserted</code> { message }
22
- Agent->>Driver: queued work wakes driver
23
- Driver-->>SDK: <code>agent/status</code> running
24
- Driver->>Session: <code>turn/start</code>
25
- Note over Agent,Driver: claim pending next-step input plus one queued prompt
26
- Driver-->>SDK: <code>agent/inbox/spliced</code> pure deletion
27
- Driver-->>SDK: <code>agent/inbox/claimed</code> { message, turn } per message
28
- Driver->>Prompt: <code>system-prompt/assemble</code> waterfall
29
- Driver->>Hooks: <code>agent/pre-step</code> waterfall
30
- Hooks-->>Driver: authoritative reject or enter(messages)
31
- alt proposed step rejected, first batch empty, or pre-step failed
32
- Driver-->>Driver: claimed batch stays removed, the open turn spends no step
33
- else enter proposed step
34
- Driver->>Session: <code>step/start</code>
35
- Driver->>Hooks: <code>agent/request</code> waterfall
36
- Driver->>LLM: prepareCall(config, signal)
37
- Note over Driver,LLM: cancellation during either async phase commits neither system nor users
38
- Note over Driver,Session: synchronous admission using the prepared call capability
39
- Driver->>Session: <code>system/message</code> ordered per-node reconciliation
40
- Driver->>Session: <code>user/message</code> per entered message
41
- Driver->>Session: <code>request/header</code> and <code>request/context</code> as needed
42
- Driver->>Driver: derive and freeze request from the log
43
- Driver->>LLM: bound prepared call through <code>llm/stream</code> waterfall
44
- LLM-->>Driver: StreamChunk*
45
- Driver-->>SDK: <code>agent/assistant-stream</code> chunk*
46
- alt final adapter or terminal in-band request failure
47
- Driver->>Session: <code>assistant/attempt</code>
48
- Driver-->>SDK: <code>agent/assistant-stream</code> committed end
49
- Driver->>Hooks: <code>agent/request-error</code> waterfall
50
- Hooks-->>Driver: return retry action or preserve the original error
51
- Note over Driver,LLM: retry in the open step: prepare and reconcile the same rendered assembly without repeating pre-step or users
52
- else model request succeeded
53
- Driver->>Session: <code>assistant/message</code>
54
- Driver-->>SDK: <code>agent/assistant-stream</code> committed end
55
- Driver->>Tools: classify pending call by executionMode
56
- loop barriers and bounded rolling pool, reclassify before start
57
- opt call starts
58
- Driver->>Session: <code>tool/call</code>
59
- Driver->>Tools: ordered pre, concurrent execute
60
- Tools-->>Session: tool-owned events when applicable
61
- end
62
- opt next model-order result ready
63
- Driver->>Tools: ordered post
64
- Driver->>Session: <code>tool/result</code>
65
- end
66
- end
67
- Driver->>Session: <code>step/end</code>
68
- opt natural stop and next-step inbox empty
69
- Driver->>Hooks: <code>agent/turn-stopping</code> serial terminal checkpoint
70
- end
71
- opt next-step input is pending
72
- Driver-->>Driver: claim pending next-step input
73
- Driver-->>SDK: <code>agent/inbox/claimed</code> { message, turn } per message
74
- Driver->>Hooks: <code>agent/pre-step</code> waterfall
75
- Hooks-->>Driver: authoritative reject or enter(messages)
76
- end
77
- end
78
- end
79
- Driver->>Session: <code>turn/end</code>
80
- Driver-->>SDK: <code>agent/status</code> idle
81
- ```
82
-
83
- The `assistant/message` event records every successful provider call, including content-less and `max-tokens` finishes, and embeds the exact compact timed stream. Empty content stays out of derived history. A failed, retried, cancelled, or stream-error attempt that reaches settlement without a surface message records its stream as `assistant/attempt`. Live `agent/assistant-stream` chunk frames are transient; replay reads either durable settlement, and a hard process loss before settlement leaves no durable attempt stream.
84
-
85
- `dsh-compaction-basic` uses `agent/pre-step` for pressure before request derivation and `agent/request-error` only for canonical context overflow. Once either trigger qualifies, optional tool-result pruning runs before summary selection. Recovery runs within the open step and retries only when pruning or summarization advances the surface replacement generation; otherwise the original request error remains authoritative. Each retry prepares its call and reconciles the retained rendered assembly before request derivation, without repeating assembly, pre-step, or user admission.
86
-
87
- The returned `agent/pre-step` decision is authoritative; listeners wrapping `next()` preserve downstream messages and `startsRequestSeries` unless replacement is intentional. Steering and injected context pass through the same waterfall after a later claim operation takes their next-step batch.
88
-
89
- SDK users that need replayable transcript data should consume `session/event`; `agent/*` is the live coordination API for queue/status, prompt interception, request construction, steering, continuation, and errors.
90
-
91
- Maintenance mode: curated Mermaid sequence; exact event signatures live in the generated Cordis catalog.
@@ -1,93 +0,0 @@
1
- <!-- 英文源文件由 scripts/gen-doc-graphs.ts 生成;本中文文件是通过双语配对维护的经评审对侧。
2
- 更新时先运行 `pnpm run gen-doc-graphs` 更新英文,再更新本文件并运行 `pnpm run verify-translation-pairing --write docs/agent-lifecycle.md` 重新记录配对。 -->
3
-
4
- # Agent 轮次与步骤生命周期
5
-
6
- [English](agent-lifecycle.md) | 中文
7
-
8
- 此时序图是 [architecture.md](architecture.zh.md#turn-flow) 的配套图示。持久的回放事实保存在 `session/event` 中,实时控制与状态则保存在 `agent/*` 中。
9
-
10
- ```mermaid
11
- sequenceDiagram
12
- participant User
13
- participant Agent
14
- participant Driver
15
- participant Hooks as hook listeners
16
- participant Prompt as ctx.systemPrompt
17
- participant LLM as ctx.llm
18
- participant Tools as ctx.tools
19
- participant Session
20
- participant SDK as UI or SDK listener
21
- User->>Agent: followup(content)
22
- Agent-->>SDK: <code>agent/inbox/spliced</code>
23
- Agent-->>SDK: <code>agent/inbox/inserted</code> { message }
24
- Agent->>Driver: queued work wakes driver
25
- Driver-->>SDK: <code>agent/status</code> running
26
- Driver->>Session: <code>turn/start</code>
27
- Note over Agent,Driver: claim pending next-step input plus one queued prompt
28
- Driver-->>SDK: <code>agent/inbox/spliced</code> pure deletion
29
- Driver-->>SDK: <code>agent/inbox/claimed</code> { message, turn } per message
30
- Driver->>Prompt: <code>system-prompt/assemble</code> waterfall
31
- Driver->>Hooks: <code>agent/pre-step</code> waterfall
32
- Hooks-->>Driver: authoritative reject or enter(messages)
33
- alt proposed step rejected, first batch empty, or pre-step failed
34
- Driver-->>Driver: claimed batch stays removed, the open turn spends no step
35
- else enter proposed step
36
- Driver->>Session: <code>step/start</code>
37
- Driver->>Hooks: <code>agent/request</code> waterfall
38
- Driver->>LLM: prepareCall(config, signal)
39
- Note over Driver,LLM: cancellation during either async phase commits neither system nor users
40
- Note over Driver,Session: synchronous admission using the prepared call capability
41
- Driver->>Session: <code>system/message</code> ordered per-node reconciliation
42
- Driver->>Session: <code>user/message</code> per entered message
43
- Driver->>Session: <code>request/header</code> and <code>request/context</code> as needed
44
- Driver->>Driver: derive and freeze request from the log
45
- Driver->>LLM: bound prepared call through <code>llm/stream</code> waterfall
46
- LLM-->>Driver: StreamChunk*
47
- Driver-->>SDK: <code>agent/assistant-stream</code> chunk*
48
- alt final adapter or terminal in-band request failure
49
- Driver->>Session: <code>assistant/attempt</code>
50
- Driver-->>SDK: <code>agent/assistant-stream</code> committed end
51
- Driver->>Hooks: <code>agent/request-error</code> waterfall
52
- Hooks-->>Driver: return retry action or preserve the original error
53
- Note over Driver,LLM: retry in the open step: prepare and reconcile the same rendered assembly without repeating pre-step or users
54
- else model request succeeded
55
- Driver->>Session: <code>assistant/message</code>
56
- Driver-->>SDK: <code>agent/assistant-stream</code> committed end
57
- Driver->>Tools: classify pending call by executionMode
58
- loop barriers and bounded rolling pool, reclassify before start
59
- opt call starts
60
- Driver->>Session: <code>tool/call</code>
61
- Driver->>Tools: ordered pre, concurrent execute
62
- Tools-->>Session: tool-owned events when applicable
63
- end
64
- opt next model-order result ready
65
- Driver->>Tools: ordered post
66
- Driver->>Session: <code>tool/result</code>
67
- end
68
- end
69
- Driver->>Session: <code>step/end</code>
70
- opt natural stop and next-step inbox empty
71
- Driver->>Hooks: <code>agent/turn-stopping</code> serial terminal checkpoint
72
- end
73
- opt next-step input is pending
74
- Driver-->>Driver: claim pending next-step input
75
- Driver-->>SDK: <code>agent/inbox/claimed</code> { message, turn } per message
76
- Driver->>Hooks: <code>agent/pre-step</code> waterfall
77
- Hooks-->>Driver: authoritative reject or enter(messages)
78
- end
79
- end
80
- end
81
- Driver->>Session: <code>turn/end</code>
82
- Driver-->>SDK: <code>agent/status</code> idle
83
- ```
84
-
85
- `assistant/message` 事件会记录每次成功的提供方调用,包括返回空内容或以 `max-tokens` 结束的调用,并嵌入精确的紧凑带时间 stream。空内容不会进入派生历史。失败、重试、取消或 stream error attempt 到达 settlement 时,如果没有 surface message,就会把 stream 记录为 `assistant/attempt`。实时 `agent/assistant-stream` chunk frame 是瞬态数据;回放读取任一种持久 settlement,如果进程在 settlement 前硬中断,则不会留下持久 attempt stream。
86
-
87
- `dsh-compaction-basic` 在派生请求之前通过 `agent/pre-step` 处理压力,而 `agent/request-error` 仅用于规范的上下文溢出。任一触发条件满足后,系统都会先执行可选的工具结果剪枝,再选择摘要。恢复发生在仍打开的步骤内,只有剪枝或摘要生成推进 surface replacement generation 时才重试,否则仍以原始请求错误为准。每次重试都会准备调用,并在派生请求之前协调保留的已渲染组装结果,不重复组装、pre-step 或用户消息准入。
88
-
89
- 以返回的 `agent/pre-step` 决策为准;通过包装 `next()` 的监听器会保留下游消息与 `startsRequestSeries`,除非有意替换。steering(中途引导)和注入的上下文在后续的认领操作取得其下一步骤批次后,会经过同一 waterfall(瀑布式事件)。
90
-
91
- 需要可回放 transcript(文本记录)数据的 SDK 用户应当消费 `session/event`;`agent/*` 是用于队列与状态、提示词拦截、请求构造、steering、继续执行和错误处理的实时协调接口。
92
-
93
- 维护模式:英文源文件包含人工维护的 Mermaid 时序图,并由生成器写出;本中文文件作为经评审对侧通过双语配对维护。确切的事件签名位于生成的 Cordis 目录中。
@@ -1,172 +0,0 @@
1
- # API Gateway
2
-
3
- English | [中文](api-gateway.zh.md)
4
-
5
- This is the current-state reference for the Typert API Gateway. It describes how business services declare unary and stream Remote methods, how the build generates Host and Client contracts, and how calls reuse the Connection RPC and `/api` route. Session events, incremental data, and other streaming protocols are outside this document's scope; they may use the same Connection but do not use Remote method descriptors.
6
-
7
- ## Programming model
8
-
9
- Business services use `@Remote` or `@RemoteScope` to select the methods exposed to the Client. Unmarked methods do not enter the generated Client types or runtime contributions and cannot be called through `ctx.remote`.
10
-
11
- `@Remote` denotes calling a Cordis service registered on the root Host Context. Complex Host objects cannot cross the wire directly; the business package must declare their association with a wire identity through `TypertLookupMap` and register a default resolution provider with `ctx.typert.lookups` at runtime. For example, an `Agent` parameter named `agent` in the Host signature produces an `agentId` wire field, and the Gateway resolves that id to a Host object before invoking the business method. Host composition can use `ctx.typert.lookups.configure()` to override the resolution policy for a lookup key without changing the parameter name, wire field, or canonical type symbol owned by the business package.
12
-
13
- `@RemoteScope(key)` first resolves an identity to a scoped Context through `ctx.typert.contexts`, then obtains the service from that Context and invokes the method. It applies when the method itself depends on scoped composition and does not need to receive objects such as `Agent` explicitly.
14
-
15
- `@Remote` accepts an export name or `{ name?, mode?, resources? }`, and `@RemoteScope(key, option?)` accepts an export name, as in `@RemoteScope('agent', 'current')` below, or `{ name?, resources? }` as its second argument. `resources` holds per-kind readers that return the identities of the resources one call touches for access control; each reader receives the method's wire arguments as its own parameters, with types inferred from the decorated method. Most methods declare no readers, because the Gateway also reads identities from lookup parameters and scoped Contexts that declare a `resource`, and from the default fields in `typert.resources`; the [Typert subsystem](subsystems/typert.md) owns that order.
16
-
17
- Services normally extend `TypertRemoteService` so the constructor explicitly binds the Cordis service key and default Remote namespace. A service that already has another base class can instead declare `readonly typertRemote = bindTypertRemote(this, serviceKey)`; both forms leave an inspectable public binding and do not depend on the compiler injecting a symbol into the constructor.
18
-
19
- ```ts
20
- import type { Agent } from '@deepseek-ai/dsh-agent'
21
- import { TypertRemoteService, Remote, RemoteScope } from '@deepseek-ai/dsh-typert-protocol'
22
- import type { Context } from '@deepseek-ai/cordis'
23
-
24
- export interface CreateGoalRequest {
25
- objective: string
26
- }
27
-
28
- export interface CreateGoalResult {
29
- accepted: boolean
30
- }
31
-
32
- export class GoalService extends TypertRemoteService {
33
- constructor(ctx: Context) {
34
- super(ctx, 'goals')
35
- }
36
-
37
- @Remote('create')
38
- createForClient(
39
- agent: Agent,
40
- request: CreateGoalRequest,
41
- signal: AbortSignal,
42
- ): CreateGoalResult {
43
- signal.throwIfAborted()
44
- return this.create(agent, request)
45
- }
46
-
47
- @RemoteScope('agent', 'current')
48
- currentForClient(): CreateGoalResult {
49
- return { accepted: true }
50
- }
51
-
52
- private create(_agent: Agent, request: CreateGoalRequest): CreateGoalResult {
53
- return { accepted: request.objective.length > 0 }
54
- }
55
- }
56
- ```
57
-
58
- Remote methods may return a value synchronously or return a Promise. For cooperative cancellation, the final parameter in the Host signature must be `signal: AbortSignal` using the global type; it is recorded in the descriptor instead of entering `args`, while the generated Client method accepts an optional final `AbortSignal`.
59
-
60
- `@Remote({ mode: 'stream' })` marks a method that returns `Iterable`, `AsyncIterable`, or `RemoteStream<Out, In>`: the Gateway delivers each yielded item, a value the Host method produced, over its multiplexed `/api/remote.mux` WebSocket or an in-process carrier, and the generated Client method returns a `RemoteStreamHandle<Out, In>` that iterates the items and exposes `send`, `end`, and `dispose` for the Client-to-Host uplink of the same logical stream. The second type argument of `RemoteStream<Out, In>` declares the uplink item type; the Gateway validates each item the Client sends, because it arrives from the browser, with the generated `In` codec before the Host method reads it through `this.ctx.invocation.uplink<In>()`. The uplink enters neither `args` nor the parameter list; the [Gateway README](../packages/api/gateway/README.md) owns the frame, half-close, cancellation, and inbox-bound contracts.
61
-
62
- The Client uses concrete functions on ordinary objects, not a JavaScript Proxy. Direct and scoped calls appear under `ctx.remote.<namespace>` and `agentCtx.remote.<namespace>`. Each namespace is a traced Cordis child Service registered as `remote.<namespace>`; the Client assembly mounts contributions through `ctx.remote.$mount()`, and the namespace unloads after its last method is withdrawn. Dependency declarations belong to the actual caller: only a business package that reads `ctx.remote.<namespace>` or `agentCtx.remote.<namespace>` declares both `remote` and `remote.<namespace>` in its own `inject`; assemblies that only mount contributions and higher-level runtimes that do not call that namespace do not declare the namespace dependency on the business package's behalf. When an `@Remote` method has exactly one lookup parameter and a same-named `TypertContextMap` uses the same wire identity, the generated scoped signature omits that identity parameter. `@RemoteScope` generates only the scoped invocation interface.
63
-
64
- ```ts ignore-check
65
- import type { SessionId } from '@deepseek-ai/dsh-session/types'
66
- import type { AgentContext } from '@deepseek-ai/dsh-api-session-controller/client'
67
- import type { Context } from '@deepseek-ai/cordis'
68
- import type {} from '@deepseek-ai/dsh-api-remotes/client'
69
-
70
- export const inject = ['remote', 'remote.goals']
71
-
72
- declare const ctx: Context
73
- declare const agentCtx: AgentContext
74
- declare const agentId: SessionId
75
-
76
- await ctx.remote.goals.create(agentId, { objective: 'ship it' })
77
- await agentCtx.remote.goals.create({ objective: 'ship it' })
78
- ```
79
-
80
- Client applications assemble only `@deepseek-ai/dsh-api-remotes`. That package imports the `/remote` subpaths of selected business packages as runtime values, mounts their contributions through `ctx.remote.$mount()`, and re-exports the declaration merges from the same files. Adding a Host Remote package is an explicit choice by the Client composition owner; business components do not need to load the Typert Gateway or the business package's Remote JS separately.
81
-
82
- The `api-remotes` assembly and the `ctx.remote` contract are React-independent; the Host methods visible to any Client assembly are limited to the Remote methods selected at generation time.
83
-
84
- ## Component responsibilities
85
-
86
- | Location | Package or entry | Responsibility |
87
- |---|---|---|
88
- | Shared | `@deepseek-ai/dsh-typert-protocol` | Declares decorators, Gateway bindings, merge-extensible protocol maps, invocation descriptors, and provider types; starts no TypeScript analysis and registers no Cordis services |
89
- | Build | `@deepseek-ai/dsh-typert-generator` | Strictly analyzes Remote signatures, the type graph, lookups, Contexts, and source locations from the Host `ts.Program`, then generates Host and Host-for-Client artifacts |
90
- | Host | `@deepseek-ai/dsh-typert-registry` and Loader | Places generated Host descriptors, schemas, and business-package registrations in `ctx.typert`, and holds lookup and Context providers |
91
- | Host | `@deepseek-ai/dsh-api-session-controller` | Owns the application Agent/Session identity policy and configures the corresponding Typert lookups |
92
- | Host | `@deepseek-ai/dsh-api-gateway` | Provides `ctx.typertGateway`, claims Remote endpoints, validates request values, resolves objects or Contexts, and invokes live Cordis services |
93
- | Host | `@deepseek-ai/dsh-api-remote-access` | Decides which Remote methods a non-owner Peer may call through business-registered role-based policies, filters list results, and streams each Peer's access snapshot; the Gateway requires it |
94
- | Client | `@deepseek-ai/dsh-api-gateway/client` | Provides `ctx.remote` and `remote.<namespace>` child Services, mounts generated descriptors as concrete methods, and initiates and cancels calls through the Connection |
95
- | Client | `@deepseek-ai/dsh-api-remotes/client` | Explicitly selects and mounts the `/remote` contributions allowed by the application and brings the corresponding declaration merges into business code |
96
- | Both | `@deepseek-ai/dsh-client-connection` | Provides the RPC carrier, request correlation, trust boundary, cancellation, response envelope, and the `/api` HTTP bridge |
97
-
98
- The API Gateway package owns the Host dispatcher and Client Remote endpoint as peer entries, but the two builds never enter the same `ts.Program`. The Host entry does not import the Client Cordis `Context` merge, and the Client entry does not import the Host Gateway service.
99
-
100
- ## Strict generation pipeline
101
-
102
- The root build compiles and bundles the Host face, then the Client face, then builds the Web shell ([step order](development.md#typescript-project-layout)). The Host phase first compiles the Host package references, then runs `tsdown --env.DSH_BUILD_FACE host`; the normal Host Project Reference graph compiles the Typert generator, which runs during this tsdown pass with the Host aggregate as its only `ts.Program` seed. The Client phase then compiles the Client package references and runs `tsdown --env.DSH_BUILD_FACE client`, consuming the newly generated Remote Client declarations and runtime contributions without starting Typert again.
103
-
104
- Both tsdown passes match `vendor/*`, `packages/*/*`, and `apps/cli`, the Host pass also `apps/desktop-host` ([build order](development.md#typescript-project-layout)), and both bundle only JavaScript emitted to `lib/types` by the corresponding tsc phase. The root config does not scan Client artifacts, classify package names, or pass a maintained filter to tsdown; package-local configs return entries for the current phase based on `DSH_BUILD_FACE`. An ordinary Client plugin produces both its Node loader entry and browser bundle during the Client phase.
105
-
106
- `api/remotes`, `api/gateway`, `api/session-controller`, and `api/workspace-controller` (plus `client/connection`) split TypeScript faces. `api/remotes`' Client project depends on `/remote` declarations generated for business packages during Host tsdown; root aggregates and direct consumers must reference each split package's `tsconfig.host.json` or `tsconfig.client.json` respectively. `api-remotes`' `clientBundle(..., { hostPhase: true })` produces its Host entry during Host tsdown and leaves only the browser entry for Client tsdown. The Agent/Session lookup policy lives in `@deepseek-ai/dsh-api-session-controller`, not in `api-remotes`.
107
-
108
- Each contributing business package writes generated files to its own `lib/` directory, not to its source directory:
109
-
110
- | File | Consumer | Contents |
111
- |---|---|---|
112
- | `typert.host.js` | Host Loader | Runtime reflection for the Host face, strict invocation descriptors, and schema registration values |
113
- | `typert.host.d.ts` | Host type system | Generated declarations for the Host face |
114
- | `typert.remote-client.js` | `api-remotes` | A mountable `TypertRemoteContribution` containing strict descriptors and runtime codecs |
115
- | `typert.remote-client.d.ts` | Client type system | Declaration merges for `TypertRemoteNamespaceMap` and `TypertRemoteScopeMap`, plus Client-safe type references |
116
- | `typert.remote-client.d.ts.map` | Editor | Maps generated method properties back to Remote method declarations in the Host package |
117
-
118
- Business packages expose the Host Loader entry through `./typert` and the Host-for-Client entry through `./remote`. The generator also validates these package exports and published-file lists; it generates artifacts only for explicit contribution packages that provide the corresponding entry.
119
-
120
- Parameter names in Remote Client declarations come from wire fields, while parameter and return types reference Client-safe types exported by the original business package. The declaration map resolves the generated property behind `ctx.remote.goals.create` back to the Host source method marked with `@Remote`, so editors that support declaration maps can navigate from a Client call to the real implementation instead of stopping at the generated `.d.ts`.
121
-
122
- Strict analysis requires a Remote to be a public, non-static instance method with a concrete implementation. The method cannot be generic; parameters must be required, named simple identifiers and cannot use destructuring, default values, rest parameters, or optional parameters. Typert generates strict schemas for ordinary JSON-representable types; complex objects such as workspace classes must have a unique `TypertLookupMap` declaration. Lookup and Context packages are responsible for both static declaration merges and runtime provider registration; if either side is missing, the build fails or the first call that needs the provider fails.
123
-
124
- ## Runtime invocation
125
-
126
- Remote calls use the Connection's `/api` route. The Client Remote calls `connection.rpc.call('/api', '<namespace>/<method>', { args }, signal)`; the HTTP carrier maps this to `POST /api/<namespace>/<method>`, with a payload containing only a named `args` object.
127
-
128
- The Connection performs the unified trust check for `/api` before the HTTP bridge, then dispatches inside the shared FetchHandler. The Typert Gateway claims only two-segment endpoints that have a strict descriptor or active SRC marker; it projects binary Remote fields into JSON-compatible metadata and result-relative byte attachments, which Connection frames as multipart responses. Feature-owned exact Fetch routes handle responses outside the RPC envelope, and other requests return 404. Connection owns transport, RPC ids, response envelopes, and request cancellation, while Gateway owns the Remote data protocol and business dispatch. Replacing the Connection carrier does not require changes to Remote descriptors or the Client programming interface.
129
-
130
- For every call, the Gateway resolves the descriptor and live service from the current registries instead of caching business objects. Every call names the Peer it speaks for, and a disposed Peer is refused with `gateway/peer-disposed`. The Gateway requires the fields in `args` to match the descriptor exactly; for a call whose Peer principal is not the owner it then resolves the resources the call touches and asks `ctx.remoteAccess.decide()`, so a refused call resolves no lookup and activates no Agent. It validates wire values with codecs, resolves objects or receivers through registered lookup or Context providers, and invokes the service method targeted by the binding. The Client Gateway validates decoded binary results with the generated result codec; ordinary JSON results retain their existing handling. A missing provider, unknown identity, binding mismatch, missing or extra argument, schema failure, or missing method fails before entering or after leaving business code.
131
-
132
- The lookup provider's `register()` supplies both the stable declaration and the default resolver; `configure()` supplies a resolver owned by Host composition that may execute asynchronously and is scoped to an effect lifetime. Configuration may precede provider mounting; without a provider, invocation still fails with `gateway/lookup-unavailable`, and unloading the configuration restores the provider's default policy. The Session Controller owns the standard resolver semantics for `agent` and `session`: it reuses a live Agent, automatically resumes ordinary cold sessions, deduplicates concurrent resumes, and rejects identities owned by subagent routing; the `session` lookup returns that Agent's Session. A resume failure and an ownership fence raise a `RemoteError` carrying their own code, `session/not-found` or `session/agent-busy`, which the Gateway encodes onto the wire unchanged; only an unclassified throw folds into `gateway/internal`.
133
-
134
- Unloading a Client contribution removes its descriptors and concrete methods together, aborts its in-flight calls, and makes stale method handles retained by external code reject further calls. A strict endpoint withdrawn on the Host also does not degrade to SRC inference, preventing a hot unload from silently weakening validation.
135
-
136
- ## SRC development fallback
137
-
138
- When the Host starts from source through `node --import tsx/esm`, it does not execute the Typert compiler plugin. Standard decorator initializers still record the method name and invocation mode in a versioned descriptor on the Service prototype, while `TypertRemoteService` or `bindTypertRemote()` supplies the explicit service binding; the Gateway can therefore construct a weaker temporary descriptor without starting a `ts.Program`. The descriptor's stable string property name lets `remoteMethods()` read markers written by another installed copy of the protocol package.
139
-
140
- The SRC fallback parses simple parameter names from the live function. When a parameter name matches the `parameter` of a registered lookup, such as `agent` or `session`, it uses the lookup's `agentId` or `sessionId` wire field and resolves the object on the Host; other parameters are checked only for cycle-free, JSON-safe data with no special prototype. `@RemoteScope` directly uses the wire field of a registered Host Context provider. SRC does not read TypeScript types, generate Zod schemas, infer optional parameters, or support destructuring, default values, rest parameters, or duplicate parameter names.
141
-
142
- SRC solves only dispatch for a Host process running from source. The Client does not discover decorators from the running Host, and the Client Remote refuses to mount SRC descriptors that lack strict codecs; its types, codecs, and Remote registration values always come from the most recently generated `lib/typert.remote-client.*` artifacts.
143
-
144
- ## Development mode
145
-
146
- Web development runs one command, which builds current Host, Client, and Web artifacts, starts the source Host, and keeps Client bundles rebuilt:
147
-
148
- ```sh
149
- pnpm run dev:web
150
- ```
151
-
152
- `dsh` starts the Host source through tsx, so the Host can use the SRC fallback; the `dev:web` watchers rebuild the client-face type emit, Client plugin and library bundles, and the Web shell on source edits. They do not analyze Host decorators or generate Remote Client DTS; only the complete build that `dev:web` runs first (or `pnpm run build`) does.
153
-
154
- Changing only a Remote method's implementation body without changing its contract does not require regenerating the Typert files. After adding or removing a decorator or changing an export name, namespace, parameter, return value, lookup, Context, or cancellation signature, rerun the ordered lib build so the Host generates the strict contract before the Client compiles and bundles the new contribution:
155
-
156
- ```sh
157
- pnpm run build:lib
158
- ```
159
-
160
- The running Client watcher consumes these generated files when it rebundles. If `pnpm run build:lib:host` has already refreshed the Host contract, `pnpm run build:lib:client` can complete the Client side; a clean worktree cannot skip the Host phase. Recompiling only the frontend source cannot infer new types from Host decorators. `pnpm run typecheck` generates the Host contract with the bundle-free Typert pass before Client tsc, and the CI build lanes and release builds generate it in the Host bundle phase before Client tsc.
161
-
162
- ## Boundaries
163
-
164
- Remote handles unary method calls with one request and one result, and stream methods whose items flow Host → Client while the Client's items reach the running Host method through `this.ctx.invocation.uplink()`. Session event streams, pagination, incremental reduce, projection, and entity substreams still require a separate data protocol and registration model; even when they reuse the Connection, they must not masquerade as Remote methods or enter invocation descriptors.
165
-
166
- The API layers are organized as `remotes → gateway → connection → webserver`. The BFF and Typert RPC layers live under `packages/api`; Connection and WebServer live at `packages/client/connection` and `packages/host/webserver`. Unary results containing `Uint8Array`, including nested fields and array entries, use [binary Remote transfer](../.agents/notes/implemented/architecture/2026-09-17-workspace-file-binary-transfer.md). A feature that needs a response outside the RPC envelope registers an exact Connection Fetch route.
167
-
168
- Lookup policy is configured per key, so all `agent` or `session` parameters share the cold-resume behavior. Accepting live objects only would require an explicit per-parameter or per-endpoint policy, which does not exist; the business method must not guess whether the object came from restoration.
169
-
170
- ### Business ownership
171
-
172
- `packages/api` owns transport, call shape, and session lifecycle; a business rule belongs to an independent business package and reaches this layer through a registration surface or projected data. The requirements a change here must satisfy — the four `@Remote` disciplines, the additive-names rule, and the boundary this layer keeps — are owned by [Remote and API rules](defensive-patterns/remote-and-api.md), which is where a review checks them.
@@ -1,178 +0,0 @@
1
- # API Gateway
2
-
3
- [English](api-gateway.md) | 中文
4
-
5
- 本文是 Typert API Gateway 的当前状态参考。它描述业务服务如何声明一元与流式 Remote 方法、构建如何生成 Host 与 Client 约定,以及调用如何复用 Connection 的 RPC 与 `/api` 路由。会话事件、增量数据和其他流协议不属于本文范围;它们可以使用同一个 Connection,但不使用 Remote 方法描述符。
6
-
7
- <a id="programming-model"></a>
8
-
9
- ## 编程模型
10
-
11
- 业务服务通过 `@Remote` 或 `@RemoteScope` 选择对 Client 开放的方法。未标记的方法不会进入生成的 Client 类型或运行时贡献,也不能通过 `ctx.remote` 调用。
12
-
13
- `@Remote` 表示调用根 Host Context 中注册的 Cordis 服务。复杂的 Host 对象不能直接跨 wire 传输;业务包必须通过 `TypertLookupMap` 声明它与 wire identity 的关联,并在运行时向 `ctx.typert.lookups` 注册默认解析提供方。例如 `Agent` 参数在 Host 签名中名为 `agent`,生成的 wire 字段为 `agentId`,Gateway 在调用业务方法前将 id 解析为 Host 对象。Host 组合可以用 `ctx.typert.lookups.configure()` 覆盖某个 lookup key 的解析策略,而不改变业务包拥有的参数名、wire 字段或规范类型 symbol。
14
-
15
- `@RemoteScope(key)` 表示先通过 `ctx.typert.contexts` 把 identity 解析为一个作用域 Context,再从该 Context 取得服务并调用方法。它适用于方法本身依赖作用域组合、而不需要显式接收 `Agent` 等对象的情形。
16
-
17
- `@Remote` 接受导出名或 `{ name?, mode?, resources? }`;`@RemoteScope(key, option?)` 的第二个参数接受导出名(如下文的 `@RemoteScope('agent', 'current')`)或 `{ name?, resources? }`。`resources` 按资源种类给出读取函数,返回一次调用所访问资源的身份,供访问控制使用;每个读取函数以方法的 wire 参数作为自身参数,类型从被装饰方法推断。多数方法不声明读取函数,因为 Gateway 还会从声明了 `resource` 的 lookup 参数与作用域 Context 以及 `typert.resources` 中的默认字段读取身份;[Typert 子系统](subsystems/typert.zh.md)负责该顺序。
18
-
19
- 服务通常继承 `TypertRemoteService`,让 Cordis 服务 key 与默认 Remote namespace 在构造器中显式绑定。已有其他基类的服务可以改为声明 `readonly typertRemote = bindTypertRemote(this, serviceKey)`;两种方式都会留下可检查的公开 binding,不依赖编译器向构造函数注入 symbol。
20
-
21
- ```ts
22
- import type { Agent } from '@deepseek-ai/dsh-agent'
23
- import { TypertRemoteService, Remote, RemoteScope } from '@deepseek-ai/dsh-typert-protocol'
24
- import type { Context } from '@deepseek-ai/cordis'
25
-
26
- export interface CreateGoalRequest {
27
- objective: string
28
- }
29
-
30
- export interface CreateGoalResult {
31
- accepted: boolean
32
- }
33
-
34
- export class GoalService extends TypertRemoteService {
35
- constructor(ctx: Context) {
36
- super(ctx, 'goals')
37
- }
38
-
39
- @Remote('create')
40
- createForClient(
41
- agent: Agent,
42
- request: CreateGoalRequest,
43
- signal: AbortSignal,
44
- ): CreateGoalResult {
45
- signal.throwIfAborted()
46
- return this.create(agent, request)
47
- }
48
-
49
- @RemoteScope('agent', 'current')
50
- currentForClient(): CreateGoalResult {
51
- return { accepted: true }
52
- }
53
-
54
- private create(_agent: Agent, request: CreateGoalRequest): CreateGoalResult {
55
- return { accepted: request.objective.length > 0 }
56
- }
57
- }
58
- ```
59
-
60
- Remote 方法可以同步返回或返回 Promise。若需要协作式取消,Host 签名的最后一个参数必须是全局类型的 `signal: AbortSignal`;它记录在描述符中而不是进入 `args`,Client 生成的方法则接受最后一个可选的 `AbortSignal`。
61
-
62
- `@Remote({ mode: 'stream' })` 标记返回 `Iterable`、`AsyncIterable` 或 `RemoteStream<Out, In>` 的方法:Gateway 把每个产出的项(Host 方法产出的值)经其多路复用的 `/api/remote.mux` WebSocket 或进程内载体投递,Client 生成的方法返回一个 `RemoteStreamHandle<Out, In>`,它迭代这些项,并为同一条逻辑流上从 Client 到 Host 的上行提供 `send`、`end` 与 `dispose`。`RemoteStream<Out, In>` 的第二个类型参数声明上行项类型;Gateway 在 Host 方法通过 `this.ctx.invocation.uplink<In>()` 读取之前,用生成的 `In` codec 校验 Client 发送的每一项——它们来自浏览器。上行既不进入 `args` 也不进入参数列表;帧、半关闭、取消与 inbox 上限的约定由 [Gateway README](../packages/api/gateway/README.zh.md) 拥有。
63
-
64
- Client 使用普通对象上的具体函数,不使用 JavaScript Proxy。直接调用与作用域调用分别出现在 `ctx.remote.<namespace>` 和 `agentCtx.remote.<namespace>`。每个 namespace 都是注册为 `remote.<namespace>` 的可追踪 Cordis 子服务;Client assembly 通过 `ctx.remote.$mount()` 挂载贡献,最后一个方法撤回后该 namespace 随即卸载。依赖声明归实际调用方所有:只有读取 `ctx.remote.<namespace>` 或 `agentCtx.remote.<namespace>` 的业务包才在自己的 `inject` 中同时声明 `remote` 与 `remote.<namespace>`;只负责挂载 contribution 的 assembly,以及不调用该 namespace 的上层运行时,不代业务包声明 namespace 依赖。当一个 `@Remote` 方法恰好有一个 lookup 参数、且同名 `TypertContextMap` 使用相同 wire identity 时,生成的作用域签名会省略该 identity 参数。`@RemoteScope` 只生成作用域调用接口。
65
-
66
- ```ts ignore-check
67
- import type { SessionId } from '@deepseek-ai/dsh-session/types'
68
- import type { AgentContext } from '@deepseek-ai/dsh-api-session-controller/client'
69
- import type { Context } from '@deepseek-ai/cordis'
70
- import type {} from '@deepseek-ai/dsh-api-remotes/client'
71
-
72
- export const inject = ['remote', 'remote.goals']
73
-
74
- declare const ctx: Context
75
- declare const agentCtx: AgentContext
76
- declare const agentId: SessionId
77
-
78
- await ctx.remote.goals.create(agentId, { objective: 'ship it' })
79
- await agentCtx.remote.goals.create({ objective: 'ship it' })
80
- ```
81
-
82
- Client 应用只装配 `@deepseek-ai/dsh-api-remotes`。该包以运行时值导入被选业务包的 `/remote` 子路径,通过 `ctx.remote.$mount()` 挂载贡献,同时重新导出相同文件中的声明合并。增加一个 Host Remote 包是 Client 组合所有者的显式选择;业务组件不需要分别加载 Typert Gateway 或业务包的 Remote JS。
83
-
84
- `api-remotes` 装配与 `ctx.remote` 约定不依赖 React;任何 Client 装配能看到的 Host 方法都只限于生成时选择的 Remote 方法。
85
-
86
- ## 组件职责
87
-
88
- | 位置 | 包或入口 | 职责 |
89
- |---|---|---|
90
- | 共享 | `@deepseek-ai/dsh-typert-protocol` | 声明 decorator、Gateway binding、可合并协议映射、调用描述符及提供方类型;不启动 TypeScript 分析,也不注册 Cordis 服务 |
91
- | 构建 | `@deepseek-ai/dsh-typert-generator` | 从 Host `ts.Program` 严格分析 Remote 签名、类型图、lookup、Context 与源码位置,并生成 Host 和 Host-for-Client 产物 |
92
- | Host | `@deepseek-ai/dsh-typert-registry` 与 Loader | 把生成的 Host 描述符、schema 及业务包注册项放入 `ctx.typert`,并持有 lookup 与 Context 提供方 |
93
- | Host | `@deepseek-ai/dsh-api-session-controller` | 负责应用的 Agent/Session 身份策略,并配置对应的 Typert lookup |
94
- | Host | `@deepseek-ai/dsh-api-gateway` | 提供 `ctx.typertGateway`,认领 Remote endpoint,校验请求值,解析对象或 Context,并调用实时 Cordis 服务 |
95
- | Host | `@deepseek-ai/dsh-api-remote-access` | 按业务方注册的基于 role 的 policy 判定非 owner Peer 可调用哪些 Remote 方法,过滤列表结果,并为每个 Peer 推送访问快照;Gateway 依赖它 |
96
- | Client | `@deepseek-ai/dsh-api-gateway/client` | 提供 `ctx.remote` 与 `remote.<namespace>` 子服务,把生成的描述符挂成具体方法,并通过 Connection 发起和取消调用 |
97
- | Client | `@deepseek-ai/dsh-api-remotes/client` | 显式选择并挂载本应用允许使用的 `/remote` 贡献,向业务代码带入对应的声明合并 |
98
- | 双侧 | `@deepseek-ai/dsh-client-connection` | 提供 RPC carrier、请求关联、信任边界、取消、响应 envelope 与 `/api` HTTP bridge |
99
-
100
- API Gateway 包同时拥有 Host dispatcher 与 Client Remote endpoint 两个对等入口,但两侧构建不会进入同一个 `ts.Program`。Host 入口不导入 Client 的 Cordis `Context` 合并,Client 入口也不导入 Host Gateway 服务。
101
-
102
- ## 严格生成流水线
103
-
104
- 根构建依次编译并打包 Host face、Client face,再构建 Web 壳层([步骤顺序](development.zh.md#typescript-project-layout))。Host 阶段先编译 Host 包 reference,再运行 `tsdown --env.DSH_BUILD_FACE host`;Typert generator 由正常 Host Project Reference 图编译,并在这次 tsdown 中以 Host aggregate 为唯一 `ts.Program` 种子运行。Client 阶段随后编译 Client 包 reference 并运行 `tsdown --env.DSH_BUILD_FACE client`,使用刚生成的 Remote Client 声明和运行时贡献,但不再次启动 Typert。
105
-
106
- 两次 tsdown 都匹配 `vendor/*`、`packages/*/*` 与 `apps/cli`,Host 阶段另外匹配 `apps/desktop-host`([构建顺序](development.zh.md#typescript-project-layout)),且都只打包 `lib/types` 中由对应 tsc 阶段发射的 JavaScript。根配置不扫描 Client 产物、不按包名分类,也不向 tsdown 传维护式 filter;各包的本地配置根据 `DSH_BUILD_FACE` 返回当前阶段的入口。普通 Client 插件在 Client 阶段一起生成 Node loader 入口与 browser bundle。
107
-
108
- `api/remotes`、`api/gateway`、`api/session-controller` 与 `api/workspace-controller`(外加 `client/connection`)都拆分 TypeScript face。`api/remotes` 的 Client project 依赖业务包在 Host tsdown 中生成的 `/remote` 声明;根 aggregate 与直接消费方必须分别引用各拆分包自己的 `tsconfig.host.json` 或 `tsconfig.client.json`。`api-remotes` 的 `clientBundle(..., { hostPhase: true })` 让 Host 入口在 Host tsdown 中生成,让 Client tsdown 只生成 browser 入口。Agent/Session lookup 策略位于 `@deepseek-ai/dsh-api-session-controller`,而非 `api-remotes`。
109
-
110
- 每个贡献业务包把生成文件写入自己的 `lib/`,而不是源码目录:
111
-
112
- | 文件 | 消费方 | 内容 |
113
- |---|---|---|
114
- | `typert.host.js` | Host Loader | Host face 的运行时反射、严格调用描述符和 schema 注册值 |
115
- | `typert.host.d.ts` | Host 类型系统 | Host face 的生成声明 |
116
- | `typert.remote-client.js` | `api-remotes` | 可挂载的 `TypertRemoteContribution`,包含严格描述符与运行时 codec |
117
- | `typert.remote-client.d.ts` | Client 类型系统 | `TypertRemoteNamespaceMap` 与 `TypertRemoteScopeMap` 的声明合并及 Client-safe 类型引用 |
118
- | `typert.remote-client.d.ts.map` | 编辑器 | 将生成的方法属性映射回 Host 包中的 Remote 方法声明 |
119
-
120
- 业务包通过 `./typert` 暴露 Host Loader 入口,通过 `./remote` 暴露 Host-for-Client 入口。生成器同时校验这些包 export 及发布文件清单;只有具备相应入口的显式贡献包才会生成产物。
121
-
122
- Remote Client 声明中的参数名来自 wire 字段,参数和返回类型则引用原业务包导出的 Client-safe 类型。声明 map 把 `ctx.remote.goals.create` 最终解析到的生成属性映射到带 `@Remote` 的 Host 源方法,因此支持 declaration-map 的编辑器可以从 Client 调用跳到真实实现,而不是停在生成的 `.d.ts`。
123
-
124
- 严格分析要求 Remote 是公开、非静态、有具体实现的实例方法。方法不能是泛型;参数必须是具名且必填的简单标识符,不能使用解构、默认值、rest 或可选参数。可 JSON 表示的普通类型由 Typert 生成严格 schema;工作区 class 等复杂对象必须具有唯一的 `TypertLookupMap` 声明。lookup 与 Context 包同时负责静态声明合并和运行时提供方注册;缺少任一侧都会导致构建失败,或者首次调用需要该提供方时失败。
125
-
126
- ## 运行时调用
127
-
128
- Remote 调用使用 Connection 的 `/api` 路由。Client Remote 调用 `connection.rpc.call('/api', '<namespace>/<method>', { args }, signal)`;HTTP carrier 对应 `POST /api/<namespace>/<method>`,payload 只包含一个具名 `args` 对象。
129
-
130
- Connection 在 HTTP bridge 之前执行 `/api` 的统一信任检查,再在共享 FetchHandler 内分发。Typert Gateway 只认领存在严格描述符或活跃 SRC marker 的两段式 endpoint;它把二进制 Remote 字段投影为 JSON 兼容元数据及相对于结果的字节附件,再由 Connection 封装为 multipart 响应。功能自有的精确 Fetch 路由处理 RPC 信封之外的响应,其他请求返回 404。Connection 拥有传输、RPC id、响应 envelope 和请求取消,Gateway 拥有 Remote 数据协议和业务分发。替换 Connection carrier 不要求改变 Remote 描述符或 Client 编程接口。
131
-
132
- Gateway 每次调用都从当前注册表解析描述符和实时服务,不缓存业务对象。每次调用都给出其代表的 Peer,已 dispose 的 Peer 以 `gateway/peer-disposed` 被拒。Gateway 要求 `args` 的字段集合与描述符完全一致;对 Peer principal 不是 owner 的调用,随后解析调用访问的资源并询问 `ctx.remoteAccess.decide()`,被拒的调用不解析任何 lookup,也不激活 Agent。之后它先用 codec 校验 wire 值,再通过注册的 lookup 或 Context 提供方解析对象或接收者,最后调用 binding 指向的服务方法。Client Gateway 使用生成的结果 codec 校验解码后的二进制结果;普通 JSON 结果保持原有处理方式。缺少提供方、identity 未命中、binding 不一致、参数缺失或多余、schema 失败和方法不存在都会在进入业务代码前或离开业务代码后失败。
133
-
134
- lookup 提供方的 `register()` 同时提供稳定声明和默认 resolver;`configure()` 提供由 Host 组合拥有、可异步执行且受 effect 生命周期约束的 resolver。配置可以先于提供方挂载;没有提供方时调用仍以 `gateway/lookup-unavailable` 失败,配置卸载后则恢复提供方默认策略。Session Controller 负责 `agent` 与 `session` 的标准 resolver 语义:复用 live Agent,自动恢复普通冷会话,对并发恢复去重,并拒绝由 subagent routing 拥有的 identity;`session` lookup 返回该 Agent 的 Session。恢复失败与 ownership fence 抛出携带自有码的 `RemoteError`(`session/not-found` 或 `session/agent-busy`),Gateway 原样编码上 wire;只有未归类的 throw 才折成 `gateway/internal`。
135
-
136
- Client 卸载一个贡献时会一起移除描述符和具体方法,中止其进行中的调用,并使外部仍持有的陈旧方法句柄拒绝继续调用。Host 上已经注册过的严格 endpoint 被撤回后也不会降级到 SRC 推断,以免热卸载悄然降低校验强度。
137
-
138
- ## SRC 开发回退
139
-
140
- Host 通过 `node --import tsx/esm` 从源码启动时不会执行 Typert 编译插件。标准 decorator 初始化器仍会把方法名和调用模式记录到 Service 原型上的带版本描述符中,`TypertRemoteService` 或 `bindTypertRemote()` 则提供显式服务 binding;Gateway 因而可以在不启动 `ts.Program` 的情况下构造一个较弱的临时描述符。描述符使用稳定的字符串属性名,因此 `remoteMethods()` 能读取协议包另一个已安装副本写入的标记。
141
-
142
- SRC 回退从运行中函数解析简单参数名。参数名与某个已注册 lookup 的 `parameter` 相同,例如 `agent` 或 `session`,就使用其 `agentId` 或 `sessionId` wire 字段并在 Host 解析对象;其他参数只检查值是否为无循环、无特殊 prototype 的 JSON-safe 数据。`@RemoteScope` 直接使用已注册 Host Context 提供方的 wire 字段。SRC 不读取 TypeScript 类型,不生成 Zod schema,不推断可选参数,也不支持解构、默认值、rest 或重复参数名。
143
-
144
- SRC 只解决 Host 源码进程的分发问题。Client 不会从运行中的 Host 发现 decorator,Client Remote 也拒绝挂载缺少严格 codec 的 SRC 描述符;其类型、codec 和 Remote 注册值始终来自最近一次生成的 `lib/typert.remote-client.*`。
145
-
146
- ## 开发模式
147
-
148
- Web 开发只需一条命令:它先构建当前 Host、Client 与 Web 产物,再启动源码 Host,并持续重建 Client bundle:
149
-
150
- ```sh
151
- pnpm run dev:web
152
- ```
153
-
154
- `dsh` 通过 tsx 启动 Host 源码,所以 Host 可以使用 SRC 回退;`dev:web` 的 watcher 会在源码修改时重建 client 侧类型输出、Client 插件与库 bundle 以及 Web 壳层。它们不会分析 Host decorator,也不会生成 Remote Client DTS;只有 `dev:web` 首先执行的完整构建(或 `pnpm run build`)才会。
155
-
156
- 只修改 Remote 方法实现体而不改变约定时,无需重新生成 Typert 文件。新增或删除 decorator、修改导出名、namespace、参数、返回值、lookup、Context 或取消签名时,重新执行有序 lib 构建,让 Host 先生成严格约定,再让 Client 编译并打包新的贡献:
157
-
158
- ```sh
159
- pnpm run build:lib
160
- ```
161
-
162
- 运行中的 Client watcher 会在重新打包时消费这些生成文件。若已单独运行 `pnpm run build:lib:host` 刷新 Host 约定,也可再运行 `pnpm run build:lib:client` 完成 Client 侧;干净工作树不能跳过 Host 阶段。仅重新编译前端源码不能从 Host decorator 推导新类型。`pnpm run typecheck` 先以不打包的 Typert 生成刷新 Host 约定,再运行 Client tsc;CI 的构建 lane 与发布构建则在 Client tsc 之前的 Host bundle 阶段生成它。
163
-
164
- <a id="boundaries"></a>
165
-
166
- ## 边界
167
-
168
- Remote 处理单请求单结果的一元方法调用,以及项沿 Host → Client 方向流动、而 Client 的项经 `this.ctx.invocation.uplink()` 到达正在运行的 Host 方法的流方法。会话事件流、分页、增量 reduce、projection 和实体子流仍需要独立的数据协议与注册模型;即使它们复用 Connection,也不应伪装成 Remote 方法或放入调用描述符。
169
-
170
- API 各层按 `remotes → gateway → connection → webserver` 组织。BFF 与 Typert RPC 层位于 `packages/api`;Connection 与 WebServer 位于 `packages/client/connection` 和 `packages/host/webserver`。包含 `Uint8Array` 的一元结果(包括嵌套字段和数组条目)使用[二进制 Remote 传输](../.agents/notes/implemented/architecture/2026-09-17-workspace-file-binary-transfer.zh.md)。需要 RPC 信封之外响应的功能注册精确的 Connection Fetch 路由。
171
-
172
- lookup 策略按 key 配置,因此所有 `agent` 或 `session` 参数共享冷恢复行为。只接受 live 对象需要显式的逐参数或逐 endpoint 策略,而这种策略并不存在;不能通过业务方法内部猜测对象是否来自恢复。
173
-
174
- <a id="business-ownership"></a>
175
-
176
- ### 业务所有权
177
-
178
- `packages/api` 负责传输、调用形态与会话生命周期;业务规则归独立的业务包,经注册面或投影数据接入本层。这里改动必须满足的要求——`@Remote` 的四条纪律、存量名只增不改、以及本层保留的边界——正家是[远程与 API 规则](defensive-patterns/remote-and-api.zh.md),评审就在那里核对。