Mounts
Mount shared folders into your users’ terminals and decide which changes agents may make to them.
What a mount is#
A mount is a folder of files and subfolders that Smallworld stores and mounts into the terminal at a path inside /workspace, such as /workspace/docs. Every command of a user who gets the mount sees it there, in every World. A session gets the global mounts, the mounts of the group it acts for, and the user's own. Each mount has one scope:
global: every user in the workspace.group: every member of one group, in their sessions for that group. Two groups that each need/workspace/docsget two mounts with separate files, also when a user belongs to both.user: one user.
Mount files aren't session files: they don't count toward the session's limits and never appear in fileChanges. Smallworld keeps only a mount's current files, not earlier versions.
1. Create a mount and add files#
Create mounts from your backend with Create a mount, and manage their files with the file endpoints. Writes through the API, like Write a mount file, are saved at once without the mount's settings, hooks, or approvals. They always overwrite; there is no version check.
const baseUrl = "https://api.smallworld.sh/api/v1";
const apiKey = process.env.SMALLWORLD_API_KEY;
if (!apiKey) throw new Error("Set SMALLWORLD_API_KEY on your server");
async function request(method: string, path: string, body?: unknown) {
const response = await fetch(baseUrl + path, {
method,
headers: {
Authorization: `Bearer ${apiKey}`,
...(body === undefined ? {} : { "Content-Type": "application/json" }),
},
...(body === undefined ? {} : { body: JSON.stringify(body) }),
});
const data = await response.json();
if (!response.ok) throw new Error(`${response.status} ${data.code}: ${data.message}`);
return data;
}
// Mount the docs at /workspace/docs for every member of the group team_42.
// Agents may add files; every other change waits for an approval.
const mount = await request("POST", "/mounts", {
path: "/workspace/docs",
scope: "group",
groupId: "team_42",
description: "Product documentation. Answers to customer questions go in faq.md.",
settings: { create: "allow" },
});
// Your backend's writes are saved at once, without the mount's settings.
const path = encodeURIComponent("/faq.md");
await request("PUT", `/mounts/${mount.id}/files/content?path=${path}`, {
content: "# FAQ\n\nRefunds take 5 business days.\n",
});
Files can also arrive with an execution: an upload whose path lies inside one of the user's mounts is saved into the mount directly when persistInSession is true. Without it, only that command sees the file, and the mount isn't changed.
List a user's World tools returns the user's mounts with their descriptions and settings, to put into your agent's context.
2. Choose what agents may change#
Reading a mount is always allowed. Each mount has five settings for agents' changes, each Allow, Ask, or Deny; the ones you leave out are Ask.
| Setting | Covers |
|---|---|
create | A new file or folder, including mkdir and a file moved in from /workspace. |
update | New content, permissions, or modification time of an existing file, such as an edit, chmod, or touch. |
delete | A removed file or folder, including a file moved out to /workspace. |
move | An entry moved to another folder, with or without a new name. |
rename | A new name in the same folder. |
- Deny makes the operation fail at once with
Permission denied, as for a read-only file, such asrm: cannot remove '/workspace/docs/a.md': Permission denied. The rest of the command continues, so the agent can react. - Ask holds the mount's changes until the command ends. Then, before anything is saved, one approval per changed mount lists all of its changes. The execution is
requires_approvaluntil someone decides it, as in Approve a tool call. - Allow saves the changes when the command ends.
Changes count by their net effect: a file created and then edited is one create, and a file created and then deleted is no change. A folder moved or deleted with its contents is one change. Moving a file onto an existing one needs the setting for the move and the delete setting for the replaced file, and a move between two mounts is one approval for both; the strictest setting wins. Tool call hooks also check every changed mount at the end of the command, and can ask for approval or deny.
3. Read the outcome#
execution.mountChanges lists each mount the command changed, with outcome saved or discarded and the reason. When a mount's changes aren't saved, all of that mount's changes from the command are dropped, stderr gets a notice, and an exit code of 0 becomes 1. The session's /workspace files and other mounts are still saved.
{
"execution": {
"status": "completed",
"exitCode": 1,
"stderr": "Changes to /workspace/docs were not saved: a person rejected them.\n",
"fileChanges": [],
"mountChanges": [
{
"mountId": "0199a1c4-5b6e-7a10-9c2d-3e4f5a6b7c8d",
"path": "/workspace/docs",
"outcome": "discarded",
"reason": "a person rejected them",
"toolCallId": "c3e1a9f2-4b7d-4e8a-9f10-2a3b4c5d6e7f",
"changes": [
{
"operation": "update",
"kind": "file",
"path": "/workspace/docs/faq.md"
}
]
}
]
}
}
Changes are discarded when they are rejected, expire, or a hook denies them; when they conflict with someone else's change; when the mount is edited or deleted, or the user loses it, before they are saved; and when the command hits its active-time limit while they need approval. A command that hits the limit still saves mounts whose changes are all allowed when no hook asks or denies. An interrupted command saves nothing.
4. Paths and overlaps#
Mount paths are inside /workspace, next to the agent's own files. Session files at a mount's path are hidden under the mount. Two mounts with the same scope and target, such as two mounts of one group, can't have the same path or paths where one lies inside the other: that returns mount_path_conflict.
Mounts of different scopes may overlap. In each session, the broader scope wins: global beats group, and group beats user. The other mount isn't mounted in that session while the overlap lasts. List a user's mounts shows which mounts are active; for a user in several groups, pass groupId to choose the group.
5. Concurrent changes#
A command sees each mount file as it was when the command first touched it. If someone else changes a file after that and the command changes it too, by your backend, an upload, or another command, also while the command waits for approval, that mount's changes from the command are discarded with a notice naming the files. Changes to different files of the same mount both succeed.
6. Limits#
- A mount holds at most 64 MiB and 10,000 files and folders, and a file at most 64 MiB. An API write beyond them returns
mount_limit; a command that would exceed them has that mount's changes discarded. - A symbolic link left in a mount discards all of the command's file changes, as in the rest of /workspace.
- Deleting a mount, its group, or its user deletes its files for good.