import { Mesa } from "@mesadev/sdk";
const mesa = new Mesa({ apiKey: process.env.MESA_API_KEY });
// Create a scoped, short-lived API key for the sandbox
const ephemeralKey = await mesa.apiKeys.create({
name: "sandbox-session",
scopes: ["read", "write"],
expires_in_seconds: 3600, // 1 hour
});
// Start Mesa as a background daemon.
// MESA_ORGS configures the org and API key in one step.
await sandbox.process.exec({
command: `MESA_ORGS=my-org:${ephemeralKey.key} mesa mount -d -y`,
waitForCompletion: true,
});
// Your repos are now at ~/.local/share/mesa/mnt/<org>/<repo>
await sandbox.process.exec({
command: 'cd ~/.local/share/mesa/mnt/my-org/my-repo \
&& claude "Implement the feature described in TODO.md"',
waitForCompletion: true,
});