Getting Started
Node.js
Run Node.js code and built-in modules inside Agent OS Exec.
Install AgentOS and import the JavaScript runtime:
pnpm add @rivet-dev/agentos
Guest code gets Node.js globals, node: builtins, ESM and CommonJS loading, and
npm-style package resolution, all backed by the AgentOS VM rather than the host
process.
const runtime = await JavaScriptRuntime.create();
try {
const result = await runtime.evaluate<{
filename: string;
digest: string;
}>(`(async () => {
const { createHash } = await import("node:crypto");
const { join } = await import("node:path");
return {
filename: join("/workspace", "report.json"),
digest: createHash("sha256").update("agentos").digest("hex"),
};
})()`);
if (!result.success) throw new Error(result.error.message);
console.log(result.value);
} finally {
await runtime.dispose();
}
To load npm dependencies, continue to
NPM & Module Loading. TypeScript is built
into this same runtime at runtime.typescript; it is not another package.