Environment variables
Variables passed to Sandbox.create are available to commands throughout the sandbox. Variables passed to commands.run apply only to that command and override a sandbox-wide value with the same name.
mjs
import { Sandbox } from "@abox-dev/sdk";
const sandbox = await Sandbox.create({
envs: { APP_ENV: "development" },
});
try {
const result = await sandbox.commands.run(
'printf \'%s %s %s\' "$AGENTBOX_SANDBOX_ID" "$APP_ENV" "$REQUEST_ID"',
{ envs: { REQUEST_ID: "request-42" } },
);
console.log(result.stdout);
} finally {
await sandbox.kill();
}AgentBox also provides these variables to processes started through the SDK:
AGENTBOX_SANDBOX=trueidentifies an AgentBox microVM;AGENTBOX_SANDBOX_IDcontains the sandbox ID;AGENTBOX_TEMPLATE_IDcontains the template ID.
Their file forms are available under /run/agentbox for tools that do not inherit the SDK command environment.
Environment variables are visible to processes with sufficient permissions inside the sandbox. Treat them as runtime configuration, not as an isolation boundary between processes.