@deepseek-ai/dsh-session-telemetry 0.1.7-rc.1 → 0.2.0-rc.1

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.
package/README.i18n.yaml CHANGED
@@ -1,6 +1,64 @@
1
- # Bilingual-pair consistency record (docs/i18n/README.md): the git blob hash of each
2
- # side as of the last confirmed-consistent state. Both languages carry equal authority;
3
- # after editing either side, bring the other along and re-record with:
1
+ # Bilingual-pair consistency record for README.md (docs/i18n/README.md): per heading
2
+ # section, a hash of its English and Chinese blocks outside code blocks and generated regions.
3
+ # After editing either side, bring the other along and re-record with:
4
4
  # pnpm run verify-translation-pairing --write packages/session/session-telemetry/README.md
5
- README.md: c7d76686415ee4874e29ec191d8456c31a3019f4
6
- README.zh.md: 2e9bc7e6619f30d18660ef2a11ab703b02647aa3
5
+ /:
6
+ en: 5c553664bfb6ebaa
7
+ zh: 0ad10e1597cb65bc
8
+ /deepseek-ai-dsh-session-telemetry:
9
+ en: f38756c64b49af33
10
+ zh: 837746cfd00d13ea
11
+ /deepseek-ai-dsh-session-telemetry/summary:
12
+ en: 2ee6fcb4e68f6c9b
13
+ zh: 8ddc8d1f3c645757
14
+ /deepseek-ai-dsh-session-telemetry/table-of-contents:
15
+ en: d152484eb41ac6b4
16
+ zh: 09388d293f9be9cb
17
+ /deepseek-ai-dsh-session-telemetry/use-this-package:
18
+ en: f103da7913199503
19
+ zh: 623f7a102c451289
20
+ /deepseek-ai-dsh-session-telemetry/use-this-package/choosing-and-mounting-a-backend:
21
+ en: cc1b92c9563ec9e9
22
+ zh: 6e80c5e002a6c83d
23
+ /deepseek-ai-dsh-session-telemetry/use-this-package/the-backend-contract:
24
+ en: e3cc8ee7774a0ad5
25
+ zh: 3c039339870b8cf9
26
+ /deepseek-ai-dsh-session-telemetry/use-this-package/what-gets-captured:
27
+ en: 5b7fbbe1c55997e8
28
+ zh: d62d9118fd8df2f4
29
+ /deepseek-ai-dsh-session-telemetry/use-this-package/the-sharing-disclosure:
30
+ en: 5c325a8aaadf17c7
31
+ zh: 5c493d2333f82b28
32
+ /deepseek-ai-dsh-session-telemetry/use-this-package/redacting-records:
33
+ en: 22ed345bf7746611
34
+ zh: a57d2eaa878c8cce
35
+ /deepseek-ai-dsh-session-telemetry/understand-the-implementation:
36
+ en: cad1e9d195916553
37
+ zh: 2192f3ce5e2196bd
38
+ /deepseek-ai-dsh-session-telemetry/understand-the-implementation/design-concept:
39
+ en: 56c449be11e6bac1
40
+ zh: 6b62969e93313c3e
41
+ /deepseek-ai-dsh-session-telemetry/understand-the-implementation/source-map:
42
+ en: 5dc345ec3dda38b8
43
+ zh: 189d673734a2c20e
44
+ /deepseek-ai-dsh-session-telemetry/understand-the-implementation/capture-flow:
45
+ en: f86c2777668ae89e
46
+ zh: 710c28c18f3f4402
47
+ /deepseek-ai-dsh-session-telemetry/understand-the-implementation/the-handoff-cursor:
48
+ en: c213358e20f27173
49
+ zh: 84a5501335891f0b
50
+ /deepseek-ai-dsh-session-telemetry/further-exploration:
51
+ en: 12c383ffe3448557
52
+ zh: e78cbffe565ce340
53
+ /deepseek-ai-dsh-session-telemetry/model-experience:
54
+ en: 6a6b429828997572
55
+ zh: bde61df9dab8f840
56
+ /deepseek-ai-dsh-session-telemetry/model-experience/kv-cache-effect:
57
+ en: 7593cf5d0d2cedd6
58
+ zh: f57cc48a1b5cbfa9
59
+ /deepseek-ai-dsh-session-telemetry/known-limitations-and-deferred-work:
60
+ en: dc950b1f59a057ec
61
+ zh: 6f353d426b03abb1
62
+ /deepseek-ai-dsh-session-telemetry/known-limitations-and-deferred-work/dev-note:
63
+ en: e10a3d2c84d710a6
64
+ zh: 910927bba4d34a85
package/README.md CHANGED
@@ -39,6 +39,8 @@ A backend implements three members: `emit(record)` must be a non-blocking enqueu
39
39
 
