pi-harness-runtime 1.1.13 → 1.1.15

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.
Files changed (99) hide show
  1. package/CHANGELOG.md +19 -26
  2. package/footer-status.ts +107 -7
  3. package/harness/e2e/glm-quota-scraper.ts +44 -0
  4. package/harness/glm-quota-countdown.test.ts +323 -0
  5. package/harness/glm-quota-countdown.ts +615 -0
  6. package/harness/index.ts +12 -0
  7. package/package.json +1 -1
  8. package/packages/a2a-adapter/package.json +1 -1
  9. package/packages/architecture-generator/package.json +1 -1
  10. package/packages/auth/package.json +1 -1
  11. package/packages/autonomous-refactor/package.json +1 -1
  12. package/packages/autonomous-runtime/package.json +1 -1
  13. package/packages/cache-strategy/package.json +1 -1
  14. package/packages/capability-registry/package.json +1 -1
  15. package/packages/checkpoint/package.json +1 -1
  16. package/packages/cli-plugin-sdk/package.json +1 -1
  17. package/packages/clipboard/package.json +1 -1
  18. package/packages/clipboard-plugin/package.json +1 -1
  19. package/packages/code-generation/package.json +1 -1
  20. package/packages/code-review/package.json +1 -1
  21. package/packages/codex-adapter/package.json +1 -1
  22. package/packages/config-capture/package.json +1 -1
  23. package/packages/context-compiler/package.json +1 -1
  24. package/packages/context-discovery/package.json +1 -1
  25. package/packages/context-manager/package.json +1 -1
  26. package/packages/cookie-sanitizer/package.json +1 -1
  27. package/packages/cost-optimizer/package.json +1 -1
  28. package/packages/dependency-analyzer/package.json +1 -1
  29. package/packages/django-plugin/package.json +1 -1
  30. package/packages/doc-generator/package.json +1 -1
  31. package/packages/evaluation-engine/package.json +1 -1
  32. package/packages/evaluation-runner/package.json +1 -1
  33. package/packages/event-bus/package.json +1 -1
  34. package/packages/event-store/package.json +1 -1
  35. package/packages/experience-replay/package.json +1 -1
  36. package/packages/feedback-collector/package.json +1 -1
  37. package/packages/file-copy-helper/package.json +1 -1
  38. package/packages/framework-detector/package.json +1 -1
  39. package/packages/framework-plugin-sdk/package.json +1 -1
  40. package/packages/frappe-plugin/package.json +1 -1
  41. package/packages/generic-web-plugin/package.json +1 -1
  42. package/packages/health-monitor/package.json +1 -1
  43. package/packages/intent-analyzer/package.json +1 -1
  44. package/packages/knowledge-graph/package.json +1 -1
  45. package/packages/knowledge-retrieval/package.json +1 -1
  46. package/packages/laravel-plugin/package.json +1 -1
  47. package/packages/learning-engine/package.json +1 -1
  48. package/packages/mcp-adapter/package.json +1 -1
  49. package/packages/memory-engine/package.json +1 -1
  50. package/packages/milestone-manager/package.json +1 -1
  51. package/packages/model-registry/package.json +1 -1
  52. package/packages/nextjs-plugin/package.json +1 -1
  53. package/packages/notification/package.json +1 -1
  54. package/packages/observability/package.json +1 -1
  55. package/packages/okf-indexer/package.json +1 -1
  56. package/packages/performance-optimizer/package.json +1 -1
  57. package/packages/privilege-broker/package.json +1 -1
  58. package/packages/project-analyzer/package.json +1 -1
  59. package/packages/project-bootstrap/package.json +1 -1
  60. package/packages/projection-engine/package.json +1 -1
  61. package/packages/prompt-compiler/package.json +1 -1
  62. package/packages/prompt-versioning/package.json +1 -1
  63. package/packages/provider-adapter-sdk/package.json +1 -1
  64. package/packages/provider-router/package.json +1 -1
  65. package/packages/provider-selector/package.json +1 -1
  66. package/packages/providers/package.json +1 -1
  67. package/packages/quota-manager/dist/tui-usage-monitor.d.ts.map +1 -1
  68. package/packages/quota-manager/dist/tui-usage-monitor.js +20 -4
  69. package/packages/quota-manager/dist/tui-usage-monitor.js.map +1 -1
  70. package/packages/quota-manager/package.json +1 -1
  71. package/packages/quota-manager/src/tui-usage-monitor.ts +21 -4
  72. package/packages/rate-limiter/package.json +1 -1
  73. package/packages/react-vite-plugin/package.json +1 -1
  74. package/packages/release-manager/package.json +1 -1
  75. package/packages/requirement-compiler/package.json +1 -1
  76. package/packages/runtime/package.json +1 -1
  77. package/packages/scheduler/package.json +1 -1
  78. package/packages/scheduler-adapter/package.json +1 -1
  79. package/packages/session/package.json +1 -1
  80. package/packages/session-api/package.json +1 -1
  81. package/packages/session-export/package.json +1 -1
  82. package/packages/shared-context/package.json +1 -1
  83. package/packages/skill-registry/package.json +1 -1
  84. package/packages/sprint-planner/package.json +1 -1
  85. package/packages/subscription-engine/package.json +1 -1
  86. package/packages/task-compiler/package.json +1 -1
  87. package/packages/tencentdb-memory/package.json +1 -1
  88. package/packages/tencentdb-sync/package.json +1 -1
  89. package/packages/test-data-generator/package.json +1 -1
  90. package/packages/test-generator/package.json +1 -1
  91. package/packages/todo-bd-sync/package.json +1 -1
  92. package/packages/token-estimation/package.json +1 -1
  93. package/packages/token-optimizer/package.json +1 -1
  94. package/packages/tui/package.json +1 -1
  95. package/packages/types/package.json +1 -1
  96. package/packages/workflow-events/package.json +1 -1
  97. package/packages/workspace-scanner/package.json +1 -1
  98. package/packages/worktree/package.json +1 -1
  99. package/packages/write-review/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -2,23 +2,39 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
