mirror of
https://github.com/openai/codex.git
synced 2026-12-05 01:00:54 +00:00
## Why
Remote-control clients need to list and revoke controller-device grants
without enabling or enrolling the local relay. These are signed-in
account-management operations, so coupling them to websocket, pairing,
enrollment, or persisted relay state would prevent clients from managing
stale grants from the picker.
Related enhancement request: N/A. This adds the Codex app-server surface
for the planned upstream environment-scoped revoke endpoint.
## What Changed
- Added experimental app-server v2 RPCs:
- `remoteControl/client/list`
- `remoteControl/client/revoke`
- Added picker-oriented protocol types and standard generated schema
fixtures. The list response intentionally omits backend account id,
enrollment status, and location fields.
- Added `app-server-transport/src/transport/remote_control/clients.rs`
for environment-scoped GET and DELETE requests. It builds escaped URL
path segments, forwards optional pagination query fields, sends ChatGPT
auth plus `chatgpt-account-id`, converts RFC3339 `last_seen_at` values
to Unix seconds, accepts `204 No Content` revoke responses, and retries
once after a `401`.
- Extracted shared ChatGPT auth loading and recovery into
`app-server-transport/src/transport/remote_control/auth.rs` so
websocket, pairing, and client management use the same account-auth
boundary.
- Retained the configured remote-control base URL on
`RemoteControlHandle` and resolve management URLs lazily, preserving
deferred validation while relay startup is disabled.
- Registered list as `global_shared_read("remote-control-clients")` and
revoke as `global("remote-control-clients")`.
## Verification
- Added transport coverage proving list and revoke work while relay
state is disabled, IDs are escaped, picker-only fields are returned,
timestamps are converted, revoke accepts `204`, auth headers are
forwarded, `401` retries exactly once, `403` is not retried, and
malformed list payloads retain decode context.
- Added an app-server integration test proving both JSON-RPC methods
work before relay enablement and successful revoke returns `{}`.
- Regenerated and validated experimental and standard app-server schema
fixtures.
168 lines
5.1 KiB
Rust
168 lines
5.1 KiB
Rust
use schemars::JsonSchema;
|
|
use serde::Deserialize;
|
|
use serde::Serialize;
|
|
use ts_rs::TS;
|
|
|
|
/// Current remote-control connection status and remote identity exposed to clients.
|
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
|
#[serde(rename_all = "camelCase")]
|
|
#[ts(export_to = "v2/")]
|
|
pub struct RemoteControlStatusChangedNotification {
|
|
pub status: RemoteControlConnectionStatus,
|
|
pub server_name: String,
|
|
pub installation_id: String,
|
|
pub environment_id: Option<String>,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
|
#[serde(rename_all = "camelCase")]
|
|
#[ts(export_to = "v2/")]
|
|
pub struct RemoteControlEnableResponse {
|
|
pub status: RemoteControlConnectionStatus,
|
|
pub server_name: String,
|
|
pub installation_id: String,
|
|
pub environment_id: Option<String>,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
|
#[serde(rename_all = "camelCase")]
|
|
#[ts(export_to = "v2/")]
|
|
pub struct RemoteControlDisableResponse {
|
|
pub status: RemoteControlConnectionStatus,
|
|
pub server_name: String,
|
|
pub installation_id: String,
|
|
pub environment_id: Option<String>,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
|
#[serde(rename_all = "camelCase")]
|
|
#[ts(export_to = "v2/")]
|
|
pub struct RemoteControlStatusReadResponse {
|
|
pub status: RemoteControlConnectionStatus,
|
|
pub server_name: String,
|
|
pub installation_id: String,
|
|
pub environment_id: Option<String>,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq, Eq, JsonSchema, TS)]
|
|
#[serde(rename_all = "camelCase")]
|
|
#[ts(export_to = "v2/")]
|
|
pub struct RemoteControlPairingStartParams {
|
|
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
|
pub manual_code: bool,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
|
#[serde(rename_all = "camelCase")]
|
|
#[ts(export_to = "v2/")]
|
|
pub struct RemoteControlPairingStartResponse {
|
|
pub pairing_code: String,
|
|
pub manual_pairing_code: Option<String>,
|
|
pub environment_id: String,
|
|
pub expires_at: i64,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq, Eq, JsonSchema, TS)]
|
|
#[serde(rename_all = "camelCase")]
|
|
#[ts(export_to = "v2/")]
|
|
pub struct RemoteControlClientsListParams {
|
|
pub environment_id: String,
|
|
#[ts(optional = nullable)]
|
|
pub cursor: Option<String>,
|
|
#[ts(optional = nullable)]
|
|
pub limit: Option<u32>,
|
|
#[ts(optional = nullable)]
|
|
pub order: Option<RemoteControlClientsListOrder>,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)]
|
|
#[serde(rename_all = "camelCase")]
|
|
#[ts(rename_all = "camelCase", export_to = "v2/")]
|
|
pub enum RemoteControlClientsListOrder {
|
|
Asc,
|
|
Desc,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
|
#[serde(rename_all = "camelCase")]
|
|
#[ts(export_to = "v2/")]
|
|
pub struct RemoteControlClientsListResponse {
|
|
pub data: Vec<RemoteControlClient>,
|
|
pub next_cursor: Option<String>,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
|
#[serde(rename_all = "camelCase")]
|
|
#[ts(export_to = "v2/")]
|
|
pub struct RemoteControlClient {
|
|
pub client_id: String,
|
|
pub display_name: Option<String>,
|
|
pub device_type: Option<String>,
|
|
pub platform: Option<String>,
|
|
pub os_version: Option<String>,
|
|
pub device_model: Option<String>,
|
|
pub app_version: Option<String>,
|
|
pub last_seen_at: Option<i64>,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
|
#[serde(rename_all = "camelCase")]
|
|
#[ts(export_to = "v2/")]
|
|
pub struct RemoteControlClientsRevokeParams {
|
|
pub environment_id: String,
|
|
pub client_id: String,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
|
#[serde(rename_all = "camelCase")]
|
|
#[ts(export_to = "v2/")]
|
|
pub struct RemoteControlClientsRevokeResponse {}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)]
|
|
#[serde(rename_all = "camelCase")]
|
|
#[ts(rename_all = "camelCase", export_to = "v2/")]
|
|
pub enum RemoteControlConnectionStatus {
|
|
Disabled,
|
|
Connecting,
|
|
Connected,
|
|
Errored,
|
|
}
|
|
|
|
impl From<RemoteControlStatusChangedNotification> for RemoteControlEnableResponse {
|
|
fn from(notification: RemoteControlStatusChangedNotification) -> Self {
|
|
let RemoteControlStatusChangedNotification {
|
|
status,
|
|
server_name,
|
|
installation_id,
|
|
environment_id,
|
|
} = notification;
|
|
Self {
|
|
status,
|
|
server_name,
|
|
installation_id,
|
|
environment_id,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl From<RemoteControlStatusChangedNotification> for RemoteControlDisableResponse {
|
|
fn from(notification: RemoteControlStatusChangedNotification) -> Self {
|
|
let RemoteControlStatusChangedNotification {
|
|
status,
|
|
server_name,
|
|
installation_id,
|
|
environment_id,
|
|
} = notification;
|
|
Self {
|
|
status,
|
|
server_name,
|
|
installation_id,
|
|
environment_id,
|
|
}
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
#[path = "remote_control_tests.rs"]
|
|
mod tests;
|