前言¶
在 DeepSeek Harness(DSH)裏用 Composer 對話時,界面統計欄通常只顯示速度與 token 用量。若要對照 DeepSeek 公開價目表估算「這一整段 Session 大概花了多少錢」,需要自己查 projection、手算分桶,或離開當前界面。下面介紹的客戶端插件 dsh-client-ui-session-cost 在 Composer 輸入框下方統計欄裏增加一枚 Session 費用 小標籤,與現有 speed、token 標籤並列,數字隨 Session 流式更新,懸停可看分桶與費率說明。
這是什麼¶
dsh-client-ui-session-cost 是 DSH 的 客戶端(client) 插件,維護者爲 iskrantxusa,倉庫 iskrantxusa/dsh-client-ui-session-cost。官方簡介爲:在 DeepSeek Harness Composer dock 中顯示 Estimated session cost pill(Session 費用估算標籤)。
插件不發起網絡請求、不上報遙測,只讀取 DSH 已爲 Session 維護的 tokenUsage projection,按內置 DeepSeek 列表價(USD / 1M tokens)換算後展示。估算覆蓋 整個 Session(不限於當前已加載的歷史頁),因爲計價依據是 DSH 持久化的 token 用量投影。
社區目錄頁:https://www.skillhub.cn/plugins/iskrantxusa/dsh-client-ui-session-cost(獨立站點,與 DeepSeek / 幻方無官方從屬關係)。
核心功能¶
統計欄費用標籤¶
安裝並在 Web 或 Desktop DSH profile 中生效後,Composer 統計 dock(輸入框下方、與 speed / token 同一行)會出現類似:
Cost ≈ $0.15
的展示。鼠標懸停該標籤時,可查看 token 分桶、當前生效費率以及所用模型。
計價範圍與數據來源¶
Wire 視圖上的用量字段爲:
{ uncachedInputTokens, outputTokens, cacheReadTokens, cacheWriteTokens }
合計邏輯爲 cacheMiss + cacheRead + output;cache miss 側包含 cacheWriteTokens。模型來自 modelSelection projection(優先 next,否則 lastUsed)。若模型未知,則按 deepseek-flash 費率估算,tooltip 會標明 assumed rates。Session 中途換模型時,整段 Session 按 最新模型 計價(projection 不保留逐請求模型歷史)。
以下情況 不計入 該估算:Search/Fetch API 請求、自帶計費的工具、賬戶贈金等。
內置費率與峯谷¶
費率對齊 DeepSeek 文檔 Models & Pricing(USD / 1M tokens):
| Model | Cache hit (peak / off-peak) | Cache miss (peak / off-peak) | Output (peak / off-peak) |
|---|---|---|---|
deepseek-flash |
$0.006 / $0.003 | $0.30 / $0.15 | $1.20 / $0.60 |
deepseek-v4-pro |
$0.044 / $0.022 | $1.32 / $0.66 | $3.96 / $1.98 |
Peak 爲 UTC 週一到週五 01:00–04:00 與 06:00–10:00;其餘時段、週末及 DSH 未識別的中國節假日按 off-peak(半價)處理。官方價目變更時,需自行修改倉庫 lib/client.js 中的 PRICES、 bump 版本並重新安裝。
實現要點(便於排查)¶
lib/index.js:host 側空實現,僅滿足 Loader 對dsh.client包的行聲明。lib/client.js:在conversation.composer.dock列表槽註冊id: cost、order: 2的條目;無構建步驟,除平臺 React 外無額外依賴。- 安裝包同時是 bundle 與 patch 目標:
cordis.patch.yml插入ui-session-costloader 行,並在dsh.profile.bundles中選中本包。
安裝與啓用¶
插件以當前 DSH 進程權限運行;安裝前建議瀏覽倉庫源碼與 MIT 許可證。下列命令與路徑均來自項目 README。
從 Discover 市場索引安裝¶
- 開啓 Experimental plugins → Custom plugin markets。
- 打開 Plugins → Discover → Add index source,填入:
https://raw.githubusercontent.com/iskrantxusa/dsh-client-ui-session-cost/main/market/index.json
- 在市場中選擇 Session cost pill,按確認流程安裝所需版本。索引爲 format-1 JSON,位於倉庫
market/index.json,並 pin 到指定 Git commit。
從 GitHub 安裝(README 推薦的無市場方式)¶
PowerShell:
dsh plugin add github:iskrantxusa/dsh-client-ui-session-cost
或在 Web GUI:Sidebar → Plugins → Add plugin,粘貼 github:iskrantxusa/dsh-client-ui-session-cost 後安裝。
默認開啓 HMR 時,patch 熱應用,標籤無需重啓即可出現;若關閉 HMR,需重啓 DSH。
從 release 壓縮包安裝¶
下載 dsh-client-ui-session-cost-0.1.0.tgz,在 Plugins → Add plugin 選擇本地文件,或:
dsh plugin add C:\path\to\dsh-client-ui-session-cost-0.1.0.tgz
手動安裝(無法使用插件管理器時)¶
將本倉庫目錄複製到:
%USERPROFILE%\.dsh\profiles\desktop\node_modules\dsh-client-ui-session-cost
並在 %USERPROFILE%\.dsh\profiles\desktop\cordis.patch.yml 增加:
- insert:
- id: ui-session-cost
name: dsh-client-ui-session-cost
不要 在已通過 bundle 安裝後再保留上述 manual 塊:兩者插入相同 row id。若改用 bundle,請先刪除 manual 塊。
典型用法¶
經過上面的安裝步驟後,正常使用 Composer 即可:統計欄會自動出現費用標籤,Session 流式輸出時數字會隨 tokenUsage 更新。需要覈對分桶或峯谷費率時,懸停 Cost ≈ $… 標籤查看 tooltip。
本地開發或改價後,可在倉庫根目錄執行:
node test/test-cost.cjs
該測試在 VM 中加載 bundle 樁環境,校驗官方費率數學、峯谷邊界、展示舍入、未知模型回退以及 conversation.composer.dock 註冊行爲。
適用場景與注意¶
適合:在 Web / Desktop DSH 中長期使用 Composer、希望在同屏看到 整段 Session 參考費用、並與 token 速度信息對照的開發者。
注意:
- 展示結果爲 參考信息,不是賬單;以 DeepSeek 價目頁 爲準。
- 需要 Web 或 Desktop DSH profile;無 HMR 時需重啓。
- 卸載:Plugins → 對應 bundle → Remove,或等價的
dsh plugin remove;手動安裝則刪除包目錄及cordis.patch.yml中- id: ui-session-cost塊。
結尾¶
dsh-client-ui-session-cost 把 Session 級 token projection 轉成 Composer 統計欄上的一枚費用標籤,只讀本地 projection、不聯網,適合作爲日常開發的用量與價目對照。目錄頁見 skillhub.cn/plugins/iskrantxusa/dsh-client-ui-session-cost,源碼與安裝說明見 GitHub 倉庫。