mirror of
https://github.com/openai/codex.git
synced 2026-04-27 16:15:09 +00:00
feat: opt-out of events in the app-server (#11319)
Add `optOutNotificationMethods` in the app-server to opt-out events based on exact method matching
This commit is contained in:
@@ -806,6 +806,94 @@ mod tests {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn serialize_initialize_with_opt_out_notification_methods() -> Result<()> {
|
||||
let request = ClientRequest::Initialize {
|
||||
request_id: RequestId::Integer(42),
|
||||
params: v1::InitializeParams {
|
||||
client_info: v1::ClientInfo {
|
||||
name: "codex_vscode".to_string(),
|
||||
title: Some("Codex VS Code Extension".to_string()),
|
||||
version: "0.1.0".to_string(),
|
||||
},
|
||||
capabilities: Some(v1::InitializeCapabilities {
|
||||
experimental_api: true,
|
||||
opt_out_notification_methods: Some(vec![
|
||||
"codex/event/session_configured".to_string(),
|
||||
"item/agentMessage/delta".to_string(),
|
||||
]),
|
||||
}),
|
||||
},
|
||||
};
|
||||
|
||||
assert_eq!(
|
||||
json!({
|
||||
"method": "initialize",
|
||||
"id": 42,
|
||||
"params": {
|
||||
"clientInfo": {
|
||||
"name": "codex_vscode",
|
||||
"title": "Codex VS Code Extension",
|
||||
"version": "0.1.0"
|
||||
},
|
||||
"capabilities": {
|
||||
"experimentalApi": true,
|
||||
"optOutNotificationMethods": [
|
||||
"codex/event/session_configured",
|
||||
"item/agentMessage/delta"
|
||||
]
|
||||
}
|
||||
}
|
||||
}),
|
||||
serde_json::to_value(&request)?,
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn deserialize_initialize_with_opt_out_notification_methods() -> Result<()> {
|
||||
let request: ClientRequest = serde_json::from_value(json!({
|
||||
"method": "initialize",
|
||||
"id": 42,
|
||||
"params": {
|
||||
"clientInfo": {
|
||||
"name": "codex_vscode",
|
||||
"title": "Codex VS Code Extension",
|
||||
"version": "0.1.0"
|
||||
},
|
||||
"capabilities": {
|
||||
"experimentalApi": true,
|
||||
"optOutNotificationMethods": [
|
||||
"codex/event/session_configured",
|
||||
"item/agentMessage/delta"
|
||||
]
|
||||
}
|
||||
}
|
||||
}))?;
|
||||
|
||||
assert_eq!(
|
||||
request,
|
||||
ClientRequest::Initialize {
|
||||
request_id: RequestId::Integer(42),
|
||||
params: v1::InitializeParams {
|
||||
client_info: v1::ClientInfo {
|
||||
name: "codex_vscode".to_string(),
|
||||
title: Some("Codex VS Code Extension".to_string()),
|
||||
version: "0.1.0".to_string(),
|
||||
},
|
||||
capabilities: Some(v1::InitializeCapabilities {
|
||||
experimental_api: true,
|
||||
opt_out_notification_methods: Some(vec![
|
||||
"codex/event/session_configured".to_string(),
|
||||
"item/agentMessage/delta".to_string(),
|
||||
]),
|
||||
}),
|
||||
},
|
||||
}
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn conversation_id_serializes_as_plain_string() -> Result<()> {
|
||||
let id = ThreadId::from_string("67e55044-10b1-426f-9247-bb680e5fe0c8")?;
|
||||
|
||||
Reference in New Issue
Block a user