Notificationの実装

This commit is contained in:
2026-04-18 17:48:35 +09:00
parent b538c2f1ea
commit 74ee96ef82
11 changed files with 421 additions and 125 deletions
+14
View File
@@ -10,6 +10,7 @@ use serde::{Deserialize, Serialize};
#[serde(tag = "method", content = "params", rename_all = "snake_case")]
pub enum Method {
Run { input: String },
Notify { source: String, message: String },
Resume,
Cancel,
Shutdown,
@@ -192,6 +193,19 @@ mod tests {
assert_eq!(parsed["data"]["result"], "limit_reached");
}
#[test]
fn method_notify_json_roundtrip() {
let json = r#"{"method":"notify","params":{"source":"child-pod","message":"turn done"}}"#;
let method: Method = serde_json::from_str(json).unwrap();
assert!(matches!(
method,
Method::Notify { ref source, ref message }
if source == "child-pod" && message == "turn done"
));
let serialized = serde_json::to_string(&method).unwrap();
assert_eq!(serialized, json);
}
#[test]
fn method_get_history() {
let json = r#"{"method":"get_history"}"#;