Skip to content

Open-source runtime

Your agents.
On the record.

VaernJS is a JavaScript and TypeScript runtime for AI agents. Set a budget, record effects, and replay a run using the original script.

npm install -g @vaernjs/vaern

Run inspector

run.ts

Recorded sample

Declared tool budget

$0.03 / $0.05

  • Reservecount_ready reserves $0.03
  • ReturnTool returns 2 ready entries
  • BlockNext $0.03 call exceeds the $0.02 left
Runtime JavaScript + TypeScriptPlatforms Linux, macOS, WindowsLicense MIT

From a budget to a replay.

Each part of the runtime answers a different question about the run.

budget.reserve

Can this call spend?

Vaern compares each reserve with the remaining budget before dispatching a model call or tool.

Read about budgets
journal.jsonl

What actually happened?

The runtime writes a hash-chained record of effects. Verify the journal and retain its final hash when you need to check it later.

Inspect the journal format
vaern replay

Can I reproduce it?

Replay supported effects offline with their recorded results. Vaern checks whether the transcript matches.

Read about replay

Run the same example.

The script counts local sample entries. It makes two calls to the same tool so you can see the second call stop at the budget limit. It needs no API key.

run.ts
import { budget, BudgetError, tool } from "vaern:ai";

budget({ usd: 0.05 });

const count = tool({
  name: "count_ready",
  cost: { usd: 0.03 },
  run: () => ["new", "ready", "ready", "queued"]
    .filter((entry) => entry === "ready").length,
});

console.log("Ready entries:", await count.call({}));

try {
  await count.call({});
} catch (error) {
  if (!(error instanceof BudgetError)) throw error;
  console.log("Second call blocked:", error.code);
}
  1. Install the CLI

    npm install -g @vaernjs/vaern
  2. Save the script as run.ts

    Run these commands from the directory where you saved the file.

    vaern run run.ts
    vaern journal verify latest
    vaern replay latest