Skip to main content

agent_core/core/
shell_config.rs

1//! Shell session configuration — parsed from ~/.synaps-cli/config shell.* keys.
2//! Lives in `core` so that `core::config` can embed it without a back-edge into `tools`.
3
4use std::time::Duration;
5
6/// Configuration for interactive shell sessions.
7#[derive(Debug, Clone)]
8pub struct ShellConfig {
9    pub max_sessions: usize,
10    pub idle_timeout: Duration,
11    pub readiness_timeout_ms: u64,
12    pub max_readiness_timeout_ms: u64,
13    pub default_rows: u16,
14    pub default_cols: u16,
15    pub prompt_patterns: Vec<String>,
16    pub readiness_strategy: String,
17    pub max_output: usize,
18}
19
20impl Default for ShellConfig {
21    fn default() -> Self {
22        Self {
23            max_sessions: 5,
24            idle_timeout: Duration::from_secs(600),
25            readiness_timeout_ms: 300,
26            max_readiness_timeout_ms: 10_000,
27            default_rows: 24,
28            default_cols: 80,
29            prompt_patterns: default_prompt_patterns(),
30            readiness_strategy: "hybrid".to_string(),
31            max_output: 30000,
32        }
33    }
34}
35
36fn default_prompt_patterns() -> Vec<String> {
37    vec![
38        r"[$#%»] $".into(),
39        r"[$#%»]\s*$".into(),
40        r"\(gdb\)\s*$".into(),
41        r">>>\s*$".into(),
42        r"\.\.\.\:\s*$".into(),
43        r"In \[\d+\]:\s*$".into(),
44        r"irb.*>\s*$".into(),
45        r"mysql>\s*$".into(),
46        r"postgres[=#]>\s*$".into(),
47        r"Password:\s*$".into(),
48        r"\[Y/n\]\s*$".into(),
49        r"\(yes/no.*\)\?\s*$".into(),
50        r"% $".into(),
51        r"% \s*$".into(),
52        r"root@[\w.-]+:[/~].*# $".into(),
53        r"[\w.-]+@[\w.-]+:[/~].*\$ $".into(),
54        r"Enter passphrase.*:\s*$".into(),
55        r"Token:\s*$".into(),
56        r"Verification code:\s*$".into(),
57    ]
58}