- ### [1.1.13](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v1.1.12...v1.1.13) (2026-08-21)
5
+ ### [1.1.15](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v1.1.13...v1.1.15) (2026-08-24)
6
+
7
+
8
+ ### Features
9
+
10
+ * **glm-quota:** add robust GLM quota countdown with auto-resume ([cb78a2b](https://github.com/ManotLuijiu/pi-harness-runtime/commit/cb78a2bdf5ecf79fc028030d43e3ce40767253cb))
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * **glm:** improve footer status display with specific 5h quota and reset time ([ab991c3](https://github.com/ManotLuijiu/pi-harness-runtime/commit/ab991c329bdb4097e77503d3d7f574edc6cdc1c4))
16
+
17
+ ### [1.1.14](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v1.1.13...v1.1.14) (2026-08-24)
6
18
 
7
19
 
20
+ ### Features
21
+
22
+ * **glm-quota:** add robust GLM quota countdown with auto-resume ([cb78a2b](https://github.com/ManotLuijiu/pi-harness-runtime/commit/cb78a2bdf5ecf79fc028030d43e3ce40767253cb))
23
+
24
+ ### [1.1.13](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v1.1.12...v1.1.13) (2026-08-21)
25
+
8
26
  ### Bug Fixes
9
27
 
10
28
  * **runtime:** auto-resume after provider overload ([7bd98bb](https://github.com/ManotLuijiu/pi-harness-runtime/commit/7bd98bb885536667a5eb35cfe6de45a06dc77269))
11
29
 
12
30
  ### [1.1.12](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v1.1.11...v1.1.12) (2026-08-20)
13
31
 
14
-
15
32
  ### Bug Fixes
16
33
 
17
34
  * **runtime:** refresh minimax quota from provider mirror ([a8976b4](https://github.com/ManotLuijiu/pi-harness-runtime/commit/a8976b4ff61e28b964bf76405142672798714647))
18
35
 
19
36
  ### [1.1.11](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v0.10.42...v1.1.11) (2026-08-20)
20
37
 
21
-
22
38
  ### Features
23
39
 
24
40
  * add quota scrapers for ChatGPT and GLM providers ([17f9d0e](https://github.com/ManotLuijiu/pi-harness-runtime/commit/17f9d0e7d6f486210a30244f2fecc0131e8b7d57))
@@ -26,7 +42,6 @@ All notable changes to this project will be documented in this file. See [standa
26
42
  * index.ts ([d0fc002](https://github.com/ManotLuijiu/pi-harness-runtime/commit/d0fc002d6d16e59318155677cb6128846bc993a4))
27
43
  * update workflow run name to show version number ([ee8c59f](https://github.com/ManotLuijiu/pi-harness-runtime/commit/ee8c59fec4c0116a5948b2ae04ad4609edaed3ac))
28
44
 
29
-
30
45
  ### Bug Fixes
31
46
 
32
47
  * add typescript as devDependency, build notification dist ([c76b522](https://github.com/ManotLuijiu/pi-harness-runtime/commit/c76b5221c33262c38615c6117ecf9db13ab7b5d2))
@@ -49,7 +64,6 @@ All notable changes to this project will be documented in this file. See [standa
49
64
 
50
65
  ### [1.1.10](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v0.10.42...v1.1.10) (2026-08-20)
51
66
 
52
-
53
67
  ### Features
54
68
 
55
69
  * add quota scrapers for ChatGPT and GLM providers ([17f9d0e](https://github.com/ManotLuijiu/pi-harness-runtime/commit/17f9d0e7d6f486210a30244f2fecc0131e8b7d57))
@@ -57,7 +71,6 @@ All notable changes to this project will be documented in this file. See [standa
57
71
  * index.ts ([d0fc002](https://github.com/ManotLuijiu/pi-harness-runtime/commit/d0fc002d6d16e59318155677cb6128846bc993a4))
58
72
  * update workflow run name to show version number ([ee8c59f](https://github.com/ManotLuijiu/pi-harness-runtime/commit/ee8c59fec4c0116a5948b2ae04ad4609edaed3ac))
59
73
 
60
-
61
74
  ### Bug Fixes
62
75
 
63
76
  * add typescript as devDependency, build notification dist ([c76b522](https://github.com/ManotLuijiu/pi-harness-runtime/commit/c76b5221c33262c38615c6117ecf9db13ab7b5d2))
@@ -79,7 +92,6 @@ All notable changes to this project will be documented in this file. See [standa
79
92
 
80
93
  ### [0.10.30](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v0.10.29...v0.10.30) (2026-08-11)
81
94
 
82
-
83
95
  ### Bug Fixes
84
96
 
85
97
  * **file-copy-helper:** require explicit intent for copy rule injection ([ddfece0](https://github.com/ManotLuijiu/pi-harness-runtime/commit/ddfece0bcbf440dfd4edc0d442b078e84e906c68))
@@ -98,13 +110,11 @@ All notable changes to this project will be documented in this file. See [standa
98
110
 
99
111
  ### [0.10.27](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v0.10.14...v0.10.27) (2026-08-10)
100
112
 
101
-
102
113
  ### Features
103
114
 
104
115
  * create packages for missing RFC implementations ([e6ce2ff](https://github.com/ManotLuijiu/pi-harness-runtime/commit/e6ce2ffdd455b33c55212ec2b61eedcdcfb43b5e))
105
116
  * **file-copy-helper:** inject cp rule when user asks to mimic/copy files ([f089f0d](https://github.com/ManotLuijiu/pi-harness-runtime/commit/f089f0d5e3e933231c99ee38cf18fa208c8eb8b2))
106
117
 
107
-
108
118
  ### Bug Fixes
109
119
 
110
120
  * align TS formatting with main (remove 3-line logError) ([2515ad5](https://github.com/ManotLuijiu/pi-harness-runtime/commit/2515ad54f43f0566123c686d3ec4f92ad363ea13))
@@ -120,12 +130,10 @@ All notable changes to this project will be documented in this file. See [standa
120
130
 
121
131
  ### [0.10.26](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v0.10.14...v0.10.26) (2026-08-10)
122
132
 
123
-
124
133
  ### Features
125
134
 
126
135
  * **file-copy-helper:** inject cp rule when user asks to mimic/copy files ([f089f0d](https://github.com/ManotLuijiu/pi-harness-runtime/commit/f089f0d5e3e933231c99ee38cf18fa208c8eb8b2))
127
136
 
128
-
129
137
  ### Bug Fixes
130
138
 
131
139
  * align TS formatting with main (remove 3-line logError) ([2515ad5](https://github.com/ManotLuijiu/pi-harness-runtime/commit/2515ad54f43f0566123c686d3ec4f92ad363ea13))
@@ -141,12 +149,10 @@ All notable changes to this project will be documented in this file. See [standa
141
149
 
142
150
  ### [0.10.25](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v0.10.14...v0.10.25) (2026-08-10)
143
151
 
144
-
145
152
  ### Features
146
153
 
147
154
  * **file-copy-helper:** inject cp rule when user asks to mimic/copy files ([f089f0d](https://github.com/ManotLuijiu/pi-harness-runtime/commit/f089f0d5e3e933231c99ee38cf18fa208c8eb8b2))
148
155
 
149
-
150
156
  ### Bug Fixes
151
157
 
152
158
  * align TS formatting with main (remove 3-line logError) ([2515ad5](https://github.com/ManotLuijiu/pi-harness-runtime/commit/2515ad54f43f0566123c686d3ec4f92ad363ea13))
@@ -161,12 +167,10 @@ All notable changes to this project will be documented in this file. See [standa
161
167
 
162
168
  ### [0.10.24](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v0.10.14...v0.10.24) (2026-08-09)
163
169
 
164
-
165
170
  ### Features
166
171
 
167
172
  * **file-copy-helper:** inject cp rule when user asks to mimic/copy files ([f089f0d](https://github.com/ManotLuijiu/pi-harness-runtime/commit/f089f0d5e3e933231c99ee38cf18fa208c8eb8b2))
168
173
 
169
-
170
174
  ### Bug Fixes
171
175
 
172
176
  * align TS formatting with main (remove 3-line logError) ([2515ad5](https://github.com/ManotLuijiu/pi-harness-runtime/commit/2515ad54f43f0566123c686d3ec4f92ad363ea13))
@@ -180,12 +184,10 @@ All notable changes to this project will be documented in this file. See [standa
180
184
 
181
185
  ### [0.10.23](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v0.10.14...v0.10.23) (2026-08-09)
182
186
 
183
-
184
187
  ### Features
185
188
 
186
189
  * **file-copy-helper:** inject cp rule when user asks to mimic/copy files ([f089f0d](https://github.com/ManotLuijiu/pi-harness-runtime/commit/f089f0d5e3e933231c99ee38cf18fa208c8eb8b2))
187
190
 
188
-
189
191
  ### Bug Fixes
190
192
 
191
193
  * align TS formatting with main (remove 3-line logError) ([2515ad5](https://github.com/ManotLuijiu/pi-harness-runtime/commit/2515ad54f43f0566123c686d3ec4f92ad363ea13))
@@ -198,7 +200,6 @@ All notable changes to this project will be documented in this file. See [standa
198
200
 
199
201
  ### [0.10.22](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v0.10.14...v0.10.22) (2026-08-09)
200
202
 
201
-
202
203
  ### Bug Fixes
203
204
 
204
205
  * align TS formatting with main (remove 3-line logError) ([2515ad5](https://github.com/ManotLuijiu/pi-harness-runtime/commit/2515ad54f43f0566123c686d3ec4f92ad363ea13))
@@ -211,7 +212,6 @@ All notable changes to this project will be documented in this file. See [standa
211
212
 
212
213
  ### [0.10.21](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v0.10.14...v0.10.21) (2026-08-08)
213
214
 
214
-
215
215
  ### Bug Fixes
216
216
 
217
217
  * align TS formatting with main (remove 3-line logError) ([2515ad5](https://github.com/ManotLuijiu/pi-harness-runtime/commit/2515ad54f43f0566123c686d3ec4f92ad363ea13))
@@ -223,7 +223,6 @@ All notable changes to this project will be documented in this file. See [standa
223
223
 
224
224
  ### [0.10.20](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v0.10.14...v0.10.20) (2026-08-08)
225
225
 
226
-
227
226
  ### Bug Fixes
228
227
 
229
228
  * align TS formatting with main (remove 3-line logError) ([2515ad5](https://github.com/ManotLuijiu/pi-harness-runtime/commit/2515ad54f43f0566123c686d3ec4f92ad363ea13))
@@ -234,14 +233,12 @@ All notable changes to this project will be documented in this file. See [standa
234
233
 
235
234
  ### [0.10.11](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v0.10.9...v0.10.11) (2026-08-03)
236
235
 
237
-
238
236
  ### Features
239
237
 
240
238
  * add knowledge-retrieval package for TencentDB-Agent-Memory MCP (RFC-0105) ([a4558d0](https://github.com/ManotLuijiu/pi-harness-runtime/commit/a4558d098c7b662b01d9502c8560219eafbf1941))
241
239
  * add okf-indexer package for SKILL.md indexing (RFC-0106) ([a3cc7da](https://github.com/ManotLuijiu/pi-harness-runtime/commit/a3cc7da0a390d5c8176d0d871418780facabcb5c))
242
240
  * extend a2a-adapter with discovery server (RFC-0104) ([0c4fc18](https://github.com/ManotLuijiu/pi-harness-runtime/commit/0c4fc1826fd55f10305bfbd894b32b5b55f1ab86))
243
241
 
244
-
245
242
  ### Bug Fixes
246
243
 
247
244
  * act on CONFLICTING immediately even when mergeStateStatus=DIRTY ([b7f290e](https://github.com/ManotLuijiu/pi-harness-runtime/commit/b7f290ece8e0e989635aacc456fffd4ee19183ec))
@@ -263,14 +260,12 @@ All notable changes to this project will be documented in this file. See [standa
263
260
 
264
261
  ## [0.10.0](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v0.9.24...v0.10.0) (2026-07-30)
265
262
 
266
-
267
263
  ### Features
268
264
 
269
265
  * blackboard-coordinated loop controller with early exit ([f3cf3ea](https://github.com/ManotLuijiu/pi-harness-runtime/commit/f3cf3ea479170dd75b7e9a7c3515dde230bb0da7))
270
266
  * herdr inter-agent event bus for autonomous code review ([1490cdd](https://github.com/ManotLuijiu/pi-harness-runtime/commit/1490cddec80dac812065c3c681984524ad3194e1))
271
267
  * loop controller for write-review cycles with early exit ([95066ce](https://github.com/ManotLuijiu/pi-harness-runtime/commit/95066ce8cb58c55eaa14d69fd826b5aaff680c16))
272
268
 
273
-
274
269
  ### Bug Fixes
275
270
 
276
271
  * **clipboard:** pass UTF-8 bytes directly to xclip via stdin, avoid pipeline corruption ([051ca18](https://github.com/ManotLuijiu/pi-harness-runtime/commit/051ca18fb1deb1169a8a4da16aa9314d2e6ec66d))
@@ -283,7 +278,6 @@ All notable changes to this project will be documented in this file. See [standa
283
278
 
284
279
  ### [0.9.25](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v0.9.21...v0.9.25) (2026-07-27)
285
280
 
286
-
287
281
  ### Bug Fixes
288
282
 
289
283
  * **ci:** explicitly list test files to exclude cookie auth tests in release workflow ([1c96002](https://github.com/ManotLuijiu/pi-harness-runtime/commit/1c9600232282a1ef9323300fbd763c962aff49f6))
@@ -294,7 +288,6 @@ All notable changes to this project will be documented in this file. See [standa
294
288
 
295
289
  ### [0.9.24](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v0.9.21...v0.9.24) (2026-07-27)
296
290
 
297
-
298
291
  ### Bug Fixes
299
292
 
300
293
  * **ci:** skip browser auth tests in release workflow ([6117ed5](https://github.com/ManotLuijiu/pi-harness-runtime/commit/6117ed5af11357c6f12d11f4cd8d3441de519043))
package/footer-status.ts CHANGED
@@ -6,6 +6,106 @@ import {
6
6
  type ParsedContextWindowUsage,
7
7
  type ParsedQuotaUsageData,
8
8
  } from "./status-parsers.ts";
9
+
10
+ /**
11
+ * Format countdown seconds into a human-readable string for TUI display.
12
+ * Examples: "4h 32m", "45m 12s", "12s"
13
+ */
14
+ export function formatCountdownForDisplay(seconds: number): string {
15
+ if (seconds <= 0) return "RESET";
16
+
17
+ const days = Math.floor(seconds / 86400);
18
+ const hours = Math.floor((seconds % 86400) / 3600);
19
+ const minutes = Math.floor((seconds % 3600) / 60);
20
+ const secs = seconds % 60;
21
+
22
+ if (days > 0) {
23
+ return `${days}d ${hours}h`;
24
+ }
25
+ if (hours > 0) {
26
+ return `${hours}h ${minutes}m`;
27
+ }
28
+ if (minutes > 0) {
29
+ return `${minutes}m ${secs}s`;
30
+ }
31
+ return `${secs}s`;
32
+ }
33
+
34
+ /**
35
+ * Get a human-readable limit type label.
36
+ * Special cases for GLM's 5h quota limit.
37
+ */
38
+ function getLimitTypeLabel(provider: string, limitType?: string): string {
39
+ // GLM specific: 5h quota limit
40
+ if (provider === "glm" && limitType === "rate_limit") {
41
+ return "5h quota";
42
+ }
43
+ return limitType ?? "tokens";
44
+ }
45
+
46
+ /**
47
+ * Format reset time for display.
48
+ * Converts ISO strings or human-readable times to a compact format.
49
+ */
50
+ function formatResetTime(resetAt?: string): string {
51
+ if (!resetAt) return "soon";
52
+
53
+ // If it's already a short human-readable string, return as-is
54
+ if (/^\d+\s*(hr|min|day|d|h|m|s)/i.test(resetAt)) {
55
+ return resetAt;
56
+ }
57
+
58
+ // Try to parse as ISO datetime
59
+ const date = new Date(resetAt);
60
+ if (!isNaN(date.getTime())) {
61
+ // Format as "Aug 25 01:47" or similar
62
+ const now = new Date();
63
+ const sameYear = date.getFullYear() === now.getFullYear();
64
+ const sameDay = date.toDateString() === now.toDateString();
65
+
66
+ const timeStr = date.toLocaleTimeString("en-US", {
67
+ hour: "2-digit",
68
+ minute: "2-digit",
69
+ hour12: false,
70
+ });
71
+
72
+ if (sameDay) {
73
+ return `today ${timeStr}`;
74
+ }
75
+
76
+ const month = date.toLocaleString("en-US", { month: "short" });
77
+ const day = date.getDate();
78
+
79
+ if (sameYear) {
80
+ return `${month} ${day} ${timeStr}`;
81
+ }
82
+
83
+ return `${month} ${day} ${date.getFullYear()} ${timeStr}`;
84
+ }
85
+
86
+ return resetAt;
87
+ }
88
+
89
+ /**
90
+ * Build a TUI-signal exhaustion status line with optional countdown.
91
+ * This is used when a provider (like GLM) hits its limit.
92
+ */
93
+ export function buildExhaustionStatusLine(
94
+ provider: string,
95
+ view: ProviderMirrorRecord,
96
+ countdownSeconds?: number,
97
+ ): string {
98
+ const label = providerDisplayName(provider);
99
+ const limitTypeLabel = getLimitTypeLabel(provider, view.limitType);
100
+ const resetFormatted = formatResetTime(view.resets_at ?? view.h5_resets_at);
101
+
102
+ if (countdownSeconds !== undefined && countdownSeconds > 0) {
103
+ const countdown = formatCountdownForDisplay(countdownSeconds);
104
+ return `${label}: ⏳ ${countdown} (${limitTypeLabel})`;
105
+ }
106
+
107
+ return `${label}: ${limitTypeLabel} hit, resets ${resetFormatted}`;
108
+ }
9
109
  import { getProviderLabel } from "./packages/types/src/ai-providers.js";
10
110
  import {
11
111
  providerHasContinuousScrape,
@@ -135,9 +235,9 @@ export function buildFooterStatusValue(
135
235
  view.resets_at !== undefined ||
136
236
  view.h5_resets_at !== undefined)
137
237
  ) {
138
- const reset = view.resets_at ?? view.h5_resets_at ?? "soon";
139
- const limitType = view.limitType ?? "tokens";
140
- return `${label}: limit hit (${limitType}), reset ${reset}`;
238
+ const limitTypeLabel = getLimitTypeLabel(provider, view.limitType ?? undefined);
239
+ const resetFormatted = formatResetTime(view.resets_at ?? view.h5_resets_at);
240
+ return `${label}: ${limitTypeLabel} hit, resets ${resetFormatted}`;
141
241
  }
142
242
 
143
243
  // Continuous data path: providers with continuous scrape (MiniMax has 5h+weekly, OpenAI has weekly-only)
@@ -153,14 +253,14 @@ export function buildFooterStatusValue(
153
253
  const weeklyResets = view.weekly_resets_at ?? "soon";
154
254
 
155
255
  let statusLine: string;
156
- if (view.h5_used_pct !== undefined) {
256
+ if (view.h5_used_pct === undefined) {
257
+ // OpenAI: weekly-only (no 5h window)
258
+ statusLine = `week: ${weeklyLeft.toFixed(0)}% left (resets ${weeklyResets})`;
259
+ } else {
157
260
  // MiniMax: has both 5h and weekly windows
158
261
  const h5Pct = view.h5_used_pct;
159
262
  const h5Left = Math.max(0, 100 - h5Pct);
160
263
  statusLine = `5h: ${h5Left.toFixed(0)}% left · week: ${weeklyLeft.toFixed(0)}% left`;
161
- } else {
162
- // OpenAI: weekly-only (no 5h window)
163
- statusLine = `week: ${weeklyLeft.toFixed(0)}% left (resets ${weeklyResets})`;
164
264
  }
165
265
 
166
266
  const freshnessSuffix =
@@ -407,6 +407,50 @@ export class GLMQuotaScraper {
407
407
  }
408
408
  }
409
409
 
410
+ /**
411
+ * Parse reset time from GLM 429 error message.
412
+ * Extracts the reset timestamp from messages like:
413
+ * '{"code":"1308","message":"Usage limit reached for 5 hour. Your limit will reset at 2026-08-25 01:47:16"}'
414
+ */
415
+ export function parseGLMErrorResetTime(errorMessage: string): string | null {
416
+ // Try to find the JSON object in the message
417
+ const jsonMatch = errorMessage.match(/\{[^{}]*\}/);
418
+ if (jsonMatch) {
419
+ try {
420
+ const json = JSON.parse(jsonMatch[0]);
421
+ if (json.code === 1308 && json.message) {
422
+ // Extract datetime from message
423
+ const datetimeMatch = json.message.match(
424
+ /reset at (\d{4}-\d{2}-\d{2}[T ]?\d{2}:\d{2}:\d{2})/i,
425
+ );
426
+ if (datetimeMatch) {
427
+ const datetimeStr = datetimeMatch[1].replace(" ", "T");
428
+ const date = new Date(datetimeStr);
429
+ if (!isNaN(date.getTime())) {
430
+ return date.toISOString();
431
+ }
432
+ }
433
+ }
434
+ } catch {
435
+ // Not JSON, try plain text parsing
436
+ }
437
+ }
438
+
439
+ // Fallback: try plain text parsing
440
+ const plainMatch = errorMessage.match(
441
+ /reset at (\d{4}-\d{2}-\d{2}[T ]?\d{2}:\d{2}:\d{2})/i,
442
+ );
443
+ if (plainMatch) {
444
+ const datetimeStr = plainMatch[1].replace(" ", "T");
445
+ const date = new Date(datetimeStr);
446
+ if (!isNaN(date.getTime())) {
447
+ return date.toISOString();
448
+ }
449
+ }
450
+
451
+ return null;
452
+ }
453
+
410
454
  /**
411
455
  * Integration helper for index.ts
412
456
  */