Skip to main content
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 Mesa just-bash guide.

Imports

The SDK re-exports the core just-bash types alongside the Mesa filesystem:
import { Mesa, Bash, MesaFileSystem } from "@mesadev/sdk";
import type {
  BashOptions,
  ExecResult,
  BashLogger,
  CommandName,
  ChangeEditArgs,
  ChangeNewArgs,
  ChangeListArgs,
  ChangeResult,
  ChangeInfo,
  CustomCommand,
  BookmarkCreateArgs,
  BookmarkListArgs,
  NetworkConfig,
  JavaScriptConfig,
  SecureFetch,
} from "@mesadev/sdk";

Mounting a Filesystem

Use mesa.fs.mount() to mount a MesaFileSystem instance scoped to specific repositories:
const mesa = new Mesa({ apiKey: process.env.MESA_API_KEY });

const fs = await mesa.fs.mount({
  repos: [
    { name: "my-repo", bookmark: "main" },
    { name: "another-repo", bookmark: "feature-branch" },
  ],
  mode: "rw",
  cache: {
    diskCache: {
      path: "/tmp/mesa-cache",
      maxSizeBytes: 1024 * 1024 * 1024,
    },
  },
});

MesaFileSystemConfig

FieldTypeDescription
reposRepoConfig[]Repositories to mount. Optionally specify bookmark or changeId to control the base revision.
mode"ro" | "rw"Read-only or read-write access
cacheobjectOptional caching configuration
cache.diskCache.pathstringPath for on-disk cache
cache.diskCache.maxSizeBytesnumberMaximum 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

OptionTypeDescription
envRecord<string, string>Environment variables for the shell
cwdstringInitial working directory
executionLimitsobjectResource limits (timeouts, memory)
fetchtypeof fetchCustom fetch for network access
networkNetworkConfigNetwork access configuration
pythonobjectPython runtime configuration
javascriptJavaScriptConfigJavaScript runtime configuration
commandsCommandName[]Built-in commands to enable
customCommandsCustomCommand[]User-defined commands
loggerBashLoggerLogging interface

Executing Commands

bash.exec(command)

Runs a shell command and returns the result.
const result = await bash.exec("ls -la /my-repo/src");

ExecResult

FieldTypeDescription
stdoutstringStandard output
stderrstringStandard error
exitCodenumberExit 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

MethodReturnsDescription
readFile(path, options?)stringRead file with encoding
readFileBuffer(path)BufferRead file as raw bytes
readdir(path)string[]List directory entry names
readdirWithFileTypes(path)DirEntry[]List directory with type info
readlink(path)stringRead symlink target

Writing

MethodReturnsDescription
writeFile(path, content, options?)voidWrite string or bytes
appendFile(path, content, options?)voidAppend to file
mkdir(path, options?)voidCreate directory

Querying

MethodReturnsDescription
exists(path)booleanCheck file existence
stat(path)MetadataFile metadata (follows symlinks)
lstat(path)MetadataFile metadata (no symlink follow)
realpath(path)stringResolve canonical path
resolvePath(base, path)stringPure path resolution (sync)

Modifying

MethodReturnsDescription
rm(path, options?)voidRemove file or directory
cp(src, dest, options?)voidCopy file or directory
mv(src, dest)voidMove or rename
chmod(path, mode)voidChange permissions
utimes(path, atime, mtime)voidSet timestamps
symlink(target, linkPath)voidCreate symbolic link
link(existing, new)Always returns ENOTSUP

Change and Bookmark APIs

MesaFileSystem also exposes two namespace-style API groups:
  • fs.change for creating or switching changes
  • fs.bookmark for bookmark management

fs.change.new(args)

Create a new change and switch to it.
const result = await fs.change.new({
  repo: "my-repo",
  bookmark: "main",
});

console.log(result.changeOid);
Exactly one of bookmark or changeId must be set.

fs.change.edit(args)

Switch to an existing change. This does not create a new change.
await fs.change.edit({
  repo: "my-repo",
  bookmark: "feature-branch",
});
Or switch by change ID:
await fs.change.edit({
  repo: "my-repo",
  changeId: "abc123...",
});

fs.change.list(args)

List changes reachable from the current checkout’s commit.
const changes = await fs.change.list({
  repo: "my-repo",
  limit: 10,
});

for (const change of changes) {
  console.log(change.changeId, change.commitOid);
}
Returns an array of ChangeInfo objects, each with:
FieldTypeDescription
changeIdstringHex-encoded change ID
commitOidstringHex-encoded commit OID the change points to
The limit parameter defaults to 50. Pass 0 for no limit.

fs.bookmark.create(args)

Create a bookmark on the current commit without switching.
await fs.bookmark.create({
  repo: "my-repo",
  name: "feature-branch",
});

fs.bookmark.list(args)

List bookmark names for a repository.
const bookmarks = await fs.bookmark.list({ repo: "my-repo" });
// ["main", "feature-branch", ...]

Type Summary

APIArgs typeReturn type
fs.change.newChangeNewArgsPromise<ChangeResult>
fs.change.editChangeEditArgsPromise<ChangeResult>
fs.change.listChangeListArgsPromise<ChangeInfo[]>
fs.bookmark.createBookmarkCreateArgsPromise<void>
fs.bookmark.listBookmarkListArgsPromise<string[]>