The Mesa SDK integrates with Vercel’s just-bash library to provide shell execution against Mesa repositories without needing a sandbox.
This page covers the API surface exposed through @mesadev/sdk.
For a higher-level overview, see the MesaFS just-bash guide.
Imports
The SDK re-exports the core just-bash types alongside the Mesa filesystem:
import { Mesa, Bash, MesaFS } from "@mesadev/sdk";
import type {
BashOptions,
ExecResult,
BashLogger,
CommandName,
CustomCommand,
NetworkConfig,
JavaScriptConfig,
SecureFetch,
} from "@mesadev/sdk";
Creating a Filesystem
Use mesa.fs.create() to create a MesaFileSystem instance scoped to specific repositories:
const mesa = new Mesa({ adminApiKey: process.env.MESA_ADMIN_API_KEY });
const fs = await mesa.fs.create({
repos: [
{ name: "my-repo", desiredBookmark: "main" },
{ name: "another-repo", desiredBookmark: "feature-branch" },
],
mode: "rw",
cache: {
diskCache: {
path: "/tmp/mesa-cache",
maxSizeBytes: 1024 * 1024 * 1024,
},
},
});
MesaFileSystemConfig
| Field | Type | Description |
|---|
repos | { name: string; desiredBookmark: string }[] | Repositories and bookmarks to mount |
mode | "ro" | "rw" | Read-only or read-write access |
cache | object | Optional caching configuration |
cache.diskCache.path | string | Path for on-disk cache |
cache.diskCache.maxSizeBytes | number | Maximum cache size in bytes |
Getting a Bash Shell
Call .bash() on a MesaFileSystem to get a Bash instance:
const bash = fs.bash({
env: { NODE_ENV: "production", CI: "true" },
cwd: "/my-repo",
});
MesaBashOptions
| Option | Type | Description |
|---|
env | Record<string, string> | Environment variables for the shell |
cwd | string | Initial working directory |
executionLimits | object | Resource limits (timeouts, memory) |
fetch | typeof fetch | Custom fetch for network access |
network | NetworkConfig | Network access configuration |
python | object | Python runtime configuration |
javascript | JavaScriptConfig | JavaScript runtime configuration |
commands | CommandName[] | Built-in commands to enable |
customCommands | CustomCommand[] | User-defined commands |
logger | BashLogger | Logging interface |
Options like fs and files from BashOptions are intentionally omitted — the filesystem is always
the MesaFileSystem instance, and files are populated from your Mesa repositories.
If you need to use advanced just-bash features such as overlay filesystems, you should separately install the just-bash package and use the MesaFileSystem instance directly to construct a Bash instance.import { Mesa } from "@mesadev/sdk";
import { Bash } from "just-bash";
const mesa = new Mesa();
const fs = await mesa.fs.create({...});
const bash = new Bash({ fs, ...otherOptions });
Executing Commands
bash.exec(command)
Runs a shell command and returns the result.
const result = await bash.exec("ls -la /my-repo/src");
ExecResult
| Field | Type | Description |
|---|
stdout | string | Standard output |
stderr | string | Standard error |
exitCode | number | Exit code (0 = success) |
const result = await bash.exec("grep -r 'TODO' /my-repo/src");
if (result.exitCode === 0) {
console.log("Found TODOs:", result.stdout);
} else {
console.log("No matches or error:", result.stderr);
}
IFileSystem Methods
The MesaFileSystem class implements the full IFileSystem interface from just-bash. All methods are async unless noted.
Reading
| Method | Returns | Description |
|---|
readFile(path, options?) | string | Read file with encoding |
readFileBuffer(path) | Buffer | Read file as raw bytes |
readdir(path) | string[] | List directory entry names |
readdirWithFileTypes(path) | DirEntry[] | List directory with type info |
readlink(path) | string | Read symlink target |
Writing
| Method | Returns | Description |
|---|
writeFile(path, content, options?) | void | Write string or bytes |
appendFile(path, content, options?) | void | Append to file |
mkdir(path, options?) | void | Create directory |
Querying
| Method | Returns | Description |
|---|
exists(path) | boolean | Check file existence |
stat(path) | Metadata | File metadata (follows symlinks) |
lstat(path) | Metadata | File metadata (no symlink follow) |
realpath(path) | string | Resolve canonical path |
resolvePath(base, path) | string | Pure path resolution (sync) |
Modifying
| Method | Returns | Description |
|---|
rm(path, options?) | void | Remove file or directory |
cp(src, dest, options?) | void | Copy file or directory |
mv(src, dest) | void | Move or rename |
chmod(path, mode) | void | Change permissions |
utimes(path, atime, mtime) | void | Set timestamps |
symlink(target, linkPath) | void | Create symbolic link |
link(existing, new) | — | Always returns ENOTSUP |