pub struct WorkspaceManager { /* private fields */ }Expand description
Manages workspace lifecycle (create, list, load, status, delete).
Implementations§
Source§impl WorkspaceManager
impl WorkspaceManager
Sourcepub fn ensure_agent_workspace(&self, agent_id: &str) -> Result<PathBuf>
pub fn ensure_agent_workspace(&self, agent_id: &str) -> Result<PathBuf>
Create or ensure a per-agent workspace exists.
Idempotent: if the workspace already exists, returns its path without modifying it. Creates the directory structure described in the module docs.
Directories are created with 0700 permissions on Unix for security.
Sourcepub fn create_agent_workspace(
&self,
agent_id: &str,
template: Option<&Path>,
) -> Result<PathBuf>
pub fn create_agent_workspace( &self, agent_id: &str, template: Option<&Path>, ) -> Result<PathBuf>
Create a per-agent workspace from a template.
If template is None, falls back to ~/.clawft/agents/default/ if
it exists, otherwise creates a bare workspace via
ensure_agent_workspace.
Sourcepub fn delete_agent_workspace(&self, agent_id: &str) -> Result<()>
pub fn delete_agent_workspace(&self, agent_id: &str) -> Result<()>
Delete a per-agent workspace by agent ID.
Removes the directory and all its contents from disk.
Sourcepub fn list_agent_workspaces(&self) -> Result<Vec<String>>
pub fn list_agent_workspaces(&self) -> Result<Vec<String>>
List all per-agent workspaces.
Returns a sorted list of agent IDs found under the agents directory.
Set up a cross-agent symlink for shared namespace access.
Creates a symlink from importer_id’s memory directory to
exporter_id’s namespace directory. The symlink provides
read-only access by default.
§Security
- Validates both agent IDs to prevent path traversal.
- The exporter workspace must exist.
- The namespace directory must exist under the exporter.
Source§impl WorkspaceManager
impl WorkspaceManager
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Create a new manager, loading the registry from the default path.
The default registry path is ~/.clawft/workspaces.json.
Sourcepub fn with_registry_path(registry_path: PathBuf) -> Result<Self>
pub fn with_registry_path(registry_path: PathBuf) -> Result<Self>
Create a new manager with an explicit registry path.
Useful for testing.
Sourcepub fn create(&mut self, name: &str, parent_dir: &Path) -> Result<PathBuf>
pub fn create(&mut self, name: &str, parent_dir: &Path) -> Result<PathBuf>
Create a new workspace.
Creates:
.clawft/and subdirectories (sessions,memory,skills,agents,hooks).clawft/config.jsonwith{}CLAWFT.mdwith a starter template- Registers the workspace in the global registry
Returns the absolute path to the workspace root.
Sourcepub fn list(&self) -> Vec<&WorkspaceEntry>
pub fn list(&self) -> Vec<&WorkspaceEntry>
List all registered workspaces.
Sourcepub fn load(&mut self, name_or_path: &str) -> Result<PathBuf>
pub fn load(&mut self, name_or_path: &str) -> Result<PathBuf>
Load a workspace by name or path string.
Returns the workspace root path if found.
Sourcepub fn status(&self, path: &Path) -> Result<WorkspaceStatus>
pub fn status(&self, path: &Path) -> Result<WorkspaceStatus>
Get the status of a workspace at the given path.
Auto Trait Implementations§
impl Freeze for WorkspaceManager
impl RefUnwindSafe for WorkspaceManager
impl Send for WorkspaceManager
impl Sync for WorkspaceManager
impl Unpin for WorkspaceManager
impl UnsafeUnpin for WorkspaceManager
impl UnwindSafe for WorkspaceManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more