Runtime
Permissions
A short overview of Agent OS Exec permissions.
Pass a permission policy when creating the runtime. Denied guest operations fail before a host file, socket, process, environment value, or binding is reached.
import { JavaScriptRuntime } from "@rivet-dev/agentos/javascript";
const runtime = await JavaScriptRuntime.create({
permissions: {
fs: "allow",
network: "deny",
childProcess: "allow",
process: "allow",
env: "allow",
},
});
try {
const result = await runtime.evaluate<{
fileContents: string;
networkBlocked: boolean;
}>(`(async () => {
const { writeFileSync, readFileSync } = await import("node:fs");
writeFileSync("/workspace/note.txt", "inside the VM");
let networkBlocked = false;
try { await fetch("https://example.com"); } catch { networkBlocked = true; }
return {
fileContents: readFileSync("/workspace/note.txt", "utf8"),
networkBlocked,
};
})()`);
if (!result.success) throw new Error(result.error.message);
console.log(result.value);
} finally {
await runtime.dispose();
}
The high-level client defaults to allow, so configure an explicit policy before running untrusted code. See AgentOS Permissions for the policy grammar, defaults, and enforcement details.