Runtime
Bindings
Give guest code narrow, validated host-backed commands.
Bindings expose narrow, validated host functions to executed code as VM-local commands. The handler stays in the trusted host and the guest receives only its JSON result.
import { binding, bindings } from "@rivet-dev/agentos";
import { JavaScriptRuntime } from "@rivet-dev/agentos/javascript";
import { z } from "zod";
const toolBindings = bindings({
name: "tools",
description: "Curated host capabilities for generated code.",
bindings: {
weather: binding({
description: "Look up a city's temperature.",
inputSchema: z.object({ city: z.string() }),
execute: ({ city }) => ({
city,
tempF: city === "San Francisco" ? 61 : 75,
}),
}),
},
});
const runtime = await JavaScriptRuntime.create({
bindings: [toolBindings],
permissions: { binding: "allow" },
});
Bindings are declared with binding() and bindings() from
@rivet-dev/agentos, then passed through the normal AgentOsOptions accepted
by either language runtime. See the general AgentOS Bindings
docs for schemas, command naming, permissions, and handler behavior; see the
Code Mode cookbook for the complete pattern.