dsh-observe 0.2.8 → 0.2.10

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.pt.md CHANGED
@@ -8,7 +8,7 @@
8
8
  *Transforme eventos de sessão em traces OTLP e observações Langfuse — saneados, com buffer e desligados por padrão.*
9
9
 
10
10
  [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
11
- [![DSH plugin](https://img.shields.io/badge/dsh-plugin-✅-green)](https://github.com/topics/dsh-plugin)
11
+ [![DSH plugin](https://img.shields.io/badge/dsh--plugin-✅-green)](https://github.com/topics/dsh-plugin)
12
12
  [![Node](https://img.shields.io/badge/node-%5E22.19%20%7C%7C%20%3E%3D24-brightgreen.svg)](#)
13
13
  [![CI](https://img.shields.io/github/actions/workflow/status/PerryLink/dsh-observe/ci.yml?branch=main&label=CI)](https://github.com/PerryLink/dsh-observe/actions)
14
14
  [![Version](https://img.shields.io/github/v/tag/PerryLink/dsh-observe?label=version)](https://github.com/PerryLink/dsh-observe/releases)
@@ -25,7 +25,7 @@
25
25
 
26
26
  | Superfície | Status |
27
27
  |---|---|
28
- | Harness | DeepSeek Harness `dsh-v0.1.3-alpha.1` (adaptado em 2026-09-02): o envelope de sessão mantém seu campo ignorable apenas para compatibilidade de leitura de logs armazenados - o Session.append ainda não consegue estampá-lo, então o comportamento da porta não muda. Verificado em 2026-09-06 contra o checkout master dsh-v0.1.3-alpha.1 (cadeia completa de portas + smoke de instalação de perfil). |
28
+ | Harness | DeepSeek Harness `dsh-v0.1.5-alpha.1` (adaptado em 2026-09-09): o formato de sessão V3 embute o fluxo do assistente em `assistant/message` / `assistant/attempt` e representa o prompt de sistema como nó 0 da superfície (`system/message`); o plugin consome apenas o fluxo de eventos ao vivo e nunca lê arquivos de log de sessão. Verificado em 2026-09-09 contra a tag dsh-v0.1.5-alpha.1 (cadeia completa de portas local; o workflow compat mensal cobre o smoke de instalação de perfil). |
29
29
  | Node | `^22.19.0 \|\| >=24.0.0` |
30
30
  | Backends | OpenTelemetry OTLP/HTTP (traces + metrics, codificação JSON) e Langfuse (observabilidade de LLM) — um ou ambos |
31
31
  | Modelo | Independente de modelo: exporta o fluxo `session/event`; não faz chamadas a modelos |
@@ -165,11 +165,11 @@ Este plugin **não registra ferramentas de modelo** — é um exportador em segu
165
165
  - **Sanear antes de enviar** — redação estrutural de chaves, padrões de segredos embutidos (chaves de API, tokens do GitHub, chaves da AWS, credenciais bearer, chaves privadas), seus padrões e orçamentos de caracteres aplicam-se antes de qualquer registro sair da memória.
166
166
  - **Re-validação no limite durável** — registros lidos do armazenamento são checados novamente antes que um sink possa vê-los.
167
167
  - **Falha ruidosa, falha contida** — falhas de exportação avisam, contam, tentam de novo e por fim vão para o spool; um manipulador de sessão que falha é capturado e registrado, de modo que a observabilidade nunca pode quebrar o caminho quente do harness.
168
- - **Model-visible ⟺ logged** — as exportações de prompt/completion projetam apenas o cabeçalho registrado e a superfície da sessão; o exportador não inventa conteúdo.
168
+ - **Model-visible ⟺ logged** — as exportações de prompt/completion projetam apenas a superfície da sessão (cujo nó 0 é o prompt de sistema) e o cabeçalho registrado (configuração da chamada e ferramentas); o exportador não inventa conteúdo.
169
169
 
170
170
  ## Known limitations
171
171
 
172
- - **npm 0.1.2-rc.1** — o plugin é desenvolvido e testado contra `@deepseek-ai/dsh@0.1.2-rc.1`; baselines mais novos devem funcionar e são verificados pelo workflow compat mensal.
172
+ - **npm 0.1.5-alpha.1** — o plugin é desenvolvido e testado contra `@deepseek-ai/dsh@0.1.5-alpha.1` (devDeps e CI fixados); o intervalo de peers `>=0.1.2-rc.1 <0.2.0 || >=0.1.5-alpha.1 <0.2.0` mantém a linha rc.1 publicada instalável, e o workflow compat mensal cobre baselines mais novos.
173
173
  - **Métricas evitam o caminho de tentativa/spool** — as métricas OTLP são agregadas cumulativamente, então um flush perdido se autocura no seguinte (por design, não é um bug).
174
174
  - **Sem amostragem** — toda família de spans habilitada é exportada; ajuste os interruptores `capture.*` e `batch.maxBufferRecords` para sessões de alto volume.
175
175
 
@@ -177,9 +177,9 @@ Este plugin **não registra ferramentas de modelo** — é um exportador em segu
177
177
 
178
178
  ```sh
179
179
  pnpm install # node ^22.19 || >=24
180
- pnpm run typecheck # tsc: src + tests contra o checkout local do harness
181
- pnpm run typecheck:ci # tsc contra os tipos publicados 0.1.2-rc.1 (sem paths)
182
- pnpm test # vitest: 95 testes, 13 suítes (Context/Session/storage seam reais)
180
+ pnpm run typecheck # tsc: src + tests contra os devDeps fixados 0.1.5-alpha.1 (sem tsconfig paths)
181
+ pnpm run typecheck:ci # tsc contra os tipos publicados 0.1.5-alpha.1 (sem paths)
182
+ pnpm test # vitest: 124 testes, 18 suítes (Context/Session/storage seam reais)
183
183
  pnpm run test:coverage # porta de cobertura (90/80/90/90)
184
184
  pnpm run build # bundle tsdown + declarações tsc (lib/)
185
185
  pnpm run verify:self-contained # as especificações de dependências resolvem pelo registry
@@ -198,42 +198,46 @@ pnpm pack # o tarball publicado
198
198
 
199
199
  ## PerryLink DSH Plugin Family
200
200
 
201
- Este projeto é um dos [33 plugins de DeepSeek Harness](https://github.com/PerryLink) mantidos por [PerryLink](https://github.com/PerryLink). Se este ajuda você, os outros provavelmente também:
201
+ Este projeto é um dos [37 plugins de DeepSeek Harness](https://github.com/PerryLink) mantidos por [PerryLink](https://github.com/PerryLink). Se este ajuda você, os outros provavelmente também:
202
202
 
203
203
  | Plugin | One-liner |
204
204
  |---|---|
205
- | **[dsh-dsh-auto-review](https://github.com/PerryLink/dsh-dsh-auto-review)** | Auto-revisão de segundo modelo na cadeia de aprovação, com falha fechada por padrão | |
206
- | **[dsh-dsh-background-agents](https://github.com/PerryLink/dsh-dsh-background-agents)** | Agentes filhos em segundo plano duráveis com barra lateral de UI web, mensagens e interrupção | |
207
- | **[dsh-dsh-budget](https://github.com/PerryLink/dsh-dsh-budget)** | Governança de custos para DeepSeek Harness: orçamentos, carbono e latência em um painel. | |
208
- | **[dsh-dsh-checkpoint-rewind](https://github.com/PerryLink/dsh-dsh-checkpoint-rewind)** | Equivalente ao /rewind do Claude Code: instantâneos, bifurcações de sessão, restauração de uso único | |
209
- | **[dsh-dsh-claude-move](https://github.com/PerryLink/dsh-dsh-claude-move)** | Migre sessões, memória, habilidades e CLAUDE.md do Claude Code para o DSH | |
210
- | **[dsh-dsh-click](https://github.com/PerryLink/dsh-dsh-click)** | Controle de desktop nativo multiplataforma para DeepSeek Harness — Windows primeiro. | |
211
- | **[dsh-dsh-composer-history](https://github.com/PerryLink/dsh-dsh-composer-history)** | Histórico de entrada estilo terminal para o compositor web: setas, busca Ctrl+R | |
212
- | **[dsh-dsh-data-quality](https://github.com/PerryLink/dsh-dsh-data-quality)** | Verificações de qualidade de datasets e verificação de citações (a ponte numérica opcional consumida aqui) | |
213
- | **[dsh-dsh-defend](https://github.com/PerryLink/dsh-dsh-defend)** | Defesa contra injeção de prompt, jailbreak e vazamento de segredos para DeepSeek Harness. | |
214
- | **[dsh-dsh-doublecheck](https://github.com/PerryLink/dsh-dsh-doublecheck)** | Guardião de disciplina de engenharia: sabatina de requisitos, portões de teste, revisão adversária | |
215
- | **[dsh-dsh-draw](https://github.com/PerryLink/dsh-dsh-draw)** | Roteamento unificado de geração de imagens estáticas para DeepSeek Harness. | |
216
- | **[dsh-dsh-fast](https://github.com/PerryLink/dsh-dsh-fast)** | Diagnóstico de desempenho só de leitura para DeepSeek Harness. | |
217
- | **[dsh-dsh-fund-research](https://github.com/PerryLink/dsh-dsh-fund-research)** | Relatórios de pesquisa deterministas para fundos mútuos públicos chineses | |
218
- | **[dsh-dsh-github](https://github.com/PerryLink/dsh-dsh-github)** | Integração de PR/issues do GitHub para o DSH, cada escrita controlada por aprovação | |
219
- | **[dsh-dsh-industry-research](https://github.com/PerryLink/dsh-dsh-industry-research)** | Orquestração de pesquisa setorial que sela as suas entregas através do `ctx.researchReport.assemble` deste plugin | |
220
- | **[dsh-dsh-library](https://github.com/PerryLink/dsh-dsh-library)** | Base de conhecimento documental local para DeepSeek Harness. | |
221
- | **[dsh-dsh-local-ai](https://github.com/PerryLink/dsh-dsh-local-ai)** | Integração de modelos locais (Ollama) para DeepSeek Harness. | |
222
- | **[dsh-dsh-lsp-actions](https://github.com/PerryLink/dsh-dsh-lsp-actions)** | Diagnósticos, formatação, autocompletar, ações de código e renomeação LSP sobre servidores de linguagem | |
223
- | **[dsh-dsh-mask](https://github.com/PerryLink/dsh-dsh-mask)** | Middleware de mascaramento de PII: anonimiza no limite do modelo, restaura na camada de exibição | |
224
- | **[dsh-dsh-mcp-panel](https://github.com/PerryLink/dsh-dsh-mcp-panel)** | Painel de tempo de execução MCP somente leitura: comando /mcp + aba Settings com status, ferramentas e erros | |
225
- | **[dsh-dsh-memento](https://github.com/PerryLink/dsh-dsh-memento)** | Memória entre sessões controlada por aprovação: costura ctx.memory + SQLite + ferramenta de memória | |
226
- | **[dsh-dsh-output-styles](https://github.com/PerryLink/dsh-dsh-output-styles)** | Troca de estilo em tempo de execução equivalente ao outputStyles do Claude Code | |
227
- | **[dsh-dsh-permission-rules](https://github.com/PerryLink/dsh-dsh-permission-rules)** | Regras de permissão declarativas allow/deny/ask estilo Claude Code com auditoria | |
228
- | **[dsh-dsh-plugin-guide](https://github.com/PerryLink/dsh-dsh-plugin-guide)** | Base de conhecimento de desenvolvimento de plugins como habilidade de agente sob demanda | |
229
- | **[dsh-dsh-research-report](https://github.com/PerryLink/dsh-dsh-research-report)** | Motor de relatórios de pesquisa verificáveis com evidência endereçada por conteúdo | |
230
- | **[dsh-dsh-score](https://github.com/PerryLink/dsh-dsh-score)** | Pontuação de qualidade multidimensional para plugins de DeepSeek Harness. | |
231
- | **[dsh-dsh-session-pin](https://github.com/PerryLink/dsh-dsh-session-pin)** | Fixe sessões na barra lateral web com ordenação durável | |
232
- | **[dsh-dsh-session-sync](https://github.com/PerryLink/dsh-dsh-session-sync)** | Sincronização de sessões entre dispositivos para DeepSeek Harness — um espelho git dedicado do seu armazenamento de sessões. | |
233
- | **[dsh-dsh-skill-pack-security](https://github.com/PerryLink/dsh-dsh-skill-pack-security)** | Pacote de habilidades de auditoria de segurança: varredura de segredos, revisão de dependências e cadeia de suprimentos | |
234
- | **[dsh-dsh-talk](https://github.com/PerryLink/dsh-dsh-talk)** | Loop de sessão com voz para DeepSeek Harness: fale e ouça a resposta. | |
235
- | **[dsh-dsh-test-drive](https://github.com/PerryLink/dsh-dsh-test-drive)** | Test drives isolados de instalação e smoke para plugins de DeepSeek Harness. | |
236
- | **[dsh-dsh-translate](https://github.com/PerryLink/dsh-dsh-translate)** | Tradução de parâmetros entre fornecedores e reparo determinístico de JSON para DeepSeek Harness. | |
205
+ | **[dsh-auto-review](https://github.com/PerryLink/dsh-auto-review)** | Auto-revisão de segundo modelo na cadeia de aprovação, com falha fechada por padrão | |
206
+ | **[dsh-background-agents](https://github.com/PerryLink/dsh-background-agents)** | Agentes filhos em segundo plano duráveis com barra lateral de UI web, mensagens e interrupção | |
207
+ | **[dsh-budget](https://github.com/PerryLink/dsh-budget)** | Governança de custos para DeepSeek Harness: orçamentos, carbono e latência em um painel. | |
208
+ | **[dsh-checkpoint-rewind](https://github.com/PerryLink/dsh-checkpoint-rewind)** | Equivalente ao /rewind do Claude Code: instantâneos, bifurcações de sessão, restauração de uso único | |
209
+ | **[dsh-claude-move](https://github.com/PerryLink/dsh-claude-move)** | Migre sessões, memória, habilidades e CLAUDE.md do Claude Code para o DSH | |
210
+ | **[dsh-click](https://github.com/PerryLink/dsh-click)** | Controle de desktop nativo multiplataforma para DeepSeek Harness — Windows primeiro. | |
211
+ | **[dsh-composer-history](https://github.com/PerryLink/dsh-composer-history)** | Histórico de entrada estilo terminal para o compositor web: setas, busca Ctrl+R | |
212
+ | **[dsh-data-quality](https://github.com/PerryLink/dsh-data-quality)** | Verificações de qualidade de datasets e verificação de citações (a ponte numérica opcional consumida aqui) | |
213
+ | **[dsh-defend](https://github.com/PerryLink/dsh-defend)** | Defesa contra injeção de prompt, jailbreak e vazamento de segredos para DeepSeek Harness. | |
214
+ | **[dsh-doublecheck](https://github.com/PerryLink/dsh-doublecheck)** | Guardião de disciplina de engenharia: sabatina de requisitos, portões de teste, revisão adversária | |
215
+ | **[dsh-draw](https://github.com/PerryLink/dsh-draw)** | Roteamento unificado de geração de imagens estáticas para DeepSeek Harness. | |
216
+ | **[dsh-fast](https://github.com/PerryLink/dsh-fast)** | Diagnóstico de desempenho só de leitura para DeepSeek Harness. | |
217
+ | **[dsh-fund-research](https://github.com/PerryLink/dsh-fund-research)** | Relatórios de pesquisa deterministas para fundos mútuos públicos chineses | |
218
+ | **[dsh-github](https://github.com/PerryLink/dsh-github)** | Integração de PR/issues do GitHub para o DSH, cada escrita controlada por aprovação | |
219
+ | **[dsh-industry-research](https://github.com/PerryLink/dsh-industry-research)** | Orquestração de pesquisa setorial que sela as suas entregas através do `ctx.researchReport.assemble` deste plugin | |
220
+ | **[dsh-library](https://github.com/PerryLink/dsh-library)** | Base de conhecimento documental local para DeepSeek Harness. | |
221
+ | **[dsh-local-ai](https://github.com/PerryLink/dsh-local-ai)** | Integração de modelos locais (Ollama) para DeepSeek Harness. | |
222
+ | **[dsh-lsp-actions](https://github.com/PerryLink/dsh-lsp-actions)** | Diagnósticos, formatação, autocompletar, ações de código e renomeação LSP sobre servidores de linguagem | |
223
+ | **[dsh-mask](https://github.com/PerryLink/dsh-mask)** | Middleware de mascaramento de PII: anonimiza no limite do modelo, restaura na camada de exibição | |
224
+ | **[dsh-mcp-panel](https://github.com/PerryLink/dsh-mcp-panel)** | Painel de tempo de execução MCP somente leitura: comando /mcp + aba Settings com status, ferramentas e erros | |
225
+ | **[dsh-memento](https://github.com/PerryLink/dsh-memento)** | Memória entre sessões controlada por aprovação: costura ctx.memory + SQLite + ferramenta de memória | |
226
+ | **[dsh-output-styles](https://github.com/PerryLink/dsh-output-styles)** | Troca de estilo em tempo de execução equivalente ao outputStyles do Claude Code | |
227
+ | **[dsh-permission-rules](https://github.com/PerryLink/dsh-permission-rules)** | Regras de permissão declarativas allow/deny/ask estilo Claude Code com auditoria | |
228
+ | **[dsh-personal-directive](https://github.com/PerryLink/dsh-personal-directive)** | Injetor de diretivas pessoais com alternância na barra superior (edição framework) |
229
+ | **[dsh-plugin-guide](https://github.com/PerryLink/dsh-plugin-guide)** | Base de conhecimento de desenvolvimento de plugins como habilidade de agente sob demanda | |
230
+ | **[dsh-reach](https://github.com/PerryLink/dsh-reach)** | Ponte multicanal de aprovação/perguntas: WeChat/Telegram/Feishu, console de sessão |
231
+ | **[dsh-research-report](https://github.com/PerryLink/dsh-research-report)** | Motor de relatórios de pesquisa verificáveis com evidência endereçada por conteúdo | |
232
+ | **[dsh-score](https://github.com/PerryLink/dsh-score)** | Pontuação de qualidade multidimensional para plugins de DeepSeek Harness. | |
233
+ | **[dsh-session-pin](https://github.com/PerryLink/dsh-session-pin)** | Fixe sessões na barra lateral web com ordenação durável | |
234
+ | **[dsh-session-sync](https://github.com/PerryLink/dsh-session-sync)** | Sincronização de sessões entre dispositivos para DeepSeek Harness — um espelho git dedicado do seu armazenamento de sessões. | |
235
+ | **[dsh-skill-pack-security](https://github.com/PerryLink/dsh-skill-pack-security)** | Pacote de habilidades de auditoria de segurança: varredura de segredos, revisão de dependências e cadeia de suprimentos | |
236
+ | **[dsh-talk](https://github.com/PerryLink/dsh-talk)** | Loop de sessão com voz para DeepSeek Harness: fale e ouça a resposta. | |
237
+ | **[dsh-test-drive](https://github.com/PerryLink/dsh-test-drive)** | Test drives isolados de instalação e smoke para plugins de DeepSeek Harness. | |
238
+ | **[dsh-ticktick](https://github.com/PerryLink/dsh-ticktick)** | Ponte de tarefas TickTick/Dida365: painel no cabeçalho da sessão + 11 ferramentas |
239
+ | **[dsh-translate](https://github.com/PerryLink/dsh-translate)** | Tradução de parâmetros entre fornecedores e reparo determinístico de JSON para DeepSeek Harness. | |
240
+ | **[dsh-wechat](https://github.com/PerryLink/dsh-wechat)** | Ponte WeChat ↔ DSH (bot Tencent iLink): texto/imagem/arquivo/voz, aprovações no chat |
237
241
 
238
242
  ## License
239
243
 
package/README.zh.md CHANGED
@@ -8,7 +8,7 @@
8
8
  *把会话事件变成 OTLP 追踪与 Langfuse 观测 —— 脱敏、缓冲、默认关闭。*
9
9
 
10
10
  [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
11
- [![DSH plugin](https://img.shields.io/badge/dsh-plugin-✅-green)](https://github.com/topics/dsh-plugin)
11
+ [![DSH plugin](https://img.shields.io/badge/dsh--plugin-✅-green)](https://github.com/topics/dsh-plugin)
12
12
  [![Node](https://img.shields.io/badge/node-%5E22.19%20%7C%7C%20%3E%3D24-brightgreen.svg)](#)
13
13
  [![CI](https://img.shields.io/github/actions/workflow/status/PerryLink/dsh-observe/ci.yml?branch=main&label=CI)](https://github.com/PerryLink/dsh-observe/actions)
14
14
  [![Version](https://img.shields.io/github/v/tag/PerryLink/dsh-observe?label=version)](https://github.com/PerryLink/dsh-observe/releases)
@@ -25,7 +25,7 @@
25
25
 
26
26
  | 方面 | 状态 |
27
27
  |---|---|
28
- | Harness | DeepSeek Harness `dsh-v0.1.3-alpha.1`(2026-09-02 已适配):会话信封保留 ignorable 字段但仅用于存量日志读取兼容——Session.append 仍无法盖章,门控行为不变。已于 2026-09-06 对照 dsh-v0.1.3-alpha.1 master 检出核验(完整门禁链 + profile 安装冒烟)。 |
28
+ | Harness | DeepSeek Harness `dsh-v0.1.5-alpha.1`(2026-09-09 已适配):会话格式 V3 把助手流内嵌到 `assistant/message` / `assistant/attempt`,系统提示词成为 surface 节点 0(`system/message`);本插件只消费实时事件流,从不读取会话日志文件。已于 2026-09-09 对照 dsh-v0.1.5-alpha.1 tag 核验(本地完整门禁链;profile 安装冒烟由月度 compat 工作流覆盖)。 |
29
29
  | Node | `^22.19.0 \|\| >=24.0.0` |
30
30
  | 后端 | OpenTelemetry OTLP/HTTP(traces + metrics,JSON 编码)与 Langfuse(LLM 可观测)——二选一或同时 |
31
31
  | 模型 | 与模型无关:它导出 session/event 流,自身不调用任何模型 |
@@ -165,11 +165,11 @@ dsh --profile web --dump-config | grep -A2 'id: dsh-observe'
165
165
  - **发送前脱敏** —— 结构性键名脱敏、内置密钥模式(API key、GitHub token、AWS key、bearer 凭据、私钥)、自定义模式与字符预算,全部在任何记录离开内存前生效。
166
166
  - **持久边界再校验** —— 从存储读回的记录在到达 sink 前再次检查。
167
167
  - **失败大声、失败隔离** —— 导出失败会告警、计数、重试并最终入缓冲;会话事件处理失败被捕获并记录,可观测性永远不会拖垮 harness 热路径。
168
- - **模型可见 ⟺ 已记录** —— prompt/completion 导出只投影已记录的 header 与会话 surface;导出器不发明任何内容。
168
+ - **模型可见 ⟺ 已记录** —— prompt/completion 导出只投影会话 surface(其节点 0 即系统提示词)与已记录的 header(调用配置与工具);导出器不发明任何内容。
169
169
 
170
170
  ## Known limitations
171
171
 
172
- - **npm 0.1.2-rc.1** —— 插件针对 `@deepseek-ai/dsh@0.1.2-rc.1` 开发与测试;更新的 harness 基线预期可用,由月度 compat 工作流验证。
172
+ - **npm 0.1.5-alpha.1** —— 插件针对 `@deepseek-ai/dsh@0.1.5-alpha.1` 开发与测试(devDeps 与 CI 均钉此版本);peer 复合范围 `>=0.1.2-rc.1 <0.2.0 || >=0.1.5-alpha.1 <0.2.0` 保持已发布的 rc.1 线可安装,更新的 harness 基线由月度 compat 工作流验证。
173
173
  - **Metrics 不走重试/缓冲路径** —— OTLP metrics 按累计聚合,丢失一次 flush 会在下一次自愈(设计如此,非缺陷)。
174
174
  - **无采样** —— 每个启用的 span 族都会导出;大流量会话请调整 `capture.*` 开关与 `batch.maxBufferRecords`。
175
175
 
@@ -177,9 +177,9 @@ dsh --profile web --dump-config | grep -A2 'id: dsh-observe'
177
177
 
178
178
  ```sh
179
179
  pnpm install # node ^22.19 || >=24
180
- pnpm run typecheck # tsc:src + tests,对照本地 harness checkout
181
- pnpm run typecheck:ci # tsc:对照已发布的 0.1.2-rc.1 类型(无 paths)
182
- pnpm test # vitest:95 个测试、13 个套件(真实 Context/Session/storage 接缝)
180
+ pnpm run typecheck # tsc:src + tests,对照钉定的 0.1.5-alpha.1 devDeps(无 tsconfig paths)
181
+ pnpm run typecheck:ci # tsc:对照已发布的 0.1.5-alpha.1 类型(无 paths)
182
+ pnpm test # vitest:124 个测试、18 个套件(真实 Context/Session/storage 接缝)
183
183
  pnpm run test:coverage # 覆盖率门禁(90/80/90/90)
184
184
  pnpm run build # tsdown bundle + tsc 声明(lib/)
185
185
  pnpm run verify:self-contained # 依赖声明全部来自 registry
@@ -198,42 +198,46 @@ pnpm pack # 发布用 tarball
198
198
 
199
199
  ## PerryLink DSH Plugin Family
200
200
 
201
- 这是 [PerryLink](https://github.com/PerryLink) 维护的 [33 个 DeepSeek Harness 插件](https://github.com/PerryLink) 之一。如果它能帮到你,其他的也会:
201
+ 这是 [PerryLink](https://github.com/PerryLink) 维护的 [37 个 DeepSeek Harness 插件](https://github.com/PerryLink) 之一。如果它能帮到你,其他的也会:
202
202
 
203
203
  | Plugin | One-liner |
204
204
  |---|---|
205
- | **[dsh-dsh-auto-review](https://github.com/PerryLink/dsh-dsh-auto-review)** | 审批链上的第二模型自动审查,默认失败关闭 | |
206
- | **[dsh-dsh-background-agents](https://github.com/PerryLink/dsh-dsh-background-agents)** | 带 Web UI 侧栏、消息与中断的持久后台子代理 | |
207
- | **[dsh-dsh-budget](https://github.com/PerryLink/dsh-dsh-budget)** | DeepSeek Harness 的成本治理:预算、碳排与延迟一屏呈现。 | |
208
- | **[dsh-dsh-checkpoint-rewind](https://github.com/PerryLink/dsh-dsh-checkpoint-rewind)** | Claude Code /rewind 等价:快照、会话 fork、一次性恢复 | |
209
- | **[dsh-dsh-claude-move](https://github.com/PerryLink/dsh-dsh-claude-move)** | 把 Claude Code 会话、记忆、技能与 CLAUDE.md 迁入 DSH | |
210
- | **[dsh-dsh-click](https://github.com/PerryLink/dsh-dsh-click)** | 跨平台原生桌面控制(DeepSeek Harness),Windows 优先。 | |
211
- | **[dsh-dsh-composer-history](https://github.com/PerryLink/dsh-dsh-composer-history)** | Web 输入框的终端式历史:方向键、Ctrl+R 搜索 | |
212
- | **[dsh-dsh-data-quality](https://github.com/PerryLink/dsh-dsh-data-quality)** | 数据集质量检查与引文核查(本插件可选消费的数字核查桥) | |
213
- | **[dsh-dsh-defend](https://github.com/PerryLink/dsh-dsh-defend)** | DeepSeek Harness 的提示注入、越狱与密钥泄露防护。 | |
214
- | **[dsh-dsh-doublecheck](https://github.com/PerryLink/dsh-dsh-doublecheck)** | 工程纪律守卫:需求质询、测试门禁、对手评审 | |
215
- | **[dsh-dsh-draw](https://github.com/PerryLink/dsh-dsh-draw)** | DeepSeek Harness 的统一静态图像生成路由。 | |
216
- | **[dsh-dsh-fast](https://github.com/PerryLink/dsh-dsh-fast)** | DeepSeek Harness 只读性能诊断。 | |
217
- | **[dsh-dsh-fund-research](https://github.com/PerryLink/dsh-dsh-fund-research)** | 面向中国公募基金的确定性研究报告 | |
218
- | **[dsh-dsh-github](https://github.com/PerryLink/dsh-dsh-github)** | 面向 DSH 的 GitHub PR/issues 集成,每次写入经审批门控 | |
219
- | **[dsh-dsh-industry-research](https://github.com/PerryLink/dsh-dsh-industry-research)** | 行业研究编排,经本插件的 `ctx.researchReport.assemble` 封存交付物 | |
220
- | **[dsh-dsh-library](https://github.com/PerryLink/dsh-dsh-library)** | DeepSeek Harness 的本地文档知识库。 | |
221
- | **[dsh-dsh-local-ai](https://github.com/PerryLink/dsh-dsh-local-ai)** | DeepSeek Harness 的本地模型(Ollama)接入。 | |
222
- | **[dsh-dsh-lsp-actions](https://github.com/PerryLink/dsh-dsh-lsp-actions)** | 通过语言服务器的 LSP 诊断、格式化、补全、代码操作与重命名 | |
223
- | **[dsh-dsh-mask](https://github.com/PerryLink/dsh-dsh-mask)** | PII 脱敏中间件:模型边界匿名化、展示层还原 | |
224
- | **[dsh-dsh-mcp-panel](https://github.com/PerryLink/dsh-dsh-mcp-panel)** | 只读 MCP 运行时面板:/mcp 命令 + 带状态、工具与错误的 Settings 标签页 | |
225
- | **[dsh-dsh-memento](https://github.com/PerryLink/dsh-dsh-memento)** | 审批门控的跨会话记忆:ctx.memory 接缝 + SQLite + 记忆工具 | |
226
- | **[dsh-dsh-output-styles](https://github.com/PerryLink/dsh-dsh-output-styles)** | Claude Code outputStyles 等价的运行时风格切换 | |
227
- | **[dsh-dsh-permission-rules](https://github.com/PerryLink/dsh-dsh-permission-rules)** | Claude Code 风格声明式 allow/deny/ask 权限规则,带审计 | |
228
- | **[dsh-dsh-plugin-guide](https://github.com/PerryLink/dsh-dsh-plugin-guide)** | 作为按需代理技能的插件开发知识库 | |
229
- | **[dsh-dsh-research-report](https://github.com/PerryLink/dsh-dsh-research-report)** | 可验证研究报告引擎:内容寻址证据账本与封存版本 | |
230
- | **[dsh-dsh-score](https://github.com/PerryLink/dsh-dsh-score)** | DeepSeek Harness 插件的多维质量评分。 | |
231
- | **[dsh-dsh-session-pin](https://github.com/PerryLink/dsh-dsh-session-pin)** | 在 Web 侧栏置顶会话,带持久排序 | |
232
- | **[dsh-dsh-session-sync](https://github.com/PerryLink/dsh-dsh-session-sync)** | DeepSeek Harness 的跨设备会话同步——会话存储的专用 git 镜像。 | |
233
- | **[dsh-dsh-skill-pack-security](https://github.com/PerryLink/dsh-dsh-skill-pack-security)** | 安全审计技能包:密钥扫描、依赖与供应链审查 | |
234
- | **[dsh-dsh-talk](https://github.com/PerryLink/dsh-dsh-talk)** | DeepSeek Harness 的语音优先会话闭环:对它说,听它答。 | |
235
- | **[dsh-dsh-test-drive](https://github.com/PerryLink/dsh-dsh-test-drive)** | DeepSeek Harness 插件的隔离试装冒烟。 | |
236
- | **[dsh-dsh-translate](https://github.com/PerryLink/dsh-dsh-translate)** | DeepSeek Harness 的厂商参数翻译与确定性 JSON 修复。 | |
205
+ | **[dsh-auto-review](https://github.com/PerryLink/dsh-auto-review)** | 审批链上的第二模型自动审查,默认失败关闭 | |
206
+ | **[dsh-background-agents](https://github.com/PerryLink/dsh-background-agents)** | 带 Web UI 侧栏、消息与中断的持久后台子代理 | |
207
+ | **[dsh-budget](https://github.com/PerryLink/dsh-budget)** | DeepSeek Harness 的成本治理:预算、碳排与延迟一屏呈现。 | |
208
+ | **[dsh-checkpoint-rewind](https://github.com/PerryLink/dsh-checkpoint-rewind)** | Claude Code /rewind 等价:快照、会话 fork、一次性恢复 | |
209
+ | **[dsh-claude-move](https://github.com/PerryLink/dsh-claude-move)** | 把 Claude Code 会话、记忆、技能与 CLAUDE.md 迁入 DSH | |
210
+ | **[dsh-click](https://github.com/PerryLink/dsh-click)** | 跨平台原生桌面控制(DeepSeek Harness),Windows 优先。 | |
211
+ | **[dsh-composer-history](https://github.com/PerryLink/dsh-composer-history)** | Web 输入框的终端式历史:方向键、Ctrl+R 搜索 | |
212
+ | **[dsh-data-quality](https://github.com/PerryLink/dsh-data-quality)** | 数据集质量检查与引文核查(本插件可选消费的数字核查桥) | |
213
+ | **[dsh-defend](https://github.com/PerryLink/dsh-defend)** | DeepSeek Harness 的提示注入、越狱与密钥泄露防护。 | |
214
+ | **[dsh-doublecheck](https://github.com/PerryLink/dsh-doublecheck)** | 工程纪律守卫:需求质询、测试门禁、对手评审 | |
215
+ | **[dsh-draw](https://github.com/PerryLink/dsh-draw)** | DeepSeek Harness 的统一静态图像生成路由。 | |
216
+ | **[dsh-fast](https://github.com/PerryLink/dsh-fast)** | DeepSeek Harness 只读性能诊断。 | |
217
+ | **[dsh-fund-research](https://github.com/PerryLink/dsh-fund-research)** | 面向中国公募基金的确定性研究报告 | |
218
+ | **[dsh-github](https://github.com/PerryLink/dsh-github)** | 面向 DSH 的 GitHub PR/issues 集成,每次写入经审批门控 | |
219
+ | **[dsh-industry-research](https://github.com/PerryLink/dsh-industry-research)** | 行业研究编排,经本插件的 `ctx.researchReport.assemble` 封存交付物 | |
220
+ | **[dsh-library](https://github.com/PerryLink/dsh-library)** | DeepSeek Harness 的本地文档知识库。 | |
221
+ | **[dsh-local-ai](https://github.com/PerryLink/dsh-local-ai)** | DeepSeek Harness 的本地模型(Ollama)接入。 | |
222
+ | **[dsh-lsp-actions](https://github.com/PerryLink/dsh-lsp-actions)** | 通过语言服务器的 LSP 诊断、格式化、补全、代码操作与重命名 | |
223
+ | **[dsh-mask](https://github.com/PerryLink/dsh-mask)** | PII 脱敏中间件:模型边界匿名化、展示层还原 | |
224
+ | **[dsh-mcp-panel](https://github.com/PerryLink/dsh-mcp-panel)** | 只读 MCP 运行时面板:/mcp 命令 + 带状态、工具与错误的 Settings 标签页 | |
225
+ | **[dsh-memento](https://github.com/PerryLink/dsh-memento)** | 审批门控的跨会话记忆:ctx.memory 接缝 + SQLite + 记忆工具 | |
226
+ | **[dsh-output-styles](https://github.com/PerryLink/dsh-output-styles)** | Claude Code outputStyles 等价的运行时风格切换 | |
227
+ | **[dsh-permission-rules](https://github.com/PerryLink/dsh-permission-rules)** | Claude Code 风格声明式 allow/deny/ask 权限规则,带审计 | |
228
+ | **[dsh-personal-directive](https://github.com/PerryLink/dsh-personal-directive)** | 个人指令注入器:顶栏开关(框架版) |
229
+ | **[dsh-plugin-guide](https://github.com/PerryLink/dsh-plugin-guide)** | 作为按需代理技能的插件开发知识库 | |
230
+ | **[dsh-reach](https://github.com/PerryLink/dsh-reach)** | 多渠道审批/提问桥接:微信/Telegram/飞书,会话控制台 |
231
+ | **[dsh-research-report](https://github.com/PerryLink/dsh-research-report)** | 可验证研究报告引擎:内容寻址证据账本与封存版本 | |
232
+ | **[dsh-score](https://github.com/PerryLink/dsh-score)** | DeepSeek Harness 插件的多维质量评分。 | |
233
+ | **[dsh-session-pin](https://github.com/PerryLink/dsh-session-pin)** | 在 Web 侧栏置顶会话,带持久排序 | |
234
+ | **[dsh-session-sync](https://github.com/PerryLink/dsh-session-sync)** | DeepSeek Harness 的跨设备会话同步——会话存储的专用 git 镜像。 | |
235
+ | **[dsh-skill-pack-security](https://github.com/PerryLink/dsh-skill-pack-security)** | 安全审计技能包:密钥扫描、依赖与供应链审查 | |
236
+ | **[dsh-talk](https://github.com/PerryLink/dsh-talk)** | DeepSeek Harness 的语音优先会话闭环:对它说,听它答。 | |
237
+ | **[dsh-test-drive](https://github.com/PerryLink/dsh-test-drive)** | DeepSeek Harness 插件的隔离试装冒烟。 | |
238
+ | **[dsh-ticktick](https://github.com/PerryLink/dsh-ticktick)** | TickTick/滴答清单任务桥接:会话头面板 + 11 个工具 |
239
+ | **[dsh-translate](https://github.com/PerryLink/dsh-translate)** | DeepSeek Harness 的厂商参数翻译与确定性 JSON 修复。 | |
240
+ | **[dsh-wechat](https://github.com/PerryLink/dsh-wechat)** | 微信 ↔ DSH 桥接(Tencent iLink 机器人):文本/图片/文件/语音,聊天内审批卡片 |
237
241
 
238
242
  ## License
239
243
 
package/lib/index.js CHANGED
@@ -571,7 +571,7 @@ function langfuseId(...parts) {
571
571
  * @module dsh-observe/version
572
572
  */
573
573
  /** The dsh-observe package version, kept in sync with package.json. */
574
- const VERSION = "0.2.8";
574
+ const VERSION = "0.2.10";
575
575
  //#endregion
576
576
  //#region src/sinks.ts
577
577
  /** POST a JSON body with a timeout; throws on non-2xx. */
@@ -1379,13 +1379,11 @@ function normalizeUsage(usage) {
1379
1379
  }
1380
1380
  /**
1381
1381
  * Whether a stream chunk carries visible model output (the first-token
1382
- * boundary). Local replication of the rc.2 `@deepseek-ai/dsh-llm/message`
1383
- * `isTokenDelta` helper, which host 0.1.2-alpha.1 removed from that module:
1384
- * the host's whole-log sessionStats projection now inlines the same switch
1385
- * (`packages/session/session-stats/src/projection.ts`), and the chunk
1386
- * grammar itself is unchanged, so this predicate stays identical on both
1387
- * rulers. Empty deltas (heartbeats, empty tool-call frames) do not count as
1388
- * a first token.
1382
+ * boundary). Local copy of the predicate host 0.1.5 exports as
1383
+ * `isTokenDelta` from `@deepseek-ai/dsh-llm/assistant-stream`; kept local
1384
+ * because the 0.1.2-rc.1 line has no such export and the chunk grammar is
1385
+ * unchanged, so the switch below stays identical on both rulers. Empty
1386
+ * deltas (heartbeats, empty tool-call frames) do not count as a first token.
1389
1387
  * @param chunk - the stream chunk to test.
1390
1388
  * @returns true when the chunk contains a non-empty text/reasoning/tool delta.
1391
1389
  */
@@ -1398,15 +1396,15 @@ function isTokenDelta(chunk) {
1398
1396
  }
1399
1397
  }
1400
1398
  /**
1401
- * Recover finish reason and first-token timing from the v2 embedded stream
1402
- * when an `assistant/message` event carries one. On the pinned rc.1 line the
1403
- * field is absent and the legacy `assistant/chunk` branch keeps doing the
1404
- * work; on 0.1.3-alpha.1 `assistant/chunk` no longer exists, so this path is
1405
- * the only source for those two span fields. Compact runs carry member i at
1406
- * `time0 + sum(dt[0..i-1])`; every member is a token-delta boundary, so the
1407
- * run's first non-empty member is the first token.
1399
+ * Recover finish reason and first-token timing from an embedded assistant
1400
+ * stream. Host 0.1.5 carries the exact timed model stream on the required
1401
+ * `assistant/message.stream` field and, for a failed/cancelled/stream-errored
1402
+ * attempt that never commits a message, on `assistant/attempt.stream`; the
1403
+ * removed `assistant/chunk` events were the rc.1-only equivalent. Compact runs
1404
+ * carry member i at `time0 + sum(dt[0..i-1])`; every member is a token-delta
1405
+ * boundary, so the run's first non-empty member is the first token.
1408
1406
  * @param state - the open step state to fill.
1409
- * @param data - the `assistant/message` event data.
1407
+ * @param data - the event data carrying the stream.
1410
1408
  */
1411
1409
  function consumeEmbeddedStream(state, data) {
1412
1410
  const stream = data?.stream;
@@ -1483,16 +1481,13 @@ var Collector = class {
1483
1481
  case "request/context":
1484
1482
  state.context = event.data;
1485
1483
  break;
1486
- case "assistant/chunk":
1487
- if (state.step !== void 0) {
1488
- if (event.data.chunk.type === "finish") state.step.finishReason = event.data.chunk.reason.kind;
1489
- else if (state.step.firstChunkUnixNano === void 0 && isTokenDelta(event.data.chunk)) state.step.firstChunkUnixNano = event.time * NANO;
1490
- }
1491
- break;
1492
1484
  case "assistant/message":
1493
1485
  consumeEmbeddedStream(state, event.data);
1494
1486
  this.assistantMessage(session, state, event);
1495
1487
  break;
1488
+ case "assistant/attempt":
1489
+ consumeEmbeddedStream(state, event.data);
1490
+ break;
1496
1491
  case "tool/call":
1497
1492
  this.toolCall(session, state, event);
1498
1493
  break;
@@ -1502,10 +1497,30 @@ var Collector = class {
1502
1497
  case "step/end":
1503
1498
  this.stepEnd(session, state, event);
1504
1499
  break;
1505
- case "turn/end": this.turnEnd(session, state, event);
1500
+ case "turn/end":
1501
+ this.turnEnd(session, state, event);
1502
+ break;
1503
+ default: this.legacyChunk(state, event);
1506
1504
  }
1507
1505
  }
1508
1506
  /**
1507
+ * Fold one legacy `assistant/chunk` event. The type is absent from the
1508
+ * 0.1.3+ SessionEventMap (streams are embedded in `assistant/message` and
1509
+ * `assistant/attempt`), so the read is structural and only the 0.1.2-rc.1
1510
+ * runtime line ever reaches it.
1511
+ * @param state - the session state.
1512
+ * @param event - the appended event.
1513
+ */
1514
+ legacyChunk(state, event) {
1515
+ const legacy = event;
1516
+ if (legacy.type !== "assistant/chunk") return;
1517
+ const chunk = legacy.data?.chunk;
1518
+ const step = state.step;
1519
+ if (chunk === void 0 || step === void 0) return;
1520
+ if (chunk.type === "finish") step.finishReason = chunk.reason.kind;
1521
+ else if (step.firstChunkUnixNano === void 0 && isTokenDelta(chunk)) step.firstChunkUnixNano = legacy.time * NANO;
1522
+ }
1523
+ /**
1509
1524
  * Close every open span for a session leaving the store.
1510
1525
  * @param session - the disposed session.
1511
1526
  */
@@ -1824,10 +1839,15 @@ var Collector = class {
1824
1839
  }
1825
1840
  });
1826
1841
  }
1827
- /** The sanitized prompt snapshot: logged system prompt plus the current session surface. */
1842
+ /**
1843
+ * The sanitized prompt snapshot: the current session surface, whose node 0
1844
+ * is the rendered system prompt (`system/message`, host 0.1.5), plus the
1845
+ * legacy logged `header.system` when a 0.1.2-rc.1 runtime still stamps it.
1846
+ */
1828
1847
  capturePrompt(session, header) {
1829
1848
  const parts = [];
1830
- if (header?.system !== void 0) parts.push(header.system);
1849
+ const legacySystem = header?.system;
1850
+ if (legacySystem !== void 0) parts.push(legacySystem);
1831
1851
  const events = typeof session.snapshotEvents === "function" ? session.snapshotEvents() : session.events;
1832
1852
  for (const seq of session.surface.nodes) {
1833
1853
  const event = events[seq];
@@ -7,7 +7,8 @@
7
7
  * with an error status at the latest observed event time. Everything
8
8
  * exported is reconstructable from the session log alone — the collector
9
9
  * invents no model-visible content, and prompt/completion bodies come from
10
- * the logged header and the session surface.
10
+ * the session surface and the logged header (call config and tools). The
11
+ * system prompt is surface node 0, a `system/message` event (host 0.1.5).
11
12
  * @module dsh-observe/collector
12
13
  */
13
14
  import type { Session, SessionEvent } from '@deepseek-ai/dsh-session';
@@ -52,6 +53,15 @@ export declare class Collector {
52
53
  * @param event - the appended event.
53
54
  */
54
55
  handleEvent(session: Session, event: SessionEvent): void;
56
+ /**
57
+ * Fold one legacy `assistant/chunk` event. The type is absent from the
58
+ * 0.1.3+ SessionEventMap (streams are embedded in `assistant/message` and
59
+ * `assistant/attempt`), so the read is structural and only the 0.1.2-rc.1
60
+ * runtime line ever reaches it.
61
+ * @param state - the session state.
62
+ * @param event - the appended event.
63
+ */
64
+ private legacyChunk;
55
65
  /**
56
66
  * Close every open span for a session leaving the store.
57
67
  * @param session - the disposed session.
@@ -71,7 +81,11 @@ export declare class Collector {
71
81
  private emitContextGauge;
72
82
  /** Token and cost counters for one LLM call. */
73
83
  private emitUsageMetrics;
74
- /** The sanitized prompt snapshot: logged system prompt plus the current session surface. */
84
+ /**
85
+ * The sanitized prompt snapshot: the current session surface, whose node 0
86
+ * is the rendered system prompt (`system/message`, host 0.1.5), plus the
87
+ * legacy logged `header.system` when a 0.1.2-rc.1 runtime still stamps it.
88
+ */
75
89
  private capturePrompt;
76
90
  /** The current provider/model attribution: request context first, then the logged header. */
77
91
  private modelOf;
@@ -1 +1 @@
1
- {"version":3,"file":"collector.d.ts","sourceRoot":"","sources":["../../src/collector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,KAAK,EAA+B,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAElG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,KAAK,EAAc,YAAY,EAAE,UAAU,EAAe,MAAM,YAAY,CAAA;AAInF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAK/C;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG;QACzB,WAAW,EAAE,MAAM,CAAA;QACnB,QAAQ,CAAC,EAAE;YAAE,IAAI,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;KAC7B,CAAA;CACF;AAmID;;;GAGG;AACH,qBAAa,SAAS;IAWlB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAdzB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAuC;IAE9D;;;;;;OAMG;gBAEgB,MAAM,EAAE,cAAc,EACtB,UAAU,EAAE,MAAM,iBAAiB,GAAG,SAAS,EAC/C,MAAM,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,EAClC,QAAQ,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,EACxC,MAAM,EAAE,aAAa;IAGxC;;;;OAIG;IACH,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,GAAG,IAAI;IAsDxD;;;OAGG;IACH,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAqB7C,OAAO,CAAC,OAAO;IAef,OAAO,CAAC,SAAS;IAmBjB,OAAO,CAAC,SAAS;IAejB,OAAO,CAAC,gBAAgB;IAiDxB,OAAO,CAAC,QAAQ;IAiBhB,OAAO,CAAC,UAAU;IA6ClB,OAAO,CAAC,OAAO;IAMf,OAAO,CAAC,OAAO;IA6Bf,oGAAoG;IACpG,OAAO,CAAC,SAAS;IAsEjB,4EAA4E;IAC5E,OAAO,CAAC,gBAAgB;IAuBxB,gDAAgD;IAChD,OAAO,CAAC,gBAAgB;IAqCxB,4FAA4F;IAC5F,OAAO,CAAC,aAAa;IAiBrB,6FAA6F;IAC7F,OAAO,CAAC,OAAO;IAOf,uDAAuD;IACvD,OAAO,CAAC,cAAc;IAatB,+CAA+C;IAC/C,OAAO,CAAC,IAAI;CAGb"}
1
+ {"version":3,"file":"collector.d.ts","sourceRoot":"","sources":["../../src/collector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,KAAK,EAA+B,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAElG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,KAAK,EAAc,YAAY,EAAE,UAAU,EAAe,MAAM,YAAY,CAAA;AAInF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAK/C;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG;QACzB,WAAW,EAAE,MAAM,CAAA;QACnB,QAAQ,CAAC,EAAE;YAAE,IAAI,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;KAC7B,CAAA;CACF;AAiID;;;GAGG;AACH,qBAAa,SAAS;IAWlB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAdzB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAuC;IAE9D;;;;;;OAMG;gBAEgB,MAAM,EAAE,cAAc,EACtB,UAAU,EAAE,MAAM,iBAAiB,GAAG,SAAS,EAC/C,MAAM,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,EAClC,QAAQ,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,EACxC,MAAM,EAAE,aAAa;IAGxC;;;;OAIG;IACH,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,GAAG,IAAI;IAsDxD;;;;;;;OAOG;IACH,OAAO,CAAC,WAAW;IAanB;;;OAGG;IACH,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAqB7C,OAAO,CAAC,OAAO;IAef,OAAO,CAAC,SAAS;IAmBjB,OAAO,CAAC,SAAS;IAejB,OAAO,CAAC,gBAAgB;IAiDxB,OAAO,CAAC,QAAQ;IAiBhB,OAAO,CAAC,UAAU;IA6ClB,OAAO,CAAC,OAAO;IAMf,OAAO,CAAC,OAAO;IA6Bf,oGAAoG;IACpG,OAAO,CAAC,SAAS;IAsEjB,4EAA4E;IAC5E,OAAO,CAAC,gBAAgB;IAuBxB,gDAAgD;IAChD,OAAO,CAAC,gBAAgB;IAqCxB;;;;OAIG;IACH,OAAO,CAAC,aAAa;IAkBrB,6FAA6F;IAC7F,OAAO,CAAC,OAAO;IAOf,uDAAuD;IACvD,OAAO,CAAC,cAAc;IAatB,+CAA+C;IAC/C,OAAO,CAAC,IAAI;CAGb"}
@@ -7,7 +7,8 @@
7
7
  * with an error status at the latest observed event time. Everything
8
8
  * exported is reconstructable from the session log alone — the collector
9
9
  * invents no model-visible content, and prompt/completion bodies come from
10
- * the logged header and the session surface.
10
+ * the session surface and the logged header (call config and tools). The
11
+ * system prompt is surface node 0, a `system/message` event (host 0.1.5).
11
12
  * @module dsh-observe/collector
12
13
  */
13
14
  import { deriveEventMessage } from '@deepseek-ai/dsh-session';
@@ -30,13 +31,11 @@ function normalizeUsage(usage) {
30
31
  }
31
32
  /**
32
33
  * Whether a stream chunk carries visible model output (the first-token
33
- * boundary). Local replication of the rc.2 `@deepseek-ai/dsh-llm/message`
34
- * `isTokenDelta` helper, which host 0.1.2-alpha.1 removed from that module:
35
- * the host's whole-log sessionStats projection now inlines the same switch
36
- * (`packages/session/session-stats/src/projection.ts`), and the chunk
37
- * grammar itself is unchanged, so this predicate stays identical on both
38
- * rulers. Empty deltas (heartbeats, empty tool-call frames) do not count as
39
- * a first token.
34
+ * boundary). Local copy of the predicate host 0.1.5 exports as
35
+ * `isTokenDelta` from `@deepseek-ai/dsh-llm/assistant-stream`; kept local
36
+ * because the 0.1.2-rc.1 line has no such export and the chunk grammar is
37
+ * unchanged, so the switch below stays identical on both rulers. Empty
38
+ * deltas (heartbeats, empty tool-call frames) do not count as a first token.
40
39
  * @param chunk - the stream chunk to test.
41
40
  * @returns true when the chunk contains a non-empty text/reasoning/tool delta.
42
41
  */
@@ -52,15 +51,15 @@ function isTokenDelta(chunk) {
52
51
  }
53
52
  }
54
53
  /**
55
- * Recover finish reason and first-token timing from the v2 embedded stream
56
- * when an `assistant/message` event carries one. On the pinned rc.1 line the
57
- * field is absent and the legacy `assistant/chunk` branch keeps doing the
58
- * work; on 0.1.3-alpha.1 `assistant/chunk` no longer exists, so this path is
59
- * the only source for those two span fields. Compact runs carry member i at
60
- * `time0 + sum(dt[0..i-1])`; every member is a token-delta boundary, so the
61
- * run's first non-empty member is the first token.
54
+ * Recover finish reason and first-token timing from an embedded assistant
55
+ * stream. Host 0.1.5 carries the exact timed model stream on the required
56
+ * `assistant/message.stream` field and, for a failed/cancelled/stream-errored
57
+ * attempt that never commits a message, on `assistant/attempt.stream`; the
58
+ * removed `assistant/chunk` events were the rc.1-only equivalent. Compact runs
59
+ * carry member i at `time0 + sum(dt[0..i-1])`; every member is a token-delta
60
+ * boundary, so the run's first non-empty member is the first token.
62
61
  * @param state - the open step state to fill.
63
- * @param data - the `assistant/message` event data.
62
+ * @param data - the event data carrying the stream.
64
63
  */
65
64
  function consumeEmbeddedStream(state, data) {
66
65
  const stream = data?.stream;
@@ -152,20 +151,16 @@ export class Collector {
152
151
  case 'request/context':
153
152
  state.context = event.data;
154
153
  break;
155
- case 'assistant/chunk':
156
- if (state.step !== undefined) {
157
- if (event.data.chunk.type === 'finish') {
158
- state.step.finishReason = event.data.chunk.reason.kind;
159
- }
160
- else if (state.step.firstChunkUnixNano === undefined && isTokenDelta(event.data.chunk)) {
161
- state.step.firstChunkUnixNano = event.time * NANO;
162
- }
163
- }
164
- break;
165
154
  case 'assistant/message':
166
155
  consumeEmbeddedStream(state, event.data);
167
156
  this.assistantMessage(session, state, event);
168
157
  break;
158
+ case 'assistant/attempt':
159
+ // 0.1.3+ logs a failed, cancelled, or stream-errored attempt as its own
160
+ // event with no assistant/message following, so its stream is the only
161
+ // source for the dangling LLM span's finish reason and first token.
162
+ consumeEmbeddedStream(state, event.data);
163
+ break;
169
164
  case 'tool/call':
170
165
  this.toolCall(session, state, event);
171
166
  break;
@@ -179,10 +174,36 @@ export class Collector {
179
174
  this.turnEnd(session, state, event);
180
175
  break;
181
176
  default:
182
- // Unknown or plugin-owned session events: nothing to export.
177
+ // Unknown or plugin-owned session events. The published 0.1.2-rc.1
178
+ // line still streams `assistant/chunk`, which host commit f99b06eaed
179
+ // removed from SessionEventMap, so read it structurally when present.
180
+ this.legacyChunk(state, event);
183
181
  break;
184
182
  }
185
183
  }
184
+ /**
185
+ * Fold one legacy `assistant/chunk` event. The type is absent from the
186
+ * 0.1.3+ SessionEventMap (streams are embedded in `assistant/message` and
187
+ * `assistant/attempt`), so the read is structural and only the 0.1.2-rc.1
188
+ * runtime line ever reaches it.
189
+ * @param state - the session state.
190
+ * @param event - the appended event.
191
+ */
192
+ legacyChunk(state, event) {
193
+ const legacy = event;
194
+ if (legacy.type !== 'assistant/chunk')
195
+ return;
196
+ const chunk = legacy.data?.chunk;
197
+ const step = state.step;
198
+ if (chunk === undefined || step === undefined)
199
+ return;
200
+ if (chunk.type === 'finish') {
201
+ step.finishReason = chunk.reason.kind;
202
+ }
203
+ else if (step.firstChunkUnixNano === undefined && isTokenDelta(chunk)) {
204
+ step.firstChunkUnixNano = legacy.time * NANO;
205
+ }
206
+ }
186
207
  /**
187
208
  * Close every open span for a session leaving the store.
188
209
  * @param session - the disposed session.
@@ -532,11 +553,16 @@ export class Collector {
532
553
  });
533
554
  }
534
555
  }
535
- /** The sanitized prompt snapshot: logged system prompt plus the current session surface. */
556
+ /**
557
+ * The sanitized prompt snapshot: the current session surface, whose node 0
558
+ * is the rendered system prompt (`system/message`, host 0.1.5), plus the
559
+ * legacy logged `header.system` when a 0.1.2-rc.1 runtime still stamps it.
560
+ */
536
561
  capturePrompt(session, header) {
537
562
  const parts = [];
538
- if (header?.system !== undefined)
539
- parts.push(header.system);
563
+ const legacySystem = header?.system;
564
+ if (legacySystem !== undefined)
565
+ parts.push(legacySystem);
540
566
  // alpha.5 renamed the Session.events getter to snapshotEvents(); older hosts
541
567
  // (the >=0.1.0-rc.8 peer floor) still expose .events, so detect at runtime.
542
568
  const events = typeof session.snapshotEvents === 'function'