dsh-plugin-dev-kb 1.0.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 (234) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +56 -0
  3. package/cordis.patch.yml +12 -0
  4. package/kb/INDEX.md +210 -0
  5. package/kb/README.md +69 -0
  6. package/kb/extra/AGENTS.md +75 -0
  7. package/kb/extra/api-gateway.md +164 -0
  8. package/kb/extra/api-gateway.zh.md +164 -0
  9. package/kb/extra/cookbook/adding-a-vendored-package.md +59 -0
  10. package/kb/extra/cookbook/adding-a-vendored-package.zh.md +59 -0
  11. package/kb/extra/cookbook/maintaining-dsh-code-review.md +64 -0
  12. package/kb/extra/cookbook/maintaining-dsh-code-review.zh.md +64 -0
  13. package/kb/extra/cookbook/responding-to-pr-review-on-a-stack.md +32 -0
  14. package/kb/extra/cookbook/responding-to-pr-review-on-a-stack.zh.md +32 -0
  15. package/kb/extra/defensive-patterns.md +33 -0
  16. package/kb/extra/defensive-patterns.zh.md +33 -0
  17. package/kb/extra/development.md +171 -0
  18. package/kb/extra/development.zh.md +171 -0
  19. package/kb/extra/event-producer-consumer.md +76 -0
  20. package/kb/extra/event-producer-consumer.zh.md +78 -0
  21. package/kb/extra/glossary.md +45 -0
  22. package/kb/extra/glossary.zh.md +45 -0
  23. package/kb/extra/graph-atlas.md +24 -0
  24. package/kb/extra/graph-atlas.zh.md +26 -0
  25. package/kb/extra/i18n/README.md +60 -0
  26. package/kb/extra/i18n/README.zh.md +60 -0
  27. package/kb/extra/i18n/style-samples.md +87 -0
  28. package/kb/extra/i18n/terminology.md +214 -0
  29. package/kb/extra/i18n/translation-prompt.md +263 -0
  30. package/kb/extra/i18n/translation-rules.md +69 -0
  31. package/kb/extra/i18n/translation-rules.zh.md +69 -0
  32. package/kb/extra/module-graph.md +1641 -0
  33. package/kb/extra/module-graph.zh.md +1643 -0
  34. package/kb/extra/postmortem/0001-acp-default-export-drops-inject.md +113 -0
  35. package/kb/extra/postmortem/0001-acp-default-export-drops-inject.zh.md +113 -0
  36. package/kb/extra/postmortem/0002-js-expression-disabled-filesystem-tools.md +47 -0
  37. package/kb/extra/postmortem/0002-js-expression-disabled-filesystem-tools.zh.md +47 -0
  38. package/kb/extra/postmortem/0003-web-agent-gui-feedback-loop.md +53 -0
  39. package/kb/extra/postmortem/0003-web-agent-gui-feedback-loop.zh.md +53 -0
  40. package/kb/extra/postmortem/0004-landlock-partial-notice-misclassified-child-failures.md +55 -0
  41. package/kb/extra/postmortem/0004-landlock-partial-notice-misclassified-child-failures.zh.md +55 -0
  42. package/kb/extra/postmortem/README.md +18 -0
  43. package/kb/extra/postmortem/README.zh.md +18 -0
  44. package/kb/extra/rescope.md +53 -0
  45. package/kb/extra/rescope.zh.md +53 -0
  46. package/kb/extra/subsystems/attachment.md +125 -0
  47. package/kb/extra/subsystems/attachment.zh.md +125 -0
  48. package/kb/extra/subsystems/extensions.md +364 -0
  49. package/kb/extra/subsystems/extensions.zh.md +364 -0
  50. package/kb/extra/subsystems/feedback.md +266 -0
  51. package/kb/extra/subsystems/feedback.zh.md +266 -0
  52. package/kb/extra/testing.md +49 -0
  53. package/kb/extra/testing.zh.md +49 -0
  54. package/kb/extra/web-styling.md +25 -0
  55. package/kb/extra/web-styling.zh.md +25 -0
  56. package/kb/meta/search-index.json +1328 -0
  57. package/kb/meta/site-pages.txt +168 -0
  58. package/kb/meta/source.json +13 -0
  59. package/kb/meta/topics.md +75 -0
  60. package/kb/site/develop/basic/config.md +108 -0
  61. package/kb/site/develop/basic/index.md +146 -0
  62. package/kb/site/develop/basic/publish.md +185 -0
  63. package/kb/site/develop/basic/tool.md +54 -0
  64. package/kb/site/develop/cordis-tutorial/01-first-plugin.md +95 -0
  65. package/kb/site/develop/cordis-tutorial/02-lifecycle-and-effects.md +98 -0
  66. package/kb/site/develop/cordis-tutorial/03-services.md +98 -0
  67. package/kb/site/develop/cordis-tutorial/04-events.md +144 -0
  68. package/kb/site/develop/cordis-tutorial/05-config.md +84 -0
  69. package/kb/site/develop/cordis-tutorial/06-composition-and-hmr.md +113 -0
  70. package/kb/site/develop/cordis-tutorial/07-into-the-harness.md +107 -0
  71. package/kb/site/develop/cordis-tutorial/index.md +62 -0
  72. package/kb/site/develop/framework/events.md +145 -0
  73. package/kb/site/develop/framework/index.md +139 -0
  74. package/kb/site/develop/framework/service.md +152 -0
  75. package/kb/site/develop/practice/index.md +157 -0
  76. package/kb/site/develop/practice/llm-adapter.md +190 -0
  77. package/kb/site/en/develop/basic/config.md +108 -0
  78. package/kb/site/en/develop/basic/index.md +146 -0
  79. package/kb/site/en/develop/basic/publish.md +185 -0
  80. package/kb/site/en/develop/basic/tool.md +54 -0
  81. package/kb/site/en/develop/cordis-tutorial/01-first-plugin.md +95 -0
  82. package/kb/site/en/develop/cordis-tutorial/02-lifecycle-and-effects.md +98 -0
  83. package/kb/site/en/develop/cordis-tutorial/03-services.md +98 -0
  84. package/kb/site/en/develop/cordis-tutorial/04-events.md +144 -0
  85. package/kb/site/en/develop/cordis-tutorial/05-config.md +84 -0
  86. package/kb/site/en/develop/cordis-tutorial/06-composition-and-hmr.md +113 -0
  87. package/kb/site/en/develop/cordis-tutorial/07-into-the-harness.md +107 -0
  88. package/kb/site/en/develop/cordis-tutorial/index.md +60 -0
  89. package/kb/site/en/develop/framework/events.md +145 -0
  90. package/kb/site/en/develop/framework/index.md +139 -0
  91. package/kb/site/en/develop/framework/service.md +150 -0
  92. package/kb/site/en/develop/practice/index.md +157 -0
  93. package/kb/site/en/develop/practice/llm-adapter.md +190 -0
  94. package/kb/site/en/guide/providers-custom-form.png +0 -0
  95. package/kb/site/en/guide/providers-models-page.png +0 -0
  96. package/kb/site/en/guide/providers.md +100 -0
  97. package/kb/site/en/guide/python-sdk.md +106 -0
  98. package/kb/site/en/guide/quickstart.md +32 -0
  99. package/kb/site/en/index.md +8 -0
  100. package/kb/site/en/reference/agent-lifecycle.md +86 -0
  101. package/kb/site/en/reference/capability-seams.md +475 -0
  102. package/kb/site/en/reference/config-catalog.md +3155 -0
  103. package/kb/site/en/reference/cookbook/adding-a-conversation-node.md +235 -0
  104. package/kb/site/en/reference/cookbook/adding-a-package.md +120 -0
  105. package/kb/site/en/reference/cookbook/adding-a-settings-card.md +102 -0
  106. package/kb/site/en/reference/cookbook/adding-a-tool.md +96 -0
  107. package/kb/site/en/reference/cookbook/adding-an-llm-adapter.md +45 -0
  108. package/kb/site/en/reference/cookbook/extension-cookbook.md +131 -0
  109. package/kb/site/en/reference/cordis-api/context.md +368 -0
  110. package/kb/site/en/reference/cordis-api/events.md +211 -0
  111. package/kb/site/en/reference/cordis-api/fiber.md +379 -0
  112. package/kb/site/en/reference/cordis-api/inherited.md +43 -0
  113. package/kb/site/en/reference/cordis-api/registry.md +156 -0
  114. package/kb/site/en/reference/cordis-api/service.md +106 -0
  115. package/kb/site/en/reference/cordis-primer.md +46 -0
  116. package/kb/site/en/reference/index.md +131 -0
  117. package/kb/site/en/reference/persistence-catalog.md +949 -0
  118. package/kb/site/en/reference/subsystems/approval.md +173 -0
  119. package/kb/site/en/reference/subsystems/client-modules.md +121 -0
  120. package/kb/site/en/reference/subsystems/code-runtime.md +194 -0
  121. package/kb/site/en/reference/subsystems/commands.md +190 -0
  122. package/kb/site/en/reference/subsystems/compaction.md +241 -0
  123. package/kb/site/en/reference/subsystems/core.md +1073 -0
  124. package/kb/site/en/reference/subsystems/credentials.md +136 -0
  125. package/kb/site/en/reference/subsystems/filesystem.md +498 -0
  126. package/kb/site/en/reference/subsystems/goal.md +280 -0
  127. package/kb/site/en/reference/subsystems/index.md +58 -0
  128. package/kb/site/en/reference/subsystems/invariants.md +91 -0
  129. package/kb/site/en/reference/subsystems/jobs.md +293 -0
  130. package/kb/site/en/reference/subsystems/llm-streaming.md +920 -0
  131. package/kb/site/en/reference/subsystems/lsp.md +205 -0
  132. package/kb/site/en/reference/subsystems/permission-presets.md +134 -0
  133. package/kb/site/en/reference/subsystems/persistence.md +388 -0
  134. package/kb/site/en/reference/subsystems/plan.md +90 -0
  135. package/kb/site/en/reference/subsystems/sandbox.md +221 -0
  136. package/kb/site/en/reference/subsystems/schedule.md +189 -0
  137. package/kb/site/en/reference/subsystems/scope.md +62 -0
  138. package/kb/site/en/reference/subsystems/session-projection.md +265 -0
  139. package/kb/site/en/reference/subsystems/session-query.md +498 -0
  140. package/kb/site/en/reference/subsystems/session-reference.md +111 -0
  141. package/kb/site/en/reference/subsystems/session-telemetry.md +197 -0
  142. package/kb/site/en/reference/subsystems/session-title.md +207 -0
  143. package/kb/site/en/reference/subsystems/session.md +852 -0
  144. package/kb/site/en/reference/subsystems/settings.md +313 -0
  145. package/kb/site/en/reference/subsystems/shell.md +306 -0
  146. package/kb/site/en/reference/subsystems/skills.md +334 -0
  147. package/kb/site/en/reference/subsystems/spill.md +120 -0
  148. package/kb/site/en/reference/subsystems/storage.md +232 -0
  149. package/kb/site/en/reference/subsystems/subagent.md +737 -0
  150. package/kb/site/en/reference/subsystems/subprocess.md +327 -0
  151. package/kb/site/en/reference/subsystems/system-prompt.md +210 -0
  152. package/kb/site/en/reference/subsystems/terminal.md +187 -0
  153. package/kb/site/en/reference/subsystems/token-meter.md +93 -0
  154. package/kb/site/en/reference/subsystems/tools.md +723 -0
  155. package/kb/site/en/reference/subsystems/typert.md +339 -0
  156. package/kb/site/en/reference/subsystems/user-questions.md +181 -0
  157. package/kb/site/en/reference/subsystems/web-server.md +111 -0
  158. package/kb/site/en/reference/subsystems/web.md +202 -0
  159. package/kb/site/en/reference/subsystems/workflow.md +281 -0
  160. package/kb/site/en/reference/subsystems/workspace.md +231 -0
  161. package/kb/site/en/reference/tool-catalog.md +1877 -0
  162. package/kb/site/en/reference/tool-execution-pipeline.md +66 -0
  163. package/kb/site/guide/providers-custom-form.zh.png +0 -0
  164. package/kb/site/guide/providers-models-page.zh.png +0 -0
  165. package/kb/site/guide/providers.md +100 -0
  166. package/kb/site/guide/python-sdk.md +106 -0
  167. package/kb/site/guide/quickstart.md +32 -0
  168. package/kb/site/index.md +8 -0
  169. package/kb/site/reference/agent-lifecycle.md +86 -0
  170. package/kb/site/reference/capability-seams.md +475 -0
  171. package/kb/site/reference/config-catalog.md +3154 -0
  172. package/kb/site/reference/cookbook/adding-a-conversation-node.md +235 -0
  173. package/kb/site/reference/cookbook/adding-a-package.md +120 -0
  174. package/kb/site/reference/cookbook/adding-a-settings-card.md +102 -0
  175. package/kb/site/reference/cookbook/adding-a-tool.md +98 -0
  176. package/kb/site/reference/cookbook/adding-an-llm-adapter.md +45 -0
  177. package/kb/site/reference/cookbook/extension-cookbook.md +133 -0
  178. package/kb/site/reference/cordis-api/context.md +368 -0
  179. package/kb/site/reference/cordis-api/events.md +211 -0
  180. package/kb/site/reference/cordis-api/fiber.md +379 -0
  181. package/kb/site/reference/cordis-api/inherited.md +43 -0
  182. package/kb/site/reference/cordis-api/registry.md +156 -0
  183. package/kb/site/reference/cordis-api/service.md +106 -0
  184. package/kb/site/reference/cordis-primer.md +52 -0
  185. package/kb/site/reference/index.md +135 -0
  186. package/kb/site/reference/persistence-catalog.md +949 -0
  187. package/kb/site/reference/subsystems/approval.md +173 -0
  188. package/kb/site/reference/subsystems/client-modules.md +121 -0
  189. package/kb/site/reference/subsystems/code-runtime.md +194 -0
  190. package/kb/site/reference/subsystems/commands.md +190 -0
  191. package/kb/site/reference/subsystems/compaction.md +241 -0
  192. package/kb/site/reference/subsystems/core.md +1081 -0
  193. package/kb/site/reference/subsystems/credentials.md +136 -0
  194. package/kb/site/reference/subsystems/filesystem.md +498 -0
  195. package/kb/site/reference/subsystems/goal.md +280 -0
  196. package/kb/site/reference/subsystems/index.md +58 -0
  197. package/kb/site/reference/subsystems/invariants.md +91 -0
  198. package/kb/site/reference/subsystems/jobs.md +293 -0
  199. package/kb/site/reference/subsystems/llm-streaming.md +926 -0
  200. package/kb/site/reference/subsystems/lsp.md +205 -0
  201. package/kb/site/reference/subsystems/permission-presets.md +134 -0
  202. package/kb/site/reference/subsystems/persistence.md +388 -0
  203. package/kb/site/reference/subsystems/plan.md +90 -0
  204. package/kb/site/reference/subsystems/sandbox.md +221 -0
  205. package/kb/site/reference/subsystems/schedule.md +189 -0
  206. package/kb/site/reference/subsystems/scope.md +62 -0
  207. package/kb/site/reference/subsystems/session-projection.md +265 -0
  208. package/kb/site/reference/subsystems/session-query.md +498 -0
  209. package/kb/site/reference/subsystems/session-reference.md +111 -0
  210. package/kb/site/reference/subsystems/session-telemetry.md +197 -0
  211. package/kb/site/reference/subsystems/session-title.md +207 -0
  212. package/kb/site/reference/subsystems/session.md +854 -0
  213. package/kb/site/reference/subsystems/settings.md +313 -0
  214. package/kb/site/reference/subsystems/shell.md +306 -0
  215. package/kb/site/reference/subsystems/skills.md +334 -0
  216. package/kb/site/reference/subsystems/spill.md +120 -0
  217. package/kb/site/reference/subsystems/storage.md +232 -0
  218. package/kb/site/reference/subsystems/subagent.md +739 -0
  219. package/kb/site/reference/subsystems/subprocess.md +327 -0
  220. package/kb/site/reference/subsystems/system-prompt.md +210 -0
  221. package/kb/site/reference/subsystems/terminal.md +187 -0
  222. package/kb/site/reference/subsystems/token-meter.md +93 -0
  223. package/kb/site/reference/subsystems/tools.md +723 -0
  224. package/kb/site/reference/subsystems/typert.md +339 -0
  225. package/kb/site/reference/subsystems/user-questions.md +181 -0
  226. package/kb/site/reference/subsystems/web-server.md +111 -0
  227. package/kb/site/reference/subsystems/web.md +202 -0
  228. package/kb/site/reference/subsystems/workflow.md +281 -0
  229. package/kb/site/reference/subsystems/workspace.md +231 -0
  230. package/kb/site/reference/tool-catalog.md +1880 -0
  231. package/kb/site/reference/tool-execution-pipeline.md +66 -0
  232. package/package.json +40 -0
  233. package/scripts/rebuild-index.mjs +88 -0
  234. package/skills/dsh-plugin-dev-kb.md +66 -0
