diff options
Diffstat (limited to 'src/api/schema/response.rs')
| -rw-r--r-- | src/api/schema/response.rs | 248 |
1 files changed, 248 insertions, 0 deletions
diff --git a/src/api/schema/response.rs b/src/api/schema/response.rs new file mode 100644 index 00000000..51ea0d36 --- /dev/null +++ b/src/api/schema/response.rs @@ -0,0 +1,248 @@ +use serde::{Deserialize, Serialize}; + +use super::agents::AgentInfo; +use super::common::{ClientWindowTitleReason, NotificationShowReason}; +use super::events::EventEnvelope; +use super::integrations::{ + IntegrationInstallResult, IntegrationTarget, IntegrationUninstallResult, +}; +use super::panes::{ + LayoutDescription, PaneEdgesResult, PaneFocusDirectionResult, PaneInfo, PaneLayoutSnapshot, + PaneMoveResult, PaneNeighborResult, PaneProcessInfo, PaneReadResult, PaneResizeResult, + PaneSwapResult, PaneZoomResult, +}; +use super::plugins::{ + InstalledPluginInfo, PluginActionInfo, PluginCommandLogInfo, PluginInvocationContext, + PluginPaneInfo, +}; +use super::server::ServerCapabilities; +use super::tabs::TabInfo; +use super::workspaces::WorkspaceInfo; +use super::worktrees::{WorktreeInfo, WorktreeSourceInfo}; + +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +pub struct SuccessResponse { + pub id: String, + pub result: ResponseResult, +} + +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +pub struct ErrorResponse { + pub id: String, + pub error: ErrorBody, +} + +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +pub struct ErrorBody { + pub code: String, + pub message: String, +} + +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[serde(tag = "type", rename_all = "snake_case")] +pub enum ResponseResult { + Pong { + version: String, + protocol: u32, + #[serde(default)] + capabilities: Option<ServerCapabilities>, + }, + WorkspaceInfo { + workspace: WorkspaceInfo, + }, + WorkspaceCreated { + workspace: WorkspaceInfo, + tab: TabInfo, + root_pane: PaneInfo, + }, + WorkspaceList { + workspaces: Vec<WorkspaceInfo>, + }, + WorktreeList { + source: WorktreeSourceInfo, + worktrees: Vec<WorktreeInfo>, + }, + WorktreeCreated { + workspace: WorkspaceInfo, + tab: TabInfo, + root_pane: PaneInfo, + worktree: WorktreeInfo, + }, + WorktreeOpened { + workspace: WorkspaceInfo, + tab: TabInfo, + root_pane: PaneInfo, + worktree: WorktreeInfo, + already_open: bool, + }, + WorktreeRemoved { + workspace_id: String, + path: String, + forced: bool, + }, + TabInfo { + tab: TabInfo, + }, + TabCreated { + tab: TabInfo, + root_pane: PaneInfo, + }, + TabList { + tabs: Vec<TabInfo>, + }, + AgentInfo { + agent: AgentInfo, + }, + AgentStarted { + agent: AgentInfo, + argv: Vec<String>, + }, + AgentList { + agents: Vec<AgentInfo>, + }, + PaneInfo { + pane: PaneInfo, + }, + PaneList { + panes: Vec<PaneInfo>, + }, + PaneCurrent { + pane: PaneInfo, + }, + PaneSwap { + swap: PaneSwapResult, + }, + PaneMove { + move_result: PaneMoveResult, + }, + PaneZoom { + zoom: PaneZoomResult, + }, + PaneLayout { + layout: PaneLayoutSnapshot, + }, + PaneProcessInfo { + process_info: PaneProcessInfo, + }, + LayoutExport { + layout: LayoutDescription, + }, + LayoutApply { + layout: LayoutDescription, + }, + PaneNeighbor { + neighbor: PaneNeighborResult, + }, + PaneEdges { + edges: PaneEdgesResult, + }, + PaneFocusDirection { + focus: PaneFocusDirectionResult, + }, + PaneResize { + resize: PaneResizeResult, + }, + PaneRead { + read: PaneReadResult, + }, + AgentExplain { + explain: serde_json::Value, + }, + SubscriptionStarted {}, + WaitMatched { + event: EventEnvelope, + }, + OutputMatched { + pane_id: String, + revision: u64, + matched_line: Option<String>, + read: PaneReadResult, + }, + NotificationShow { + shown: bool, + reason: NotificationShowReason, + }, + ClientWindowTitle { + changed: bool, + reason: ClientWindowTitleReason, + }, + IntegrationInstall { + target: IntegrationTarget, + details: IntegrationInstallResult, + }, + IntegrationUninstall { + target: IntegrationTarget, + details: IntegrationUninstallResult, + }, + AgentManifestReload { + manifests: Vec<AgentManifestInfo>, + }, + AgentManifestStatus { + #[serde(default, skip_serializing_if = "Option::is_none")] + last_check_unix: Option<u64>, + #[serde(default, skip_serializing_if = "Option::is_none")] + last_result: Option<String>, + manifests: Vec<AgentManifestInfo>, + }, + PluginLinked { + plugin: InstalledPluginInfo, + }, + PluginList { + plugins: Vec<InstalledPluginInfo>, + }, + PluginUnlinked { + plugin_id: String, + removed: bool, + }, + PluginEnabled { + plugin: InstalledPluginInfo, + }, + PluginDisabled { + plugin: InstalledPluginInfo, + }, + PluginActionList { + actions: Vec<PluginActionInfo>, + }, + PluginActionInvoked { + action: PluginActionInfo, + context: PluginInvocationContext, + log: PluginCommandLogInfo, + }, + PluginLogList { + logs: Vec<PluginCommandLogInfo>, + }, + PluginPaneOpened { + plugin_pane: PluginPaneInfo, + }, + PluginPaneFocused { + plugin_pane: PluginPaneInfo, + }, + PluginPaneClosed { + pane_id: String, + }, + ConfigReload { + status: crate::config::ConfigReloadStatus, + diagnostics: Vec<String>, + }, + Ok {}, +} + +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +pub struct AgentManifestInfo { + pub agent: String, + pub source: String, + pub source_kind: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub active_version: Option<String>, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub cached_remote_version: Option<String>, + pub local_override_shadowing_remote: bool, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub remote_update_result: Option<String>, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub remote_update_error: Option<String>, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub remote_last_checked_unix: Option<u64>, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub warning: Option<String>, +} |
