Fetch the caller's current shared premium-session quota snapshot for * `model`, or undefined if the model is unlimited. Used by both POST (after * admit) and GET polls so the CLI's "N of M sessions used" line stays live * instead of disappearing after the first poll.
( userId: string, model: string, accessTier: FreebuffAccessTier, deps: SessionDeps, )
| 152 | * admit) and GET polls so the CLI's "N of M sessions used" line stays live |
| 153 | * instead of disappearing after the first poll. */ |
| 154 | async function fetchRateLimitSnapshot( |
| 155 | userId: string, |
| 156 | model: string, |
| 157 | accessTier: FreebuffAccessTier, |
| 158 | deps: SessionDeps, |
| 159 | ): Promise< |
| 160 | | { |
| 161 | info: FreebuffSessionRateLimit |
| 162 | resetsAt: Date |
| 163 | } |
| 164 | | undefined |
| 165 | > { |
| 166 | const config = quotaConfigForModel(model, accessTier) |
| 167 | if (!config) return undefined |
| 168 | const snapshot = await fetchSessionQuotaSnapshot(userId, config, deps) |
| 169 | return { |
| 170 | info: toRateLimitInfo(model, snapshot), |
| 171 | resetsAt: snapshot.resetsAt, |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | async function fetchRateLimitsByModel( |
| 176 | userId: string, |
no test coverage detected