npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@xfcodeai/dsh-session-log-deepseek

v0.1.5-rc.5

Published

Incremental lossless session-log request extension for the official DeepSeek LLM API

Readme


description: "面向启用官方 DeepSeek 请求元数据的部署,增量上传规范会话日志。" kind: "package-reference"

@xfcodeai/dsh-session-log-deepseek

English | 中文

概述

用于 DeepSeek 官方 LLM(大语言模型)API 请求的增量规范会话日志上传。该函数插件注入 ctx.sessions 与 ctx.deepseekLlmApiExtensions,并拥有 dsh_session_log 请求字段以及用于派生接受水位的持久 session-log-deepseek/delivery-accepted 事件。仅当官方 API 需要接收会话日志后缀时才启用它。

目录


配置

| 配置键 | 默认值 | 含义 | |---|---:|---| | enabled | false | 注册 dsh_session_log 贡献。将其设为 true 可选择启用会话日志上传。 |

随附 profile 会挂载该插件,让 overlay 可以启用它;默认配置不会注册请求字段,也不会追加接受水位。

请求字段

对于携带存活 sessionId 的请求,插件会折叠该确切会话格式代的最大已接受水位,对 Session.events 取快照,并发送水位之后的连续后缀。进程内 fold 会让每条事件只被扫描一次并增量消费后续追加;重启与 HMR(热模块替换)会从持久日志重建它。版本 1 字段包含 sessionFormatVersion、原始会话 header(仅 seeded Session 携带 seedLength)、数值型 afterSeq 与 throughSeq,以及每个已转换为原始数值 envelope 字段的完整规范事件。只有记录的会话 id 与格式代均匹配请求来源时水位才生效,因此 fork 会话会忽略从父会话继承的水位。表层事件必须携带 surfaceOp,替换范围使用数值型 startSeq 与 endSeq;仅 user 与 tool 事件可以携带 sourceEventSeqs。assistant 的来源保留在内嵌流中,只出现在日志中的事件不携带这两个元数据字段。

接受与重试

DeepSeek 适配器会在 HTTP 2xx 后、消费 SSE(Server-Sent Events)正文前调用已准备贡献的 accept()。接受操作会追加 session-log-deepseek/delivery-accepted,其中包含已上传的 throughSeq 与 sessionFormatVersion;省略格式字段的记录表示 v0。下一次请求再把该事件作为新后缀的一部分上传。传输失败与非 2xx 失败不会追加接受记录,因此后续请求会重发不确定范围。并发交付可能乱序得到接受;折叠匹配记录中最大的 throughSeq 可以防止游标回退。

服务端接受后、持久化水位前发生崩溃,可能让恢复后的进程重放已经接受的范围。这是至少一次交付的失败方向:不确定性会制造重复,绝不会跳过序列。普通会话检查点策略会在下一个语义检查点持久化水位;本插件不执行独立 I/O。

缺少存活会话的直接请求会省略 dsh_session_log。普通 agent(智能体)、压缩(compaction)与会话标题调用都会携带存活会话 id。

模型体验

会话日志元数据

模型看到的内容

无。dsh_session_log 是 DeepSeek 请求中模型输入字段的同级字段,不会插入 messages、系统提示词或工具 schema。

Token 影响

模型输入 token 为零;该字段只会增加 HTTP 请求字节数。

KV Cache 影响

无;模型可见请求前缀保持不变。

已知限制与暂缓事项

  • 崩溃窗口重复——2xx 后、接受水位持久化前进程终止,会在恢复时触发保守重放。
  • 缺少存活会话就没有字段——直接调用或陈旧会话调用没有可供快照的规范日志;显式缺失语义仍暂缓处理。
  • 没有独立请求大小上限——完整交付采用 fail-closed 策略;提供方拒绝会保持游标不变,而非截断日志。

开发备注

无。