1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
//! cnctd-service-ssh - SSH command execution library
//!
//! This library provides secure SSH command execution capabilities,
//! including interactive shell sessions for LLM agents.
//!
//! # Library Usage
//!
//! ```rust,no_run
//! use cnctd_service_ssh::{SshService, SshRegisterArgs, SshExecArgs};
//!
//! #[tokio::main]
//! async fn main() -> anyhow::Result<()> {
//! let service = SshService::new();
//!
//! // Register a target
//! service.register(SshRegisterArgs {
//! id: "my-server".to_string(),
//! host: "example.com".to_string(),
//! user: "ubuntu".to_string(),
//! port: 22,
//! key_passphrase: None,
//! known_hosts_path: "~/.ssh/known_hosts".to_string(),
//! client_id: Some("my-app".to_string()),
//! }).await?;
//!
//! // Execute a command
//! let result = service.exec(SshExecArgs {
//! id: "my-server".to_string(),
//! command: "hostname".to_string(),
//! timeout_secs: 30,
//! context: Some("checking hostname".to_string()),
//! }).await?;
//!
//! println!("Output: {}", result.stdout);
//! Ok(())
//! }
//! ```
//!
//! # Interactive Shell Sessions
//!
//! ```rust,no_run
//! use cnctd_service_ssh::sessions::{ShellSessionService, ShellSessionCreateArgs};
//!
//! #[tokio::main]
//! async fn main() -> anyhow::Result<()> {
//! let shell_service = ShellSessionService::global();
//!
//! // Create an interactive shell session
//! let result = shell_service.create(ShellSessionCreateArgs {
//! target_id: "my-server".to_string(),
//! name: Some("dev-shell".to_string()),
//! shell: None, // Use default login shell
//! cols: 120,
//! rows: 40,
//! client_id: Some("my-app".to_string()),
//! env: Default::default(),
//! }).await?;
//!
//! println!("Session created: {}", result.session_id);
//! Ok(())
//! }
//! ```
//!
//! # Tool Definitions
//!
//! To get tool schemas for LLM integration (avoiding hardcoded schemas):
//!
//! ```rust
//! use cnctd_service_ssh::{get_tool_definitions, get_all_tool_definitions};
//!
//! // Get only SSH exec tools
//! let ssh_tools = get_tool_definitions();
//!
//! // Get all tools including interactive shell sessions
//! let all_tools = get_all_tool_definitions();
//! ```
//!
//! # MCP Server
//!
//! Run as a standalone MCP server:
//! ```bash
//! cnctd-service-ssh
//! ```
// Re-export main types for convenience
pub use ;
pub use ServiceError;
// Re-export sessions types
pub use ;
/// Get all tool definitions (SSH exec + interactive sessions)