40
40
  Capture runs in one of two modes. `live` capture follows session events as they are appended, replays already-live sessions at mount time, and records lifecycle markers; `on-demand` capture reads the canonical session log only when the backend requests a prefix through `captureSession(session, throughSeq?)`. Coordinator options select whether stored history is included. Every canonical session event maps to one ledger record in order. An `assistant/message` or `assistant/attempt` record carries its complete embedded compact stream, including failed and retried output. Each ledger record also carries `session.id`, `session.format_version`, the numeric event identity, optional header facts, and a pre-mapped severity (`error` for `tool/result.isError`, `turn/end` error reasons, and `agent-error`; `info` otherwise).
41
41
 
42
+ Ledger records carry `sourceEvent` with the owning Session id and a copied event envelope excluding `data`. The redaction waterfall receives `body` as the only payload copy. Backends can reconstruct a complete exported event from the envelope and redacted body without bypassing redaction.
43
+
42
44
  ### The sharing disclosure
43
45
 
44
46
  <a id="the-sharing-disclosure"></a>
@@ -63,7 +65,7 @@ This section explains the capture design; the observable behavior is fully cover
63
65
 
64
66
  ### Design concept
65
67
 
66
- The seam is built on one boundary: the harness's aspect ends at `emit()`. Complete event capture, redaction, and the handoff cursor live here; batching, retry, queueing, and loss policy are the reporting SDK's, deliberately not modelled or wrapped. The design and rejected alternatives are pinned in the [revival Agent Note](../../../.agents/notes/implemented/feature/2026-07-23-session-telemetry-otel-revival.md).
68
+ The capture package owns complete event capture, redaction, and handoff cursors. Redaction rules must preserve `sourceEvent` for OTel upload; returning a fresh record without it withholds the event with a diagnostic. Its cloned envelope excludes `data`, which is carried only in `body`. The OTel backend owns byte/count scheduling and uses SDK transport/retries. The [revival Agent Note](../../../.agents/notes/implemented/feature/2026-07-23-session-telemetry-otel-revival.md) owns capture and redaction rationale.
67
69
 
68
70
  ### Source map
69
71
 
package/README.zh.md CHANGED
@@ -39,6 +39,8 @@ kind: "package-library"
39
39
 
40
40
  捕获以两种模式之一运行。`live` 捕获在追加时跟随会话事件、在挂载时回放已存活会话并记录生命周期标记;`on-demand` 捕获只在后端通过 `captureSession(session, throughSeq?)` 请求前缀时读取权威会话日志。协调器选项决定是否包含存储历史。每条权威会话事件都按顺序映射为一条 ledger 记录。`assistant/message` 或 `assistant/attempt` 记录会携带完整的嵌入式紧凑流,包括失败和重试输出。每条 ledger 记录还携带 `session.id`、`session.format_version`、数值型事件标识、可选 header 事实与预先映射的严重级别(`tool/result.isError`、`turn/end` 的错误原因与 `agent-error` 映射为 `error`;其余为 `info`)。
41
41
 
42
+ ledger 记录携带 `sourceEvent`,其中包含所属 Session id 和不含 `data` 的事件信封副本。脱敏 waterfall 接收的 `body` 是唯一的载荷副本。后端可从信封和脱敏后的 body 重建完整导出事件,而不绕过脱敏。
43
+
42
44
  ### 共享披露
43
45
 
44
46
  <a id="the-sharing-disclosure"></a>
@@ -63,7 +65,7 @@ kind: "package-library"
63
65
 
64
66
  ### 设计理念
65
67
 
66
- seam 建立在一个边界之上:harness 的职责止于 `emit()`。完整事件捕获、脱敏与 handoff 游标都在这里;批处理、重试、排队与丢失策略属于上报 SDK,本包有意不建模也不包装。设计与被否决的替代方案见[复活 Agent Note](../../../.agents/notes/implemented/feature/2026-07-23-session-telemetry-otel-revival.zh.md)。
68
+ 捕获包负责完整事件捕获、脱敏和交接游标。脱敏规则必须保留 `sourceEvent` 才能通过 OTel 上传;返回不含它的新记录会阻止该事件上传并产生诊断。复制的 envelope 不含 `data`,数据仅由 `body` 携带。OTel 后端负责字节/条数调度并使用 SDK 传输和重试。[恢复遥测决策记录](../../../.agents/notes/implemented/feature/2026-07-23-session-telemetry-otel-revival.zh.md) 说明捕获和脱敏依据。
67
69
 
