Skip to main content

ssh_mcp/background/
mod.rs

1//! Local background job state + log spooling (Phase 1 scaffold).
2//!
3//! Goal: move background job logs from remote `system temp directory / ssh-mcp subdirectory/*.log` to a local-only
4//! spool directory while keeping the public MCP tool API stable.
5//!
6//! Phase 1 provides the core types:
7//! - [`JobState`]: per-job state (pid, local log path, exit code, status)
8//! - [`JobRegistry`]: thread-safe registry for active + recently completed jobs
9//! - [`LocalLogSpooler`]: local `system temp directory / ssh-mcp subdirectory` directory management
10
11pub(crate) mod detach;
12pub mod job;
13pub(crate) mod marker;
14pub mod registry;
15pub(crate) mod response;
16pub mod spooler;
17pub mod stream;
18pub(crate) mod wrapper;
19
20pub use job::{JobState, JobStatus, SharedJobState};
21pub use registry::JobRegistry;
22pub use spooler::LocalLogSpooler;
23pub use stream::OutputStreamer;
24
25use thiserror::Error;
26
27/// Background subsystem errors.
28#[derive(Debug, Error)]
29pub enum BackgroundError {
30    #[error("io error: {0}")]
31    Io(#[from] std::io::Error),
32
33    #[error("invalid job id: {job_id}")]
34    InvalidJobId { job_id: String },
35
36    #[error("job not found: {job_id}")]
37    JobNotFound { job_id: String },
38
39    #[error("invalid job state: {message}")]
40    InvalidState { message: &'static str },
41
42    #[error("time error: {0}")]
43    Time(#[from] std::time::SystemTimeError),
44}
45
46pub type Result<T> = std::result::Result<T, BackgroundError>;