//! Lossless projection of legacy cancellation targets through the pinned SDK. use rmcp::model::CancelledNotificationParam; use serde_json::{Map, Value}; pub(super) fn decode_cancelled_request_id(params: &Value) -> Option { let mut projection = Map::new(); let original_id = params.get("requestId"); if let Some(id) = original_id { // SDK IDs use i64; the temporary string never reaches the in-flight lookup. let projected = match id { Value::Number(number) if number.as_i64().is_none() => Value::String(number.to_string()), _ => id.clone(), }; projection.insert("requestId".to_owned(), projected); } // Only requestId names a target; reason, _meta and extensions retain their ignore semantics. let decoded = serde_json::from_value::(Value::Object(projection)).ok()?; #[cfg(test)] super::dispatch_observer::sdk_cancelled_params_decoded(); let id = decoded.request_id?; Some(match original_id { Some(Value::Number(number)) => Value::Number(number.clone()), _ => id.into_json_value(), }) } #[cfg(test)] #[path = "rmcp_progress_cancel_tests.rs"] mod tests;