camelAI Documentation

Guides

Files, CamelFS repositories, and session VMs in camelRun v2

Store agent files in CamelFS Git-backed repositories (/v2/repos), attach pinned files to runs, and run persistent bash shells at /workspace.

View as Markdown

camelRun v2 replaces v1 mutable volumes and multi-path mounts (/v1/volumes, /v1/agents/:id/mounts) with CamelFS, a content-addressed Git-backed repository service at /v2/repos.

Every agent binds to a single repository (repoId) and branch (branch, default refs/heads/main), mounted at /workspace. Every file edit, API write, and bash command produces an immutable commit SHA-256, giving you full history, checkpoints, instant forking, and restore.

Create and bind a repository

Create a repository and attach it when upserting an agent:

ts
const repo = await client.repos.create({ name: "support-kb" });

await client.repos.write(repo.repoId, {
  message: "seed initial docs",
  puts: [
    { path: "README.md", content: "# Support Knowledge Base\n" },
    { path: "faq/billing.md", content: "Refunds are processed within 5 business days.\n" },
  ],
});

const agent = await client.agents.upsert("support-agent", {
  instructions: "Answer questions using the repository files in /workspace.",
  builtins: ["files", "bash"],
  repoId: repo.repoId,
  branch: "refs/heads/main",
});
  • If you omit repoId when upserting an agent, camelRun provisions a dedicated repository on demand when the agent first uses file or bash tools, or when you call PUT /v2/agents/:idOrKey/repo.
  • Each agent binds one (repoId, branch) pair. Forking an agent (POST /v2/agents/:idOrKey/fork) automatically forks its CamelFS lineage so both agents diverge independently while sharing content-addressed objects.

Repository API (/v2/repos)

All repository endpoints require a tenant API key (cr_live_...).

Method and pathSDK methodPurpose
POST /v2/reposclient.repos.create({ name? })Create a new repository ({ repoId, name, lineage, defaultRef, commit })
GET /v2/reposclient.repos.list()List all repositories for the tenant
GET /v2/repos/:repoIdclient.repos.get(repoId)Get repository metadata and current refs (including active leases)
DELETE /v2/repos/:repoIdclient.repos.delete(repoId)Stop active VMs on the repo and delete it
GET /v2/repos/:repoId/files?path=&at=&offset=&limit=client.repos.read(repoId, { path, at?, offset?, limit? })Read one file (UTF-8 content or base64 for binary files) at a ref or commit
GET /v2/repos/:repoId/read-all?at=&path=(REST)Read all files under an optional prefix at one consistent commit (up to 1,000 files and 16 MiB total)
POST /v2/repos/:repoId/writeclient.repos.write(repoId, input)Atomic multi-file puts, deletes, and moves producing a new commit
GET /v2/repos/:repoId/ls?at=&path=&recursive=&glob=client.repos.ls(repoId, opts)List files and directories (recursive=1 by default, pass recursive=0 for shallow)
POST /v2/repos/:repoId/grepclient.repos.grep(repoId, { pattern, at?, pathPrefix?, maxMatches? })Regex search across repository files
GET /v2/repos/:repoId/history?ref=&limit=client.repos.history(repoId, { ref?, limit? })List recent commits (commit, tree, parents, author, message, createdAt)
POST /v2/repos/:repoId/fork(REST)Fork a repository into a new independent repository ({ name?, sourceRef?, atCommit? })
POST /v2/repos/:repoId/restoreclient.repos.restore(repoId, { targetCommit, ref?, message? })Restore a branch to a previous commit SHA
PUT /v2/agents/:idOrKey/repo(REST)Ensure an agent has a provisioned repository and return { repoId, lineage, branch }

Atomic writes and optimistic concurrency

POST /v2/repos/:repoId/write commits multiple file puts, deletes, and moves in a single transaction:

