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,894 @@
1
+ # LLM(大语言模型)流式输出
2
+
3
+ [English](llm-streaming.md) | 中文
4
+
5
+ [`packages/llm`](../../packages/llm/README.md) 提供对话与流式输出类型:每个请求和持久历史共用的 `Message`/`ContentBlock` 变体、完整组装的模型请求、原始 `StreamChunk` 协议、每个适配器必须实现的适配器约定(adapter contract),以及共享的 assembler。[核心包](core.md)在每个轮次持有并记录这些值;本页声明它们。
6
+
7
+ 源码:[`packages/llm/llm/src/types.ts`](../../packages/llm/llm/src/types.ts)
8
+
9
+ <a id="content-blocks-and-messages"></a>
10
+
11
+ ## 内容块与消息
12
+
13
+ 一段对话由 `Message` 组成;一条消息是一个类型化**内容块**的数组。块的联合类型从 `ContentBlockMap` 派生。
14
+
15
+ 源码:[`packages/llm/llm/src/types.ts`](../../packages/llm/llm/src/types.ts)
16
+
17
+ ```ts type-equiv
18
+ /**
19
+ * Merge-extensible content blocks keyed by `type`. New core blocks must land
20
+ * with adapter, UI, and compaction support.
21
+ */
22
+ interface ContentBlockMap {
23
+ 'text': TextBlock
24
+ 'reasoning': ReasoningBlock
25
+ 'image': ImageBlock
26
+ 'tool-call': ToolCallBlock
27
+ 'tool-result': ToolResultBlock
28
+ }
29
+ ```
30
+
31
+ 各块接口(完整字段见源码):`TextBlock`(`text`)、`ReasoningBlock`(thinking,区别于可见文本)、`ImageBlock`(一个持久的[图片附件](attachment.md))、`ToolCallBlock`(`id: CallId`、`name`、原始 JSON `arguments`),以及 `ToolResultBlock`(`toolCallId`、嵌套 `content: ContentBlock[]`、`isError?`)。`ContentBlock = ContentBlockMap[ContentBlockType]`。仅当适配器、UI、压缩(compaction)和持久回放路径均支持某种新模态时,才将其纳入可合并扩展的 map。
32
+
33
+ 源码:[`packages/llm/llm/src/message.ts`](../../packages/llm/llm/src/message.ts)
34
+
35
+ `Message` 是一个带标识且不可变的角色/来源/内容值。模型生成的 assistant 消息会在来源中记录生成它的提供方和模型,以及可选的适配器私有回放数据:
36
+
37
+ ```ts type-equiv
38
+ /** Provider/model identity and adapter-private replay data for an assistant message. */
39
+ interface AssistantProvenance {
40
+ /** Provider route that produced the message. */
41
+ provider: string
42
+ /** Provider model id that produced the message. */
43
+ model: string
44
+ /**
45
+ * Lossless-JSON adapter state needed to replay the provider response.
46
+ * `LlmRuntime` exposes it to a target adapter only when that adapter instance
47
+ * currently owns both this historical provider and the target provider.
48
+ */
49
+ replayState?: unknown
50
+ }
51
+ ```
52
+
53
+ ```ts type-equiv
54
+ /** One immutable message representation shared by delivery, durable history, and model requests. */
55
+ interface Message {
56
+ /** Stable identity preserved across every representation boundary. */
57
+ readonly id: MessageId
58
+ /** Provider-neutral conversation role. */
59
+ readonly role: 'system' | 'user' | 'assistant'
60
+ /** Exact model-facing blocks. */
61
+ readonly content: ContentBlock[]
62
+ /** Required source fields supplied by the producer. */
63
+ readonly source: MessageSource
64
+ }
65
+ ```
66
+
67
+ 消息来源本身也是一个可合并扩展的和类型:
68
+
69
+ ```ts type-equiv
70
+ /**
71
+ * Where a message (or injected content) came from.
72
+ * Merge-extensible sum type — plugins add their own `kind`s.
73
+ */
74
+ interface MessageSourceMap {
75
+ user: { kind: 'user' }
76
+ plugin: { kind: 'plugin'; plugin: string } & ContextFormed
77
+ model: ModelMessageSource
78
+ tool: ToolMessageSource
79
+ }
80
+ ```
81
+
82
+ 生产方标识与呈现形式相互独立。`kind` 回答「由谁产生」;可选的 `form` 回答「这是什么类型的信息」,消费方决定如何呈现。多个生产方可以共用一种 `form`,一个生产方在一次会话中也可以发出多种 `form`。这些取值描述语义,并逐个增加;未声明或无法识别的值使用文档规定的默认值,按不透明内容呈现:
83
+
84
+ ```ts type-equiv
85
+ /**
86
+ * The kind of information in producer-supplied context, declared by the
87
+ * producer beside its provenance.
88
+ *
89
+ * `MessageSource.kind` answers *who produced this*; `form` answers *what kind
90
+ * of thing it is*, and the two axes are deliberately independent — several
91
+ * producers share one form, and one producer may emit more than one form over
92
+ * a session.
93
+ *
94
+ * The vocabulary is SEMANTIC, never visual: a value states that the content is
95
+ * a file's instructions or a catalog of available items, and a consumer decides
96
+ * what that looks like. Colors, icons, ordering, and collapse defaults are the
97
+ * consumer's business and must not enter this union. It grows one value at a
98
+ * time as producers gain the structured fields their form needs; an absent or
99
+ * unknown value is the documented default, presented as opaque content.
100
+ */
101
+ type ContextForm =
102
+ /** Instructions read out of workspace files the model is expected to follow. */
103
+ | 'instructions'
104
+ /** A catalog of items available in this session, republished as it changes. */
105
+ | 'catalog'
106
+ /** Current state, where a later snapshot from the same producer supersedes an earlier one. */
107
+ | 'snapshot'
108
+ /** A one-off account of something that just happened; it supersedes nothing. */
109
+ | 'notice'
110
+ /** A message another agent addressed to this one. */
111
+ | 'relay'
112
+ /** Material lifted out of another session's log, possibly reduced on the way in. */
113
+ | 'recall'
114
+ ```
115
+
116
+ ```ts type-equiv
117
+ /** One named contribution to a `snapshot`-form context, in assembly order. */
118
+ interface ContextSnapshotSection {
119
+ /** The contributing subsystem's name. */
120
+ readonly name: string
121
+ /** That contribution's model-facing text, exactly as assembled. */
122
+ readonly text: string
123
+ }
124
+ ```
125
+
126
+ ```ts type-equiv
127
+ /**
128
+ * Producer-declared {@link ContextForm} and the fields that form requires,
129
+ * mixed into the source types that carry one.
130
+ *
131
+ * Discriminated by `form` so a producer cannot select a form without the
132
+ * fields needed to present it: a `notice` must record its one-line
133
+ * account, a `snapshot` its sections. Omitting `form` stays valid — an
134
+ * undeclared context is the documented default.
135
+ */
136
+ type ContextFormed =
137
+ | { readonly form?: never }
138
+ | { readonly form: 'instructions' }
139
+ | { readonly form: 'catalog' }
140
+ | {
141
+ readonly form: 'snapshot'
142
+ /** The named contributions this snapshot assembled, in order. */
143
+ readonly sections: readonly ContextSnapshotSection[]
144
+ }
145
+ | {
146
+ readonly form: 'notice'
147
+ /** One-line account of what happened, shown without expanding the row. */
148
+ readonly summary: string
149
+ }
150
+ | { readonly form: 'relay' }
151
+ | { readonly form: 'recall' }
152
+ ```
153
+
154
+ <a id="streamchunk--the-raw-protocol"></a>
155
+
156
+ ## `StreamChunk`:原始协议
157
+
158
+ 一个流式响应交错包含多种类型的块(文本、推理(reasoning)、多个工具调用)。`index` 将每个 delta 关联到其所属块;`block-end` 携带完整组装好的 `ContentBlock`,消费方无需自行重新组装 delta。这是一个**封闭的**可辨识联合类型:对 `type` 的 `switch` 以 `assertNever` 结尾,因此新增变体会在每个必须处理它的消费方处触发编译错误。
159
+
160
+ ```ts type-equiv
161
+ /**
162
+ * Raw streaming protocol emitted by adapters.
163
+ * Block indexes correlate interleaved deltas, and `block-end` carries the
164
+ * assembled block. Adapters emit usage before the terminal finish and nothing
165
+ * afterward; tool arguments remain raw JSON strings. An adapter implementation
166
+ * may throw, but `LlmRuntime.stream()` normalizes that failure to a terminal
167
+ * `error` or `aborted` finish before exposing it to consumers.
168
+ */
169
+ type StreamChunk =
170
+ | { type: 'block-start'; index: number; blockType: ContentBlockType }
171
+ | { type: 'text-delta'; index: number; text: string }
172
+ | { type: 'reasoning-delta'; index: number; text: string }
173
+ | { type: 'tool-call-delta'; index: number; id: CallId; name?: string; argumentsDelta: string }
174
+ | { type: 'block-end'; index: number; block: ContentBlock }
175
+ | { type: 'usage'; usage: TokenUsage }
176
+ | {
177
+ type: 'finish'
178
+ reason: FinishReason
179
+ /** Adapter-private lossless-JSON state for replaying a successful response. */
180
+ replayState?: unknown
181
+ }
182
+ ```
183
+
184
+ <a id="llmfailure"></a>
185
+
186
+ ## `LlmFailure`
187
+
188
+ 每个抛出的失败或最终适配器的带内失败都会规范化为一种可序列化、提供方无关的 payload。`providerRetryAfterMs` 是经校验、由提供方请求的正数延迟,而不是重试决策;`ProviderRequestId` 是用于诊断的不透明品牌字符串。
189
+
190
+ ```ts type-equiv
191
+ /** Serializable provider or transport failure facts; policy decides whether they are retryable. */
192
+ interface LlmFailure {
193
+ /** Human-readable provider or transport failure. */
194
+ readonly message: string
195
+ /** Stable provider-neutral machine-routing code. */
196
+ readonly code: string
197
+ /** HTTP status returned by the provider, when available. */
198
+ readonly status?: number
199
+ /** Provider-requested delay in milliseconds, when valid and available. */
200
+ readonly providerRetryAfterMs?: number
201
+ /** Opaque provider-issued request identifier for diagnostics. */
202
+ readonly requestId?: ProviderRequestId
203
+ }
204
+ ```
205
+
206
+ ## 适配器约定
207
+
208
+ 每个适配器必须遵守以下规则,每个消费方可以依赖它们:
209
+
210
+ - **`usage` 在 `finish` 之前,`finish` 之后不再有任何分片。** 将两者都推迟到提供方的流结束标记,这样尾部的 usage-only 分片就不会违反顺序。
211
+ - **工具调用的 `arguments` 全程保持原始 JSON 字符串。** 部分片段通过 `argumentsDelta` 流式传输;如果提供方返回的是已解析的对象,适配器在 `block-end` 时重新序列化为字符串。
212
+ - **两条受支持的错误路径,共用一个 `LlmFailure` 类型。** 失败可以从 `stream()` 抛出(传输/协议错误),**或者**以 `finish {kind:'error'|'aborted', failure}` 结束流(无法在流中途抛异常的适配器用它表示提供方带内错误)。`LlmError.failure` 携带同一个 `LlmFailure`。调用选定适配器后,流会保留被抛出的确切 `Error` 对象,并将不可变事实以及实际服务注册所对应的不可变重试策略关联到该调用;agent loop(智能体循环)关闭失败步骤,再把错误、事实、不可变的先前已重试失败事实、实际服务策略和轮次信号提供给 `agent/request-error`。处理该错误的 listener 在其 await 的修复完成后返回 `{ kind: 'retry' }`;若未恢复,结构化失败会成为轮次错误,并且该次尝试不会提交正常 assistant 消息或工具副作用。
213
+ - **一次适配器调用就是一次提供方尝试。** 适配器禁用库重试。agent 层恢复会打开另一个持久、带编号的轮次;直接调用 `ctx.llm.stream()` 的调用方仍然只尝试一次。
214
+ - **提供方停顿在传输层受到时限约束。** 两个已交付的远程适配器都暴露正数且有限的 `streamIdleTimeoutMs`,默认五分钟。watchdog 只在 iterator `next()` 尚未完成时启动,整个请求使用同一个稳定 signal,把自身到期映射为 `TIMEOUT`,并把更早发生的调用方中止保留为 `ABORTED`。
215
+ - **上下文溢出只有一个规范 code。** 两个 DeepSeek 适配器都通过 `isContextWindowExceededError()` 对提供方的显式细节分类并暴露 `CONTEXT_WINDOW_EXCEEDED`,无论失败以抛出的 HTTP `LlmError` 还是带内 finish error 到达。消费方按 code 路由,绝不依赖提供方文本。
216
+ - **空 completion 是可重试错误,而不是静默的成功结果。** 两个适配器都把没有携带任何内容块的终止性 `stop` 结束映射为携带规范 `EMPTY_RESPONSE` code 的 `finish {kind:'error'}`,`dsh-llm-retry` 默认会重试它;详见[空模型响应可重试](../../.agents/notes/implemented/bug-fix/2026-07-24-empty-model-response-is-retryable.md)。
217
+ - **每个提供方 HTTP 请求都携带应用归属头。** 适配器发送 `attributionHeaders()`(见下文)作为 `User-Agent` 基线,并通过协议级测试加以证明。
218
+ - **回放状态归适配器所有。** 成功的 `finish` 可以携带重建提供方原生响应所需的无损 JSON 状态。循环会将其与组装后的 assistant 消息一起存储。后续请求中,仅当历史提供方与目标提供方当前注册到完全相同的适配器实例时,`LlmRuntime` 才会传递该状态。该适配器负责校验状态并拥有所有跨模型或跨提供方转换;其他适配器只会收到提供方无关的内容以及提供方/模型字段,不会收到私有状态。
219
+
220
+ ## `ResolvedRetryPolicy`
221
+
222
+ 提供方配置会在路由注册前解析为不可变的可辨识联合。normal mode 携带 `mode: 'normal'`、有限的 `maxRetries`、`retryableCodes`,以及必填的 `initialDelayMs`、`maxDelayMs` 与 `jitterRatio`;always mode 携带 `mode: 'always'` 和相同的必填退避字段,但没有有限上限。`LlmRuntime.providerRetryPolicy(provider)` 返回当前注册的值,并在适配器省略策略时提供 normal 默认值;调用选定该注册后,`llmRetryPolicyOf(stream)` 返回为该调用服务的注册所捕获的值,因此之后释放或替换路由都无法改变进行中失败的恢复策略。可选配置输入字段由[生成的配置目录](../config-catalog.md)列出。
223
+
224
+ ## `AppIdentity`:应用归属
225
+
226
+ 每个适配器都会向提供方发送的静态公开应用标识([`packages/llm/llm/src/attribution.ts`](../../packages/llm/llm/src/attribution.ts))。`attributionHeaders(identity?)` 只把它映射到标准 `User-Agent` header;该约定有意不支持 OpenRouter 特有的应用归属 header。默认 `APP_IDENTITY` 从包 manifest(元数据清单)获取版本;每个字段都是公开产品事实——不含 secret、路径、会话 id 或逐用户标识,且任何逐请求信息都不得影响这些值。设计理由见[强制 `User-Agent` 归属](../../.agents/notes/implemented/architecture/2026-06-21-mandatory-app-attribution-headers.md)。
227
+
228
+ ```ts type-equiv
229
+ /**
230
+ * Static public application identity sent to LLM providers.
231
+ *
232
+ * Every field is a public product fact, safe on every request: no secrets,
233
+ * local paths, session ids, prompt text, or per-user identifiers belong here,
234
+ * and nothing per-request may influence the values.
235
+ */
236
+ interface AppIdentity {
237
+ /** `User-Agent` product token (lowercase, hyphenated). */
238
+ product: string
239
+ /** Product version; sourced from package metadata, never hand-copied. */
240
+ version: string
241
+ /** Repository home URL of the app, used as the `User-Agent` comment. */
242
+ url: string
243
+ }
244
+ ```
245
+
246
+ <a id="tokenusage"></a>
247
+
248
+ ## `TokenUsage`
249
+
250
+ 逐调用 token 记账。各计数**互不重叠**:`inputTokens` 只包含未缓存输入;缓存输入单独报告,计费输入是三者之和。若提供方把缓存命中折入单一提示词总数(如 DeepSeek 的 `prompt_tokens`),适配器会再将其扣除。`reasoningTokens` 存在时只是信息性细节,已经包含在 `outputTokens` 中;汇总时不得重复相加。
251
+
252
+ ```ts type-equiv
253
+ /**
254
+ * Token accounting for one model call (cache fields are optional).
255
+ *
256
+ * Counts are DISJOINT: `inputTokens` is uncached input only; cached input is
257
+ * reported separately as `cacheReadTokens`/`cacheWriteTokens` (billed input =
258
+ * sum of the three). Adapters whose providers fold cache hits into a total
259
+ * prompt count (DeepSeek's `prompt_tokens`) subtract them out.
260
+ */
261
+ interface TokenUsage {
262
+ inputTokens: number
263
+ outputTokens: number
264
+ cacheReadTokens?: number
265
+ cacheWriteTokens?: number
266
+ reasoningTokens?: number
267
+ }
268
+ ```
269
+
270
+ <a id="blockassembler"></a>
271
+
272
+ ## `BlockAssembler`
273
+
274
+ `BlockAssembler`([`packages/llm/llm/src/assembler.ts`](../../packages/llm/llm/src/assembler.ts))是唯一的共享实现,负责把 `StreamChunk` 流折叠回 `ContentBlock`、usage、结束原因与回放状态。循环在记录原始分片的同时,把同一批分片送入 assembler,再将组装后的 assistant 内容连同生成它的提供方和模型一起存储。需要组装结果、又不想重新实现 fold 的消费方使用它。
275
+
276
+ ```ts public-api
277
+ /**
278
+ * Incrementally assembles raw {@link StreamChunk}s into complete
279
+ * {@link ContentBlock}s and a final assistant {@link Message}.
280
+ *
281
+ * The agent loop feeds it while logging raw chunks for replay fidelity, then
282
+ * reads `blocks()` / `message()` / `usage` / `finish` once the stream ends.
283
+ *
284
+ * Tolerant of delta-only protocols (no block-start/end); deltas arriving for
285
+ * an index already closed by `block-end` are ignored (malformed stream) so a
286
+ * misbehaving adapter cannot grow memory or corrupt a completed block.
287
+ */
288
+ declare class BlockAssembler {
289
+ /**
290
+ * Feed one chunk into the assembly state.
291
+ * @param chunk - the next raw chunk, in stream order.
292
+ */
293
+ push(chunk: StreamChunk): void;
294
+ /**
295
+ * Assemble all blocks seen so far, in stream order.
296
+ * @returns one block per seen index, except that max-token truncation drops
297
+ * tool calls that cannot be executed safely; an open block assembles from
298
+ * its accumulated deltas (an unknown block type never closed by `block-end` throws).
299
+ */
300
+ blocks(): ContentBlock[];
301
+ /** Usage from the `usage` chunk; undefined until one arrives. */
302
+ get usage(): TokenUsage | undefined;
303
+ /** Finish reason from the `finish` chunk; `{kind: 'stop'}` when the stream ended without one. */
304
+ get finish(): FinishReason;
305
+ /** Adapter-private replay state from the terminal finish chunk, if any. */
306
+ get replayState(): unknown;
307
+ /**
308
+ * The assembled assistant message.
309
+ * @param source - producer attribution for the assembled message.
310
+ * @returns a frozen assistant-role message over `blocks()` (same open-block assembly rules).
311
+ */
312
+ message(source: MessageSource = { kind: 'plugin', plugin: 'dsh-llm/assembler' }): Message;
313
+ }
314
+ ```
315
+
316
+ <a id="the-model-request-and-result"></a>
317
+
318
+ ## 模型请求
319
+
320
+ 一次模型调用是一个完全组装好的 `GenerateOptions`。适配器以原始 [`StreamChunk`](#streamchunk--the-raw-protocol) 流作答;消费方用 [`BlockAssembler`](#blockassembler) 组装它。
321
+
322
+ 源码:[`packages/llm/llm/src/types.ts`](../../packages/llm/llm/src/types.ts)
323
+
324
+ 提供方与模型发现使用小型、提供方无关的描述符。模型目录仅供参考:路由仍以已注册提供方为键,适配器也可以接受未列出的模型 id。
325
+
326
+ 注册适配器会返回一个句柄:既是释放器,也带有原子的路由替换——路由集合由用户配置决定的插件正需要它。
327
+
328
+ ```ts type-equiv
329
+ /**
330
+ * What {@link LlmRuntime.registerAdapter} returns: the disposer, plus an
331
+ * atomic route replacement for the same adapter instance.
332
+ */
333
+ interface AdapterRegistrationHandle {
334
+ /** Release every route this registration currently holds. */
335
+ (): void
336
+ /**
337
+ * Replace this registration's routes with `providers`, keeping the same
338
+ * adapter instance. The candidate set is validated in full first — a
339
+ * conflict with another adapter, an invalid name, or bad provider metadata
340
+ * throws and leaves the current routes untouched — and the swap itself is
341
+ * one synchronous section, so no request can observe a gap. An empty array
342
+ * is legal here (a settings section that emptied holds zero routes while
343
+ * staying registered), unlike an empty initial registration.
344
+ *
345
+ * Throws `LlmError` with code `REGISTRATION_DISPOSED` once the registration
346
+ * has been released: its routes are gone and its disposer has already run,
347
+ * so anything registered afterwards would have no owner left to release it.
348
+ * @param providers - the complete next route set for this registration.
349
+ */
350
+ replace(providers: string[]): void
351
+ }
352
+ ```
353
+
354
+ ```ts type-equiv
355
+ /** Display metadata for one registered provider route. */
356
+ interface LlmProviderInfo {
357
+ /** Provider route key used by {@link GenerateOptions.provider}. */
358
+ id: string
359
+ /** Human-readable provider name for selectors and diagnostics. */
360
+ name: string
361
+ }
362
+ ```
363
+
364
+ 适配器插件还会通过 `registerConfigurableProviders()` 声明哪些路由*可以*运行,并指明每条路由的用户设置分节,使配置界面能在任何路由注册之前就呈现休眠的提供方。
365
+
366
+ ```ts type-equiv
367
+ /**
368
+ * One provider route an adapter plugin can activate through configuration,
369
+ * whether or not the route is currently registered. Configuration surfaces
370
+ * merge this directory with `listProviders()` to offer every configurable
371
+ * provider alongside its live/dormant state.
372
+ */
373
+ interface LlmConfigurableProvider {
374
+ /** Provider route key this entry activates when configured. */
375
+ provider: string
376
+ /** Human-readable provider name for configuration surfaces. */
377
+ displayName: string
378
+ /** User-settings namespace whose section configures this provider. */
379
+ settingsNs: string
380
+ /**
381
+ * Path from that namespace's section root to this provider's profile
382
+ * object; empty when the whole section is the profile.
383
+ */
384
+ settingsPath: readonly string[]
385
+ /**
386
+ * Whether the owning adapter knows this route only because configuration
387
+ * declared it — a gateway or self-hosted server it ships nothing about.
388
+ * Absent means the adapter draws no such distinction; false means it does
389
+ * and this route is one of its own. Only the adapter can answer: a stored
390
+ * profile is how a user-added route AND a corrected shipped one both look
391
+ * from outside.
392
+ */
393
+ declared?: boolean
394
+ }
395
+ ```
396
+
397
+ ```ts type-equiv
398
+ /** One adapter-discovered model; catalog membership is advisory, not request validation. */
399
+ interface LlmModelInfo {
400
+ /** Provider route that owns this model entry. */
401
+ provider: string
402
+ /** Model id passed to {@link GenerateOptions.model}. */
403
+ id: string
404
+ /** Human-readable model name for selectors. */
405
+ name: string
406
+ /** Optional user-facing distinction from otherwise similar models. */
407
+ description?: string
408
+ /** Accepted request modalities; absent means unknown, while an explicit omission is negative capability. */
409
+ inputModalities?: readonly ModelModality[]
410
+ }
411
+ ```
412
+
413
+ 对正确性敏感的元数据与参考目录分开解析,并归服务该确切路由的适配器所有。上下文容量、适配器调用默认值和推理选项共用同一个确切模型结果,消费方因而无需重复执行权威模型解析。
414
+
415
+ ```ts type-equiv
416
+ /** Provider-owned context capacity for one exact provider/model route. */
417
+ interface LlmModelContext {
418
+ /** Maximum combined request and response context in tokens. */
419
+ contextWindow: number
420
+ }
421
+ ```
422
+
423
+ 推理强度是另一项针对确切路由的能力。核心为标识符添加品牌类型,但不枚举其值;有序集合、展示名称和可选的部署默认值均由各适配器持有。
424
+
425
+ ```ts type-equiv
426
+ /** Adapter-owned identifier for one model's selectable reasoning effort. */
427
+ type ReasoningEffortId = Branded<'ReasoningEffortId'>
428
+ ```
429
+
430
+ ```ts type-equiv
431
+ /** Display metadata for one adapter-owned reasoning effort. */
432
+ interface LlmReasoningEffortInfo {
433
+ /** Opaque stable value accepted by {@link GenerateOptions.reasoningEffort}. */
434
+ id: ReasoningEffortId
435
+ /** Human-readable effort name for selectors and diagnostics. */
436
+ name: string
437
+ /** Optional user-facing distinction from otherwise similar efforts. */
438
+ description?: string
439
+ }
440
+ ```
441
+
442
+ ```ts type-equiv
443
+ /** Selectable reasoning efforts for one exact provider/model route. */
444
+ interface LlmModelReasoningInfo {
445
+ /** Supported efforts in adapter-preferred display order. */
446
+ efforts: readonly LlmReasoningEffortInfo[]
447
+ /**
448
+ * Adapter-configured default materialized into requests when callers omit
449
+ * an effort. Absence preserves the provider's own default.
450
+ */
451
+ defaultEffort?: ReasoningEffortId
452
+ }
453
+ ```
454
+
455
+ ```ts type-equiv
456
+ /** Exact-route model metadata resolved by its owning adapter. */
457
+ interface LlmResolvedModelInfo extends LlmModelInfo {
458
+ /** Provider-owned context capacity when known. */
459
+ context?: LlmModelContext
460
+ /** Adapter-configured per-request output cap materialized when callers omit one. */
461
+ defaultMaxTokens?: number
462
+ /** Adapter-owned selectable reasoning levels when exposed. */
463
+ reasoning?: LlmModelReasoningInfo
464
+ }
465
+ ```
466
+
467
+ ```ts type-equiv
468
+ /** A single model request, fully assembled. */
469
+ interface GenerateOptions {
470
+ /** Registered provider route selecting the adapter instance. */
471
+ provider: string
472
+ model: string
473
+ /** Adapter-owned reasoning effort selected for this exact model. */
474
+ reasoningEffort?: ReasoningEffortId
475
+ /**
476
+ * Ordered conversation messages, exactly as the provider sees them (after
477
+ * the `system` slot). A loop-built request assembles them as
478
+ * the derived history (dsh-agent-loop); a hand-built one-shot passes any list.
479
+ */
480
+ messages: Message[]
481
+ /** System prompt text (adapters map to the provider's system slot). */
482
+ system?: string
483
+ /** Tool schemas (adapters map to the provider's `tools` field). */
484
+ tools?: ToolSchema[]
485
+ temperature?: number
486
+ maxTokens?: number
487
+ /**
488
+ * Stop sequences: generation halts as soon as the model produces any one of
489
+ * these strings (adapters map to the provider's stop field, e.g. OpenAI
490
+ * `stop`). The stop string itself is not included in the output.
491
+ */
492
+ stop?: string[]
493
+ signal?: AbortSignal
494
+ /**
495
+ * Session identity stamped by the loop for request routing. Replay uses it
496
+ * to separate cursors; adapters may map it to model-hidden transport metadata.
497
+ */
498
+ sessionId?: Branded<'SessionId'>
499
+ /**
500
+ * Provider-neutral classification for an auxiliary model call. Adapters may
501
+ * map the purpose to model-hidden transport metadata or purpose-specific
502
+ * generation policy. Ordinary conversation requests leave it unset.
503
+ */
504
+ purpose?: 'compaction' | 'session-title'
505
+ }
506
+ ```
507
+
508
+ 模型响应为何停止由可合并扩展的原因表示。提供方终态失败携带流式约定的 [`LlmFailure`](#llmfailure):
509
+
510
+ ```ts type-equiv
511
+ /**
512
+ * Why a model response stopped.
513
+ * Merge-extensible so adapters can surface provider-specific reasons.
514
+ */
515
+ interface FinishReasonMap {
516
+ 'stop': { kind: 'stop' }
517
+ 'tool-calls': { kind: 'tool-calls' }
518
+ 'max-tokens': { kind: 'max-tokens' }
519
+ 'aborted': { kind: 'aborted'; failure: LlmFailure }
520
+ 'error': { kind: 'error'; failure: LlmFailure }
521
+ }
522
+ ```
523
+
524
+ `FinishReason = FinishReasonMap[keyof FinishReasonMap]`。`TokenUsage`(逐调用计量,含不相交的缓存字段)详见[下文](#tokenusage)。
525
+
526
+ `GenerateOptions.tools` 携带 `ToolSchema`——工具的 JSON Schema 描述,发送给模型。它声明在 dsh-llm(而非 dsh-tools)中,正是因为它是循环每一步组装请求的一部分:
527
+
528
+ ```ts type-equiv
529
+ /**
530
+ * JSON-schema description of a tool, as sent to the model.
531
+ *
532
+ * Declared here (not in dsh-tools) because it is part of {@link GenerateOptions};
533
+ * dsh-tools' ToolDefinition and dsh-system-prompt's PromptAssembly both import
534
+ * it from this package.
535
+ */
536
+ interface ToolSchema {
537
+ name: string
538
+ description: string
539
+ /** JSON Schema object for the arguments. */
540
+ parameters: Record<string, unknown>
541
+ }
542
+ ```
543
+
544
+ 面向模型的 `ToolSchema` 是协议类型;产出它的已注册 `ToolDefinition`(schema + `execute`)在 [tools.md](tools.md) 中。
545
+
546
+ 界面正在起草的提供方既没有路由也没有 catalog,因此询问被单独描述:请求携带用户正在编辑的草稿,回复是界面可以采纳的候选,而不是它必须服务的 catalog。
547
+
548
+ ```ts type-equiv
549
+ /**
550
+ * One interrogation of a provider endpoint that configuration has not stored
551
+ * yet. Configuration surfaces send the draft a user is still editing, so the
552
+ * request carries the endpoint and credential directly instead of naming a
553
+ * route: a provider being added has no route to name.
554
+ */
555
+ interface LlmModelDiscoveryRequest {
556
+ /**
557
+ * Route the draft is editing, when it edits an existing one. A route whose
558
+ * adapter already knows its models answers from that knowledge instead of
559
+ * asking the endpoint — the adapter's own registry is the better answer, and
560
+ * it costs no network call.
561
+ */
562
+ provider?: string
563
+ /**
564
+ * Endpoint to interrogate. Optional because a route the adapter already
565
+ * describes needs none; a route it does not must supply one.
566
+ */
567
+ baseURL?: string
568
+ /** Wire protocol the endpoint speaks, when the draft names one. */
569
+ api?: string
570
+ /** Credential for this interrogation alone; the harness never stores it. */
571
+ apiKey?: string
572
+ /** Caller cancellation; implementations must settle promptly after it aborts. */
573
+ signal?: AbortSignal
574
+ }
575
+ ```
576
+
577
+ ```ts type-equiv
578
+ /**
579
+ * One model an endpoint reports about itself. Every field but the id is
580
+ * optional because most provider listings disclose an id and nothing else;
581
+ * a surface adopting one of these still owes the capacities its adapter needs.
582
+ */
583
+ interface LlmDiscoveredModel {
584
+ /** Model id the endpoint accepts. */
585
+ id: string
586
+ /** Human-readable name when the endpoint supplies one. */
587
+ name?: string
588
+ /** Maximum combined request and response context, when disclosed. */
589
+ contextWindow?: number
590
+ /** Maximum output tokens, when disclosed. */
591
+ maxTokens?: number
592
+ }
593
+ ```
594
+
595
+ ### 请求信封:`LlmCallConfig` 与记录的 header
596
+
597
+ 循环从已记录状态构建每个请求。`EpochHeader` 记录调用配置,标记由适配器默认值提供的字段,并通过完整的 `request/header` 快照记录渲染后的提示词以及权威返回工具顺序(由 `toolOrder` 配置;未配置时按字典序)。结合派生历史,请求便可由会话日志重建。见 [session.md](session.md#the-request-header-event-requestheader) 与[可重建性 Agent Note](../../.agents/notes/implemented/architecture/2026-07-05-reconstructable-requests.md)。
598
+
599
+ `agent/request` 接收冻结的调用配置种子,并可返回替代值以切换提供方、模型、推理强度或采样参数。waterfall(瀑布式事件)开始前,循环会移除标记为适配器默认值的值,使确切模型准备过程填入所选路由的当前值;未带标记的显式设置仍保留在提议中。waterfall 结束后,准备过程会在轮次信号控制下拒绝显式指定但不受支持的推理强度 ID(不自动调整),并记录生效配置以及由适配器默认值提供的字段。准备完成的调用直至分派完成始终持有同一项适配器注册。到达 `llm/stream` 的请求会被深度冻结,因此变更会抛异常;请求还携带进程本地循环标识,使观察者不会把单独记录的冻结辅助调用误认成对话请求。
600
+
601
+ 在协议中,循环构建的请求先读取 `system` slot(渲染后的提示词组装),再读取派生历史。已记录的请求快照会以最新的 `user/message`(轮次首步)或上一步的工具结果(后续步骤)结尾。开发不变式针对每个循环构建的请求精确重算此等式。
602
+
603
+ FIXME(call-config-shape):重新审视其余哪些字段出于缓存目的确实属于 epoch 层级(`model` 和模型持有的推理强度已明确属于;采样标量目前出于谨慎保留在此)。
604
+
605
+ ```ts type-equiv
606
+ /**
607
+ * Provider, model, reasoning effort, and sampling scalars of one conversation's
608
+ * requests. Every field maps 1:1 onto the same-named `GenerateOptions` field;
609
+ * the loop builds requests from the logged header rather than accepting these
610
+ * per call.
611
+ */
612
+ interface LlmCallConfig {
613
+ provider: string
614
+ model: string
615
+ reasoningEffort?: ReasoningEffortId
616
+ temperature?: number
617
+ maxTokens?: number
618
+ stop?: string[]
619
+ }
620
+ ```
621
+
622
+ ```ts type-equiv
623
+ /**
624
+ * Effective config fields supplied by exact-model adapter resolution rather
625
+ * than by the caller's request proposal.
626
+ */
627
+ interface LlmCallConfigAdapterDefaults {
628
+ reasoningEffort?: true
629
+ maxTokens?: true
630
+ }
631
+ ```
632
+
633
+ ## 服务与提供方约定
634
+
635
+ `LlmAdapter` 是提供方约定:创建子类、实现 `stream()`,再用 `ctx.llm.registerAdapter(providers, adapter)` 注册一个适配器实例。`GenerateOptions.provider` 选择已注册适配器;`GenerateOptions.model` 会传给该适配器,无需在生命周期启动时注册。重复提供方路由会原子失败。可选的 `providerRetryPolicy()` 会按路由捕获并填入 normal 默认值,`providerInfo()` 与异步 `listModels()` 方法则为 `LlmRuntime.listProviders()` / `listModels()` 提供分离的 selector 元数据。该目录仅供参考,不是请求白名单:适配器仍是权威,并可接受未列出的模型 id。单次异步 `resolveModel()` 查询返回确切模型身份,以及可选的对正确性敏感的上下文容量、适配器配置的 `defaultMaxTokens`、由模型持有的有序推理强度 ID 和可选的部署默认值;字段缺失表示元数据不可用或保留提供方持有的行为,而不表示目录成员关系无效。解析器会接收可选的取消信号,并且必须在信号中止后迅速完成结算。`LlmRuntime.resolveModelInfo()` 会校验聚合结果并返回分离值。在最终适配器边界,`resolveCallConfig()` 仅在 `maxTokens` 缺失时填入输出默认值,并校验和填入推理强度,因此直接调用也无法绕过任何一项已配置行为;直接分派会在等待解析前捕获一项适配器注册。agent loop 则使用 `prepareCall()`,使模型解析、请求头持久记录和分派全程使用同一项注册,保留来自同一次查询的分离上下文元数据,并报告适配器填入的配置字段。适配器查找发生在 `llm/stream` waterfall 的终端 continuation,因此 listener 可以在查找前短路调用,或路由一个可变的一次性请求。AgentLoop 在外层 waterfall 返回流句柄时观察到一次请求尝试;这个有限边界不能证明惰性终端适配器已构造完成或开始提供方 I/O。`block-start` / `block-end` 的 `index` 关联与 assembler 共同意味着适配器只需 emit 格式正确的分片——块重组不是每个适配器各自的问题。`ctx.llm.stream()` 与 `llm/stream` waterfall 在一个轮次中的位置见 [architecture.md](../architecture.md#turn-flow)。
636
+
637
+ ```ts type-equiv
638
+ /** One model call whose config and adapter registration were resolved together. */
639
+ interface PreparedLlmCall {
640
+ /** Detached, deep-frozen config with any adapter-owned default materialized. */
641
+ readonly config: LlmCallConfig
642
+ /** Immutable retry policy captured with the adapter registration. */
643
+ readonly retryPolicy: ResolvedRetryPolicy
644
+ /** Detached context metadata resolved with the registration-bound call. */
645
+ readonly context?: LlmModelContext
646
+ /** Config fields materialized by the captured adapter rather than proposed by the caller. */
647
+ readonly adapterDefaults: LlmCallConfigAdapterDefaults
648
+ /**
649
+ * Dispatch this call once through the registration captured during
650
+ * preparation. The request's call-config fields must match {@link config};
651
+ * reuse or mismatch fails with `INVALID_PREPARED_CALL`.
652
+ * @param options - fully assembled request carrying the prepared config.
653
+ * @returns the chunk stream, including the `llm/stream` waterfall.
654
+ */
655
+ stream(options: GenerateOptions): AsyncIterable<StreamChunk>
656
+ }
657
+ ```
658
+
659
+ ```ts public-api
660
+ /**
661
+ * Provider-wire adapter for the harness message and stream vocabulary. Register implementations
662
+ * with `ctx.llm.registerAdapter(providers, adapter)`. Every provider HTTP request must include
663
+ * `attributionHeaders()`; prove the headers are added in the wire request or library header hook. The direct-fetch
664
+ * DeepSeek and library-backed pi-ai adapters meet this contract through different internals.
665
+ */
666
+ declare abstract class LlmAdapter {
667
+ /**
668
+ * Describe one provider route owned by this adapter.
669
+ * @param provider - a route passed to `registerAdapter()` for this instance.
670
+ * @returns detached display metadata whose id must equal `provider`.
671
+ */
672
+ providerInfo(provider: string): LlmProviderInfo;
673
+ /**
674
+ * Return the provider-owned retry policy captured with this route.
675
+ * @param _provider - a route passed to `registerAdapter()` for this instance.
676
+ * @returns a resolved policy, or `undefined` to use the normal defaults.
677
+ */
678
+ providerRetryPolicy(_provider: string): ResolvedRetryPolicy | undefined;
679
+ /**
680
+ * List models this adapter can currently advertise for one owned provider.
681
+ * The result is advisory: an adapter may accept unlisted model ids, and
682
+ * consumers must not turn absence into request rejection.
683
+ * @param _provider - one provider route owned by this adapter.
684
+ * @returns discoverable models in adapter-preferred order.
685
+ */
686
+ listModels(_provider: string): Promise<readonly LlmModelInfo[]>;
687
+ /**
688
+ * Resolve all metadata available for one exact model. This query is
689
+ * independent of the advisory catalog and does not validate request routing.
690
+ * @param provider - one provider route owned by this adapter.
691
+ * @param model - exact model id passed to {@link GenerateOptions.model}.
692
+ * @param _signal - cancellation for this exact-model lookup; asynchronous
693
+ * implementations must settle promptly after it aborts.
694
+ * @returns provider/model identity plus any context, call-default, and reasoning metadata.
695
+ */
696
+ resolveModel(
697
+ provider: string,
698
+ model: string,
699
+ _signal?: AbortSignal,
700
+ ): Promise<LlmResolvedModelInfo>;
701
+ /**
702
+ * Stream one model call as raw chunks. The only required method.
703
+ * @param options - the fully-assembled request; implementations must honor `options.signal`.
704
+ * @returns the chunk stream, obeying the adapter contract documented on `StreamChunk`.
705
+ */
706
+ abstract stream(options: GenerateOptions): AsyncIterable<StreamChunk>;
707
+ }
708
+ ```
709
+
710
+ `ContentBlockType`(带 `index` 关联的块所携带的键集合)从上文的 [`ContentBlockMap`](#content-blocks-and-messages) 派生。
711
+
712
+ <!-- BEGIN GENERATED cordis-surface (gen-cordis-catalog.ts) — do not edit between markers -->
713
+
714
+ <a id="cordis-surface"></a>
715
+
716
+ ## Cordis API
717
+
718
+ 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).
719
+
720
+ <a id="ctxllm--llmruntime"></a>
721
+
722
+ ### `ctx.llm` — `LlmRuntime`
723
+
724
+ The abstract `llm` service: an adapter registry plus a streaming model-call API, interceptable via the `llm/stream` waterfall.
725
+
726
+ ```ts cordis-catalog
727
+ /**
728
+ * Register an adapter for the given provider routes. Throws `LlmError` with code
729
+ * `DUPLICATE_ADAPTER` if any provider already has an adapter (all-or-nothing).
730
+ * Disposed with the fiber.
731
+ * @param providers - every provider route this adapter should serve.
732
+ * @param adapter - the adapter that streams calls for those providers.
733
+ * @returns the disposer, carrying {@link AdapterRegistrationHandle.replace}.
734
+ */
735
+ registerAdapter(providers: string[], adapter: LlmAdapter): AdapterRegistrationHandle
736
+
737
+ /**
738
+ * Describe provider routes with a registered adapter.
739
+ * @returns detached provider metadata in registration order.
740
+ */
741
+ listProviders(): LlmProviderInfo[]
742
+
743
+ /**
744
+ * Declare provider routes an adapter plugin can activate through
745
+ * configuration. Registration is all-or-nothing: an empty list, invalid
746
+ * entry, or a provider already declared by any registration throws
747
+ * `LlmError` without registering the rest. Disposed with the fiber.
748
+ * @param entries - every configurable provider this plugin owns.
749
+ * @returns a handle that withdraws all of them, and can atomically replace them.
750
+ */
751
+ registerConfigurableProviders(entries: readonly LlmConfigurableProvider[]): DirectoryRegistrationHandle
752
+
753
+ /**
754
+ * List every declared configurable provider, registered or dormant.
755
+ * @returns detached directory entries in declaration order.
756
+ */
757
+ listConfigurableProviders(): LlmConfigurableProvider[]
758
+
759
+ /**
760
+ * Offer to interrogate provider endpoints on behalf of the settings
761
+ * namespace this plugin owns. The namespace is the key because that is what
762
+ * a configuration surface already holds from the configurable-provider
763
+ * directory, and because a provider being *added* has no route to name yet.
764
+ * Disposed with the fiber.
765
+ * @param settingsNs - the namespace whose profiles this discovery serves.
766
+ * @param discover - interrogates one endpoint; must honor `request.signal`.
767
+ * @returns the disposer that withdraws the offer.
768
+ */
769
+ registerModelDiscovery( settingsNs: string, discover: (request: LlmModelDiscoveryRequest) => Promise<readonly LlmDiscoveredModel[]>, ): () => void
770
+
771
+ /**
772
+ * Interrogate one provider endpoint for the models it advertises. The
773
+ * request describes a draft, not a stored route, so nothing here reads or
774
+ * writes settings or credentials — the caller owns both, and the reply is
775
+ * candidate metadata a surface may offer for adoption.
776
+ * @param settingsNs - namespace whose registered discovery serves this draft.
777
+ * @param request - the endpoint, protocol, and one-shot credential to use.
778
+ * @returns the advertised models, deduplicated in endpoint order.
779
+ */
780
+ async discoverModels( settingsNs: string, request: LlmModelDiscoveryRequest, ): Promise<LlmDiscoveredModel[]>
781
+
782
+ /**
783
+ * Resolve the retry policy captured when one provider route was registered.
784
+ * @param provider - registered provider route to inspect.
785
+ * @returns the provider-owned policy, with normal defaults already resolved.
786
+ */
787
+ providerRetryPolicy(provider: string): ResolvedRetryPolicy
788
+
789
+ /**
790
+ * Discover models advertised by one registered provider. Catalog membership
791
+ * is advisory and never changes routing or request validation.
792
+ * @param provider - registered provider route to inspect.
793
+ * @returns detached model metadata in adapter-preferred order.
794
+ */
795
+ async listModels(provider: string): Promise<LlmModelInfo[]>
796
+
797
+ /**
798
+ * Resolve and validate all metadata from the adapter that owns one exact
799
+ * route. The result is detached from adapter-owned objects; catalog
800
+ * membership remains advisory and does not control request routing.
801
+ * @param provider - registered provider route to inspect.
802
+ * @param model - exact model id passed to the adapter.
803
+ * @param signal - optional cancellation for adapter-owned asynchronous lookup.
804
+ * @returns exact model identity plus available context and reasoning metadata.
805
+ */
806
+ async resolveModelInfo( provider: string, model: string, signal?: AbortSignal, ): Promise<LlmResolvedModelInfo>
807
+
808
+ /**
809
+ * Validate a conversation call config against its exact model capability and
810
+ * materialize adapter-configured defaults. Unsupported explicit efforts
811
+ * reject before provider I/O; no clamping or aliasing is performed. This
812
+ * standalone query does not bind a later dispatch; use {@link prepareCall}
813
+ * when logging and streaming must share one adapter registration.
814
+ * @param config - provider/model route and optional request controls.
815
+ * @param signal - optional cancellation for adapter-owned capability lookup.
816
+ * @returns a detached config only when a default must be materialized.
817
+ */
818
+ async resolveCallConfig(config: LlmCallConfig, signal?: AbortSignal): Promise<LlmCallConfig>
819
+
820
+ /**
821
+ * Resolve one call under its current adapter registration. The returned
822
+ * one-shot handle keeps that registration across header logging and dispatch,
823
+ * so HMR cannot combine one adapter's capability result with another adapter.
824
+ * @param config - provider/model route and optional request controls.
825
+ * @param signal - optional cancellation for adapter-owned capability lookup.
826
+ * @returns a prepared config and its registration-bound stream entry point.
827
+ */
828
+ async prepareCall(config: LlmCallConfig, signal?: AbortSignal): Promise<PreparedLlmCall>
829
+
830
+ /**
831
+ * Stream one model call as raw chunks (token-level deltas). Replay state is
832
+ * retained only when the same adapter instance owns its historical provider
833
+ * and the target provider. Final adapter selection remains fixed through
834
+ * asynchronous exact-model resolution and dispatch. Adapter selection,
835
+ * dispatch, and iteration failures become terminal `error` or `aborted`
836
+ * finish chunks; middleware, nested-call, cleanup, and consumer failures
837
+ * remain thrown.
838
+ * @param options - the full request; `options.provider` selects the adapter.
839
+ * @returns the chunk stream, possibly wrapped by `llm/stream` listeners.
840
+ */
841
+ stream(options: GenerateOptions): AsyncIterable<StreamChunk>
842
+ ```
843
+
844
+ Source: [`packages/llm/llm/src/index.ts:284`](../../packages/llm/llm/src/index.ts)
845
+
846
+ <a id="llm-events"></a>
847
+
848
+ ### `llm/*` events
849
+
850
+ <a id="llmadapters-updated--emit"></a>
851
+
852
+ #### `llm/adapters-updated` — emit
853
+
854
+ The provider topology changed: an adapter registered or unregistered routes, or the configurable-provider directory gained or lost entries. This payload-free registry notification fires at each commit point (including registration disposal); consumers re-read `listProviders()`, `listModels()`, or `listConfigurableProviders()` for the new state. Observer failures are contained and cannot veto the registry mutation.
855
+
856
+ ```ts cordis-catalog
857
+ /**
858
+ * The provider topology changed: an adapter registered or unregistered
859
+ * routes, or the configurable-provider directory gained or lost entries.
860
+ * This payload-free registry notification fires at each commit point
861
+ * (including registration disposal); consumers re-read `listProviders()`,
862
+ * `listModels()`, or `listConfigurableProviders()` for the new state.
863
+ * Observer failures are contained and cannot veto the registry mutation.
864
+ * @mode emit
865
+ */
866
+ 'llm/adapters-updated'(): void
867
+ ```
868
+
869
+ Source: [`packages/llm/llm/src/types.ts:23`](../../packages/llm/llm/src/types.ts)
870
+
871
+ <a id="llmstream--waterfall"></a>
872
+
873
+ #### `llm/stream` — waterfall
874
+
875
+ Waterfall around every streaming model call (retry, replay, routing). Bound to the LlmRuntime; call `next()` to reach the resolved adapter's stream, or yield your own chunks to short-circuit.
876
+
877
+ ```ts cordis-catalog
878
+ /**
879
+ * Waterfall around every streaming model call (retry, replay, routing).
880
+ * Bound to the {@link LlmRuntime}; call `next()` to reach the resolved
881
+ * adapter's stream, or yield your own chunks to short-circuit.
882
+ * @param options - the full request. A LOOP-built request carries the
883
+ * process-local {@link markAgentLoopRequest} identity and arrives deep-frozen
884
+ * (mutation throws): its content is a pure function of the session log (the
885
+ * reconstructability Agent Note), so listeners read it, never rewrite it.
886
+ * Hand-built calls do not carry that marker; their messages already obey
887
+ * the immutable creation contract.
888
+ * @mode waterfall
889
+ */
890
+ 'llm/stream'(this: LlmRuntime, options: GenerateOptions, next: () => AsyncIterable<StreamChunk>): AsyncIterable<StreamChunk>
891
+ ```
892
+
893
+ Source: [`packages/llm/llm/src/index.ts:64`](../../packages/llm/llm/src/index.ts)
894
+ <!-- END GENERATED cordis-surface -->