dsh-search-audit
DiscoveredRead-only observer for native DeepSeek Search calls in DeepSeek Harness (dsh): appends each call's token usage to ~/.dsh/search-usage.jsonl so accounting plugins can price it. Requests and responses a
dsh-search-audit
用途:旁路观测官方 DeepSeek 搜索的模型调用开销。
官方 @deepseek-ai/dsh-web-search-deepseek 自己 fetch 打 api.deepseek.com/anthropic/v1/messages
(原生 server tool web_search_20250305),响应里的 usage 被直接丢弃、也不进会话日志 ——
所以任何统计都看不到这笔钱。本插件包一层 globalThis.fetch,把那些响应的 usage 落盘,
供 dsh-turn-cost 等消费者读取。
命令
node tool/dsh-search-audit/tests/run_tests.mjs # 44 项回归,退出码 0 = PASS
输入
| 项 | 说明 |
|---|---|
环境变量 DSH_SEARCH_AUDIT_LOG | 覆盖落盘路径(默认 ~/.dsh/search-usage.jsonl) |
| 运行时 | 无需配置、无需 API key;随 Host 启动自动包 fetch |
输出(每行一条 JSON)
{"ts":1792392407024,"endpoint":"https://api.deepseek.com/anthropic/v1/messages",
"sessionId":"session-0123…",
"model":"deepseek-v4-flash","query":"开源 批量 翻译","maxUses":5,
"ok":true,"status":200,
"usage":{"inputTokens":93,"outputTokens":1874,"cacheReadTokens":0,"cacheWriteTokens":0},
"source":"dsh-search-audit"}
失败的调用也会记一条(ok:false、usage:null),方便区分"搜了但失败"和"没搜"。
依赖与边界
- 纯旁路:不改官方代码、不碰
app.asar、官方升级不会覆盖它;对非目标请求原样透传。 - 只认「
/anthropic/v1/messages+ body 里带web_search_20250305」的请求;free-search 等普通工具不经过这里,也不需要。 - 记账全程异步 + try/catch,永远不影响原调用;记不下来就少一条记录,不会报错给调用方。
- 只记原始 usage,不折算成钱(价格策略留给消费者,避免两处维护)。
- 若官方哪天改成注入式 fetch / undici,本插件会失效(届时靠回归与真实搜索验证)。
Comments
Loading…
Similar plugins
by shaomingbo
Accounts, subscription allowance observations, and local usage ledger for DeepSeek Harness
★ 0
↓ 255/wk
MIT
JavaScript
Sep 13, 2026
dsh plugin --profile web add dsh-token-usageby ZSeven-W
DeepSeek Harness (DSH) plugin: a read-only ledger for the plugins you already have installed — a capability inventory with file:line evidence, declared-vs-detected reconciliation, cross-profile versio
★ 25
↓ 101/wk
MIT
JavaScript
Oct 29, 2026
dsh plugin --profile web add @zseven-w/dsh-harborby Liu-Bot24
DeepSeek Harness(DSH)只读执行轨迹复盘插件,支持规则分析、独立模型解读、证据定位、任务概览与运行对比。
★ 5
MIT
JavaScript
Oct 21, 2026
dsh plugin --profile web add dsh-plugin-trace-insightby Muggle8888
Read-only update auditing for DeepSeek Harness profile plugins
★ 0
MIT
JavaScript
Sep 10, 2026
dsh plugin --profile web add dsh-plugin-update-auditby XiaHouSheng
A DeepSeek-Harness web plugin that tracks provider token usage, prices it with a peak/off-peak table, and shows the totals in the dsh GUI — plus a standalone overview page and JSON API.
★ 0
MIT
TypeScript
Aug 17, 2026
dsh plugin --profile web add dsh-token-trackerby Leitarkkk
DeepSeek Harness plugin that auto-nudges agents to consult docs or web search when local trial-and-error becomes costly. DeepSeek Harness 插件:当本地试错成本升高时,自动注入检索提示,引导 Agent 查阅文档或联网搜索。
★ 4
MIT
JavaScript
Aug 28, 2026
dsh plugin --profile web add dsh-research-nudge