rea
morluto
Reverse engineer anything with agents, from app behavior down to native binaries.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:zzzxxxxxxxxxx/dsh-balance
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
锚点 − k × 本机已消耗,所以数字随 token 实时递减。T 取得的读数只反映 T − settlementLagMs 之前的用量,因此本地累计从那个截止时刻起算;不做这个位移,最后几分钟会被重复扣除。k,把过期价目表、未收录的模型、统一折扣一并吸收。k、不作废校准窗口;成块结算只计一次。没有本地用量的大额下降单列为「非用量调整」,不算你的花费。ETA 跨时段积分,否则 17:50 起算会漏掉 18:00 开始的半价,偏小最多 2×。host 半独占凭据与出网,只把一份快照经两条精确路由交给浏览器半:凭据从不进入浏览器,两条路由也都参与宿主的 Host/Origin 与 cookie 信任围栏。出网只有两个目标——余额端点,以及你显式启用时的节假日源。
要求:DeepSeek Harness ≥ 0.2.0-rc.1,Node ^22.19.0 || >=24.0.0。
从 npm 装(推荐):
dsh plugin --profile <profile> add @zzxxxxxx/dsh-balance
从源码装 / 本地开发:
git clone https://github.com/zzzxxxxxxxxxx/dsh-balance && cd dsh-balance
npm install # 构建依赖,首次需要网络
npm run build # 产出 lib/(插件入口;仓库里不提交构建产物)
dsh plugin --profile <profile> add "$PWD"
从打好的 tarball 装(npm pack 的产物已含 lib/,无需构建):
dsh plugin --profile <profile> add ./zzxxxxxx-dsh-balance-0.1.0.tgz
装完后重启 dsh(profile 在启动时组合)。
DEEPSEEK_API_KEY,与内置 deepseek-official provider 是同一个引用——模型能用就说明它已配好;也可在 设置 → 模型、$DSH_HOME/.credentials.yaml 或导出环境变量里设置。git pull && npm install && npm run build,tarball 装则重新 add 一次。之后都要重启。dsh plugin --profile <p> remove @zzxxxxxx/dsh-balance,再重启。dsh-balance 是另一个同类插件,请按 scope 安装。npm run typecheck、npm test(87 个用例,不访问网络)、npm run build、npm run gen:holidays(重新生成节假日种子,唯一会真实出网的一步)。¥36.35 · 2 天 4 小时——预估余额与估算可用时长。状态点平时绿,低于 etaWarnMs 转橙,低于 etaCriticalMs 或余额耗尽转红,未标定或连不上时灰。GET /dsh-balance/state(快照)与 POST /dsh-balance/refresh(请求一次轮询)。全部字段都写在插件行的 config: 里(本插件没有设置页),改完需重启。下面是完整的默认值:
- insert:
- id: dsh-balance
name: '@zzxxxxxx/dsh-balance'
config:
apiKeyEnv: DEEPSEEK_API_KEY
apiOrigin: https://api.deepseek.com
balancePath: /user/balance
refreshIntervalMs: 60000 # 轮询平台的周期
requestTimeoutMs: 10000
settlementLagMs: 300000 # 平台读数滞后于用量的上界
rateWindowMs: 1800000 # 瞬时消耗速率的观测窗口
calibrationWindowMs: 21600000 # 校正系数 k 的学习窗口
correctionSamples: 9 # k 取中位数的近期候选数
probeSamples: 5 # 给出日历建议所需的探针数
retentionMs: 604800000
staleAfterMs: 180000
etaCapMs: 31536000000
minBurnPerHour: 0.01
minPredictedSpend: 0.01 # 量化步长,也是「大额下降」阈值
preferredCurrency: auto # auto | CNY | USD
priceCurrency: CNY
priceTable: # 高峰价,单位「币种 / 百万 token」
deepseek-flash: { input: 1, cacheRead: 0.02, output: 4 }
deepseek-v4-pro: { input: 4.5, cacheRead: 0.15, output: 13.5 }
offPeakFactor: 0.5
peakDays: [1, 2, 3, 4, 5]
peakWindows: ['09:00-12:00', '14:00-18:00']
priceTimeZone: Asia/Shanghai
holidays: [] # ['2027-01-01', ...]
makeupWorkdays: [] # ['2027-02-20', ...]
treatMakeupWorkdaysAsPeak: false
holidaySourceEnabled: false # 第二个出网目标,默认关闭
holidaySourceUrl: https://timor.tech/api/holiday/year/{year}
holidaySourceFormat: auto # auto | timor | holiday-cn
holidayRefreshIntervalMs: 604800000
holidayMissingYearRetryMs: 86400000
holidayTimeoutMs: 8000
weights: { uncachedInput: 1, cacheWrite: 1, cacheRead: 0.1, output: 4 }
etaIntegratesSchedule: true
etaWarnMs: 86400000
etaCriticalMs: 14400000
clientPollIntervalMs: 15000
persist: true
historyRoot: ''
allowLoopbackHttp: false
| 字段 | 默认 | 说明 |
|---|---|---|
apiKeyEnv |
DEEPSEEK_API_KEY |
取 API Key 的凭据引用(环境变量名) |
apiOrigin |
https://api.deepseek.com |
余额端点 origin;必须 https(loopback 例外) |
balancePath |
/user/balance |
余额端点路径 |
refreshIntervalMs |
60000 |
轮询平台的周期 |
requestTimeoutMs |
10000 |
单次余额请求超时 |
settlementLagMs |
300000 |
平台读数滞后于用量的上界;本地累计从此前移起算 |
rateWindowMs |
1800000 |
瞬时消耗速率的观测窗口 |
calibrationWindowMs |
21600000 |
校正系数 k 的学习窗口 |
correctionSamples |
9 |
取中位数的近期候选数 |
probeSamples |
5 |
给出日历建议所需的探针样本数 |
retentionMs |
604800000 |
读数与 token 桶的保留时长(7 天) |
staleAfterMs |
180000 |
多久没有新读数就把快照标为过期 |
etaCapMs |
31536000000 |
可用时长上限,超过显示 > 1 年 |
minBurnPerHour |
0.01 |
低于此速率视为闲置,不报 ETA |
minPredictedSpend |
0.01 |
量化步长;也是「大额下降」的判定阈值 |
preferredCurrency |
auto |
钱包偏好:auto 优先有余额的 CNY,其次 USD |
priceCurrency |
CNY |
价目表计价币种;与钱包不一致时退出价目表路径 |
priceTable |
deepseek-flash deepseek-v4-pro |
各路由的高峰价,单位「币种 / 百万 token」 |
offPeakFactor |
0.5 |
空闲时段相对高峰的倍率 |
peakDays |
[1,2,3,4,5] |
承载高峰时段的 ISO 星期 |
peakWindows |
09:00-12:00 14:00-18:00 |
高峰时段 |
priceTimeZone |
Asia/Shanghai |
高峰时段所用的时区 |
holidays |
[] |
法定节假日(YYYY-MM-DD),优先级最高 |
makeupWorkdays |
[] |
调休补班日,同样最高优先级 |
treatMakeupWorkdaysAsPeak |
false |
调休补班日是否按高峰计价 |
holidaySourceEnabled |
false |
是否启用远程节假日源 |
holidaySourceUrl |
timor.tech |
远程源 URL 模板,必须含 {year} |
holidaySourceFormat |
auto |
远程载荷结构:auto / timor / holiday-cn |
holidayRefreshIntervalMs |
604800000 |
远程源正常刷新周期 |
holidayMissingYearRetryMs |
86400000 |
当年日历尚未发布时的重试周期 |
holidayTimeoutMs |
8000 |
远程源请求超时 |
weights |
1 / 1 / 0.1 / 4 |
价目表未覆盖路由的相对权重 |
etaIntegratesSchedule |
true |
ETA 是否跨峰谷切换积分 |
etaWarnMs |
86400000 |
低于此可用时长状态点转橙 |
etaCriticalMs |
14400000 |
低于此转红 |
clientPollIntervalMs |
15000 |
浏览器读取快照的周期 |
persist |
true |
是否把读数与 token 桶落盘到 $DSH_HOME/dsh-balance/ |
historyRoot |
'' |
落盘目录覆盖,空表示用默认目录 |
allowLoopbackHttp |
false |
是否允许 http 的 loopback 端点(本地开发用) |
几条语义:
settlementLagMs(默认 5 分钟以内),不会随滞后漂移。k 会在 1.0 附近——它本身就是最好的自检。session/event 按 scope 过滤,挂在 profile 层的插件收不到 request/context,所以模型是从 modelSelection 投影主动拉取的(对加载前就已固定的选择,变化事件永远不会触发)。weights 计价,并在面板标出。holidaySourceEnabled,或在新一年公布后重跑 npm run gen:holidays 重新生成种子。未发布的年份按未知处理(绝不记成「无节假日」——那会把整年工作日按高峰计价且不再重试),重试周期缩短为每天,并在面板提示。connection 是必需注入,缺了插件就不加载,围栏不会静默失效——代价是服务短暂不可用时返回 503,而不是不带围栏地照常作答。$DSH_HOME/dsh-balance/history.json——它记录了读数与 token 桶,比截图清楚得多。CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: deepseek-harness。