AxJSRuntime Generated TypeScript API reference. typescript api api/reference build/apidocs/Class.AxJSRuntime.md class AxJSRuntime

AxJSRuntime

Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/funcs/jsRuntime.ts#L41

Browser-compatible JavaScript interpreter for RLM using Web Workers. Creates persistent sessions where variables survive across execute() calls.

Implements

Constructors

Constructor

TypeScript
new AxJSRuntime(options?: Readonly<{
  allowDenoRemoteImport?: boolean;
  allowedModules?: readonly string[];
  allowUnsafeNodeHostAccess?: boolean;
  blockDynamicImport?: boolean;
  blockShadowRealm?: boolean;
  captureConsole?: boolean;
  debugNodeWorkerPool?: boolean;
  freezeIntrinsics?: boolean;
  lockWorkerIPC?: boolean;
  nodePermissionAllowlist?: Readonly<{
     addons?: boolean;
     childProcess?: boolean;
     fsRead?: readonly string[];
     fsWrite?: readonly string[];
     wasi?: boolean;
  }>;
  nodeWorkerPoolSize?: number;
  outputMode?: AxJSRuntimeOutputMode;
  permissions?: readonly AxJSRuntimePermission[];
  preventGlobalThisExtensions?: boolean;
  resourceLimits?: Readonly<{
     codeRangeSizeMb?: number;
     maxOldGenerationSizeMb?: number;
     maxYoungGenerationSizeMb?: number;
     stackSizeMb?: number;
  }>;
  timeout?: number;
  useNodePermissionModel?: boolean | "auto";
}>): AxJSRuntime;

Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/funcs/jsRuntime.ts#L61

Parameters

ParameterType
options?Readonly<{ allowDenoRemoteImport?: boolean; allowedModules?: readonly string[]; allowUnsafeNodeHostAccess?: boolean; blockDynamicImport?: boolean; blockShadowRealm?: boolean; captureConsole?: boolean; debugNodeWorkerPool?: boolean; freezeIntrinsics?: boolean; lockWorkerIPC?: boolean; nodePermissionAllowlist?: Readonly<{ addons?: boolean; childProcess?: boolean; fsRead?: readonly string[]; fsWrite?: readonly string[]; wasi?: boolean; }>; nodeWorkerPoolSize?: number; outputMode?: AxJSRuntimeOutputMode; permissions?: readonly AxJSRuntimePermission[]; preventGlobalThisExtensions?: boolean; resourceLimits?: Readonly<{ codeRangeSizeMb?: number; maxOldGenerationSizeMb?: number; maxYoungGenerationSizeMb?: number; stackSizeMb?: number; }>; timeout?: number; useNodePermissionModel?: boolean | "auto"; }>

Returns

AxJSRuntime

Properties

PropertyModifierTypeDefault valueDescription
languagereadonly"JavaScript"'JavaScript'Human-readable language name for generated actor code. Defaults to JavaScript when omitted for backwards compatibility.

Methods

createSession()

TypeScript
createSession(globals?: Record<string, unknown>, options?: object): AxCodeSession;

Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/funcs/jsRuntime.ts#L241

Creates a persistent execution session.

Message flow:

  1. Main thread sends init with globals, function proxies, permissions.
  2. Main thread sends execute with correlation ID and code.
  3. Worker returns result or requests host callbacks via fn-call.
  4. Host responds to callback requests with fn-result.

Session closes on:

  • explicit close(),
  • timeout,
  • abort signal,
  • worker error.

Parameters

ParameterType
globals?Record<string, unknown>
options?{ shouldBubbleError?: (err: unknown) => boolean; }
options.shouldBubbleError?(err: unknown) => boolean

Returns

AxCodeSession

Implementation of

AxCodeRuntime.createSession


getUsageInstructions()

TypeScript
getUsageInstructions(): string;

Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/funcs/jsRuntime.ts#L206

Optional runtime-specific usage guidance injected into the RLM system prompt. Use this for execution semantics that differ by runtime/language.

Returns

string

Implementation of

AxCodeRuntime.getUsageInstructions


toFunction()

TypeScript
toFunction(): AxFunction;

Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/funcs/jsRuntime.ts#L895

Returns

AxFunction

Docs