Overview
TheWorkspace interface defines how each agent session gets an isolated copy of the codebase. Workspace plugins manage repository isolation, branch setup, and post-creation hooks.
Plugin Slot: workspaceDefault Plugin:
worktree
Interface Definition
Methods
Plugin name identifier (e.g.
"worktree", "clone").Create an isolated workspace for a session.Parameters:
config.projectId- Project identifierconfig.project- Full project configurationconfig.sessionId- Session identifierconfig.branch- Git branch name
Destroy a workspace and clean up resources.Parameters:
workspacePath- Absolute path to workspace directory
List existing workspaces for a project.Parameters:
projectId- Project identifier
Optional: Run hooks after workspace creation (symlinks, installs, etc.).Parameters:
info- Created workspace infoproject- Project configuration
Optional: Check if a workspace exists and is a valid git repo.Parameters:
workspacePath- Path to check
Optional: Restore a workspace (e.g. recreate a worktree for an existing branch).Parameters:
config- Workspace creation configworkspacePath- Path where workspace should be restored
Related Types
WorkspaceCreateConfig
Project identifier from orchestrator config
Full project configuration with repo, path, symlinks, postCreate commands
Session identifier
Git branch name for this workspace
WorkspaceInfo
Absolute path to workspace directory
Git branch name
Session identifier
Project identifier
Usage Examples
Implementing a Workspace Plugin
Using Workspace in Session Manager
Implementation Notes
Workspace Isolation
The workspace plugin must ensure complete isolation:- Each session has its own branch and working directory
- No shared state between sessions (except
.gitin worktree mode) - Symlinks can share large files (node_modules, build artifacts)
Post-Creation Hooks
ThepostCreate() method should:
- Create symlinks specified in project config
- Run postCreate commands (npm install, copy configs, etc.)
- Handle errors gracefully (warn but don’t fail)
Restoration
Therestore() method enables restoring sessions after:
- Machine reboot (worktrees still exist but runtime is gone)
- Manual cleanup (recreate worktree from existing branch)
- Plugin crash recovery
Built-in Plugins
- worktree - Git worktrees (default, lightweight)
- clone - Full git clones (isolated but slower)
