@deepseek-ai/dsh-session-telemetry 0.0.1-rc.2 → 0.0.1-rc.5

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
@@ -2,5 +2,5 @@
2
2
  # side as of the last confirmed-consistent state. Both languages carry equal authority;
3
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: 707dcfcdb0c8dfbd622630351928ac43562535ec
6
- README.zh.md: bd080adceebf83cd9e53d72a7093db376cf6cbd1
5
+ README.md: e4ebee1324bc1228d6d97d891159685b05f94e4f
6
+ README.zh.md: 963d5f6d1c5c0f60f5bf14956f3b490d60bd6574
package/README.md CHANGED
@@ -2,13 +2,13 @@
2
2
 
3
3
  English | [中文](README.zh.md)
4
4
 
5
- The telemetry Service Definition declares the `TelemetryBackend` contract, and its capture coordinator passes session records to any reporting SDK backend that implements it. Capture can follow live session events or replay a canonical session-log prefix on demand. This package stops after it calls `emit()`: batching, retry, queueing, and loss policy belong to the backend's SDK and are neither specified nor wrapped. Rationale and rejected alternatives: [the revival Agent Note](../../../.agents/notes/implemented/feature/2026-07-23-session-telemetry-otel-revival.md), [feedback-gated delivery](../../../.agents/notes/implemented/feature/2026-08-05-feedback-gated-session-telemetry.md), and [buffer-free feedback replay](../../../.agents/notes/implemented/simplification/2026-08-06-buffer-free-feedback-telemetry.md).
5
+ The telemetry Service Definition declares the `SessionTelemetrySink` contract, and its capture coordinator passes session records to any reporting SDK backend that implements it. Capture can follow live session events or replay a canonical session-log prefix on demand. This package stops after it calls `emit()`: batching, retry, queueing, and loss policy belong to the backend's SDK and are neither specified nor wrapped. Rationale and rejected alternatives: [the revival Agent Note](../../../.agents/notes/implemented/feature/2026-07-23-session-telemetry-otel-revival.md), [feedback-gated delivery](../../../.agents/notes/implemented/feature/2026-08-05-feedback-gated-session-telemetry.md), and [buffer-free feedback replay](../../../.agents/notes/implemented/simplification/2026-08-06-buffer-free-feedback-telemetry.md).
6
6
 
7
7
  ## The backend contract
8
8
 
9
- `TelemetryBackend` has three members: `emit(record)` MUST enqueue without blocking because it runs synchronously during `session/event` or explicit canonical-log replay; optional `flush()` is a fire-and-forget hint after a turn ends, and most backends omit it and use their SDK's normal batching schedule; `shutdown()` drains queued records and resolves when the SDK stops, and disposal awaits it. An implementation that provides `flush()` must order concurrent flushes with the final `shutdown()` drain. `Telemetry` registers this API under the `telemetry` context key; each context accepts one implementation, and a duplicate load throws. A backend constructs `TelemetryCoordinator` with `live` or `on-demand` capture and calls `captureSession(session, throughSeq?)` at its chosen trigger.
9
+ `SessionTelemetrySink` has three members: `emit(record)` MUST enqueue without blocking because it runs synchronously during `session/event` or explicit canonical-log replay; optional `flush()` is a fire-and-forget hint after a turn ends, and most backends omit it and use their SDK's normal batching schedule; `shutdown()` drains queued records and resolves when the SDK stops, and disposal awaits it. An implementation that provides `flush()` must order concurrent flushes with the final `shutdown()` drain. `SessionTelemetryBackend` registers this API under the `sessionTelemetry` context key; each context accepts one implementation, and a duplicate load throws. A backend constructs `SessionTelemetryCoordinator` with `live` or `on-demand` capture and calls `captureSession(session, throughSeq?)` at its chosen trigger.
10
10
 
