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 mod job;
12pub(crate) mod marker;
13pub mod registry;
14pub(crate) mod response;
15pub mod spooler;
16pub mod stream;
17pub(crate) mod wrapper;
18
19pub use job::{JobState, JobStatus, SharedJobState};
20pub use registry::JobRegistry;
21pub use spooler::LocalLogSpooler;
22pub use stream::OutputStreamer;
23
24use thiserror::Error;
25
26/// Background subsystem errors.
27#[derive(Debug, Error)]
28pub enum BackgroundError {
29    #[error("io error: {0}")]
30    Io(#[from] std::io::Error),
31
32    #[error("invalid job id: {job_id}")]
33    InvalidJobId { job_id: String },
34
35    #[error("job not found: {job_id}")]
36    JobNotFound { job_id: String },
37
38    #[error("invalid job state: {message}")]
39    InvalidState { message: &'static str },
40
41    #[error("time error: {0}")]
42    Time(#[from] std::time::SystemTimeError),
43}
44
45pub type Result<T> = std::result::Result<T, BackgroundError>;