#[cfg(test)]
use std::{fs, io::Write};
use std::{
path::{Path, PathBuf},
sync::{Arc, Mutex},
};
#[cfg(test)]
use uuid::Uuid;
#[cfg(test)]
use rho_providers::model::ContentBlock;
use rho_providers::model::Message;
use rho_sdk::SessionSnapshot;
#[cfg(test)]
use rho_sdk::{CompactionState, Revision, SessionId};
mod agent_identity;
mod append_cursor;
pub(crate) mod catalog;
mod delete;
mod display_rows;
mod id_match;
mod index;
mod layout;
mod lease;
mod mark;
mod persistence;
pub(crate) mod recall;
pub(crate) mod search;
mod search_evidence;
pub(crate) mod search_index;
mod search_journal;
pub(crate) mod search_page;
mod search_scope;
mod search_window;
mod snapshot_delta;
mod snapshot_store;
#[cfg(test)]
#[path = "session_summary_tests.rs"]
mod summary_tests;
#[cfg(test)]
#[path = "session_tests.rs"]
mod tests;
mod title;
pub(crate) mod tree;
#[cfg(test)]
#[path = "session_tree_tests.rs"]
mod tree_tests;
#[cfg(test)]
#[path = "session_version_tests.rs"]
mod version_tests;
pub(crate) mod workspace_checkpoint;
mod workspace_scope;
use append_cursor::AppendCursor;
#[cfg(test)]
use layout::encode_cwd;
pub(crate) use layout::session_root_in;
use persistence::{parse_timestamp, session_root, unix_timestamp_secs, SessionStore};
#[cfg(test)]
use persistence::{
read_entries, session_dir_in_root, summarize_session_file, SessionEntry, SESSION_VERSION,
};
pub(crate) use agent_identity::SavedAgent;
pub use delete::{is_cross_project, DeleteOptions, DeleteOutcome};
pub(crate) use delete::{
is_in_use, CleanupFailure, CleanupOutcome, ExactDelete, RunNotFinished, WorkspaceDeleteOutcome,
};
pub(crate) use id_match::SavedInManyWorkspaces;
pub(crate) use lease::SessionInUse;
use lease::{LeasePurpose, SessionLease};
pub(crate) use mark::{MarkChange, NewMark, SessionMark};
pub(crate) use persistence::NoSessionFound;
pub(crate) use title::TitleRejected;
pub(crate) use workspace_scope::Workspace;
#[derive(Clone, Debug)]
pub struct Session {
id: String,
path: PathBuf,
session_root: PathBuf,
cwd: PathBuf,
workspace_key: String,
write_lock: Arc<Mutex<AppendCursor>>,
_active_lease: SessionLease,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct SessionSummary {
pub id: String,
pub path: PathBuf,
pub cwd: PathBuf,
pub created_at: u64,
pub updated_at: u64,
pub message_count: u64,
pub title: Option<String>,
pub first_user_message: Option<String>,
pub last_user_message: Option<String>,
pub added_dirs: Vec<PathBuf>,
pub origin: Option<SessionOrigin>,
pub agent: Option<String>,
pub started_by: Option<String>,
pub(crate) mark: Option<SessionMark>,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "snake_case")]
pub(crate) enum SessionOrigin {
Interactive,
Acp,
Daemon,
Run,
Subagent,
WorkflowNode,
Fork,
#[serde(other)]
Unknown,
}
impl SessionSummary {
pub(crate) fn is_person_facing(&self) -> bool {
self.origin.is_none_or(SessionOrigin::is_person_facing)
}
}
impl SessionOrigin {
pub(crate) fn is_person_facing(self) -> bool {
match self {
Self::Interactive | Self::Acp | Self::Daemon | Self::Unknown => true,
Self::Run | Self::Subagent | Self::WorkflowNode | Self::Fork => false,
}
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub(crate) struct SessionProvenance {
pub(crate) origin: SessionOrigin,
pub(crate) parent: Option<SessionTarget>,
pub(crate) started_by: Option<String>,
}
impl From<SessionOrigin> for SessionProvenance {
fn from(origin: SessionOrigin) -> Self {
Self {
origin,
parent: None,
started_by: None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(crate) enum SessionPersistence {
Saved,
Ephemeral,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(crate) enum SessionListing {
PersonFacing,
Everything,
}
impl SessionListing {
fn retain(self, sessions: &mut Vec<SessionSummary>) {
match self {
Self::PersonFacing => sessions.retain(SessionSummary::is_person_facing),
Self::Everything => {}
}
}
}
#[derive(Clone, Debug, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
pub struct SessionTarget {
pub id: String,
pub cwd: PathBuf,
}
impl SessionTarget {
pub fn new(id: impl Into<String>, cwd: impl Into<PathBuf>) -> Self {
Self {
id: id.into(),
cwd: cwd.into(),
}
}
}
pub(crate) fn workspace_key(cwd: &Path) -> String {
layout::workspace_key(cwd)
}
fn resolve_saved(cwd: &Path, id: &str) -> anyhow::Result<persistence::ResolvedSession> {
SessionStore::new(&session_root()?, cwd)
.resolve_exact_local(id)?
.ok_or_else(|| anyhow::anyhow!("no session is saved under {id} in {}", cwd.display()))
}
impl SessionSummary {
pub fn target(&self) -> SessionTarget {
SessionTarget::new(self.id.clone(), self.cwd.clone())
}
pub fn has_messages(&self) -> bool {
self.message_count > 0
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct TitleUpdate {
pub id: String,
pub cwd: PathBuf,
pub title: String,
}
#[derive(Clone, Debug)]
pub struct ExportedMessage {
pub timestamp: Option<u64>,
pub message: Message,
}
#[derive(Clone, Debug)]
pub struct SessionExport {
pub id: String,
pub cwd: PathBuf,
pub created_at: u64,
pub updated_at: u64,
pub title: Option<String>,
pub messages: Vec<ExportedMessage>,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub(super) struct SessionIndexRecord {
pub(super) summary: SessionSummary,
pub(super) file_size: Option<i64>,
pub(super) file_mtime: Option<i64>,
pub(super) node_count: u64,
pub(super) branch_count: u64,
pub(super) active_leaf_id: Option<String>,
pub(super) effective_format_version: u32,
pub(super) parent_session: Option<SessionTarget>,
}
impl Session {
pub(crate) fn resolve_target(cwd: &Path, id_prefix: &str) -> anyhow::Result<SessionTarget> {
let root = session_root()?;
let resolved = SessionStore::new(&root, cwd).resolve(id_prefix)?;
Ok(SessionTarget::new(resolved.id, resolved.cwd))
}
pub(crate) fn workspace_of(id: &str) -> anyhow::Result<Option<PathBuf>> {
SessionStore::workspace_of(&session_root()?, id)
}
pub(crate) fn workspaces_of(
rho_home: &Path,
ids: &[String],
) -> Vec<anyhow::Result<Option<PathBuf>>> {
SessionStore::workspaces_of(&layout::session_root_in(rho_home), ids)
}
pub(crate) fn open_exact_in_workspace(
cwd: &Path,
id: &str,
) -> anyhow::Result<Option<(Self, Vec<Message>)>> {
let session_root = session_root()?;
let Some(resolved) = SessionStore::new(&session_root, cwd).resolve_exact_local(id)? else {
return Ok(None);
};
Self::open_resolved_with_history(&session_root, resolved).map(Some)
}
#[cfg(test)]
pub(crate) fn open_by_id_in_root(
session_root: &Path,
cwd: &Path,
id_prefix: &str,
) -> anyhow::Result<(Self, Vec<Message>)> {
let resolved = SessionStore::new(session_root, cwd).resolve(id_prefix)?;
Self::open_resolved_with_history(session_root, resolved)
}
fn open_resolved_with_history(
session_root: &Path,
resolved: persistence::ResolvedSession,
) -> anyhow::Result<(Self, Vec<Message>)> {
anyhow::ensure!(
resolved.cwd.is_dir(),
"session '{}' belongs to workspace {}, which is no longer an accessible directory. \
Restore or recreate that directory and resume from there; its transcript \
is preserved under ~/.rho/sessions.",
resolved.id,
resolved.cwd.display(),
);
let active_lease = lease::acquire(
session_root,
&resolved.cwd,
&resolved.id,
LeasePurpose::Open,
)?;
let tree = tree::SessionTree::load(&resolved.path)?;
let history = persistence::history_from_tree(&tree)?;
let session = Self::from_parts_with_lease(
session_root,
resolved.cwd,
resolved.id,
resolved.path,
active_lease,
);
session.cache_loaded_tree(tree);
Ok((session, history))
}
pub(crate) fn tree_facts_by_id(
cwd: &Path,
id_prefix: &str,
) -> anyhow::Result<tree::SessionTreeFacts> {
let store = SessionStore::new(&session_root()?, cwd);
let resolved = store.resolve(id_prefix)?;
Ok(resolved.tree()?.facts())
}
pub(crate) fn session_metadata_by_id(
cwd: &Path,
id: &str,
key: &str,
) -> anyhow::Result<Option<String>> {
Ok(resolve_saved(cwd, id)?
.tree()?
.newest_node_metadata(key)
.map(str::to_owned))
}
pub(crate) fn subagent_parent_by_id(
cwd: &Path,
id: &str,
) -> anyhow::Result<Option<SessionTarget>> {
agent_identity::read_subagent_parent(&resolve_saved(cwd, id)?.path)
}
pub(crate) fn tree_turn_items_by_id(
cwd: &Path,
id_prefix: &str,
) -> anyhow::Result<Vec<tree::SessionTreeItem>> {
let store = SessionStore::new(&session_root()?, cwd);
store.resolve(id_prefix)?.tree()?.turn_items()
}
pub(crate) fn turn_prompts_by_id(
cwd: &Path,
id_prefix: &str,
turns: impl IntoIterator<Item = tree::NodeId>,
) -> anyhow::Result<std::collections::HashMap<tree::NodeId, String>> {
let tree = SessionStore::new(&session_root()?, cwd)
.resolve(id_prefix)?
.tree()?;
Ok(turns
.into_iter()
.filter_map(|turn| tree.turn_prompt(&turn).map(|prompt| (turn, prompt)))
.collect())
}
pub(crate) fn workspace_checkpoint_store_by_id(
cwd: &Path,
id_prefix: &str,
) -> anyhow::Result<Option<workspace_checkpoint::WorkspaceCheckpointStore>> {
let resolved = SessionStore::new(&session_root()?, cwd).resolve(id_prefix)?;
workspace_checkpoint::WorkspaceCheckpointStore::at(
&resolved.path,
&resolved.id,
workspace_checkpoint::CheckpointLimits::default(),
)
}
pub fn export_by_id(cwd: &Path, id_prefix: &str) -> anyhow::Result<SessionExport> {
Self::export_by_id_in_root(&session_root()?, cwd, id_prefix)
}
pub(crate) fn export_by_id_in_root(
session_root: &Path,
cwd: &Path,
id_prefix: &str,
) -> anyhow::Result<SessionExport> {
let store = SessionStore::new(session_root, cwd);
let resolved = store.resolve(id_prefix)?;
let (record, tree) = resolved.summary_with_tree(cwd)?;
let title = SessionStore::new(session_root, &resolved.cwd)
.title(&resolved.id)
.ok()
.flatten();
let messages = match tree.active_leaf_id() {
Some(active_leaf_id) => persistence::insert_interrupted_display_placeholders(
tree.projected_display(active_leaf_id)?,
),
None => Vec::new(),
};
Ok(SessionExport {
id: record.summary.id,
cwd: record.summary.cwd,
created_at: record.summary.created_at,
updated_at: record.summary.updated_at,
title,
messages: messages
.into_iter()
.map(|message| ExportedMessage {
timestamp: parse_timestamp(&message.timestamp),
message: message.message,
})
.collect(),
})
}
pub(crate) fn stored_agent_identity(&self) -> anyhow::Result<Option<(String, String)>> {
agent_identity::read_agent_identity(&self.path)
}
pub(crate) fn root_agent(&self) -> anyhow::Result<Option<SavedAgent>> {
agent_identity::read_root_agent(&self.path)
}
pub(crate) fn rebind_fresh_delegated_agent(
&self,
agent_id: &str,
fingerprint: &str,
initial_snapshot: Option<&SessionSnapshot>,
) -> anyhow::Result<()> {
self.rewrite_fresh_delegated_identity(agent_id, fingerprint, initial_snapshot)
}
pub(crate) fn origin(&self) -> anyhow::Result<Option<SessionOrigin>> {
agent_identity::read_origin(&self.path)
}
pub(crate) fn forked_from(&self) -> anyhow::Result<Option<SessionTarget>> {
agent_identity::read_forked_from(&self.path)
}
pub(crate) fn delegated_agent_id(&self) -> anyhow::Result<Option<String>> {
agent_identity::read_delegated_agent_id(&self.path)
}
pub(crate) fn validate_agent_definition_identity(
&self,
definition: &crate::agent::AgentDefinition,
) -> anyhow::Result<()> {
agent_identity::validate(&self.path, definition)
}
pub(crate) fn validate_agent_definition_identity_of(
target: &SessionTarget,
definition: &crate::agent::AgentDefinition,
) -> anyhow::Result<()> {
let resolved =
SessionStore::new(&session_root()?, &target.cwd).resolve_in_workspace(&target.id)?;
agent_identity::validate(&resolved.path, definition)
}
pub(crate) fn list(cwd: &Path, listing: SessionListing) -> anyhow::Result<Vec<SessionSummary>> {
Self::list_in_root(&session_root()?, cwd, listing)
}
pub(crate) fn list_all(listing: SessionListing) -> anyhow::Result<Vec<SessionSummary>> {
Self::list_all_in_root(&session_root()?, listing)
}
pub(crate) fn list_missing_workspaces() -> anyhow::Result<Vec<SessionSummary>> {
delete::list_missing_workspaces_in_root(&session_root()?)
}
pub(crate) fn workspace_directory_is_missing(cwd: &Path) -> anyhow::Result<bool> {
delete::workspace_directory_is_missing(cwd)
}
pub(crate) fn cleanup_missing_targets(
targets: &[SessionTarget],
options: DeleteOptions,
) -> anyhow::Result<CleanupOutcome> {
delete::cleanup_missing_targets_in_roots(
&session_root()?,
&crate::paths::rho_dir()?.join("subagents"),
targets,
&options,
)
}
pub fn find_by_id_prefix(cwd: &Path, id_prefix: &str) -> anyhow::Result<Vec<SessionSummary>> {
Self::find_by_id_prefix_in_root(&session_root()?, cwd, id_prefix)
}
pub fn set_title(cwd: &Path, id_prefix: &str, title: &str) -> anyhow::Result<TitleUpdate> {
Self::set_title_in_root(&session_root()?, cwd, id_prefix, title)
}
pub(crate) fn set_generated_title(
cwd: &Path,
id_prefix: &str,
title: &str,
) -> anyhow::Result<Option<TitleUpdate>> {
Self::set_generated_title_in_root(&session_root()?, cwd, id_prefix, title)
}
pub(crate) fn title_is_set(cwd: &Path, id_prefix: &str) -> anyhow::Result<bool> {
Self::title_is_set_in_root(&session_root()?, cwd, id_prefix)
}
pub(crate) fn title(cwd: &Path, id_prefix: &str) -> anyhow::Result<Option<String>> {
Self::title_in_root(&session_root()?, cwd, id_prefix)
}
pub fn delete_target(
target: &SessionTarget,
options: DeleteOptions,
) -> anyhow::Result<DeleteOutcome> {
delete::delete_target_in_roots(
&session_root()?,
&crate::paths::rho_dir()?.join("subagents"),
target,
&options,
)
}
pub(crate) fn delete_targets(
targets: &[SessionTarget],
options: DeleteOptions,
) -> anyhow::Result<WorkspaceDeleteOutcome> {
delete::delete_targets_in_roots(
&session_root()?,
&crate::paths::rho_dir()?.join("subagents"),
targets,
&options,
)
}
fn set_title_in_root(
session_root: &Path,
cwd: &Path,
id_prefix: &str,
title: &str,
) -> anyhow::Result<TitleUpdate> {
let title = title::checked(title)?;
let resolved = SessionStore::new(session_root, cwd).resolve(id_prefix)?;
SessionStore::new(session_root, &resolved.cwd).set_title(&resolved.id, title)?;
Ok(TitleUpdate {
id: resolved.id,
cwd: resolved.cwd,
title: title.to_string(),
})
}
fn set_generated_title_in_root(
session_root: &Path,
cwd: &Path,
id_prefix: &str,
title: &str,
) -> anyhow::Result<Option<TitleUpdate>> {
let title = title.trim();
if title.is_empty() {
anyhow::bail!("title must not be empty");
}
let resolved = SessionStore::new(session_root, cwd).resolve(id_prefix)?;
let store = SessionStore::new(session_root, &resolved.cwd);
if !store.set_title_if_absent(&resolved.id, title)? {
return Ok(None);
}
Ok(Some(TitleUpdate {
id: resolved.id,
cwd: resolved.cwd,
title: title.to_string(),
}))
}
fn title_is_set_in_root(
session_root: &Path,
cwd: &Path,
id_prefix: &str,
) -> anyhow::Result<bool> {
Ok(Self::title_in_root(session_root, cwd, id_prefix)?.is_some())
}
fn title_in_root(
session_root: &Path,
cwd: &Path,
id_prefix: &str,
) -> anyhow::Result<Option<String>> {
let resolved = SessionStore::new(session_root, cwd).resolve(id_prefix)?;
SessionStore::new(session_root, &resolved.cwd).title(&resolved.id)
}
fn list_in_root(
session_root: &Path,
cwd: &Path,
listing: SessionListing,
) -> anyhow::Result<Vec<SessionSummary>> {
let mut sessions = SessionStore::new(session_root, cwd).list()?;
listing.retain(&mut sessions);
Ok(sessions)
}
#[cfg(test)]
pub(crate) fn list_in_root_for_test(
session_root: &Path,
cwd: &Path,
listing: SessionListing,
) -> anyhow::Result<Vec<SessionSummary>> {
Self::list_in_root(session_root, cwd, listing)
}
#[cfg(test)]
pub(crate) fn set_title_in_root_for_test(
session_root: &Path,
cwd: &Path,
id_prefix: &str,
title: &str,
) -> anyhow::Result<TitleUpdate> {
Self::set_title_in_root(session_root, cwd, id_prefix, title)
}
#[cfg(test)]
pub(crate) fn set_generated_title_in_root_for_test(
session_root: &Path,
cwd: &Path,
id_prefix: &str,
title: &str,
) -> anyhow::Result<Option<TitleUpdate>> {
Self::set_generated_title_in_root(session_root, cwd, id_prefix, title)
}
pub(crate) fn list_all_in_root(
session_root: &Path,
listing: SessionListing,
) -> anyhow::Result<Vec<SessionSummary>> {
let mut sessions = index::list_all_sessions(session_root)?;
listing.retain(&mut sessions);
Ok(sessions)
}
#[cfg(test)]
pub(crate) fn list_missing_workspaces_in_root_for_test(
session_root: &Path,
) -> anyhow::Result<Vec<SessionSummary>> {
delete::list_missing_workspaces_in_root(session_root)
}
#[cfg(test)]
pub(crate) fn cleanup_missing_workspaces_in_roots_for_test(
session_root: &Path,
subagents_root: &Path,
options: DeleteOptions,
) -> anyhow::Result<CleanupOutcome> {
delete::cleanup_missing_workspaces_in_roots(session_root, subagents_root, &options)
}
fn find_by_id_prefix_in_root(
session_root: &Path,
cwd: &Path,
id_prefix: &str,
) -> anyhow::Result<Vec<SessionSummary>> {
let local = SessionStore::new(session_root, cwd)
.list()?
.into_iter()
.filter(|session| session.id.starts_with(id_prefix))
.collect::<Vec<_>>();
let local = id_match::prefer_exact(local, id_prefix, |session| Some(session.id.clone()));
if !local.is_empty() {
return Ok(local);
}
index::reconcile_all_workspaces(session_root)?;
index::summaries_matching_id_prefix(session_root, id_prefix)
}
#[cfg(test)]
pub(crate) fn delete_by_id_in_roots(
session_root: &Path,
subagents_root: &Path,
cwd: &Path,
id_prefix: &str,
options: DeleteOptions,
) -> anyhow::Result<DeleteOutcome> {
delete::delete_in_roots(session_root, subagents_root, cwd, id_prefix, &options)
}
pub(crate) fn create_with_id(
cwd: &Path,
id: &str,
agent_id: &str,
agent_fingerprint: &str,
provenance: SessionProvenance,
) -> anyhow::Result<Self> {
Self::create_with_id_in_root(
&session_root()?,
cwd,
id,
Some((agent_id, agent_fingerprint)),
provenance,
)
}
#[cfg(test)]
pub(crate) fn create_in_root(session_root: &Path, cwd: &Path) -> anyhow::Result<Self> {
Self::create_in_root_from(session_root, cwd, SessionOrigin::Interactive)
}
#[cfg(test)]
pub(crate) fn create_in_root_from(
session_root: &Path,
cwd: &Path,
origin: SessionOrigin,
) -> anyhow::Result<Self> {
Self::create_with_id_in_root(
session_root,
cwd,
&Uuid::new_v4().to_string(),
None,
origin.into(),
)
}
#[cfg(test)]
pub(crate) fn create_with_id_in_root_for_test(
session_root: &Path,
cwd: &Path,
id: &str,
) -> anyhow::Result<Self> {
Self::create_with_id_in_root(
session_root,
cwd,
id,
None,
SessionOrigin::Interactive.into(),
)
}
#[cfg(test)]
pub(crate) fn create_in_root_with_agent(
session_root: &Path,
cwd: &Path,
agent_id: &str,
agent_fingerprint: &str,
) -> anyhow::Result<Self> {
Self::create_with_id_in_root(
session_root,
cwd,
&Uuid::new_v4().to_string(),
Some((agent_id, agent_fingerprint)),
SessionOrigin::Interactive.into(),
)
}
fn create_with_id_in_root(
session_root: &Path,
cwd: &Path,
id: &str,
agent: Option<(&str, &str)>,
provenance: SessionProvenance,
) -> anyhow::Result<Self> {
let store = SessionStore::new(session_root, cwd);
let id = id.to_string();
let created_at = unix_timestamp_secs();
let path = store.create_path(&id, created_at)?;
let session = Self::from_parts(session_root, cwd, id.clone(), path)?;
session.append_session_metadata(id, created_at, agent, provenance)?;
Ok(session)
}
#[cfg(test)]
pub fn append_message(&self, message: &Message) -> anyhow::Result<()> {
self.append_stored_message(message, None)
}
#[cfg(test)]
pub fn append_message_with_display(
&self,
message: &Message,
display_message: &Message,
) -> anyhow::Result<()> {
self.append_stored_message(message, Some(display_message))
}
#[cfg(test)]
pub fn replace_history(&self, messages: &[Message]) -> anyhow::Result<()> {
self.append_replaced_history(messages)
}
fn from_parts(
session_root: &Path,
cwd: &Path,
id: String,
path: PathBuf,
) -> anyhow::Result<Self> {
let active_lease = lease::acquire(session_root, cwd, &id, LeasePurpose::Open)?;
Ok(Self::from_parts_with_lease(
session_root,
cwd.to_path_buf(),
id,
path,
active_lease,
))
}
fn from_parts_with_lease(
session_root: &Path,
cwd: PathBuf,
id: String,
path: PathBuf,
active_lease: SessionLease,
) -> Self {
Self {
workspace_key: workspace_key(&cwd),
id,
path,
session_root: session_root.to_path_buf(),
cwd,
write_lock: Arc::new(Mutex::new(AppendCursor::default())),
_active_lease: active_lease,
}
}
#[cfg(test)]
pub(crate) fn active_lease_for_tests(&self) -> &SessionLease {
&self._active_lease
}
#[cfg(test)]
pub(crate) fn path(&self) -> &Path {
&self.path
}
pub(crate) fn subagents_dir(&self) -> Option<PathBuf> {
persistence::SessionUnit::from_path(&self.path)?.subagents_dir()
}
pub(crate) fn recall_dir(&self) -> Option<PathBuf> {
persistence::SessionUnit::from_path(&self.path)?.recall_dir()
}
pub fn id(&self) -> &str {
&self.id
}
pub(crate) fn cwd(&self) -> &Path {
&self.cwd
}
}