Skip to main content

shuttle/
tools.rs

1use serde_json::{json, Value};
2
3pub fn tool_definitions() -> Vec<Value> {
4    vec![
5        json!({
6            "name": "ssh_exec",
7            "label": "SSH Execute",
8            "description": "Run a command on a remote host. Returns stdout, stderr, and exit code.",
9            "parameters": {
10                "type": "object",
11                "properties": {
12                    "host": {
13                        "type": "string",
14                        "description": "Host name as defined in hosts.toml."
15                    },
16                    "command": {
17                        "type": "string",
18                        "description": "Shell command to execute on the remote host."
19                    },
20                    "timeout_secs": {
21                        "type": "integer",
22                        "description": "Override the default command timeout (seconds)."
23                    }
24                },
25                "required": ["host", "command"]
26            }
27        }),
28        json!({
29            "name": "ssh_script",
30            "label": "SSH Script",
31            "description": "Upload and execute a multi-line script on a remote host. The script is piped via stdin to the interpreter — no temporary files are created on the remote filesystem.",
32            "parameters": {
33                "type": "object",
34                "properties": {
35                    "host": {
36                        "type": "string",
37                        "description": "Host name as defined in hosts.toml."
38                    },
39                    "script": {
40                        "type": "string",
41                        "description": "Script content (bash by default). Include a shebang for other interpreters."
42                    },
43                    "interpreter": {
44                        "type": "string",
45                        "description": "Interpreter to use (default: /bin/bash)."
46                    },
47                    "timeout_secs": {
48                        "type": "integer",
49                        "description": "Override the default command timeout (seconds)."
50                    }
51                },
52                "required": ["host", "script"]
53            }
54        }),
55        json!({
56            "name": "scp_push",
57            "label": "SCP Push",
58            "description": "Copy a local file to a remote host via SFTP.",
59            "parameters": {
60                "type": "object",
61                "properties": {
62                    "host": {
63                        "type": "string",
64                        "description": "Host name as defined in hosts.toml."
65                    },
66                    "local_path": {
67                        "type": "string",
68                        "description": "Absolute path to the local file."
69                    },
70                    "remote_path": {
71                        "type": "string",
72                        "description": "Absolute path on the remote host."
73                    }
74                },
75                "required": ["host", "local_path", "remote_path"]
76            }
77        }),
78        json!({
79            "name": "scp_pull",
80            "label": "SCP Pull",
81            "description": "Copy a remote file to the local machine via SFTP.",
82            "parameters": {
83                "type": "object",
84                "properties": {
85                    "host": {
86                        "type": "string",
87                        "description": "Host name as defined in hosts.toml."
88                    },
89                    "remote_path": {
90                        "type": "string",
91                        "description": "Absolute path on the remote host."
92                    },
93                    "local_path": {
94                        "type": "string",
95                        "description": "Absolute path to write locally."
96                    }
97                },
98                "required": ["host", "remote_path", "local_path"]
99            }
100        }),
101        json!({
102            "name": "sftp_ls",
103            "label": "SFTP List",
104            "description": "List files at a path on a remote host.",
105            "parameters": {
106                "type": "object",
107                "properties": {
108                    "host": {
109                        "type": "string",
110                        "description": "Host name as defined in hosts.toml."
111                    },
112                    "path": {
113                        "type": "string",
114                        "description": "Absolute directory path on the remote host."
115                    }
116                },
117                "required": ["host", "path"]
118            }
119        }),
120        json!({
121            "name": "sftp_read",
122            "label": "SFTP Read",
123            "description": "Read a remote file's contents without copying it locally. Returns the content as text.",
124            "parameters": {
125                "type": "object",
126                "properties": {
127                    "host": {
128                        "type": "string",
129                        "description": "Host name as defined in hosts.toml."
130                    },
131                    "path": {
132                        "type": "string",
133                        "description": "Absolute file path on the remote host."
134                    },
135                    "max_bytes": {
136                        "type": "integer",
137                        "description": "Maximum bytes to read (default: max_output_bytes from config)."
138                    }
139                },
140                "required": ["host", "path"]
141            }
142        }),
143        json!({
144            "name": "ssh_tunnel_open",
145            "label": "SSH Tunnel Open",
146            "description": "Open a port-forward tunnel through an SSH host. Supports local-to-remote forwarding.",
147            "parameters": {
148                "type": "object",
149                "properties": {
150                    "host": {
151                        "type": "string",
152                        "description": "SSH host to tunnel through (from hosts.toml)."
153                    },
154                    "local_port": {
155                        "type": "integer",
156                        "description": "Local port to listen on."
157                    },
158                    "remote_host": {
159                        "type": "string",
160                        "description": "Remote destination host (as seen from the SSH host). Default: 127.0.0.1."
161                    },
162                    "remote_port": {
163                        "type": "integer",
164                        "description": "Remote destination port."
165                    }
166                },
167                "required": ["host", "local_port", "remote_port"]
168            }
169        }),
170        json!({
171            "name": "ssh_tunnel_close",
172            "label": "SSH Tunnel Close",
173            "description": "Close an open tunnel by its ID.",
174            "parameters": {
175                "type": "object",
176                "properties": {
177                    "tunnel_id": {
178                        "type": "string",
179                        "description": "Tunnel ID returned by ssh_tunnel_open."
180                    }
181                },
182                "required": ["tunnel_id"]
183            }
184        }),
185        json!({
186            "name": "ssh_tunnel_list",
187            "label": "SSH Tunnel List",
188            "description": "List all active tunnels with their endpoints and status.",
189            "parameters": {
190                "type": "object",
191                "properties": {}
192            }
193        }),
194        json!({
195            "name": "ssh_hosts",
196            "label": "SSH Hosts",
197            "description": "List all configured hosts with their address, user, port, and identity label.",
198            "parameters": {
199                "type": "object",
200                "properties": {}
201            }
202        }),
203        json!({
204            "name": "ssh_ping",
205            "label": "SSH Ping",
206            "description": "Test connectivity and authentication to a host. Returns success/failure and latency.",
207            "parameters": {
208                "type": "object",
209                "properties": {
210                    "host": {
211                        "type": "string",
212                        "description": "Host name as defined in hosts.toml."
213                    }
214                },
215                "required": ["host"]
216            }
217        }),
218        json!({
219            "name": "ssh_migrate_analyze",
220            "label": "SSH Migration Analyzer",
221            "description": "Scan the local ~/.ssh/ directory and produce a migration plan for shuttle. Parses ssh config, inventories key files, suggests identity_label groupings, and generates a draft hosts.toml. Does not read private key content — only filenames and config structure.",
222            "parameters": {
223                "type": "object",
224                "properties": {}
225            }
226        }),
227    ]
228}