68
70
  ### 源码地图
69
71
 
package/lib/index.js CHANGED
@@ -134,13 +134,18 @@ var SessionTelemetryCoordinator = class {
134
134
  }
135
135
  /** Copy, redact, and hand one canonical event to the backend. */
136
136
  captureEvent(session, event) {
137
+ const { data, ...envelope } = event;
137
138
  this.deliver(session, {
138
139
  record: this.redact({
140
+ sourceEvent: {
141
+ sessionId: session.id,
142
+ envelope: structuredClone(envelope)
143
+ },
139
144
  channel: "ledger",
140
145
  time: event.time,
141
146
  severity: severityOf(event),
142
147
  attributes: identityOf(session, event),
143
- body: structuredClone(event.data)
148
+ body: structuredClone(data)
144
149
  }),
145
150
  seq: event.seq
146
151
  });
@@ -253,7 +258,7 @@ function identityOf(session, event) {
253
258
  * forwarding), live versus on-demand canonical-log capture, and the HMR
254
259
  * cursor. Everything downstream of
255
260
  * {@link SessionTelemetryBackend.emit} — batching, retry, queueing, and loss policy — is the
256
- * reporting SDK's territory and is deliberately not modelled here. The
261
+ * backend's responsibility and is deliberately not modelled here. The
257
262
  * design and its trade-offs are pinned in
258
263
  * .agents/notes/implemented/feature/2026-07-23-session-telemetry-otel-revival.md.
259
264
  *
@@ -7,13 +7,14 @@
7
7
  * forwarding), live versus on-demand canonical-log capture, and the HMR
8
8
  * cursor. Everything downstream of
9
9
  * {@link SessionTelemetryBackend.emit} — batching, retry, queueing, and loss policy — is the
10
- * reporting SDK's territory and is deliberately not modelled here. The
10
+ * backend's responsibility and is deliberately not modelled here. The
11
11
  * design and its trade-offs are pinned in
12
12
  * .agents/notes/implemented/feature/2026-07-23-session-telemetry-otel-revival.md.
13
13
  *
14
14
  * @module @deepseek-ai/dsh-session-telemetry
15
15
  */
16
16
  import { Context, Service } from '@deepseek-ai/cordis';
17
+ import type { SessionEvent, SessionId } from '@deepseek-ai/dsh-session';
17
18
  declare module '@deepseek-ai/cordis' {
18
19
  interface Context {
19
20
  sessionTelemetry: SessionTelemetryBackend;
@@ -57,6 +58,11 @@ export type SessionTelemetrySeverity = 'info' | 'warn' | 'error';
57
58
  * identity so they can never be mistaken for ledger rows.
58
59
  */
59
60
  export interface SessionTelemetryRecord {
61
+ /** Canonical envelope without data; body carries the separately redacted payload. Absent for operational records. */
62
+ sourceEvent?: {
63
+ sessionId: SessionId;
64
+ envelope: Omit<SessionEvent, 'data'>;
65
+ };
60
66
  /** Ledger (session-log mirror) or ops (operational signal) channel; backends keep the two under separate instrumentation scopes. */
61
67
  channel: 'ledger' | 'ops';
62
68
  /** Unix epoch milliseconds — the source event's append time for ledger records, the emission time for ops records. */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deepseek-ai/dsh-session-telemetry",
3
3
  "description": "SessionTelemetryBackend seam for the DeepSeek Harness: session-event capture, projection, redaction, and handoff to a reporting backend",
4
- "version": "0.1.7-rc.1",
4
+ "version": "0.2.0-rc.1",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -27,13 +27,13 @@
27
27
  ],
28
28
  "license": "MIT",
29
29
  "peerDependencies": {
30
- "@deepseek-ai/dsh-agent": "0.1.7-rc.1",
31
- "@deepseek-ai/dsh-session": "0.1.7-rc.1",
32
- "@deepseek-ai/cordis": "~4.0.4"
30
+ "@deepseek-ai/dsh-session": "0.2.0-rc.1",
31
+ "@deepseek-ai/cordis": "~4.0.4",
32
+ "@deepseek-ai/dsh-agent": "0.2.0-rc.1"
33
33
  },
34
34
  "devDependencies": {
35
- "@deepseek-ai/dsh-agent": "0.1.7-rc.1",
36
- "@deepseek-ai/dsh-session": "0.1.7-rc.1",
35
+ "@deepseek-ai/dsh-agent": "0.2.0-rc.1",
36
+ "@deepseek-ai/dsh-session": "0.2.0-rc.1",
37
37
  "@deepseek-ai/cordis": "~4.0.4"
38
38
  }
39
39
  }