ts
const write = await client.repos.write(repo.repoId, {
  ref: "refs/heads/main",
  expectedCommit: repo.commit, // optional compare-and-swap check
  author: "app:deploy",
  message: "update config and remove legacy file",
  puts: [
    { path: "config.json", content: JSON.stringify({ env: "prod" }, null, 2) },
    { path: "assets/logo.png", base64: pngBase64 },
  ],
  deletes: ["old-config.json"],
  moves: [{ from: "draft.md", to: "published.md" }],
});
console.log(write.commit, write.changed);
  • Pass expectedCommit to prevent conflicting overwrites (a mismatch returns a conflict error).
  • If an agent currently holds a live session VM lease on (lineage, ref), writes with the matching holder apply directly into the running VM's /workspace and commit the updated tree. Writes from a different holder return 409 ref_leased.

Attach files to a run

In camelRun v2, attachments are immutable references to files already committed to the agent's repository. Write the file first with repos.write, then pass its path, resulting commit SHA-256, and contentType in files:

ts
const written = await client.repos.write(agent.repoId!, {
  message: "attach screenshot",
  puts: [{ path: "uploads/error.png", base64: screenshotBase64 }],
});

const run = await agent.run("What is wrong in this screenshot?", {
  files: [
    {
      path: "uploads/error.png",
      commit: written.commit,
      contentType: "image/png",
    },
  ],
});

Attachment rules and limits:

  • Up to 20 files per run (413 attachment_count).
  • Attachments require whileRunning: "queue" (cannot be sent on a steer) and an agent with a configured repository (400 invalid_attachments).
  • Each file is verified at its pinned commit before the run starts. History retains the pinned (path, commit, contentType) reference so later overwrites or deletes never alter earlier turns.
  • Images (image/png, image/jpeg, image/gif, image/webp) are passed natively to vision-capable models. Images larger than 3.75 MiB (up to 32 MiB) are automatically scaled down to fit within 1,568 px per side for model input while the original bytes stay untouched in the repo.
  • Across a single model request, camelRun includes the newest images up to 40 images (90 for Anthropic) and 20 MiB of base64 payload. Older images beyond that budget remain readable by the agent using read_file or view_image with their pinned commit.
  • Non-image files are referenced in the prompt with their path, commit, media type, and byte size so the agent can inspect them with read_file.

Agent built-in file tools (builtins: ["files"])

Enabling the files built-in suite gives the agent direct Git-backed workspace tools without needing a VM:

ToolPurpose
read_fileRead a file from the repo (supports optional at ref/commit, offset, and limit)
view_imageInspect a PNG, JPEG, GIF, or WebP in the repo as a visual image (supports optional at ref/commit)
write_fileCreate or overwrite a file and commit it
edit_fileReplace an exact string occurrence (oldString -> newString, optional replaceAll)
list_filesList files and directories with optional path, recursive, and glob
grep_filesSearch repository files with a regular expression (pattern, pathPrefix, maxMatches)
delete_fileDelete a file and commit the removal
repo_checkpointCreate a named checkpoint ref at the current branch head commit
repo_restoreRestore the branch to a target commit SHA
repo_historyList recent commits on the current branch

Persistent bash session VMs (builtins: ["bash"])

Enabling the bash built-in suite gives the agent a persistent Linux session VM mounted over its repository at /workspace:

  • One VM per (lineage, ref): Shell state (cwd and exported environment variables) persists across bash calls during a session.
  • Lazy FUSE + OverlayFS: On Firecracker hosts, the VM boots with a read-only FUSE lowerdir that lazily fetches immutable blobs on demand under a writable overlayfs at /workspace.
  • Atomic post-command commits: After every bash command finishes, camelfsd scans only changed files in the overlay upperdir and commits them atomically back to the branch. Changed paths are reported in run.filesChanged.
  • Metered execution: Active execution time is recorded in run.usage.vmMs and billed at $0.05 per 1,000 VM seconds.
  • Seamless coexistence: File tools (write_file, edit_file, delete_file) and bash share the same agent lease so they never conflict during a turn.