Workspace

Files & Sandbox

Work with Space files under /workspace, run commands in cloud Sandboxes, configure images, compute specs, hibernation, and .cohub/setup.sh, and preview ports.

This page explains how to manage persistent Space files under /workspace, run shell commands in the Space's cloud Sandbox, configure images, compute specs, hibernation, and .cohub/setup.sh startup scripts, preview listening ports, and handle Local Runtime boundaries.

Workspace files (/workspace)

Files under /workspace are the durable state of a Space. They are shared by you, every Chat in the Space, and published Apps, and they persist across cloud Sandbox hibernation and restarts.

  • Web: Browse the directory tree, open and edit text files, upload local files or directories, create folders, move or delete paths, and review pending changes against the latest Save.
  • CLI (cohub spaces files): Paths resolve relative to the current directory when it is inside the Space workspace (/workspace in its Sandbox or a bound Local Runtime folder); an omitted path means the Space root. Output paths (such as ls --json) are relative to the Space root.
cohub -s <space> spaces files ls [path] [--json]
cohub -s <space> spaces files cat <paths...> [--json]
cohub -s <space> spaces files cp [-r] [-n] [-p] [--json] <src...> <dst>
cohub -s <space> spaces files write <path> -c "hello" [-e utf-8|base64]
cohub -s <space> spaces files write <path> < ./local-file.txt
cohub -s <space> spaces files upload <paths...> [--dir <path>] [--json]
cohub -s <space> spaces files mkdir <path>
cohub -s <space> spaces files rm <path> [-r]
cohub -s <space> spaces files mv <from> <to>
cohub -s <space> spaces files diff [path] [--json]

Key transfer and write behaviors:

  • write stdin behavior: When -c / --content is omitted and stdin is not a TTY, cohub spaces files write <path> reads content from stdin (for example < file or a pipe). There is no --stdin flag.
  • cat binary safety: cat streams raw bytes when redirected (cohub spaces files cat assets/logo.png > logo.png) and refuses to dump binary files directly to an interactive TTY. It also accepts cross-Space paths (<space>:<path>).
  • cp across Spaces and local disk: Works like scp. <space>:<path> addresses a Space by ID, username/slug, or owned Space slug (use ./name if a local path contains :). Bare paths target the current Space when -s or COHUB_SPACE_ID is set, and local disk otherwise; absolute paths outside /workspace are always local. Use -r for directories, -n (--no-clobber) to avoid overwriting, and -p (--preserve) to preserve timestamps (not kept by uploads).
  • No stat or download subcommands: Use ls --json for entry metadata (name, type, size, mtimeMs) and cat ... > <file> or cp to download files.

Directory listing and file monitoring

  • Directory listing pagination: The /fs/tree API supports pagination=true, limit from 1 to 5000 (default 1000), and an opaque cursor, returning nextCursor and truncated. Follow nextCursor rather than entry counts because visibility filtering can produce an empty page that still has more entries. CLI spaces files ls and default SDK files.list() collect all pages automatically and fail the entire call if a later page fails rather than returning a partial result.
  • File monitoring: The file watcher emits cache-invalidation hints only and never modifies files; filesystem RPC remains authoritative. Native recursive watchers run on macOS (FSEvents), Windows (ReadDirectoryChangesW on one root handle), and Linux (inotify/fsnotify), with a 5-second polling scan fallback (up to 250,000 entries, selectable via COHUB_FILEWATCH_BACKEND=auto|fsevents|readdcw|fsnotify|scan). Temporary .cohub-upload.* staging entries and special nodes (sockets, FIFOs, device nodes) are ignored. Health is reported in RuntimeStatus.fileWatcher with a 60-second TTL; missing or expired telemetry means unknown, not healthy.

Running commands (cohub run)

Use cohub run to execute a shell command inside a Space's /workspace without opening an interactive Chat turn:

cohub run -s <space> -- npm test
cohub run -s <space> -c "pnpm build && ls -la dist"
cohub run -s <space> --async --json -- ./scripts/build.sh

Verified flags: -s / --space <space>, --base-url <url>, -c / --command <cmd>, --async, and --json.

  • By default, cohub run waits for the command to finish (up to 6 hours + 60 seconds, polling every 1500 ms) and prints output and exit code.
  • Pass --async to submit the command and return immediately with its taskRunId.
  • With --json, the completed result includes exitCode, durationMs, output, truncated, and termination metadata.

