(headers: globalThis.Headers)
| 162 | } |
| 163 | |
| 164 | function extractRawUtilization(headers: globalThis.Headers): RawUtilization { |
| 165 | const result: RawUtilization = {} |
| 166 | for (const [key, abbrev] of [ |
| 167 | ['five_hour', '5h'], |
| 168 | ['seven_day', '7d'], |
| 169 | ] as const) { |
| 170 | const util = headers.get( |
| 171 | `anthropic-ratelimit-unified-${abbrev}-utilization`, |
| 172 | ) |
| 173 | const reset = headers.get(`anthropic-ratelimit-unified-${abbrev}-reset`) |
| 174 | if (util !== null && reset !== null) { |
| 175 | result[key] = { utilization: Number(util), resets_at: Number(reset) } |
| 176 | } |
| 177 | } |
| 178 | return result |
| 179 | } |
| 180 | |
| 181 | type StatusChangeListener = (limits: ClaudeAILimits) => void |
| 182 | export const statusListeners: Set<StatusChangeListener> = new Set() |
no test coverage detected