diff options
| author | Can Celik <ogulcancelik@gmail.com> | 2026-04-01 19:30:58 +0300 |
|---|---|---|
| committer | Can Celik <ogulcancelik@gmail.com> | 2026-04-01 19:32:26 +0300 |
| commit | ca4270b31fe93c180f7321cb4006cb5e7307d889 (patch) | |
| tree | 72628e311a1b8e5ebf78c74cbc61d990253dc4c4 /src/api | |
| parent | fb0c9717cfa961a47d63272e622e9e35a001082a (diff) | |
feat: add authoritative pi hook integration
Diffstat (limited to 'src/api')
| -rw-r--r-- | src/api/schema.rs | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/src/api/schema.rs b/src/api/schema.rs index 0b807eed..a187a889 100644 --- a/src/api/schema.rs +++ b/src/api/schema.rs @@ -36,6 +36,12 @@ pub enum Method { PaneSendKeys(PaneSendKeysParams), #[serde(rename = "pane.read")] PaneRead(PaneReadParams), + #[serde(rename = "pane.report_agent")] + PaneReportAgent(PaneReportAgentParams), + #[serde(rename = "pane.clear_agent_authority")] + PaneClearAgentAuthority(PaneClearAgentAuthorityParams), + #[serde(rename = "pane.release_agent")] + PaneReleaseAgent(PaneReleaseAgentParams), #[serde(rename = "pane.close")] PaneClose(PaneTarget), #[serde(rename = "events.subscribe")] @@ -124,6 +130,30 @@ pub struct PaneReadParams { } #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +pub struct PaneReportAgentParams { + pub pane_id: String, + pub source: String, + pub agent: String, + pub state: PaneAgentState, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub message: Option<String>, +} + +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +pub struct PaneClearAgentAuthorityParams { + pub pane_id: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub source: Option<String>, +} + +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +pub struct PaneReleaseAgentParams { + pub pane_id: String, + pub source: String, + pub agent: String, +} + +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] pub enum ReadSource { Visible, @@ -476,6 +506,55 @@ mod tests { } #[test] + fn request_round_trips_for_pane_report_agent() { + let request = Request { + id: "req_hook".into(), + method: Method::PaneReportAgent(PaneReportAgentParams { + pane_id: "1-1".into(), + source: "herdr:pi".into(), + agent: "pi".into(), + state: PaneAgentState::Working, + message: Some("thinking".into()), + }), + }; + + let json = serde_json::to_string(&request).unwrap(); + let restored: Request = serde_json::from_str(&json).unwrap(); + assert_eq!(restored, request); + } + + #[test] + fn request_round_trips_for_pane_clear_agent_authority() { + let request = Request { + id: "req_clear".into(), + method: Method::PaneClearAgentAuthority(PaneClearAgentAuthorityParams { + pane_id: "1-1".into(), + source: Some("herdr:pi".into()), + }), + }; + + let json = serde_json::to_string(&request).unwrap(); + let restored: Request = serde_json::from_str(&json).unwrap(); + assert_eq!(restored, request); + } + + #[test] + fn request_round_trips_for_pane_release_agent() { + let request = Request { + id: "req_release".into(), + method: Method::PaneReleaseAgent(PaneReleaseAgentParams { + pane_id: "1-1".into(), + source: "herdr:pi".into(), + agent: "pi".into(), + }), + }; + + let json = serde_json::to_string(&request).unwrap(); + let restored: Request = serde_json::from_str(&json).unwrap(); + assert_eq!(restored, request); + } + + #[test] fn request_uses_dot_method_names() { let request = Request { id: "req_1".into(), |
