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.
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:
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
repoIdwhen upserting an agent, camelRun provisions a dedicated repository on demand when the agent first uses file or bash tools, or when you callPUT /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 path | SDK method | Purpose |
|---|---|---|
POST /v2/repos | client.repos.create({ name? }) | Create a new repository ({ repoId, name, lineage, defaultRef, commit }) |
GET /v2/repos | client.repos.list() | List all repositories for the tenant |
GET /v2/repos/:repoId | client.repos.get(repoId) | Get repository metadata and current refs (including active leases) |
DELETE /v2/repos/:repoId | client.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/write | client.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/grep | client.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/restore | client.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:
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
expectedCommitto 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 matchingholderapply directly into the running VM's/workspaceand commit the updated tree. Writes from a different holder return409 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:
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 asteer) and an agent with a configured repository (400 invalid_attachments). - Each file is verified at its pinned
commitbefore 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 than3.75 MiB(up to32 MiB) are automatically scaled down to fit within1,568 pxper 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_fileorview_imagewith their pinnedcommit. - 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:
| Tool | Purpose |
|---|---|
read_file | Read a file from the repo (supports optional at ref/commit, offset, and limit) |
view_image | Inspect a PNG, JPEG, GIF, or WebP in the repo as a visual image (supports optional at ref/commit) |
write_file | Create or overwrite a file and commit it |
edit_file | Replace an exact string occurrence (oldString -> newString, optional replaceAll) |
list_files | List files and directories with optional path, recursive, and glob |
grep_files | Search repository files with a regular expression (pattern, pathPrefix, maxMatches) |
delete_file | Delete a file and commit the removal |
repo_checkpoint | Create a named checkpoint ref at the current branch head commit |
repo_restore | Restore the branch to a target commit SHA |
repo_history | List 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 (cwdand exported environment variables) persists acrossbashcalls 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
overlayfsat/workspace. - Atomic post-command commits: After every
bashcommand finishes,camelfsdscans only changed files in the overlay upperdir and commits them atomically back to the branch. Changed paths are reported inrun.filesChanged. - Metered execution: Active execution time is recorded in
run.usage.vmMsand billed at$0.05per 1,000 VM seconds. - Seamless coexistence: File tools (
write_file,edit_file,delete_file) andbashshare the same agent lease so they never conflict during a turn.