Skip to content
Guides Vaern 0.0.8
Documentation

JavaScript and TypeScript runtime

Understand script execution, module resolution, available APIs, and the limits of Vaern 0.0.8.

Files and ES modules

Use vaern run with a .js, .mjs, or .ts entry file. Scripts run as ES modules and can use top-level await. Pass script arguments after the file path and read them from process.argv.

math.ts
export const double = (value: number) => value * 2;
main.ts
import { double } from "./math.ts";
console.log(double(21));
Terminal
vaern run main.ts
  • Use exact file names, including extensions, for relative imports.
  • Vaern resolves compatible ES module packages already installed in node_modules. Use npm or another package manager to install them.
  • The runtime strips types and preserves source positions in errors. Run a separate TypeScript checker when you need type validation.

Global and built-in APIs

  • Global APIs cover console output, timers, fetch, URL, URLSearchParams, and common request and response primitives.
  • process exposes argv, env, and exit.
  • vaern:http exports serve() for an HTTP listener with web Request and Response objects.
  • vaern:fs provides readFile(), writeFile(), and appendFile() for whole-file operations.
  • vaern:ai provides model(), tool(), agent(), and budget().
  • vaern:mcp starts and connects to local Vaern MCP tools over stdio.

Compatibility and limits

For new scripts, use standard ES module syntax and erasable TypeScript types. Syntax that needs runtime transformation, such as enums, namespaces, and decorators, fails with a source location.

  • Node built-ins such as node:fs and CommonJS packages are outside the 0.0.8 runtime surface.
  • The JavaScript heap is capped at 256 MiB and an individual UTF-8 module can be up to 64 MiB.
  • Treat scripts as trusted code. This release can access the environment, filesystem and network through its supported APIs.
Next guide · Model and tool budgets