11
- The service also carries the required [`TelemetrySharingStatus`](#the-sharing-disclosure) `sharing` member: the deployment-selected sharing policy every backend must disclose to human-facing acknowledgement surfaces (the `/feedback` command's confirmation). A consumer renders "not configured" only when no telemetry service is mounted. The seam owns the vocabulary (`full` | `feedback-only` | `disabled`) so any backend can disclose a policy without depending on the OTel package.
11
+ The service also carries the required [`SessionTelemetrySharingStatus`](#the-sharing-disclosure) `sharing` member: the deployment-selected sharing policy every backend must disclose to human-facing acknowledgement surfaces (the `/feedback` command's confirmation). A consumer renders "not configured" only when no telemetry service is mounted. The seam owns the vocabulary (`full` | `feedback-only` | `disabled`) so any backend can disclose a policy without depending on the OTel package.
12
12
 
13
13
  ## The sharing disclosure
14
14
 
@@ -20,7 +20,7 @@ In `live` mode the coordinator registers, all through the composing fiber's effe
20
20
 
21
21
  ## The redact waterfall
22
22
 
23
- Every record passes the `telemetry/record` waterfall immediately after projection — the Service Definition's scrubbing extension point. This package ships NO rules of its own: the innermost `next()` passes the record through unchanged, so with no listener mounted records reach the backend exactly as captured, and exported data is precisely as clean as the rules a deployment mounts. Listeners stack by transforming `next()`'s return value; returning without `next()` replaces everything beneath, and a throwing listener withholds that one record fail-closed inside the coordinator's containment. Live capture runs the waterfall at append time; on-demand capture runs it while replaying the canonical log, using the rules mounted at that time. Redaction applies to the outbound copy only; the canonical session log is never rewritten.
23
+ Every record passes the `sessionTelemetry/record` waterfall immediately after projection — the Service Definition's scrubbing extension point. This package ships NO rules of its own: the innermost `next()` passes the record through unchanged, so with no listener mounted records reach the backend exactly as captured, and exported data is precisely as clean as the rules a deployment mounts. Listeners stack by transforming `next()`'s return value; returning without `next()` replaces everything beneath, and a throwing listener withholds that one record fail-closed inside the coordinator's containment. Live capture runs the waterfall at append time; on-demand capture runs it while replaying the canonical log, using the rules mounted at that time. Redaction applies to the outbound copy only; the canonical session log is never rewritten.
24
24
 
25
25
  ## The handoff cursor
26
26
 
@@ -32,7 +32,7 @@ Only the first `assistant/chunk` of each `(turn, step)` ships; the rest are drop
32
32
 
33
33
  ## The logical record
34
34
 
35
- `TelemetryRecord`: `channel` (`ledger` | `ops`), `time` (epoch ms), `severity` (pre-mapped: ERROR for `tool/result.isError`, `turn/end` error reasons, and `agent-error`; INFO for other captured records, while `telemetry/record` policies may assign WARN), identity-only `attributes` (`session.id`, `event.type`, `event.seq`, plus `session.cwd`/`session.parent_id`/`session.seed_length` when the header has them), and the complete deep-copied `event.data` as `body` — post-redaction. Operational records carry `telemetry.op` (`agent-error` | `shutdown`) and `session.id`, and deliberately NO `event.seq`/`event.type` — signals to alert on, not entries to sum; `agent-error` normalizes its arbitrary thrown value into a stable `{ name, message }` body. Delivery downstream of the handoff is the backend SDK's; duplicates remain possible (cursor-less re-adoption, SDK retries), so receivers dedupe on `(session.id, event.seq)`.
35
+ `SessionTelemetryRecord`: `channel` (`ledger` | `ops`), `time` (epoch ms), `severity` (pre-mapped: ERROR for `tool/result.isError`, `turn/end` error reasons, and `agent-error`; INFO for other captured records, while `sessionTelemetry/record` policies may assign WARN), identity-only `attributes` (`session.id`, `event.type`, `event.seq`, plus `session.cwd`/`session.parent_id`/`session.seed_length` when the header has them), and the complete deep-copied `event.data` as `body` — post-redaction. Operational records carry `sessionTelemetry.op` (`agent-error` | `shutdown`) and `session.id`, and deliberately NO `event.seq`/`event.type` — signals to alert on, not entries to sum; `agent-error` normalizes its arbitrary thrown value into a stable `{ name, message }` body. Delivery downstream of the handoff is the backend SDK's; duplicates remain possible (cursor-less re-adoption, SDK retries), so receivers dedupe on `(session.id, event.seq)`.
36
36
 
37
37
  ## Model Experience
38
38
 
@@ -45,5 +45,5 @@ None; this package neither assembles nor sends a provider request.
45
45
  ## Known Limitations and Deferred Work
46
46
 
47
47
  - **Best-effort delivery** — the cursor marks handed-off, not delivered; a session torn down inside a reload window cannot be re-adopted; whatever sits in a backend queue at crash time is lost. A durable outbox (spool, per-sink cursors, at-least-once) is deferred until a deployment states a crash-loss requirement — see [the revival Agent Note](../../../.agents/notes/implemented/feature/2026-07-23-session-telemetry-otel-revival.md).
48
- - **No built-in redaction rules** — with no `telemetry/record` listener mounted, records leave the process exactly as captured, including any credentials embedded in file contents or command output; a deployment exporting to a shared collector owns its rule set.
48
+ - **No built-in redaction rules** — with no `sessionTelemetry/record` listener mounted, records leave the process exactly as captured, including any credentials embedded in file contents or command output; a deployment exporting to a shared collector owns its rule set.
49
49
  - **On-demand redaction uses current state** — uncaptured events exist only in the canonical session log. A later `captureSession()` deep-copies and redacts their current values with the policy mounted at that time; there is no capture-time telemetry snapshot or durable pre-capture spool.
package/README.zh.md CHANGED
@@ -2,13 +2,13 @@
2
2
 
3
3
  [English](README.md) | 中文
4
4
 
5
- 遥测(telemetry)Service Definition 声明 `TelemetryBackend` 后端约定,捕获协调器把会话记录传给实现该约定的任意上报 SDK 后端。捕获侧可跟随实时会话事件,也可按需回放权威会话日志前缀。本包调用 `emit()` 后就停止处理:批处理、重试、排队与丢失策略都属于后端自身的 SDK,本包既不规定也不包装。设计依据与被否决的替代方案见[复活 Agent Note](../../../.agents/notes/implemented/feature/2026-07-23-session-telemetry-otel-revival.md)、[反馈门控投递](../../../.agents/notes/implemented/feature/2026-08-05-feedback-gated-session-telemetry.md)与[无缓冲反馈回放](../../../.agents/notes/implemented/simplification/2026-08-06-buffer-free-feedback-telemetry.md)。
5
+ 遥测(telemetry)Service Definition 声明 `SessionTelemetrySink` 后端约定,捕获协调器把会话记录传给实现该约定的任意上报 SDK 后端。捕获侧可跟随实时会话事件,也可按需回放权威会话日志前缀。本包调用 `emit()` 后就停止处理:批处理、重试、排队与丢失策略都属于后端自身的 SDK,本包既不规定也不包装。设计依据与被否决的替代方案见[复活 Agent Note](../../../.agents/notes/implemented/feature/2026-07-23-session-telemetry-otel-revival.md)、[反馈门控投递](../../../.agents/notes/implemented/feature/2026-08-05-feedback-gated-session-telemetry.md)与[无缓冲反馈回放](../../../.agents/notes/implemented/simplification/2026-08-06-buffer-free-feedback-telemetry.md)。
6
6
 
7
7
  ## 后端约定
8
8
 
9
- `TelemetryBackend` 有三个成员:`emit(record)` 必须入队且不能阻塞,因为它会在 `session/event` 或显式权威日志回放期间同步执行;可选的 `flush()` 是轮次结束后的提示,调用方不等待结果,多数后端省略它并使用 SDK 的常规批处理计划;`shutdown()` 排空已入队记录,并在 SDK 停止后结束,dispose(资源释放)会等待它。提供 `flush()` 的实现必须安排并发 flush 与 `shutdown()` 最终排空的先后顺序。`Telemetry` 将此 API 注册在 `telemetry` 上下文键下:每个上下文只允许一个实现,重复加载会抛出异常。后端以 `live` 或 `on-demand` 捕获构造 `TelemetryCoordinator`,并在自己选择的触发器中调用 `captureSession(session, throughSeq?)`。
9
+ `SessionTelemetrySink` 有三个成员:`emit(record)` 必须入队且不能阻塞,因为它会在 `session/event` 或显式权威日志回放期间同步执行;可选的 `flush()` 是轮次结束后的提示,调用方不等待结果,多数后端省略它并使用 SDK 的常规批处理计划;`shutdown()` 排空已入队记录,并在 SDK 停止后结束,dispose(资源释放)会等待它。提供 `flush()` 的实现必须安排并发 flush 与 `shutdown()` 最终排空的先后顺序。`SessionTelemetryBackend` 将此 API 注册在 `sessionTelemetry` 上下文键下:每个上下文只允许一个实现,重复加载会抛出异常。后端以 `live` 或 `on-demand` 捕获构造 `SessionTelemetryCoordinator`,并在自己选择的触发器中调用 `captureSession(session, throughSeq?)`。
10
10
 
11
- 该服务还携带必需的 [`TelemetrySharingStatus`](#the-sharing-disclosure) `sharing` 成员:每个后端都必须向面向用户的确认 surface(`/feedback` 命令的确认文本)披露的部署级共享策略。消费方只有在未挂载任何遥测服务时才渲染「未配置」。seam 拥有该词汇(`full` | `feedback-only` | `disabled`),因此任何后端都可以披露策略,而无需依赖 OTel 包。
11
+ 该服务还携带必需的 [`SessionTelemetrySharingStatus`](#the-sharing-disclosure) `sharing` 成员:每个后端都必须向面向用户的确认 surface(`/feedback` 命令的确认文本)披露的部署级共享策略。消费方只有在未挂载任何遥测服务时才渲染「未配置」。seam 拥有该词汇(`full` | `feedback-only` | `disabled`),因此任何后端都可以披露策略,而无需依赖 OTel 包。
12
12
 
13
13
  <a id="the-sharing-disclosure"></a>
14
14
 
@@ -22,7 +22,7 @@
22
22
 
23
23
  ## 脱敏 waterfall(瀑布式事件)
24
24
 
25
- 每条记录在投影后立即经过 `telemetry/record` waterfall,这是 Service Definition 的脱敏扩展点。本包自身不带任何规则:最内层的 `next()` 原样透传记录,因此未挂载监听器时,记录以捕获时的原样到达后端;导出数据能干净到什么程度,恰恰取决于部署方挂载了什么规则。监听器通过变换 `next()` 的返回值来堆叠;不调用 `next()` 就返回,即替换其下方的全部逻辑;抛出异常的监听器会在协调器的隔离范围内以 fail-closed 方式拦下这一条记录。实时捕获在追加时运行 waterfall;按需捕获则在回放权威日志时使用当时挂载的规则运行 waterfall。脱敏只作用于外发副本;权威会话日志永不改写。
25
+ 每条记录在投影后立即经过 `sessionTelemetry/record` waterfall,这是 Service Definition 的脱敏扩展点。本包自身不带任何规则:最内层的 `next()` 原样透传记录,因此未挂载监听器时,记录以捕获时的原样到达后端;导出数据能干净到什么程度,恰恰取决于部署方挂载了什么规则。监听器通过变换 `next()` 的返回值来堆叠;不调用 `next()` 就返回,即替换其下方的全部逻辑;抛出异常的监听器会在协调器的隔离范围内以 fail-closed 方式拦下这一条记录。实时捕获在追加时运行 waterfall;按需捕获则在回放权威日志时使用当时挂载的规则运行 waterfall。脱敏只作用于外发副本;权威会话日志永不改写。
26
26
 
27
27
  ## handoff 游标
28
28
 
@@ -34,7 +34,7 @@
34
34
 
35
35
  ## 逻辑记录
36
36
 
37
- `TelemetryRecord` 包含:`channel`(`ledger` | `ops`)、`time`(epoch 毫秒)、`severity`(预先映射好的严重级别:`tool/result.isError`、`turn/end` 的错误原因与 `agent-error` 映射为 ERROR,其他已捕获记录映射为 INFO,而 `telemetry/record` 策略可以指定 WARN)、只含身份信息的 `attributes`(`session.id`、`event.type`、`event.seq`,header 中存在时再加 `session.cwd`/`session.parent_id`/`session.seed_length`),以及作为 `body` 的完整深拷贝 `event.data`,且以脱敏后的内容为准。运维记录携带 `telemetry.op`(`agent-error` | `shutdown`)和 `session.id`,并刻意不带 `event.seq`/`event.type`:它们是用来告警的信号,不是用来累加的条目;`agent-error` 会把任意抛出值规范化为稳定的 `{ name, message }` 记录主体。交接之后的投递由后端 SDK 负责;重复仍然可能出现(无游标的重新收养、SDK 重试),因此接收端基于 `(session.id, event.seq)` 去重。
37
+ `SessionTelemetryRecord` 包含:`channel`(`ledger` | `ops`)、`time`(epoch 毫秒)、`severity`(预先映射好的严重级别:`tool/result.isError`、`turn/end` 的错误原因与 `agent-error` 映射为 ERROR,其他已捕获记录映射为 INFO,而 `sessionTelemetry/record` 策略可以指定 WARN)、只含身份信息的 `attributes`(`session.id`、`event.type`、`event.seq`,header 中存在时再加 `session.cwd`/`session.parent_id`/`session.seed_length`),以及作为 `body` 的完整深拷贝 `event.data`,且以脱敏后的内容为准。运维记录携带 `sessionTelemetry.op`(`agent-error` | `shutdown`)和 `session.id`,并刻意不带 `event.seq`/`event.type`:它们是用来告警的信号,不是用来累加的条目;`agent-error` 会把任意抛出值规范化为稳定的 `{ name, message }` 记录主体。交接之后的投递由后端 SDK 负责;重复仍然可能出现(无游标的重新收养、SDK 重试),因此接收端基于 `(session.id, event.seq)` 去重。
38
38
 
39
39
  ## 模型体验
40
40
 
@@ -47,5 +47,5 @@
47
47
  ## 已知限制与暂缓事项
48
48
 
49
49
  - **尽力而为的投递**:游标标记的是已交接而非已投递;在重载窗口内被拆除的会话无法重新收养;崩溃时留在后端队列中的内容会丢失。持久化 outbox(spool、每 sink 游标、at-least-once)推迟到有部署方提出明确的崩溃丢失要求时再实现;见[复活 Agent Note](../../../.agents/notes/implemented/feature/2026-07-23-session-telemetry-otel-revival.md)。
50
- - **不内置脱敏规则**:未挂载 `telemetry/record` 监听器时,记录以捕获时的原样离开进程,包括文件内容或命令输出中内嵌的任何凭据;向共享 collector 导出的部署方自行负责其规则集。
50
+ - **不内置脱敏规则**:未挂载 `sessionTelemetry/record` 监听器时,记录以捕获时的原样离开进程,包括文件内容或命令输出中内嵌的任何凭据;向共享 collector 导出的部署方自行负责其规则集。
51
51
  - **按需脱敏使用当前状态**:未捕获的事件只存在于权威会话日志中。后续的 `captureSession()` 会使用当时挂载的策略,深拷贝并脱敏其当前值;不存在捕获时的遥测快照或持久化的捕获前 spool。
package/lib/index.js CHANGED
@@ -5,7 +5,7 @@ import { Service } from "@deepseek-ai/cordis";
5
5
  * the session firehose plus the one live-bus relay (`agent/error`). Both
6
6
  * capture paths apply the fixed chunk projection, build logical records, and
7
7
  * run each through the
8
- * `telemetry/record` waterfall (deployment-mounted redaction rules;
8
+ * `session-telemetry/record` waterfall (deployment-mounted redaction rules;
9
9
  * pass-through when none), then hands the result to the backend. Live capture
10
10
  * follows the session firehose; on-demand capture replays the canonical log
11
11
  * only when requested. Every synchronous handler is self-contained so a
@@ -42,7 +42,7 @@ const handoffCursor = /* @__PURE__ */ new WeakMap();
42
42
  * instead of throwing — best-effort reporting must not fail application
43
43
  * teardown.
44
44
  */
45
- var TelemetryCoordinator = class {
45
+ var SessionTelemetryCoordinator = class {
46
46
  ctx;
47
47
  backend;
48
48
  /**
@@ -163,7 +163,7 @@ var TelemetryCoordinator = class {
163
163
  });
164
164
  }
165
165
  /**
166
- * Run the `telemetry/record` waterfall at capture time. The innermost `next`
166
+ * Run the `session-telemetry/record` waterfall at capture time. The innermost `next`
167
167
  * passes the record through unchanged — this package ships no rules; exported
168
168
  * data is as clean as the listeners a deployment mounts. Callers run inside
169
169
  * {@link contain}, so a throwing rule withholds the record instead of
@@ -171,7 +171,7 @@ var TelemetryCoordinator = class {
171
171
  * while reading the canonical session log, not when the event was appended.
172
172
  */
173
173
  redact(record) {
174
- return this.ctx.waterfall("telemetry/record", record, () => record);
174
+ return this.ctx.waterfall("session-telemetry/record", record, () => record);
175
175
  }
176
176
  /** Hand one redacted record to the backend, then advance its ledger cursor. */
177
177
  deliver(session, pending) {
@@ -267,14 +267,14 @@ function identityOf(session, event) {
267
267
  //#endregion
268
268
  //#region lib/types/index.js
269
269
  /**
270
- * Telemetry Service Definition for the DeepSeek Harness.
270
+ * SessionTelemetryBackend Service Definition for the DeepSeek Harness.
271
271
  *
272
272
  * This package owns the CAPTURE side of session-event reporting — which records
273
273
  * exist (the chunk projection), what they carry (the logical record), when
274
274
  * they are captured (adoption, the per-append firehose, lifecycle
275
275
  * forwarding), live versus on-demand canonical-log capture, and the HMR
276
276
  * cursor. Everything downstream of
277
- * {@link Telemetry.emit} — batching, retry, queueing, and loss policy — is the
277
+ * {@link SessionTelemetryBackend.emit} — batching, retry, queueing, and loss policy — is the
278
278
  * reporting SDK's territory and is deliberately not modelled here. The
279
279
  * design and its trade-offs are pinned in
280
280
  * .agents/notes/implemented/feature/2026-07-23-session-telemetry-otel-revival.md.
@@ -285,12 +285,12 @@ function identityOf(session, event) {
285
285
  * Loadable form of the backend contract: one implementation per context —
286
286
  * the cordis `Service` registration under the `telemetry` key throws on a
287
287
  * duplicate, cordis' standard behavior. A backend composes a
288
- * {@link TelemetryCoordinator} in its constructor to install the capture side.
288
+ * {@link SessionTelemetryCoordinator} in its constructor to install the capture side.
289
289
  */
290
- var Telemetry = class extends Service {
290
+ var SessionTelemetryBackend = class extends Service {
291
291
  constructor(ctx) {
292
- super(ctx, "telemetry");
292
+ super(ctx, "sessionTelemetry");
293
293
  }
294
294
  };
295
295
  //#endregion
296
- export { Telemetry, TelemetryCoordinator };
296
+ export { SessionTelemetryBackend, SessionTelemetryCoordinator };
@@ -3,7 +3,7 @@
3
3
  * the session firehose plus the one live-bus relay (`agent/error`). Both
4
4
  * capture paths apply the fixed chunk projection, build logical records, and
5
5
  * run each through the
6
- * `telemetry/record` waterfall (deployment-mounted redaction rules;
6
+ * `session-telemetry/record` waterfall (deployment-mounted redaction rules;
7
7
  * pass-through when none), then hands the result to the backend. Live capture
8
8
  * follows the session firehose; on-demand capture replays the canonical log
9
9
  * only when requested. Every synchronous handler is self-contained so a
@@ -15,9 +15,9 @@
15
15
  */
16
16
  import type { Context } from '@deepseek-ai/cordis';
17
17
  import type { Session } from '@deepseek-ai/dsh-session';
18
- import type { TelemetryBackend } from './index.ts';
18
+ import type { SessionTelemetrySink } from './index.ts';
19
19
  /** Whether capture follows live events or reads the canonical log only when requested. */
20
- export type TelemetryCapture = 'live' | 'on-demand';
20
+ export type SessionTelemetryCapture = 'live' | 'on-demand';
21
21
  /**
22
22
  * Install the telemetry capture side onto a context for one backend.
23
23
  *
@@ -33,7 +33,7 @@ export type TelemetryCapture = 'live' | 'on-demand';
33
33
  * instead of throwing — best-effort reporting must not fail application
34
34
  * teardown.
35
35
  */
36
- export declare class TelemetryCoordinator {
36
+ export declare class SessionTelemetryCoordinator {
37
37
  private readonly ctx;
38
38
  private readonly backend;
39
39
  /**
@@ -49,7 +49,7 @@ export declare class TelemetryCoordinator {
49
49
  * @param backend - the backend receiving records; owned elsewhere, never disposed here beyond `shutdown()` forwarding.
50
50
  * @param capture - follow live events, or wait for explicit canonical-log capture.
51
51
  */
52
- constructor(ctx: Context, backend: TelemetryBackend, capture?: TelemetryCapture);
52
+ constructor(ctx: Context, backend: SessionTelemetrySink, capture?: SessionTelemetryCapture);
53
53
  /**
54
54
  * Project and hand over the canonical session-log suffix after the handoff
55
55
  * cursor, optionally stopping at an inclusive sequence boundary. Redaction
@@ -82,7 +82,7 @@ export declare class TelemetryCoordinator {
82
82
  /** Project, redact, and hand one event to the backend. */
83
83
  private captureEvent;
84
84
  /**
85
- * Run the `telemetry/record` waterfall at capture time. The innermost `next`
85
+ * Run the `session-telemetry/record` waterfall at capture time. The innermost `next`
86
86
  * passes the record through unchanged — this package ships no rules; exported
87
87
  * data is as clean as the listeners a deployment mounts. Callers run inside
88
88
  * {@link contain}, so a throwing rule withholds the record instead of
@@ -1,12 +1,12 @@
1
1
  /**
2
- * Telemetry Service Definition for the DeepSeek Harness.
2
+ * SessionTelemetryBackend Service Definition for the DeepSeek Harness.
3
3
  *
4
4
  * This package owns the CAPTURE side of session-event reporting — which records
5
5
  * exist (the chunk projection), what they carry (the logical record), when
6
6
  * they are captured (adoption, the per-append firehose, lifecycle
7
7
  * forwarding), live versus on-demand canonical-log capture, and the HMR
8
8
  * cursor. Everything downstream of
9
- * {@link Telemetry.emit} — batching, retry, queueing, and loss policy — is the
9
+ * {@link SessionTelemetryBackend.emit} — batching, retry, queueing, and loss policy — is the
10
10
  * reporting SDK's territory 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.
@@ -16,7 +16,7 @@
16
16
  import { Context, Service } from '@deepseek-ai/cordis';
17
17
  declare module '@deepseek-ai/cordis' {
18
18
  interface Context {
19
- telemetry: Telemetry;
19
+ sessionTelemetry: SessionTelemetryBackend;
20
20
  }
21
21
  interface Events {
22
22
  /**
@@ -37,7 +37,7 @@ declare module '@deepseek-ai/cordis' {
37
37
  * copy; listeners return a (possibly new) record and must not mutate it.
38
38
  * @mode waterfall
39
39
  */
40
- 'telemetry/record'(record: TelemetryRecord, next: () => TelemetryRecord): TelemetryRecord;
40
+ 'session-telemetry/record'(record: SessionTelemetryRecord, next: () => SessionTelemetryRecord): SessionTelemetryRecord;
41
41
  }
42
42
  }
43
43
  /**
@@ -45,10 +45,10 @@ declare module '@deepseek-ai/cordis' {
45
45
  * alert with zero configuration: `error` for events whose own outcome flag
46
46
  * says so (the tool-result block's `isError`, `turn/end` error reasons) and for
47
47
  * `agent-error` operational records. Captured events otherwise default to
48
- * `info`; `warn` remains available to `telemetry/record` policies and
48
+ * `info`; `warn` remains available to `session-telemetry/record` policies and
49
49
  * backends.
50
50
  */
51
- export type TelemetrySeverity = 'info' | 'warn' | 'error';
51
+ export type SessionTelemetrySeverity = 'info' | 'warn' | 'error';
52
52
  /**
53
53
  * One logical record handed to a backend — the capture contract's whole outbound
54
54
  * vocabulary. Ledger records mirror session-log events one-to-one;
@@ -56,13 +56,13 @@ export type TelemetrySeverity = 'info' | 'warn' | 'error';
56
56
  * home (`agent-error`, `shutdown`) and deliberately omit `event.seq`-style
57
57
  * identity so they can never be mistaken for ledger rows.
58
58
  */
59
- export interface TelemetryRecord {
59
+ export interface SessionTelemetryRecord {
60
60
  /** Ledger (session-log mirror) or ops (operational signal) channel; backends keep the two under separate instrumentation scopes. */
61
61
  channel: 'ledger' | 'ops';
62
62
  /** Unix epoch milliseconds — the source event's append time for ledger records, the emission time for ops records. */
63
63
  time: number;
64
- /** Pre-mapped alerting severity; see {@link TelemetrySeverity}. */
65
- severity: TelemetrySeverity;
64
+ /** Pre-mapped alerting severity; see {@link SessionTelemetrySeverity}. */
65
+ severity: SessionTelemetrySeverity;
66
66
  /**
67
67
  * Identity attributes, deliberately minimal: ledger records carry
68
68
  * `session.id`, `event.type`, `event.seq`, plus `session.cwd` /
@@ -81,11 +81,11 @@ export interface TelemetryRecord {
81
81
  body: unknown;
82
82
  }
83
83
  /**
84
- * The minimum backend contract the coordinator requires. {@link Telemetry} is
84
+ * The minimum backend contract the coordinator requires. {@link SessionTelemetryBackend} is
85
85
  * its service-registered form; tests compose the coordinator with a bare
86
86
  * implementation of this interface.
87
87
  */
88
- export interface TelemetryBackend {
88
+ export interface SessionTelemetrySink {
89
89
  /**
90
90
  * Hand one record to the backend's pipeline. MUST be a non-blocking
91
91
  * enqueue — the coordinator calls this synchronously from the
@@ -95,7 +95,7 @@ export interface TelemetryBackend {
95
95
  * never reach the loop.
96
96
  * @param record - the logical record to report; owned by the backend after the call.
97
97
  */
98
- emit(record: TelemetryRecord): void;
98
+ emit(record: SessionTelemetryRecord): void;
99
99
  /**
100
100
  * Optional hint that a turn ended. A backend may forward it to its SDK's
101
101
  * flush so records are exported after each turn. Called
@@ -125,19 +125,19 @@ export interface TelemetryBackend {
125
125
  }
126
126
  /**
127
127
  * Deployment-selected session-sharing policy disclosed by a mounted
128
- * {@link Telemetry} backend to human-facing acknowledgement surfaces (the
128
+ * {@link SessionTelemetryBackend} backend to human-facing acknowledgement surfaces (the
129
129
  * `/feedback` command's confirmation text). The seam owns the vocabulary so
130
130
  * any backend can disclose a policy without depending on the OTel package;
131
- * the values mirror the OTel backend's serialized `TelemetryMode` choices.
131
+ * the values mirror the OTel backend's serialized `SessionTelemetryMode` choices.
132
132
  */
133
- export type TelemetrySharingStatus = 'full' | 'feedback-only' | 'disabled';
133
+ export type SessionTelemetrySharingStatus = 'full' | 'feedback-only' | 'disabled';
134
134
  /**
135
135
  * Loadable form of the backend contract: one implementation per context —
136
136
  * the cordis `Service` registration under the `telemetry` key throws on a
137
137
  * duplicate, cordis' standard behavior. A backend composes a
138
- * {@link TelemetryCoordinator} in its constructor to install the capture side.
138
+ * {@link SessionTelemetryCoordinator} in its constructor to install the capture side.
139
139
  */
140
- export declare abstract class Telemetry extends Service implements TelemetryBackend {
140
+ export declare abstract class SessionTelemetryBackend extends Service implements SessionTelemetrySink {
141
141
  constructor(ctx: Context);
142
142
  /**
143
143
  * Deployment-selected session-sharing policy, disclosed for acknowledgement
@@ -146,19 +146,19 @@ export declare abstract class Telemetry extends Service implements TelemetryBack
146
146
  * when no telemetry service is mounted. The seam owns this vocabulary so the
147
147
  * disclosure is backend-independent.
148
148
  */
149
- abstract readonly sharing: TelemetrySharingStatus;
149
+ abstract readonly sharing: SessionTelemetrySharingStatus;
150
150
  /**
151
- * See {@link TelemetryBackend.emit} — that declaration is the contract's one home.
151
+ * See {@link SessionTelemetrySink.emit} — that declaration is the contract's one home.
152
152
  * @param record - the logical record to report; owned by the backend after the call.
153
153
  */
154
- abstract emit(record: TelemetryRecord): void;
155
- /** See {@link TelemetryBackend.flush}. */
154
+ abstract emit(record: SessionTelemetryRecord): void;
155
+ /** See {@link SessionTelemetrySink.flush}. */
156
156
  flush?(): void;
157
157
  /**
158
- * See {@link TelemetryBackend.shutdown}.
158
+ * See {@link SessionTelemetrySink.shutdown}.
159
159
  * @returns resolves when the backend's pipeline has quiesced.
160
160
  */
161
161
  abstract shutdown(): Promise<void>;
162
162
  }
163
- export { TelemetryCoordinator, type TelemetryCapture } from './coordinator.ts';
163
+ export { SessionTelemetryCoordinator, type SessionTelemetryCapture } from './coordinator.ts';
164
164
  //# sourceMappingURL=index.d.ts.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deepseek-ai/dsh-session-telemetry",
3
- "description": "Telemetry seam for the DeepSeek Harness: session-event capture, projection, redaction, and handoff to a reporting backend",
4
- "version": "0.0.1-rc.2",
3
+ "description": "SessionTelemetryBackend seam for the DeepSeek Harness: session-event capture, projection, redaction, and handoff to a reporting backend",
4
+ "version": "0.0.1-rc.5",
5
5
  "publishConfig": {
6
6
  "access": "restricted"
7
7
  },
@@ -32,15 +32,15 @@
32
32
  ],
33
33
  "license": "BSD-3-Clause",
34
34
  "peerDependencies": {
35
- "@deepseek-ai/dsh-agent": "^0.0.1-rc.2",
36
- "@deepseek-ai/dsh-invariants": "^0.0.1-rc.2",
37
- "@deepseek-ai/dsh-session": "^0.0.1-rc.2",
38
- "@deepseek-ai/cordis": "^4.0.1-rc.1"
35
+ "@deepseek-ai/dsh-invariants": "^0.0.1-rc.5",
36
+ "@deepseek-ai/dsh-agent": "^0.0.1-rc.5",
37
+ "@deepseek-ai/dsh-session": "^0.0.1-rc.5",
38
+ "@deepseek-ai/cordis": "^4.0.1-rc.4"
39
39
  },
40
40
  "devDependencies": {
41
- "@deepseek-ai/dsh-agent": "^0.0.1-rc.2",
42
- "@deepseek-ai/dsh-invariants": "^0.0.1-rc.2",
43
- "@deepseek-ai/dsh-session": "^0.0.1-rc.2",
44
- "@deepseek-ai/cordis": "^4.0.1-rc.1"
41
+ "@deepseek-ai/dsh-agent": "^0.0.1-rc.5",
42
+ "@deepseek-ai/dsh-invariants": "^0.0.1-rc.5",
43
+ "@deepseek-ai/dsh-session": "^0.0.1-rc.5",
44
+ "@deepseek-ai/cordis": "^4.0.1-rc.4"
45
45
  }
46
46
  }