Skip to main content

Overview

The Workspace 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: workspace
Default Plugin: worktree

Interface Definition

Methods

string
required
Plugin name identifier (e.g. "worktree", "clone").
(config: WorkspaceCreateConfig) => Promise<WorkspaceInfo>
required
Create an isolated workspace for a session.Parameters:
  • config.projectId - Project identifier
  • config.project - Full project configuration
  • config.sessionId - Session identifier
  • config.branch - Git branch name
Returns: WorkspaceInfo with path and metadata
(workspacePath: string) => Promise<void>
required
Destroy a workspace and clean up resources.Parameters:
  • workspacePath - Absolute path to workspace directory
(projectId: string) => Promise<WorkspaceInfo[]>
required
List existing workspaces for a project.Parameters:
  • projectId - Project identifier
Returns: Array of WorkspaceInfo
(info: WorkspaceInfo, project: ProjectConfig) => Promise<void>
Optional: Run hooks after workspace creation (symlinks, installs, etc.).Parameters:
  • info - Created workspace info
  • project - Project configuration
(workspacePath: string) => Promise<boolean>
Optional: Check if a workspace exists and is a valid git repo.Parameters:
  • workspacePath - Path to check
Returns: true if workspace exists and is valid
(config: WorkspaceCreateConfig, workspacePath: string) => Promise<WorkspaceInfo>
Optional: Restore a workspace (e.g. recreate a worktree for an existing branch).Parameters:
  • config - Workspace creation config
  • workspacePath - Path where workspace should be restored
Returns: WorkspaceInfo for restored workspace

WorkspaceCreateConfig

string
required
Project identifier from orchestrator config
ProjectConfig
required
Full project configuration with repo, path, symlinks, postCreate commands
SessionId
required
Session identifier
string
required
Git branch name for this workspace

WorkspaceInfo

string
required
Absolute path to workspace directory
string
required
Git branch name
SessionId
required
Session identifier
string
required
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 .git in worktree mode)
  • Symlinks can share large files (node_modules, build artifacts)

Post-Creation Hooks

The postCreate() method should:
  1. Create symlinks specified in project config
  2. Run postCreate commands (npm install, copy configs, etc.)
  3. Handle errors gracefully (warn but don’t fail)

Restoration

The restore() 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)
Future plugins could support Docker volumes, remote filesystems, cloud storage, etc.

See Also

  • Session - Session interface
  • Agent - Agent plugin interface
  • Runtime - Runtime execution environment interface