Cloud Sandbox

Each cloud Space runs in an isolated Sandbox container. Open Space settings → Sandbox (/spaces/:id/settings#sandbox) in the web UI, or manage Sandbox settings from the CLI via cohub spaces config and cohub spaces setup (there is no cohub spaces sandbox command).

Lifecycle states reported for a Sandbox are pending, provisioning, ready, running, stopping, stopped, error, and terminated; stop reasons are idle, manual, replaced, cleanup, and disconnected.

Compute specs

Change compute under Space settings → Sandbox → Compute spec or via cohub spaces config <space> --spec <standard|boost|ultra|auto>:

Spec Label Resource limits Plan requirement
standard Standard 2 vCPU · 4Gi memory All plans (default)
boost Boost 4 vCPU · 8Gi memory Pro
ultra Ultra 4 vCPU · 12Gi memory Max
  • Explicit compute changes resize a running cloud Sandbox in place when the image is unchanged.
  • Pass --spec auto (or clear the override in the UI) to inherit from .cohub/sandbox.json and enabled Mods again. Explicit standard overrides inheritance.
  • If a config file requests a spec above the Space owner's plan, compute is capped to the entitled tier while keeping the original requested preference visible.

Sandbox images

Select an image under Space settings → Sandbox → Image or via cohub spaces config <space> --image <default|game|auto>:

Image UI label Included tools
default General development Standard language runtimes, NumPy, Chrome, Xvfb, FFmpeg, build tools, OpenGL/EGL loader libraries
game Game development · CPU Everything in default, plus Godot 4.5.2, Blender, Mesa software rendering, Vulkan diagnostics, SDL dev libraries, CMake, Ninja, and a 256 MiB memory-backed /dev/shm (counted against container memory)
  • Neither image attaches a GPU. In game, prefer Godot's Compatibility renderer, and for Blender Cycles CPU rendering set scene.cycles.device = 'CPU' and scene.cycles.use_denoising = False (OpenImageDenoise is not bundled).
  • Godot export templates, Android SDK, .NET, Unity, and Unreal are not bundled; install project dependencies into persistent /workspace directories.
  • Switching images requires a Sandbox restart; workspace and asset volumes are preserved.

.cohub/sandbox.json and precedence

A project or Mod can declare default Sandbox preferences in .cohub/sandbox.json (valid JSON, at most 16 KiB, inside the workspace):

{
  "version": 1,
  "image": "game",
  "spec": "boost"
}

Both image and spec are optional; only default/game and standard/boost/ultra are accepted. Arbitrary image references, commands, environment variables, mounts, and privileges are rejected.

Preferences merge per field from lowest to highest priority:

  1. Platform defaults (default, standard)
  2. Enabled Mods (in sort order; later Mods override earlier Mods)
  3. Project .cohub/sandbox.json
  4. Explicit Space settings (Space settings → Sandbox or cohub spaces config)

Important behavior:

  • Mods require a Save: Mod .cohub/sandbox.json files are read from each Mod Space's published head Save (checkpoint), not its unsaved working directory. Save the Mod Space before expecting downstream Spaces to inherit the preference.
  • No automatic restart on file edit: Editing .cohub/sandbox.json or saving a Mod marks Restart to apply on a running Sandbox; changes apply on the next create, resume, or manual restart.

Hibernation, storage, and restart

  • Hibernation: Configure under Space settings → Sandbox → Hibernation or via cohub spaces config <space> --auto-destroy <idle|never> --idle-ttl <seconds>. UI presets are 5 min, 15 min, 1 h (production default: 3600 s), 6 h, 24 h, and Never. The CLI accepts --idle-ttl up to 2592000 seconds (30 days).
  • Workspace storage: Space settings → Sandbox → Workspace storage displays measured /workspace usage and measurement age. Files written outside /workspace (in the container's writable layer) are temporary and disappear when the Sandbox is replaced.
  • Restart sandbox: Click Restart sandbox in Space settings → Sandbox to recreate the container. Running processes and active Agent turns stop immediately, while /workspace files are kept.

Startup scripts (.cohub/setup.sh)

Cloud Sandboxes automatically discover and run .cohub/setup.sh after workspace bootstrap (space.meta.bootstrap reaches ready). Legacy .agents/setup.sh files are not executed and have no fallback or automatic migration.

Discovery and execution order

Each new cloud Sandbox process runs existing scripts serially with Bash (no executable bit required), with $WORKSPACE_DIR as the working directory:

  1. /configs/user/.cohub/setup.sh — projected read-only from your Home Space's .cohub/setup.sh after you Save Home Space (no other user .cohub/ files or credentials are mounted)
  2. /mods/<slug>/.cohub/setup.sh — enabled Mods in sort order
  3. /workspace/.cohub/setup.sh — the Space's own setup script

Each script runs in a separate process (export does not carry over to later scripts or the Sandbox environment). COHUB_SETUP_DIR points to the current script's directory and WORKSPACE_DIR points to the host workspace:

#!/usr/bin/env bash
set -euo pipefail
cd "$WORKSPACE_DIR"
pnpm install --frozen-lockfile

Semantics, status, and logs

  • Idempotent per Sandbox process: Setup runs once when a Sandbox process starts (browser refreshes and WebSocket reconnects do not rerun it) and runs again on Sandbox restart or recreation. Write scripts to be idempotent without overwriting user data.
  • Timeouts and failures: Each script has a 5-minute timeout and must exit (setup is not a service supervisor; do not background long-running servers here). If a step fails, subsequent scripts stop and the Sandbox enters degraded status while keeping files and repair commands accessible. Agent turns wait while setup is pending.
  • Inspecting results: View step status in Space settings → Sandbox → Startup scripts, or run:
cohub -s <space> spaces setup [space] [--json]

Full step logs are streamed to .cohub/system/setup/<run-id>/<step-number>/ (stdout.log, stderr.log, result.json). These logs persist on disk (counting toward workspace storage) and are excluded from Saves by the .cohub/system/ hard exclusion.

Ports and live preview

When a process inside the Sandbox listens on a port, Cohub surfaces it in the Ports panel with live status (Listening, Closed, or Detecting).

From a port preview you can:

  • Refresh preview once a dev server restarts (closed port previews stay open so you can refresh after recovery)
  • Open externally in a new tab if the app loads slowly or sends headers that block iframe embedding
  • Copy URL to inspect the preview link directly
  • Publish app to publish the running port as an App

Static HTML files can be previewed and published directly from the file tree without keeping a server process running.

Local Runtime and Displays

  • Local Runtime: A Space can connect to a local folder on your machine instead of a cloud Sandbox (see Local Runtime). Cloud environment preferences (.cohub/sandbox.json, image, and compute spec) do not change a local Sandbox, and Local Spaces never run .cohub/setup.sh automatically (including user and Mod scripts). If the local workspace root folder is moved or replaced, file monitoring enters degraded state and requires restarting the Local Runtime to bind the new root.
  • Displays: Spaces that expose virtual or attached graphical displays can be inspected via cohub -s <space> spaces displays (see Displays & Screens); standard web and CLI development uses port previews and cohub run.

Boundaries and common failures

  • No --stdin flag on files write: Passing --stdin fails as an unknown option. Omit -c and pipe or redirect input directly (cohub -s <space> spaces files write path < file).
  • No cohub spaces sandbox command: Use cohub spaces config <space> to configure image, compute spec, or hibernation, and cohub spaces setup [space] to inspect startup script runs.
  • Lost packages after Sandbox restart: Packages installed globally outside /workspace live in the container's temporary writable layer and are lost on replacement. Keep dependencies in /workspace or reinstall them via .cohub/setup.sh.
  • Invalid .cohub/sandbox.json blocks restart: Syntax or schema errors appear in Space settings → Sandbox and prevent provisioning a replacement Sandbox unless you fix the file or explicitly override both image and spec.
  • Startup script trust and limits: .cohub/setup.sh runs as the Sandbox user and can modify /workspace, including scripts from mounted Mods (even though /mods/<slug> itself is read-only). Only import trusted repositories and mount trusted Mods. Legacy .agents/setup.sh is ignored.
  • Unsaved Mod preferences: Editing .cohub/sandbox.json inside a Mod Space does not take effect until you create a Save in that Mod Space.

Next steps

  • Saves — capture immutable workspace snapshots, inspect diffs, and fork Spaces
  • Spaces — configure Space settings, Home Space, and mounted Mods
  • Chats — collaborate with Agents inside the same workspace
  • Local Runtime — bind a local directory and sync local harnesses
  • Displays & Screens — capture, inspect, and interact with shared screens
  • Apps — publish a file, static directory, or listening port as an App
  • CLI — full command reference and target-Space resolution