1use serde_json::{Map, Value};
2
3use crate::ssh::{
4 SshAuthKind, SshConnectionId, SshConnectionStatus, SshConnectionSummary, SshMountId,
5 SshMountStatus, SshMountSummary, SshTunnelId, SshTunnelStatus, SshTunnelSummary,
6};
7
8#[derive(Debug, Clone)]
9pub struct SpawnSessionRequest {
10 pub command: String,
11 pub args: Vec<String>,
12 pub cwd: Option<String>,
13 pub env: Option<Map<String, Value>>,
14 pub title: Option<String>,
15 pub description: Option<String>,
16}
17
18#[derive(Debug, Clone)]
19pub struct SshConnectRequest {
20 pub host_alias: Option<String>,
21 pub host: Option<String>,
22 pub user: Option<String>,
23 pub port: Option<u16>,
24 pub auth_kind: SshAuthKind,
25 pub identity_path: Option<String>,
26 pub title: Option<String>,
27 pub description: Option<String>,
28 pub verify_host_key: bool,
29}
30
31#[derive(Debug, Clone)]
32pub struct SshConnectResult {
33 pub connection: SshConnectionSummary,
34 pub reused: bool,
35}
36
37#[derive(Debug, Clone)]
38pub struct SshListResult {
39 pub connections: Vec<SshConnectionSummary>,
40 pub mounts: Vec<SshMountSummary>,
41 pub tunnels: Vec<SshTunnelSummary>,
42}
43
44#[derive(Debug, Clone)]
45pub struct SshSessionSpawnRequest {
46 pub connection_id: SshConnectionId,
47 pub command: Option<String>,
48 pub args: Vec<String>,
49 pub cwd: Option<String>,
50 pub env: Option<Map<String, Value>>,
51 pub shell: Option<String>,
52 pub interactive: bool,
53 pub login: bool,
54 pub title: Option<String>,
55 pub description: Option<String>,
56}
57
58#[derive(Debug, Clone)]
59pub struct SshExecRequest {
60 pub connection_id: SshConnectionId,
61 pub script: String,
62 pub cwd: Option<String>,
63 pub env: Option<Map<String, Value>>,
64 pub shell: Option<String>,
65 pub login: bool,
66 pub title: Option<String>,
67 pub description: Option<String>,
68}
69
70#[derive(Debug, Clone)]
71pub struct SshRunRequest {
72 pub connection_id: SshConnectionId,
73 pub script: String,
74 pub cwd: Option<String>,
75 pub env: Option<Map<String, Value>>,
76 pub shell: Option<String>,
77 pub login: bool,
78 pub timeout_ms: Option<u64>,
79 pub max_output_bytes: Option<usize>,
80}
81
82#[derive(Debug, Clone)]
83pub struct SshRunResult {
84 pub connection_id: SshConnectionId,
85 pub success: bool,
86 pub exit_code: Option<i32>,
87 pub exit_signal: Option<String>,
88 pub stdout: String,
89 pub stderr: String,
90}
91
92#[derive(Debug, Clone)]
93pub struct SshMountRequest {
94 pub connection_id: SshConnectionId,
95 pub remote_path: String,
96 pub target_path: String,
97 pub read_only: bool,
98 pub backend: Option<crate::ssh::SshMountBackend>,
99 pub create_target: bool,
100 pub title: Option<String>,
101 pub description: Option<String>,
102}
103
104#[derive(Debug, Clone)]
105pub struct SshUnmountRequest {
106 pub mount_id: SshMountId,
107 pub force: bool,
108 pub cleanup_target: bool,
109}
110
111#[derive(Debug, Clone)]
112pub struct SshUnmountResult {
113 pub mount: SshMountSummary,
114 pub previous_status: SshMountStatus,
115 pub cleanup_target: bool,
116}
117
118#[derive(Debug, Clone)]
119pub struct SshDisconnectRequest {
120 pub connection_id: SshConnectionId,
121 pub force: bool,
122 pub cleanup_mounts: bool,
123 pub cleanup_tunnels: bool,
124}
125
126#[derive(Debug, Clone)]
127pub struct SshDisconnectResult {
128 pub connection_id: SshConnectionId,
129 pub previous_status: SshConnectionStatus,
130 pub current_status: SshConnectionStatus,
131 pub closed_sessions: usize,
132 pub closed_mounts: usize,
133 pub closed_tunnels: usize,
134}
135
136#[derive(Debug, Clone)]
137pub struct SshTunnelOpenRequest {
138 pub connection_id: SshConnectionId,
139 pub bind_host: Option<String>,
140 pub local_port: u16,
141 pub remote_host: Option<String>,
142 pub remote_port: u16,
143 pub title: Option<String>,
144 pub description: Option<String>,
145}
146
147#[derive(Debug, Clone)]
148pub struct SshTunnelOpenResult {
149 pub tunnel: SshTunnelSummary,
150 pub reused: bool,
151}
152
153#[derive(Debug, Clone)]
154pub struct SshTunnelCloseRequest {
155 pub tunnel_id: SshTunnelId,
156 pub force: bool,
157}
158
159#[derive(Debug, Clone)]
160pub struct SshTunnelCloseResult {
161 pub tunnel_id: SshTunnelId,
162 pub previous_status: SshTunnelStatus,
163 pub current_status: SshTunnelStatus,
164}
165
166#[derive(Debug, Clone, PartialEq, Eq)]
167pub struct SshReadFileResult {
168 pub connection_id: SshConnectionId,
169 pub path: String,
170 pub content: String,
171 pub bytes_read: usize,
172}
173
174#[derive(Debug, Clone, PartialEq, Eq)]
175pub struct SshWriteFileResult {
176 pub connection_id: SshConnectionId,
177 pub path: String,
178 pub bytes_written: usize,
179 pub append: bool,
180}
181
182#[derive(Debug, Clone, PartialEq, Eq)]
183pub enum SshDirectoryEntryType {
184 File,
185 Directory,
186 Symlink,
187 Other,
188}
189
190#[derive(Debug, Clone, PartialEq, Eq)]
191pub struct SshDirectoryEntry {
192 pub name: String,
193 pub path: String,
194 pub entry_type: SshDirectoryEntryType,
195}
196
197#[derive(Debug, Clone, PartialEq, Eq)]
198pub struct SshListDirectoryResult {
199 pub connection_id: SshConnectionId,
200 pub path: String,
201 pub entries: Vec<SshDirectoryEntry>,
202}
203
204#[derive(Debug, Clone, PartialEq, Eq)]
205pub struct SshMkdirResult {
206 pub connection_id: SshConnectionId,
207 pub path: String,
208 pub create_parents: bool,
209}