@@ -0,0 +1,197 @@
1
+ ---
2
+ editSource: "docs/subsystems/session-telemetry.zh.md"
3
+ outline: [2,3]
4
+ ---
5
+
6
+ # 遥测(telemetry)
7
+
8
+ 对外的会话上报拆分为一项[能力 seam](../capability-seams.md):Service Definition 与捕获协调器([dsh-session-telemetry](https://github.com/deepseek-ai/deepseek-harness/tree/master/packages/session/session-telemetry),`ctx.sessionTelemetry`)拥有捕获点、固定分片投影、`session-telemetry/record` 脱敏 waterfall(瀑布式事件)、handoff 游标与最小后端约定;部署方加载的 Service Provider([dsh-session-telemetry-otel](https://github.com/deepseek-ai/deepseek-harness/tree/master/packages/session/session-telemetry-otel))则是原样配置的 OpenTelemetry JS SDK 日志流水线。它是一项可选能力,不属于 agent loop(智能体循环)主干,这里也没有任何内容会进入模型请求。边界公理(harness 的职责止于 `emit()`;批处理、重试、排队与丢失策略都属于上报 SDK)连同被否决的替代方案,均已在[复活 Agent Note](https://github.com/deepseek-ai/deepseek-harness/blob/master/.agents/notes/implemented/feature/2026-07-23-session-telemetry-otel-revival.md)中定案;捕获点、游标与投影的约定见 [Service Definition README](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/session/session-telemetry/README.md)。
9
+
10
+ 源码:[`packages/session/session-telemetry/src/index.ts`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/session/session-telemetry/src/index.ts)
11
+
12
+ ## 逻辑记录
13
+
14
+ ```ts type-equiv
15
+ /**
16
+ * Severity of a telemetry record, pre-mapped at capture so a receiver can
17
+ * alert with zero configuration: `error` for events whose own outcome flag
18
+ * says so (the tool-result block's `isError`, `turn/end` error reasons) and for
19
+ * `agent-error` operational records. Captured events otherwise default to
20
+ * `info`; `warn` remains available to `session-telemetry/record` policies and
21
+ * backends.
22
+ */
23
+ type SessionTelemetrySeverity = 'info' | 'warn' | 'error'
24
+ ```
25
+
26
+ ```ts type-equiv
27
+ /**
28
+ * One logical record handed to a backend — the capture contract's whole outbound
29
+ * vocabulary. Ledger records mirror session-log events one-to-one;
30
+ * operational records (`channel: 'ops'`) carry the two signals with no log
31
+ * home (`agent-error`, `shutdown`) and deliberately omit `event.seq`-style
32
+ * identity so they can never be mistaken for ledger rows.
33
+ */
34
+ interface SessionTelemetryRecord {
35
+ /** Ledger (session-log mirror) or ops (operational signal) channel; backends keep the two under separate instrumentation scopes. */
36
+ channel: 'ledger' | 'ops'
37
+ /** Unix epoch milliseconds — the source event's append time for ledger records, the emission time for ops records. */
38
+ time: number
39
+ /** Pre-mapped alerting severity; see {@link SessionTelemetrySeverity}. */
40
+ severity: SessionTelemetrySeverity
41
+ /**
42
+ * Identity attributes, deliberately minimal: ledger records carry
43
+ * `session.id`, `event.type`, `event.seq`, plus `session.cwd` /
44
+ * `session.parent_id` / `session.seed_length` when the header has them;
45
+ * ops records carry `telemetry.op`, `session.id`, and (for `agent-error`)
46
+ * `agent.id`, `turn`, `step`, `error.name`. Anything recoverable from the
47
+ * body is intentionally NOT duplicated here.
48
+ */
49
+ attributes: Record<string, string | number>
50
+ /**
51
+ * The complete payload: a deep copy of the session event's `data` for
52
+ * ledger records (JSON-serializable by `Session.append`'s own
53
+ * validation), or the op payload for ops records. Never mutated after
54
+ * handoff.
55
+ */
56
+ body: unknown
57
+ }
58
+ ```
59
+
60
+ 每个 `(turn, step)` 只发出第一条 `assistant/chunk`,即「流已开始」的信号;其余分片在捕获时丢弃,因此传输中的 `seq` 缺口是常态,绝不是数据丢失的信号。其他所有[会话事件](./session.md)类型都会完整透传,包括该 seam 从未听说过、由插件合并进来的事件类型。投递是尽力而为的:游标标记的是「已交接」而非「已送达」,记录可能丢失(崩溃、重载窗口)也可能重复(无游标的重新接管、SDK 重试),因此接收端对 ledger 记录基于 `(session.id, event.seq)` 去重;ops 记录刻意省略这类标识——它们是用于告警的信号,而非用于累加的条目,重复被容忍而非被去重。
61
+
62
+ ## 共享披露
63
+
64
+ 该 seam 的确认契约(归属 [Service Definition README 的共享披露段](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/session/session-telemetry/README.md#the-sharing-disclosure)):每个后端都通过 `ctx.sessionTelemetry` 上必需的抽象 `sharing` 成员披露其部署级共享策略,消费方只有在未挂载任何遥测服务时才渲染「未配置」。披露只陈述当前策略,绝不承诺投递或留存——交接是非阻塞入队,批处理、重试与丢失策略仍归上报 SDK。
65
+
66
+ ```ts type-equiv
67
+ /**
68
+ * Deployment-selected session-sharing policy disclosed by a mounted
69
+ * {@link SessionTelemetryBackend} backend to human-facing acknowledgement surfaces (the
70
+ * `/feedback` command's confirmation text). The seam owns the vocabulary so
71
+ * any backend can disclose a policy without depending on the OTel package;
72
+ * the values mirror the OTel backend's serialized `SessionTelemetryMode` choices.
73
+ */
74
+ type SessionTelemetrySharingStatus = 'full' | 'feedback-only' | 'disabled'
75
+ ```
76
+
77
+ ## 后端约定
78
+
79
+ ```ts type-equiv
80
+ /**
81
+ * The minimum backend contract the coordinator requires. {@link SessionTelemetryBackend} is
82
+ * its service-registered form; tests compose the coordinator with a bare
83
+ * implementation of this interface.
84
+ */
85
+ interface SessionTelemetrySink {
86
+ /**
87
+ * Hand one record to the backend's pipeline. MUST be a non-blocking
88
+ * enqueue — the coordinator calls this synchronously from the
89
+ * `session/event` hot path or an explicit canonical-log capture, so anything
90
+ * slower than a queue push would tax the agent loop or feedback handling.
91
+ * Errors thrown here are contained by the coordinator and logged; they
92
+ * never reach the loop.
93
+ * @param record - the logical record to report; owned by the backend after the call.
94
+ */
95
+ emit(record: SessionTelemetryRecord): void
96
+ /**
97
+ * Optional hint that a turn ended. A backend may forward it to its SDK's
98
+ * flush so records are exported after each turn. Called
99
+ * fire-and-forget; implementations must not block and must not throw
100
+ * meaningfully (the coordinator contains exceptions). Most backends should
101
+ * leave this unimplemented and let their SDK's own batching cadence govern
102
+ * export timing: a backend that does implement it owns the interaction
103
+ * between its concurrent flushes and {@link shutdown}'s drain (the OTel
104
+ * backend leaves it unimplemented for exactly that hazard — see the
105
+ * revival Agent Note).
106
+ */
107
+ flush?(): void
108
+ /**
109
+ * Forward the fiber's disposal to the SDK: flush whatever is queued and
110
+ * reach quiescence, per the SDK's own shutdown contract. Everything
111
+ * emitted before this call must still be delivered — including records
112
+ * enqueued while a {@link flush} hint is in flight, so a backend whose SDK
113
+ * guards against concurrent flushes orders behind the outstanding one (the
114
+ * coordinator emits its dispose-time `shutdown` markers immediately before
115
+ * calling this). Awaited by the coordinator's dispose; a rejection is
116
+ * logged as a warning and never fails application teardown.
117
+ * The coordinator captures dispose-time shutdown markers immediately before
118
+ * this call for live capture; on-demand capture creates no ops records.
119
+ * @returns resolves when the backend's pipeline has quiesced.
120
+ */
121
+ shutdown(): Promise<void>
122
+ }
123
+ ```
124
+
125
+ `SessionTelemetryBackend`(`ctx.sessionTelemetry`,[签名](#ctxsessiontelemetry--sessiontelemetrybackend-abstract-seam))是该约定的可加载形态:每个上下文只允许一个实现,重复加载会抛出异常;后端在其构造函数中组合 seam 的 `SessionTelemetryCoordinator`,以此装配捕获侧。
126
+
127
+ ## 脱敏 waterfall:`session-telemetry/record`
128
+
129
+ 每条记录在投影与 `emit()` 之间都要经过 `session-telemetry/record` [waterfall](../cordis-primer.md#cordis-waterfall-semantics)([事件条目](#session-telemetryrecord--waterfall))。seam 自身不带任何规则:未挂载监听器时,记录以捕获时的原样到达后端;导出数据能干净到什么程度,恰恰取决于部署方挂载了什么规则。监听器通过变换 `next()` 的返回值来堆叠;不调用 `next()` 就返回,即替换其下方的全部逻辑;抛出异常的监听器会在协调器的隔离范围内以 fail-closed 方式扣下这一条记录。脱敏只作用于导出副本;权威会话日志永不改写。
130
+
131
+ <!-- BEGIN GENERATED cordis-surface (gen-cordis-catalog.ts) — do not edit between markers -->
132
+
133
+ <a id="cordis-surface"></a>
134
+
135
+ ## Cordis API
136
+
137
+ 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).
138
+
139
+ <a id="ctxsessiontelemetry--sessiontelemetrybackend-abstract-seam"></a>
140
+
141
+ ### `ctx.sessionTelemetry` — `SessionTelemetryBackend` (abstract seam)
142
+
143
+ Loadable form of the backend contract: one implementation per context — the cordis `Service` registration under the `telemetry` key throws on a duplicate, cordis' standard behavior. A backend composes a SessionTelemetryCoordinator in its constructor to install the capture side.
144
+
145
+ ```ts cordis-catalog
146
+ /**
147
+ * See {@link SessionTelemetrySink.emit} — that declaration is the contract's one home.
148
+ * @param record - the logical record to report; owned by the backend after the call.
149
+ */
150
+ abstract emit(record: SessionTelemetryRecord): void
151
+
152
+ /** See {@link SessionTelemetrySink.flush}. */
153
+ flush?(): void
154
+
155
+ /**
156
+ * See {@link SessionTelemetrySink.shutdown}.
157
+ * @returns resolves when the backend's pipeline has quiesced.
158
+ */
159
+ abstract shutdown(): Promise<void>
160
+ ```
161
+
162
+ Source: [`packages/session/session-telemetry/src/index.ts:148`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/session/session-telemetry/src/index.ts)
163
+
164
+ <a id="session-telemetry-events"></a>
165
+
166
+ ### `session-telemetry/*` events
167
+
168
+ <a id="session-telemetryrecord--waterfall"></a>
169
+
170
+ #### `session-telemetry/record` — waterfall
171
+
172
+ Transform one outbound record before it reaches the backend. This waterfall is the Service Definition's redaction extension point. It ships NO rules of its own: the innermost `next()` passes the record through unchanged, and with no listener mounted records reach the backend as captured, so exported data is exactly as clean as the rules a deployment mounts. Listeners stack by transforming `next()`'s return value; returning without `next()` replaces everything beneath. Dispatched synchronously on the capture hot path inside the coordinator's containment: a throwing listener withholds that one record (fail-closed) and never reaches the agent loop. Live capture dispatches at append time; on-demand capture dispatches while reading the canonical log. Redaction applies to the exported copy only; the canonical session log is never rewritten.
173
+
174
+ ```ts cordis-catalog
175
+ /**
176
+ * Transform one outbound record before it reaches the backend. This
177
+ * waterfall is the Service Definition's redaction extension point. It ships NO rules
178
+ * of its own: the
179
+ * innermost `next()` passes the record through unchanged, and with no
180
+ * listener mounted records reach the backend as captured, so exported
181
+ * data is exactly as clean as the rules a deployment mounts. Listeners
182
+ * stack by transforming `next()`'s return value; returning without
183
+ * `next()` replaces everything beneath. Dispatched synchronously on the
184
+ * capture hot path inside the coordinator's containment: a throwing
185
+ * listener withholds that one record (fail-closed) and never reaches the
186
+ * agent loop. Live capture dispatches at append time; on-demand capture
187
+ * dispatches while reading the canonical log. Redaction applies to the
188
+ * exported copy only; the canonical session log is never rewritten.
189
+ * @param record - the candidate record, already the coordinator's own deep
190
+ * copy; listeners return a (possibly new) record and must not mutate it.
191
+ * @mode waterfall
192
+ */
193
+ 'session-telemetry/record'(record: SessionTelemetryRecord, next: () => SessionTelemetryRecord): SessionTelemetryRecord
194
+ ```
195
+
196
+ Source: [`packages/session/session-telemetry/src/index.ts:43`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/session/session-telemetry/src/index.ts)
197
+ <!-- END GENERATED cordis-surface -->
@@ -0,0 +1,207 @@
1
+ ---
2
+ editSource: "docs/subsystems/session-title.zh.md"
3
+ outline: [2,3]
4
+ ---
5
+
6
+ # 会话标题
7
+
8
+ [`@deepseek-ai/dsh-session-title`](https://github.com/deepseek-ai/deepseek-harness/tree/master/packages/session/session-title) 所拥有的持久、后写覆盖的标题状态与可选异步提供方词汇。共享 LLM(大语言模型)辅助组件负责精确的辅助请求记录。各包 README 负责时序、回退、失败与 fork 行为;生成的[持久化日志事件目录](../persistence-catalog.md)负责完整的事件声明。
9
+
10
+ 源码:[`packages/session/session-title/src/index.ts`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/session/session-title/src/index.ts)、[`packages/session/session-title-llm/src/index.ts`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/session/session-title-llm/src/index.ts)
11
+
12
+ ## 持久标题状态
13
+
14
+ 提供方生成修订时会记录 `SessionTitleProviderId`。`SessionTitleEventData` 列出生成标题时使用的精确人类消息 seq,`SessionTitleSnapshot` 则加入 `foldSessionTitle()` 选出的持久事件封装信息。
15
+
16
+ ```ts type-equiv
17
+ /** Identifies one session-title provider registration. */
18
+ type SessionTitleProviderId = Branded<'SessionTitleProviderId'>
19
+ ```
20
+
21
+ ```ts type-equiv
22
+ /** Exact auxiliary model route that produced a title. */
23
+ interface SessionTitleModelProvenance {
24
+ /** Registered LLM provider route. */
25
+ readonly provider: string
26
+ /** Provider model id. */
27
+ readonly model: string
28
+ }
29
+ ```
30
+
31
+ ```ts type-equiv
32
+ /** Durable ownership record for an accepted session title. */
33
+ type SessionTitleSource =
34
+ | { readonly kind: 'fallback' }
35
+ | {
36
+ readonly kind: 'provider'
37
+ readonly provider: SessionTitleProviderId
38
+ readonly model?: SessionTitleModelProvenance
39
+ }
40
+ | {
41
+ /** Explicit user rename: pins the title — automatic generation stops scheduling. */
42
+ readonly kind: 'user'
43
+ }
44
+ ```
45
+
46
+ ```ts type-equiv
47
+ /** Payload of the log-only `session/title` event. */
48
+ interface SessionTitleEventData {
49
+ /** Normalized non-empty title text. */
50
+ readonly title: string
51
+ /** Exact human `user/message` seqs used to derive this title; empty for an explicit user rename. */
52
+ readonly messageSeqs: number[]
53
+ /** Whether the built-in fallback, a registered provider, or the user supplied the title. */
54
+ readonly source: SessionTitleSource
55
+ }
56
+ ```
57
+
58
+ ```ts type-equiv
59
+ /** Latest folded title plus the title event's durable envelope facts. */
60
+ interface SessionTitleSnapshot extends SessionTitleEventData {
61
+ /** Seq of the latest `session/title` event. */
62
+ readonly eventSeq: number
63
+ /** Timestamp of the latest `session/title` event. */
64
+ readonly updatedAt: number
65
+ }
66
+ ```
67
+
68
+ ## 辅助请求记录
69
+
70
+ 共享 LLM 辅助组件会在调用模型前,记录每一项已经过验证且可分发的标题请求。即使后续生成失败,载荷仍会复现模型可见的系统输入与消息输入、路由、输出上限、提供方归属和源消息归因。
71
+
72
+ ```ts type-equiv
73
+ /** Exact model-visible request recorded before one auxiliary title dispatch. */
74
+ interface SessionTitleLlmRequestEventData {
75
+ /** Registered title-provider identity responsible for the request. */
76
+ readonly titleProvider: SessionTitleProviderId
77
+ /** Exact human `user/message` seqs represented in `messages`. */
78
+ readonly messageSeqs: number[]
79
+ /** Exact auxiliary LLM route. */
80
+ readonly route: SessionTitleModelProvenance
81
+ /** Exact auxiliary system prompt. */
82
+ readonly system: string
83
+ /** Exact auxiliary message list. */
84
+ readonly messages: Message[]
85
+ /** Exact auxiliary output-token cap. */
86
+ readonly maxTokens: number
87
+ }
88
+ ```
89
+
90
+ ## 提供方输入与输出
91
+
92
+ 服务会对截至某一修订的合格消息创建快照。提供方返回的 seq 仅可来自该请求;由服务负责的接纳流程会验证顺序、规范化标题、强制执行字节上限,并追加标题及其来源消息 seq 和来源类型。
93
+
94
+ ```ts type-equiv
95
+ /** One eligible human text message exposed to title providers. */
96
+ interface SessionTitleUserMessage {
97
+ /** Source `user/message` event seq. */
98
+ readonly seq: number
99
+ /** Exact concatenated text-block content. */
100
+ readonly text: string
101
+ }
102
+ ```
103
+
104
+ ```ts type-equiv
105
+ /** Automatic generation cadence owned by a registered provider. */
106
+ type SessionTitleAutomaticMode = 'first-prompt' | 'all-prompts'
107
+ ```
108
+
109
+ ```ts type-equiv
110
+ /** Immutable input supplied to one title-provider call. */
111
+ interface SessionTitleProviderRequest {
112
+ /** Live session being titled. */
113
+ readonly session: Session
114
+ /** All eligible human messages through this generation revision. */
115
+ readonly messages: readonly SessionTitleUserMessage[]
116
+ /** Exact current logged main-request route, when one has been recorded. */
117
+ readonly route?: SessionTitleModelProvenance
118
+ /** Cancellation for supersession, disposal, timeout composition, or the explicit caller. */
119
+ readonly signal: AbortSignal
120
+ }
121
+ ```
122
+
123
+ ```ts type-equiv
124
+ /** Provider output before service-owned normalization and log acceptance. */
125
+ interface SessionTitleProviderResult {
126
+ /** Proposed title text. */
127
+ readonly title: string
128
+ /** Exact seqs from `request.messages` used by this result. */
129
+ readonly messageSeqs: readonly number[]
130
+ /** Auxiliary LLM route, when generation used a model. */
131
+ readonly model?: SessionTitleModelProvenance
132
+ }
133
+ ```
134
+
135
+ ```ts type-equiv
136
+ /** One optional asynchronous title implementation registered with the service. */
137
+ interface SessionTitleProvider {
138
+ /** Stable id of the provider recorded with the title. */
139
+ readonly id: SessionTitleProviderId
140
+ /** When new human prompts start automatic generation. */
141
+ readonly automatic: SessionTitleAutomaticMode
142
+ /**
143
+ * Produce one title revision.
144
+ * @param request - message snapshot, current route, session, and cancellation.
145
+ * @returns proposed title plus exact input seqs and the optional provider/model route used to generate it.
146
+ */
147
+ generate(request: SessionTitleProviderRequest): Promise<SessionTitleProviderResult>
148
+ }
149
+ ```
150
+
151
+ <!-- BEGIN GENERATED cordis-surface (gen-cordis-catalog.ts) — do not edit between markers -->
152
+
153
+ <a id="cordis-surface"></a>
154
+
155
+ ## Cordis API
156
+
157
+ 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).
158
+
159
+ <a id="ctxsessiontitle--sessiontitleservice"></a>
160
+
161
+ ### `ctx.sessionTitle` — `SessionTitleService`
162
+
163
+ Log-backed title fold plus asynchronous fallback generation.
164
+
165
+ ```ts cordis-catalog
166
+ /**
167
+ * Read the latest folded title from one live or replayed session.
168
+ * @param session - session whose log is the title source of truth.
169
+ * @returns latest title snapshot, or `undefined` before eligible input.
170
+ */
171
+ get(session: Session): SessionTitleSnapshot | undefined
172
+
173
+ /**
174
+ * Accept an explicit user title. Appends a `session/title` event with the
175
+ * `user` source, which pins the title: in-flight automatic generation is
176
+ * superseded and later user messages schedule none (an explicit
177
+ * {@link SessionTitleService.refresh} remains the deliberate unpin).
178
+ * @param session - exact live session to rename.
179
+ * @param title - raw user input; normalized before acceptance.
180
+ * @returns the accepted title snapshot.
181
+ * @throws {SessionTitleInvalidError} when the title normalizes to empty.
182
+ * @throws {Error} when the session is not live or the service is disposed.
183
+ */
184
+ rename(session: Session, title: string): SessionTitleSnapshot
185
+
186
+ /**
187
+ * Explicitly retry the registered provider, or materialize the built-in
188
+ * fallback when no provider is registered.
189
+ * @param session - exact live session to refresh.
190
+ * @param signal - optional caller cancellation.
191
+ * @returns latest accepted title, or `undefined` when no eligible text exists.
192
+ */
193
+ async refresh(session: Session, signal?: AbortSignal): Promise<SessionTitleSnapshot | undefined>
194
+
195
+ /**
196
+ * Register the sole optional title provider. Disposal aborts its pending and
197
+ * active work before another provider may register.
198
+ * @param provider - provider identity, cadence, and generation function.
199
+ * @returns exact Cordis effect disposer, which settles after active calls quiesce.
200
+ */
201
+ register(provider: SessionTitleProvider): () => Promise<void>
202
+ ```
203
+
204
+ Types: [Session](./session.md)
205
+
206
+ Source: [`packages/session/session-title/src/index.ts:261`](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/session/session-title/src/index.ts)
207
+ <!-- END GENERATED cordis-surface -->