meowapi-statusline 1.0.2 → 1.0.3

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.md CHANGED
@@ -87,9 +87,10 @@ base URL 末尾带不带 `/api` 都能识别:
87
87
 
88
88
  - `utilization` 是 0–100 百分比。为了兼容按 Anthropic 原始口径返回 0–1 小数的代理,
89
89
  值 ≤ 1 且 > 0 时按小数处理。
90
- - `resets_at` 是 unix 秒。只有当它落在窗口长度**之内**时才会显示倒计时:滚动窗口的
91
- 网关每次请求都会把锚点往后推,于是 `resets_at` 恒等于「现在 + 一整个窗口」,
92
- 那个数字永远不会减小。这种值会被判定为窗口长度而非重置时刻,直接不显示转换。
90
+ - `resets_at` 是 unix 秒。一个窗口的锚点在该窗口存续期间是固定的,所以
91
+ `resets_at` 是个会随刷新递减的真实时刻。只有当它落在「窗口长度 + 5 分钟」之内
92
+ 才会画 `↻`:超出这个范围的数字不是倒计时,而是把窗口长度原样回显(网关在每次
93
+ 请求时重新锚定窗口就会这样),那种值不显示。
93
94
  - 可选字段 `seven_day_opus` / `seven_day_sonnet` 存在时额外画独立条。
94
95
 
95
96
  ## 开发
package/lib/statusline.js CHANGED
@@ -103,13 +103,17 @@ export function normalizeUsage(data) {
103
103
  return periods
104
104
  }
105
105
 
106
- // A gateway that derives resets_at from a rolling window anchor reports
107
- // "one full window from now" on every request, because each charge restarts the
108
- // anchor. That countdown never moves, so a reset that is a whole window (or
109
- // more) away is the window length echoed back at us, not a reset time.
106
+ // Clock skew between this machine and the gateway is normally sub-second, but a
107
+ // reset read moments after a window opened can still land a hair past "one
108
+ // window from now" on the client's clock. A little slack keeps that real
109
+ // countdown visible. What still gets rejected is a reset far beyond one window,
110
+ // which is not a boundary at all — the window length echoed back on every
111
+ // refresh, the shape this guard was written for.
112
+ export const RESET_SKEW_SECONDS = 120
113
+
110
114
  export function isPlausibleReset(resetsAt, nowSeconds, windowSeconds) {
111
115
  const remaining = resetsAt - nowSeconds
112
- return remaining > 0 && remaining < windowSeconds
116
+ return remaining > 0 && remaining <= windowSeconds + RESET_SKEW_SECONDS
113
117
  }
114
118
 
115
119
  export function renderLine(data, nowSeconds = Date.now() / 1000) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "meowapi-statusline",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Claude Code status line: show subscription quota bars on API-key / gateway sessions",
5
5
  "keywords": [
6
6
  "claude-code",