Self-improving AI Employees for everyone
Python ai-agentsai-employeeai-employeesassistantautonomous-agentsco-employeescompanygrok-botinstinctloop-agentsmuseown-your-datapersonalself-hosted
docs: add workspace directory and backend documentation
trohitg836e051d18ce
diff --git a/CLAUDE.md b/CLAUDE.mdindex 363171b3..4e0b9126 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -1734,6 +1734,33 @@ Console logs are persisted to SQLite database and loaded on page refresh.| `server/core/database.py` | Chat message and console log CRUD methods || `server/routers/websocket.py` | WebSocket handlers for chat and console operations |+### Per-Workflow Workspace Directory+Each workflow execution gets a persistent workspace directory where nodes save output files and AI agents (especially Deep Agent) access them via filesystem tools.++**Directory**: `data/workspaces/<workflow_id>/`++**Configuration** (`server/core/config.py`):+```python+workspace_base_dir: str = Field(default="data/workspaces", env="WORKSPACE_BASE_DIR")+```++**How it works:**+- `workflow.py` creates the workspace dir and injects `workspace_dir` into the execution context+- `fileDownloader` saves to `{workspace_dir}/downloads/` by default+- Code executors (Python/JS/TS) receive `workspace_dir` in their execution namespace+- Deep Agent uses `FilesystemBackend(root_dir=workspace_dir, virtual_mode=True)` -- its filesystem tools (`read_file`, `write_file`, `edit_file`, `ls`, `glob`, `grep`) operate within the workspace+- `virtual_mode=True` sandboxes paths to prevent traversal outside workspace++**Key Files:**+| File | Description |+|------|-------------|+| `server/core/config.py` | `workspace_base_dir` setting |+| `server/services/workflow.py` | `_get_workspace_dir()`, injects into context |+| `server/services/agents/service.py` | `FilesystemBackend(root_dir=workspace_dir, virtual_mode=True)` |+| `server/services/handlers/deep_agent.py` | Passes `workspace_dir` from context to service |+| `server/services/handlers/document.py` | `fileDownloader` uses workspace for downloads |+| `server/services/handlers/code.py` | `workspace_dir` available in Python/JS/TS execution |+### Execution System- **Supported Components**: AI models, location services, Android automation, WhatsApp messaging, HTTP requests, webhooks- **Android Integration**: ADB-based device control with 17 service nodes across monitoring, apps, automation, sensors, and mediadiff --git a/docs-internal/DESIGN.md b/docs-internal/DESIGN.mdindex 054423cb..a6eb6839 100644--- a/docs-internal/DESIGN.md+++ b/docs-internal/DESIGN.md@@ -452,6 +452,9 @@ class ExecutionContext:nodes: List[Dict] # Node definitionsedges: List[Dict] # Edge definitions+ # Workspace (per-workflow filesystem for nodes and agents)+ workspace_dir: str # Absolute path to data/workspaces/<workflow_id>/+# Execution Progressexecution_order: List[List[str]] # Computed layerscurrent_layer: int # Current layer indexdiff --git a/docs-internal/deep_agent.md b/docs-internal/deep_agent.mdindex 78702735..2ac67f50 100644--- a/docs-internal/deep_agent.md+++ b/docs-internal/deep_agent.md@@ -117,10 +117,15 @@ agent = create_deep_agent(subagents=None, # Sequence[SubAgent | CompiledSubAgent | AsyncSubAgent]skills=None, # list[str] (paths to skill dirs)memory=None, # list[str] (paths to AGENTS.md files)+ response_format=None, # ResponseFormat | type | dict+ context_schema=None, # type[ContextT]+ checkpointer=None, # Checkpointer+ store=None, # BaseStorebackend=None, # BackendProtocol | BackendFactoryinterrupt_on=None, # dict[str, bool | InterruptOnConfig]debug=False, # boolname=None, # str+ cache=None, # BaseCache)```@@ -155,6 +160,34 @@ Returns a **`CompiledStateGraph`** -- a compiled LangGraph graph compatible withCustom tools passed via `tools=` parameter are added alongside (not replacing) the built-in tools. deepagents uses LangGraph's `ToolNode` which calls `tool.ainvoke()` directly -- tools must have real executor functions.+### Backends++Backends control where filesystem tools operate. MachinaOs uses `FilesystemBackend` with `virtual_mode=True` pointed at a per-workflow workspace directory.++| Backend | Description |+|---------|-------------|+| `StateBackend` | Default. Ephemeral files in LangGraph state (in-memory) |+| `FilesystemBackend` | Direct local filesystem under `root_dir`. `virtual_mode=True` sandboxes paths |+| `LocalShellBackend` | Extends FilesystemBackend with `execute` tool (unrestricted shell) |+| `StoreBackend` | Persistent cross-thread storage via LangGraph BaseStore |+| `CompositeBackend` | Route paths to different backends by prefix |++**MachinaOs configuration** (in `services/agents/service.py`):+```python+from deepagents.backends import FilesystemBackend++workspace_dir = parameters.get('workspace_dir') # From execution context+backend = FilesystemBackend(root_dir=workspace_dir, virtual_mode=True)++agent = create_deep_agent(+ model=chat_model,+ backend=backend,+ ...+)+```++The workspace directory is created per workflow at `data/workspaces/<workflow_id>/`. Nodes (fileDownloader, code executors) save output files there, and the Deep Agent's filesystem tools operate within it. `virtual_mode=True` prevents path traversal outside the workspace.+### Sub-Agent Types| Type | Description |