55 *
66 * The CLI uses these shapes directly; there are no client-only states.
77 */
8+
9+ /**
10+ * Per-model usage counter surfaced to the CLI so the waiting-room UI can
11+ * render "N of M sessions used" alongside queue/active state. Present when
12+ * the joined model has a rate limit applied (today: GLM 5.1 with 5 admits
13+ * per 20-hour window). `recentCount` is the number of admissions inside
14+ * `windowHours` at the time the response was produced — see also the
15+ * standalone `rate_limited` status for the reject path.
16+ */
17+ export interface FreebuffSessionRateLimit {
18+ model : string
19+ limit : number
20+ windowHours : number
21+ recentCount : number
22+ }
23+
824export type FreebuffSessionServerResponse =
925 | {
1026 /** Waiting room is globally off; free-mode requests flow through
@@ -38,6 +54,10 @@ export type FreebuffSessionServerResponse =
3854 queueDepthByModel : Record < string , number >
3955 estimatedWaitMs : number
4056 queuedAt : string
57+ /** Rate-limit quota for rate-limited models (GLM 5.1 today). Absent
58+ * for unlimited models or when the status was produced outside the
59+ * rate-limit check path (e.g. pure read via GET). */
60+ rateLimit ?: FreebuffSessionRateLimit
4161 }
4262 | {
4363 status : 'active'
@@ -47,6 +67,10 @@ export type FreebuffSessionServerResponse =
4767 admittedAt : string
4868 expiresAt : string
4969 remainingMs : number
70+ /** Rate-limit quota for rate-limited models (GLM 5.1 today). Absent
71+ * for unlimited models or when the status was produced outside the
72+ * rate-limit check path (e.g. pure read via GET). */
73+ rateLimit ?: FreebuffSessionRateLimit
5074 }
5175 | {
5276 /** Session is over. While `instanceId` is present we're inside the
@@ -105,3 +129,24 @@ export type FreebuffSessionServerResponse =
105129 * stops polling and shows a banned message. */
106130 status : 'banned'
107131 }
132+ | {
133+ /** User has used up their per-model admission quota in the rolling
134+ * window (GLM 5.1: 5 one-hour sessions per 20h). Returned from POST
135+ * /session before the user is placed in the queue. `retryAfterMs` is
136+ * the time until the oldest admission inside the window falls off
137+ * and one quota slot opens up — clients should show the user when
138+ * they can try again. Terminal for the CLI's current poll session;
139+ * the user can exit and come back later. */
140+ status : 'rate_limited'
141+ /** The freebuff model the user tried to join. */
142+ model : string
143+ /** Max admissions permitted per window (e.g. 5). */
144+ limit : number
145+ /** Rolling window size in hours (e.g. 20). */
146+ windowHours : number
147+ /** Admission count inside the window at check time — will be ≥ limit. */
148+ recentCount : number
149+ /** Milliseconds from now until the oldest admission in the window
150+ * exits and the user regains one quota slot. */
151+ retryAfterMs : number
152+ }
0 commit comments