openclaw - ✅(Solved) Fix [Feature]: Full Workspace File Management API for Remote/Container Deployments [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#61368Fetched 2026-04-08 02:59:24
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×1labeled ×1referenced ×1

As OpenClaw adoption grows in containerized and cloud-native environments, users increasingly need a way to manage agent workspace files without direct filesystem access. The current agents.files.* API restricts file operations to a predefined whitelist of bootstrap files (AGENTS.md, MEMORY.md, etc.), which prevents users from:

  • Uploading custom configuration files or knowledge bases
  • Organizing files in subdirectories
  • Downloading generated artifacts or logs
  • Managing dynamic file content in remote deployments

This feature request proposes a new agents.workspace.* API namespace that provides comprehensive file management capabilities while maintaining OpenClaw's security boundaries through the existing fs-safe.ts infrastructure.

Error Message

  • Error handling

Error Handling

Standardized error responses: | Error Code | Scenario | HTTP Status |

Root Cause

As OpenClaw adoption grows in containerized and cloud-native environments, users increasingly need a way to manage agent workspace files without direct filesystem access. The current agents.files.* API restricts file operations to a predefined whitelist of bootstrap files (AGENTS.md, MEMORY.md, etc.), which prevents users from:

  • Uploading custom configuration files or knowledge bases
  • Organizing files in subdirectories
  • Downloading generated artifacts or logs
  • Managing dynamic file content in remote deployments

This feature request proposes a new agents.workspace.* API namespace that provides comprehensive file management capabilities while maintaining OpenClaw's security boundaries through the existing fs-safe.ts infrastructure.

Fix Action

Fix / Workaround

ThreatMitigationRisk Level
Path TraversalresolvePinnedPathWithinRoot validationLow
Symlink Escapefs.realpath + boundary checkLow
Hardlink AttackReject files with nlink > 1Low
DoS (Large Files)Configurable size limitsLow
DoS (Deep Recursion)Directory depth limitsLow
Unauthorized AccessScope-based permissionsLow

Potential Risks and Mitigations

RiskLikelihoodImpactMitigation
Security vulnerabilityLowHighMultiple validation layers; fs-safe.ts battle-tested
Performance degradationLowMediumLimits prevent abuse; async operations
UI complexityMediumLowProgressive disclosure; simple default view
API confusionMediumLowClear naming; documentation; deprecation path for old API if needed
Maintenance burdenLowMediumClean architecture; comprehensive tests

PR fix notes

PR #62417: feat: add workspace file management for agents

Description (problem / solution / changelog)

Summary

  • Problem: Agents have workspace directories but no way to browse or manage files through the Control UI.
  • Why it matters: Users need to inspect, edit, and organize agent workspace files without SSH or CLI access.
  • What changed: Added agents.workspace.* gateway RPC methods (list, get, set, delete, mkdir, move, stat) and a Workspace tab in the agents panel with file browser, editor, and file operations.
  • What did NOT change (scope boundary): No changes to agent runtime behavior, plugin SDK, or existing file/config panels.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Closes #61368
  • This PR fixes a bug or regression

Root Cause (if applicable)

N/A

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: src/gateway/server-methods/agents-workspace.test.ts
  • Scenario the test should lock in: Path traversal rejection, CRUD operations, file size limits, error handling
  • Why this is the smallest reliable guardrail: Unit tests cover all API methods with mocked fs, validating security and correctness without requiring a running gateway
  • Existing test that already covers this (if any): None (new feature)
  • If no new test is added, why not: Tests are included

User-visible / Behavior Changes

  • New "Workspace" tab in the agents panel for browsing and managing agent workspace files
  • File browser with directory navigation, breadcrumbs, and sorting (directories first)
  • Inline file editor with dirty state tracking and save/delete actions
  • File upload, download, and mkdir operations
  • 10MB file size limit enforced server-side

Diagram (if applicable)

Before:
[user] -> [agents panel] -> [overview | files | tools | skills | channels | cron]

After:
[user] -> [agents panel] -> [overview | files | workspace | tools | skills | channels | cron]
                                          |
                                    [file tree] + [file editor]
                                          |
                              agents.workspace.* RPC -> fs-safe

Security Impact (required)

  • New permissions/capabilities? Yes - workspace file read/write through gateway RPC
  • Secrets/tokens handling changed? No
  • New/changed network calls? Yes - new agents.workspace.* RPC methods
  • Command/tool execution surface changed? No
  • Data access scope changed? Yes - workspace directory access scoped per agent
  • Risk + mitigation: All file operations use fs-safe helpers with path traversal protection. Relative paths are validated to reject .. and absolute paths. File size capped at 10MB. Operations are scoped to the resolved agent workspace directory.

Repro + Verification

Environment

  • OS: macOS
  • Runtime/container: Docker (openclaw-workspace-test:latest)
  • Model/provider: N/A (UI feature)
  • Integration/channel: N/A
  • Relevant config: Default gateway config with --allow-unconfigured --bind lan

Steps

  1. Start gateway with openclaw gateway --allow-unconfigured
  2. Open Control UI and navigate to an agent
  3. Click the "Workspace" tab
  4. Browse files, select a file to edit, modify content, click Save

Expected

  • File tree shows workspace contents with correct icons and sizes
  • Editing a file enables the Save button (dirty state)
  • Clicking Save persists changes and disables the button
  • Navigating away resets editor state

Actual

  • All operations work as expected

Evidence

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Unit tests: 40+ test cases covering security (path traversal), CRUD, edge cases, and error handling all pass.

Human Verification (required)

  • Verified scenarios: File browse, edit, save, delete, mkdir, navigate, upload via Docker container with mounted ~/.openclaw
  • Edge cases checked: Path traversal attempts, empty directories, large file rejection, file selection reset on navigate
  • What I did not verify: Base64 encoding upload through UI, symlink display

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? Yes
  • Config/env changes? No
  • Migration needed? No

Risks and Mitigations

  • Risk: New RPC surface increases attack surface for path traversal
    • Mitigation: All paths validated with validateRelativePath() rejecting .. and absolute paths, plus fs-safe helpers enforce root directory containment

Changed files

  • CHANGELOG.md (modified, +1/-0)
  • apps/macos/Sources/OpenClawProtocol/GatewayModels.swift (modified, +410/-0)
  • apps/shared/OpenClawKit/Sources/OpenClawProtocol/GatewayModels.swift (modified, +410/-0)
  • src/gateway/method-scopes.ts (modified, +7/-0)
  • src/gateway/protocol/index.ts (modified, +72/-0)
  • src/gateway/protocol/schema.ts (modified, +1/-0)
  • src/gateway/protocol/schema/agents-workspace.ts (added, +172/-0)
  • src/gateway/protocol/schema/protocol-schemas.ts (modified, +50/-0)
  • src/gateway/protocol/schema/types.ts (modified, +15/-0)
  • src/gateway/server-methods-list.ts (modified, +7/-0)
  • src/gateway/server-methods.ts (modified, +2/-0)
  • src/gateway/server-methods/agents-workspace.test.ts (added, +999/-0)
  • src/gateway/server-methods/agents-workspace.ts (added, +723/-0)
  • src/gateway/server-methods/agents.ts (modified, +4/-0)
  • ui/src/styles/components.css (modified, +292/-0)
  • ui/src/ui/app-render.ts (modified, +386/-0)
  • ui/src/ui/app-view-state.ts (modified, +9/-1)
  • ui/src/ui/app.ts (modified, +16/-1)
  • ui/src/ui/controllers/agent-workspace.ts (added, +193/-0)
  • ui/src/ui/controllers/agents.ts (modified, +1/-1)
  • ui/src/ui/types.ts (modified, +56/-0)
  • ui/src/ui/views/agents-panels-workspace.ts (added, +282/-0)
  • ui/src/ui/views/agents.test.ts (modified, +15/-0)
  • ui/src/ui/views/agents.ts (modified, +47/-2)

Code Example

// Request
{
  agentId: string;           // Target agent
  path?: string;             // Relative path (default: "")
  recursive?: boolean;       // Include subdirectories (default: false)
}

// Response
{
  agentId: string;
  workspace: string;         // Absolute workspace path
  path: string;              // Current relative path
  entries: Array<{
    name: string;
    path: string;            // Relative to workspace
    type: "file" | "directory" | "symlink";
    size?: number;           // Bytes (files only)
    updatedAtMs?: number;    // Modification time
    createdAtMs?: number;    // Creation time
  }>;
}

---

// Request
{
  agentId: string;
  path: string;              // Relative path to file
  encoding?: "utf8" | "base64";  // Default: "utf8"
}

// Response
{
  agentId: string;
  workspace: string;
  path: string;
  content: string;           // UTF-8 text or base64-encoded binary
  encoding: "utf8" | "base64";
  size: number;              // Actual file size in bytes
  updatedAtMs?: number;
}

---

// Request
{
  agentId: string;
  path: string;              // Relative path (parent dirs created if needed)
  content: string;           // UTF-8 text or base64-encoded binary
  encoding?: "utf8" | "base64";  // Default: "utf8"
  createDirs?: boolean;      // Auto-create parent directories (default: true)
}

// Response
{
  ok: true;
  agentId: string;
  path: string;
  size: number;
  updatedAtMs: number;
}

---

// Request
{
  agentId: string;
  path: string;              // Relative path to file or directory
  recursive?: boolean;       // Delete non-empty directories (default: false)
}

// Response
{
  ok: true;
  agentId: string;
  path: string;
  deleted: boolean;          // True if existed and was deleted
}

---

// Request
{
  agentId: string;
  path: string;              // Relative path to new directory
  parents?: boolean;         // Create parent directories if needed (default: true)
}

// Response
{
  ok: true;
  agentId: string;
  path: string;
  created: boolean;          // True if created, false if already existed
}

---

// Request
{
  agentId: string;
  from: string;              // Source relative path
  to: string;                // Destination relative path
  overwrite?: boolean;       // Overwrite if exists (default: false)
}

// Response
{
  ok: true;
  agentId: string;
  from: string;
  to: string;
}

---

// Request
{
  agentId: string;
  path: string;              // Relative path
}

// Response
{
  agentId: string;
  workspace: string;
  path: string;
  type: "file" | "directory" | "symlink";
  size?: number;             // Undefined for directories
  updatedAtMs?: number;
  createdAtMs?: number;
  isWritable: boolean;       // Current user has write permission
}

---

const resolved = await resolvePinnedPathWithinRoot({
  rootDir: workspaceDir,
  relativePath: userProvidedPath,
});
// Throws SafeOpenError if path escapes workspace

---

┌─────────────────────────────────────────────────────────┐
[New File] [New Folder] [Upload] [Download] [Refresh]├─────────────────────────────────────────────────────────┤
Workspace / agent-name / 📁 subdir / 📄 current-file    │
├────────────────────────┬────────────────────────────────┤
│ 📁 folder1             │ ┌────────────────────────────┐ │
│ 📁 folder2             │ │ File Editor / Preview      │ │
│   📄 nested.md         │ │                            │ │
│ 📄 file1.md            │ │ [Content area with syntax  │ │
│ 📄 file2.json          │ │  highlighting for code]    │ │
│ 📄 image.png           │ │                            │ │
│                        │ └────────────────────────────┘ │
│                        │ [Save] [Delete] [Rename]└────────────────────────┴────────────────────────────────┘

---

// A research skill that saves findings for later analysis
await saveToWorkspace('research/findings.json', JSON.stringify(results));

// A report skill that reads and compiles previous findings
const findings = await readFromWorkspace('research/findings.json');
RAW_BUFFERClick to expand / collapse

Summary

As OpenClaw adoption grows in containerized and cloud-native environments, users increasingly need a way to manage agent workspace files without direct filesystem access. The current agents.files.* API restricts file operations to a predefined whitelist of bootstrap files (AGENTS.md, MEMORY.md, etc.), which prevents users from:

  • Uploading custom configuration files or knowledge bases
  • Organizing files in subdirectories
  • Downloading generated artifacts or logs
  • Managing dynamic file content in remote deployments

This feature request proposes a new agents.workspace.* API namespace that provides comprehensive file management capabilities while maintaining OpenClaw's security boundaries through the existing fs-safe.ts infrastructure.

Problem to solve

Problem Statement

Many OpenClaw users deploy the gateway in containers or cloud environments where direct filesystem access to agent workspaces is difficult or impossible. Currently, the agents.files.* API only allows access to a hardcoded whitelist of files (AGENTS.md, MEMORY.md, etc.), which limits the ability to:

  • Upload custom configuration files
  • Manage subdirectories within workspaces
  • Download generated files (logs, exports, artifacts)
  • Organize files in a structured way

Use Cases

  1. Cloud Deployment: Users running OpenClaw on VPS/cloud need to upload/download files via Web UI instead of SSH/SCP
  2. Container Environments: Docker/Kubernetes deployments without host volume mounts need a way to manage files through the API
  3. Multi-agent File Sharing: Copy files between agent workspaces for shared knowledge or configurations
  4. Backup/Restore: Export and import entire workspace directories for migration or disaster recovery

Proposed Solution

Add a new agents.workspace.* API namespace with full file management capabilities:

MethodDescriptionScope
agents.workspace.listList directory contents (files + subdirectories)READ
agents.workspace.getRead file content (text or binary base64)READ
agents.workspace.setWrite file content (text or binary base64)ADMIN
agents.workspace.deleteDelete file or directoryADMIN
agents.workspace.mkdirCreate directoryADMIN
agents.workspace.moveMove/rename file or directoryADMIN
agents.workspace.statGet file/directory metadataREAD

Security Design

The implementation will leverage OpenClaw's existing security infrastructure:

  • Workspace Boundaries: All operations are restricted to the agent's workspace directory using resolveAgentWorkspaceDir
  • Path Validation: Uses fs-safe.ts infrastructure (resolvePinnedPathWithinRoot) to prevent path traversal attacks
  • Permission Control: Read operations require READ_SCOPE, write operations require ADMIN_SCOPE
  • Link Protection: Symbolic links and hardlinks are validated and rejected if they escape workspace boundaries
  • File Size Limits: Configurable limits (default 10MB) to prevent DoS via large file uploads

Web UI Enhancement

A new "Workspace Files" tab will be added to the Agents page in the Control UI:

  • File Tree Browser: Navigate directories with expandable folders
  • File Upload: Drag & drop support for uploading files
  • File Download: Download individual files or directories as zip
  • File Operations: Create new files/folders, delete, rename
  • Breadcrumb Navigation: Show current path with clickable parent directories
  • File Preview: Text editor for code/markdown files, image preview for common formats

Backward Compatibility

The existing agents.files.* API remains unchanged for accessing core bootstrap files (AGENTS.md, MEMORY.md, etc.). The new agents.workspace.* API provides additional capabilities for full filesystem access within workspace boundaries. Both APIs can coexist:

  • agents.files.* - Simple access to core agent files (backward compatible)
  • agents.workspace.* - Full filesystem management (new capability)

Implementation Plan

Phase 1: Protocol Schema

  • Define TypeBox schemas for all methods
  • Add validators to protocol index
  • Export types for client use

Phase 2: Gateway Implementation

  • Implement server method handlers
  • Register methods in server-methods-list
  • Configure permission scopes in method-scopes
  • Add comprehensive unit tests

Phase 3: Web UI

  • Create workspace file controller
  • Build file manager UI component
  • Integrate into Agents page
  • Add e2e tests

Phase 4: Documentation

  • API documentation
  • User guide for file manager
  • Security considerations doc

Questions for Maintainers

  1. Security Review: Is the proposed security model (using fs-safe.ts + scope-based permissions) aligned with OpenClaw's security architecture?

  2. File Restrictions: Should we enforce specific file type restrictions (e.g., block executable files) beyond the size limit?

  3. Audit Logging: Would you like audit logging for file operations (especially deletions and overwrites)?

  4. API Naming: Is agents.workspace.* the right namespace, or would you prefer something else?

  5. Scope Assignment: Should any write operations (like mkdir) be available with WRITE_SCOPE instead of requiring ADMIN_SCOPE?

  6. Binary Handling: Is base64 encoding acceptable for binary file transfer, or would you prefer a different approach?

Looking forward to feedback from the maintainers and community!

Proposed solution

API Design

Introduce seven new gateway methods under the agents.workspace namespace:

1. agents.workspace.list

List directory contents with file metadata.

Use case: Browse workspace structure, populate file tree UI.

// Request
{
  agentId: string;           // Target agent
  path?: string;             // Relative path (default: "")
  recursive?: boolean;       // Include subdirectories (default: false)
}

// Response
{
  agentId: string;
  workspace: string;         // Absolute workspace path
  path: string;              // Current relative path
  entries: Array<{
    name: string;
    path: string;            // Relative to workspace
    type: "file" | "directory" | "symlink";
    size?: number;           // Bytes (files only)
    updatedAtMs?: number;    // Modification time
    createdAtMs?: number;    // Creation time
  }>;
}

2. agents.workspace.get

Read file content with flexible encoding.

Use case: Load file for editing, download binary files.

// Request
{
  agentId: string;
  path: string;              // Relative path to file
  encoding?: "utf8" | "base64";  // Default: "utf8"
}

// Response
{
  agentId: string;
  workspace: string;
  path: string;
  content: string;           // UTF-8 text or base64-encoded binary
  encoding: "utf8" | "base64";
  size: number;              // Actual file size in bytes
  updatedAtMs?: number;
}

3. agents.workspace.set

Write or overwrite file content.

Use case: Save edited files, upload new content.

// Request
{
  agentId: string;
  path: string;              // Relative path (parent dirs created if needed)
  content: string;           // UTF-8 text or base64-encoded binary
  encoding?: "utf8" | "base64";  // Default: "utf8"
  createDirs?: boolean;      // Auto-create parent directories (default: true)
}

// Response
{
  ok: true;
  agentId: string;
  path: string;
  size: number;
  updatedAtMs: number;
}

4. agents.workspace.delete

Remove files or directories.

Use case: Clean up temporary files, remove obsolete data.

// Request
{
  agentId: string;
  path: string;              // Relative path to file or directory
  recursive?: boolean;       // Delete non-empty directories (default: false)
}

// Response
{
  ok: true;
  agentId: string;
  path: string;
  deleted: boolean;          // True if existed and was deleted
}

5. agents.workspace.mkdir

Create new directories.

Use case: Organize files into folders, create project structure.

// Request
{
  agentId: string;
  path: string;              // Relative path to new directory
  parents?: boolean;         // Create parent directories if needed (default: true)
}

// Response
{
  ok: true;
  agentId: string;
  path: string;
  created: boolean;          // True if created, false if already existed
}

6. agents.workspace.move

Move or rename files and directories.

Use case: Rename files, reorganize directory structure.

// Request
{
  agentId: string;
  from: string;              // Source relative path
  to: string;                // Destination relative path
  overwrite?: boolean;       // Overwrite if exists (default: false)
}

// Response
{
  ok: true;
  agentId: string;
  from: string;
  to: string;
}

7. agents.workspace.stat

Get file/directory metadata without reading content.

Use case: Check file existence, get size/timestamp info.

// Request
{
  agentId: string;
  path: string;              // Relative path
}

// Response
{
  agentId: string;
  workspace: string;
  path: string;
  type: "file" | "directory" | "symlink";
  size?: number;             // Undefined for directories
  updatedAtMs?: number;
  createdAtMs?: number;
  isWritable: boolean;       // Current user has write permission
}

Security Architecture

The implementation leverages OpenClaw's existing security infrastructure:

Path Safety

All file operations use the fs-safe.ts module which provides:

  • Path traversal prevention: Rejects paths containing .. or absolute paths
  • Workspace boundary enforcement: Validates resolved paths stay within resolveAgentWorkspaceDir
  • Symbolic link validation: Follows symlinks and verifies targets remain in workspace
  • Hardlink protection: Rejects files with nlink > 1

Example validation flow:

const resolved = await resolvePinnedPathWithinRoot({
  rootDir: workspaceDir,
  relativePath: userProvidedPath,
});
// Throws SafeOpenError if path escapes workspace

Permission Model

MethodRequired ScopeRationale
listREAD_SCOPEBrowse workspace structure
getREAD_SCOPERead file content
statREAD_SCOPECheck file metadata
setADMIN_SCOPEModify file content
deleteADMIN_SCOPEDestructive operation
mkdirADMIN_SCOPEModify workspace structure
moveADMIN_SCOPEModify workspace structure

Resource Limits

Default constraints (configurable):

  • Maximum file size: 10MB for uploads
  • Maximum directory depth: 10 levels for recursive operations
  • Maximum entries per list: 1000 files (pagination support for future)

Web UI Integration

A new "Workspace Files" tab will be added to the Agents page:

Layout

┌─────────────────────────────────────────────────────────┐
│ [New File] [New Folder] [Upload] [Download] [Refresh]   │
├─────────────────────────────────────────────────────────┤
│ Workspace / agent-name / 📁 subdir / 📄 current-file    │
├────────────────────────┬────────────────────────────────┤
│ 📁 folder1             │ ┌────────────────────────────┐ │
│ 📁 folder2             │ │ File Editor / Preview      │ │
│   📄 nested.md         │ │                            │ │
│ 📄 file1.md            │ │ [Content area with syntax  │ │
│ 📄 file2.json          │ │  highlighting for code]    │ │
│ 📄 image.png           │ │                            │ │
│                        │ └────────────────────────────┘ │
│                        │ [Save] [Delete] [Rename]       │
└────────────────────────┴────────────────────────────────┘

Features

  • Tree Navigation: Expandable folder tree with lazy loading
  • Breadcrumb Path: Clickable navigation to parent directories
  • Drag & Drop Upload: Drop files from desktop to upload
  • Context Menu: Right-click for file operations (rename, delete, download)
  • Keyboard Shortcuts: F2 (rename), Delete, Ctrl+S (save)
  • File Preview:
    • Text editor with syntax highlighting for code/markdown
    • Image preview for PNG/JPG/GIF/SVG
    • Download button for binary files

Backward Compatibility

The existing agents.files.* API remains fully functional and unchanged:

  • agents.files.list - Continues to show whitelist files (AGENTS.md, MEMORY.md, etc.)
  • agents.files.get - Continues to read whitelist files
  • agents.files.set - Continues to write whitelist files

The new agents.workspace.* API operates independently:

  • No changes to existing API behavior
  • No migration required
  • Both APIs can be used simultaneously
  • Existing scripts and integrations continue to work

Implementation Phases

Phase 1: Protocol Schema (2-3 days)

  • Define TypeBox schemas for all methods
  • Add validators to src/gateway/protocol/index.ts
  • Export types for TypeScript clients
  • Add method names to src/gateway/server-methods-list.ts
  • Configure scopes in src/gateway/method-scopes.ts

Phase 2: Gateway Implementation (5-7 days)

  • Implement handlers in src/gateway/server-methods/agents-workspace.ts
  • Use fs-safe.ts utilities for all file operations
  • Add comprehensive unit tests covering:
    • Normal operations
    • Path traversal attacks
    • Symbolic link edge cases
    • Permission checks
    • Error handling

Phase 3: Web UI (5-7 days)

  • Create ui/src/ui/controllers/agent-workspace.ts
  • Build ui/src/ui/views/agents-panels-workspace.ts
  • Integrate into Agents page tab navigation
  • Add e2e tests for file manager workflows

Phase 4: Documentation (2-3 days)

  • API documentation in docs/gateway/workspace-api.md
  • User guide for file manager UI
  • Security considerations document
  • Update changelog

Error Handling

Standardized error responses:

Error CodeScenarioHTTP Status
INVALID_REQUESTPath traversal attempt, invalid parameters400
NOT_FOUNDFile/directory doesn't exist404
FORBIDDENInsufficient scope/permissions403
PAYLOAD_TOO_LARGEFile exceeds size limit413
ALREADY_EXISTSDestination exists (move without overwrite)409
NOT_EMPTYDirectory not empty (delete without recursive)409

Open Questions for Maintainers

  1. Scope Assignment: Should mkdir require ADMIN_SCOPE, or would WRITE_SCOPE be sufficient for directory creation?

  2. Binary Transfer: Is base64 encoding acceptable for binary files, or should we consider alternative approaches like multipart/form-data for uploads?

  3. Audit Logging: Should file operations (especially deletions) be logged for security auditing?

  4. File Type Restrictions: Beyond size limits, should we block specific file types (executables, scripts) from upload?

  5. Batch Operations: Should we support batch operations (delete multiple files, upload multiple files) in the initial implementation or as a future enhancement?

Alternatives considered

No response

Impact

Overview

This feature significantly expands OpenClaw's deployment flexibility and user experience, particularly for production and enterprise use cases. Below is a comprehensive analysis of the impact across multiple dimensions.


User Impact

Who Benefits

User SegmentCurrent Pain PointHow This Helps
Cloud DeployersMust use SSH/SCP or volume mounts to manage filesDirect file management through Web UI
Docker/K8s UsersDifficult to persist and manage workspace dataAPI-first file operations
Multi-Agent UsersNo easy way to share files between agentsCopy/move files via API
Non-Technical UsersRequires command line for file operationsIntuitive drag-and-drop UI
Enterprise AdminsNo audit trail for file changesStructured API with logging potential

Use Cases Enabled

1. Cloud-Native Deployments

Before: Deploy OpenClaw on VPS → SSH into server → Use vim/nano to edit files → Restart services

After: Open Web UI → Navigate to Workspace Files → Edit directly in browser → Changes apply immediately

Impact: Reduces file management time from minutes to seconds; no SSH knowledge required.

2. Knowledge Base Management

Before: Limited to AGENTS.md and MEMORY.md; large knowledge bases must be external

After: Create knowledge/ subdirectory → Upload multiple markdown files → Agent can reference organized documentation

Impact: Enables sophisticated knowledge organization for complex domains.

3. Multi-Agent Collaboration

Before: Each agent isolated; sharing requires manual file copying

After: Agent A generates report → Save to shared workspace → Agent B reads and processes

Impact: Enables agent workflows and specialization (researcher → writer → reviewer).

4. Backup and Migration

Before: Must tar.gz workspace directories manually

After: Download entire workspace as zip → Upload to new instance → Done

Impact: Simplifies disaster recovery and environment migration.


Technical Impact

Architecture Alignment

AspectCurrent StateWith This FeatureAssessment
API Surfaceagents.files.* (3 methods)Adds agents.workspace.* (7 methods)Clean separation of concerns
Security ModelWhitelist-basedPath-based with fs-safe validationMore flexible, equally secure
Permission SystemREAD/ADMIN scopesSame scopes, finer granularityNo changes needed
Web UICore files onlyFull file managerSignificant UX improvement

Performance Considerations

Resource Usage

  • Memory: Minimal increase; file operations are streaming where possible
  • CPU: Path validation adds ~1-2ms per operation (negligible)
  • Storage: No change; uses existing workspace directories
  • Network: Base64 encoding adds ~33% overhead for binary transfers

Scalability

  • Concurrent Operations: Handled by Node.js event loop; no blocking
  • Large Files: 10MB default limit prevents memory issues
  • Deep Directories: 10-level depth limit prevents recursion issues
  • Rate Limiting: Can leverage existing gateway rate limiting

Security Impact

Attack Surface Analysis

ThreatMitigationRisk Level
Path TraversalresolvePinnedPathWithinRoot validationLow
Symlink Escapefs.realpath + boundary checkLow
Hardlink AttackReject files with nlink > 1Low
DoS (Large Files)Configurable size limitsLow
DoS (Deep Recursion)Directory depth limitsLow
Unauthorized AccessScope-based permissionsLow

Security Benefits

  • Audit Trail: API operations can be logged (future enhancement)
  • No Shell Access: File operations don't require system shell
  • Workspace Isolation: Agents cannot access each other's files
  • Input Validation: Strict schema validation on all inputs

Ecosystem Impact

Integration Possibilities

Third-Party Tools

  • VS Code Extension: Edit agent files directly in IDE
  • Obsidian Plugin: Sync knowledge base with agent workspace
  • CI/CD Pipelines: Deploy configurations to agents automatically
  • Backup Services: Automated workspace backup to S3/cloud storage

Skill Development

Skills can now:

  • Generate and save artifacts (reports, exports, summaries)
  • Read configuration from JSON/YAML files
  • Maintain persistent state across sessions
  • Share data between different skill invocations

Example skill use case:

// A research skill that saves findings for later analysis
await saveToWorkspace('research/findings.json', JSON.stringify(results));

// A report skill that reads and compiles previous findings
const findings = await readFromWorkspace('research/findings.json');

Community Impact

Contribution Opportunities

  • UI Improvements: File manager can be enhanced with themes, plugins
  • New Skills: File-based skills become possible
  • Documentation: Community can share workspace templates
  • Tooling: CLI tools, desktop apps can use the API

Learning Curve

  • Beginners: Easier to get started (no SSH needed)
  • Advanced Users: More powerful automation possibilities
  • Enterprise: Better fits existing security/audit requirements

Business Impact

Adoption Enablers

BarrierHow This Addresses It
"Too complex for non-technical users"Web UI makes it accessible
"Hard to manage in production"API enables automation
"Difficult to backup/restore"One-click download/upload
"Can't share configurations"File sharing between agents

Cost Implications

Infrastructure

  • No additional costs: Uses existing workspace storage
  • Optional: Can integrate with S3/MinIO for larger storage (future)

Operational

  • Reduced support burden: Self-service file management
  • Faster onboarding: New users don't need SSH training
  • Easier debugging: Download logs and state files directly

Migration and Compatibility

Backward Compatibility

100% Backward Compatible

  • Existing agents.files.* API unchanged
  • All existing scripts continue to work
  • No configuration changes required
  • No database migrations needed

Upgrade Path

ScenarioAction Required
Existing UsersNone; feature is additive
New InstallationsFull feature available immediately
Custom FrontendsCan optionally adopt new API
SkillsCan optionally use file operations

Risk Assessment

Potential Risks and Mitigations

RiskLikelihoodImpactMitigation
Security vulnerabilityLowHighMultiple validation layers; fs-safe.ts battle-tested
Performance degradationLowMediumLimits prevent abuse; async operations
UI complexityMediumLowProgressive disclosure; simple default view
API confusionMediumLowClear naming; documentation; deprecation path for old API if needed
Maintenance burdenLowMediumClean architecture; comprehensive tests

Fallback Strategy

If critical issues are discovered:

  1. Disable via config: Add features.workspaceFiles: false option
  2. Scope restriction: Require stricter scopes temporarily
  3. Rate limiting: Aggressive limits to reduce impact
  4. Full rollback: Remove endpoints without affecting existing functionality

Success Metrics

Quantitative

MetricTargetMeasurement
API Usage>50% of deployments use within 3 monthsGateway telemetry
UI Adoption>70% of Web UI users try the featureAnalytics
Issue Reports<5 security-related issues in first 6 monthsGitHub issues
Performance<100ms p99 response time for list operationsMetrics

Qualitative

  • User Feedback: Positive mentions in Discord/community
  • Documentation: Reduced "how to manage files" questions
  • Adoption: More cloud/container deployment success stories
  • Contributions: Community contributions to file manager UI

Long-Term Vision

Phase 2 Possibilities

  1. Remote Storage: S3, GCS, Azure Blob integration for unlimited storage
  2. Version Control: Git integration for workspace versioning
  3. Collaboration: Real-time collaborative editing
  4. Templates: Pre-built workspace templates for common use cases
  5. Sync: Desktop sync client for local file editing

Alignment with Project Goals

OpenClaw VisionThis Feature Contribution
"AI for everyone"Makes deployment accessible to non-technical users
"Production-ready"Enables enterprise deployment patterns
"Extensible platform"Provides foundation for file-based skills and tools
"Community-driven"Creates new contribution opportunities

Conclusion

This feature addresses a critical gap in OpenClaw's deployment story while maintaining the project's high security standards. The impact is:

  • Immediate: Better UX for existing users
  • Short-term: Enables new deployment patterns
  • Long-term: Foundation for advanced features

The implementation is low-risk due to:

  • Use of proven security infrastructure (fs-safe.ts)
  • Additive-only changes (no breaking changes)
  • Comprehensive test coverage
  • Clear rollback path

Recommendation: Proceed with implementation.

Evidence/examples

No response

Additional information

No response

extent analysis

TL;DR

Implement a new agents.workspace.* API namespace with comprehensive file management capabilities while maintaining OpenClaw's security boundaries.

Guidance

  1. Define API Endpoints: Establish clear, well-documented endpoints for file management, such as agents.workspace.list, agents.workspace.get, agents.workspace.set, etc.
  2. Implement Security Measures: Leverage fs-safe.ts for path validation and enforce scope-based permissions to ensure secure file operations.
  3. Develop Web UI Integration: Create an intuitive file manager UI component within the Agents page, including features like drag-and-drop upload, file preview, and context menus.
  4. Conduct Thorough Testing: Perform unit tests, integration tests, and e2e tests to validate the functionality, security, and performance of the new API and UI components.

Example

// Example of a secure file upload operation
const uploadFile = async (agentId: string, filePath: string, fileContent: string) => {
  try {
    const response = await agents.workspace.set({
      agentId,
      path: filePath,
      content: fileContent,
      encoding: 'utf8',
    });
    console.log(`File uploaded successfully: ${response.path}`);
  } catch (error) {
    console.error(`Error uploading file: ${error.message}`);
  }
};

Notes

  • The implementation should prioritize backward compatibility, ensuring the existing agents.files.* API remains unchanged and functional.
  • Considerations for file type restrictions, audit logging, and binary transfer methods should be addressed based on community feedback and security reviews.
  • A phased implementation approach (Protocol Schema, Gateway Implementation, Web UI, Documentation) can help manage complexity and ensure a smooth rollout.

Recommendation

Apply the proposed solution by implementing the agents.workspace.* API and integrating it with the Web UI, as it addresses critical user needs and aligns with OpenClaw's security and extensibility goals.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING