Extend rate limit reads with usage capabilities (#42358)

## What changed

- Accept optional `account/rateLimits/read` capabilities for Luna Reserve support
  and lightweight background polling while preserving omitted and `null` params.
- Forward the Luna Reserve capability only for eligible ChatGPT sessions, and let
  lightweight polls skip the separate reset-credit detail request.
- Return the backend's `ordinaryUsageAllowed` decision only when its account and
  user identity match the active session.

## Testing

- Cover capability defaults, eligible and restricted authentication modes,
  lightweight polling, identity filtering, and backend permission handling.

GitOrigin-RevId: f407a3ae1e70e411fdf245f072a16e453f59cd87
This commit is contained in:
dhruvgupta-oai
2026-09-02 21:01:04 +00:00
committed by copyberry
parent 0227158fd5
commit 577a4fcd06
26 changed files with 459 additions and 28 deletions
@@ -493,6 +493,16 @@ enum GetAccountTokenUsageParamsTypeScript {
Undefined,
}
/// Preserve omitted/undefined params while exporting the new usage capability type.
#[allow(dead_code)]
#[derive(TS)]
#[ts(untagged)]
enum GetAccountRateLimitsParamsTypeScript {
Params(v2::GetAccountRateLimitsParams),
#[ts(type = "undefined")]
Undefined,
}
client_request_definitions! {
Initialize => "initialize" {
params: v1::InitializeParams,
@@ -1232,7 +1242,7 @@ client_request_definitions! {
},
GetAccountRateLimits => "account/rateLimits/read" {
params: #[ts(type = "undefined")] #[serde(skip_serializing_if = "Option::is_none")] Option<()>,
params: #[ts(optional, as = "Option<GetAccountRateLimitsParamsTypeScript>", inline)] #[serde(default, skip_serializing_if = "Option::is_none")] v2::NullableGetAccountRateLimitsParams,
serialization: None,
response: v2::GetAccountRateLimitsResponse,
},