Documentation

Build LLM-powered agents
with production-ready TypeScript

DSPy for TypeScript. Working with LLMs is complex—they don't always do what you want. DSPy makes it easier to build amazing things with LLMs. Just define your inputs and outputs (signature) and an efficient prompt is auto-generated and used. Connect together various signatures to build complex systems and workflows using LLMs.

15+ LLM Providers
End-to-end Streaming
Auto Prompt Tuning

AxJSRuntime

Defined in: https://github.com/ax-llm/ax/blob/71ea5064d766efdc031d375243a8e525911833e7/src/ax/funcs/jsRuntime.ts#L601

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

Implements

Constructors

Constructor

new AxJSRuntime(options?: Readonly<{
  allowUnsafeNodeHostAccess?: boolean;
  captureConsole?: boolean;
  debugNodeWorkerPool?: boolean;
  nodeWorkerPoolSize?: number;
  outputMode?: AxJSRuntimeOutputMode;
  permissions?: readonly AxJSRuntimePermission[];
  timeout?: number;
}>): AxJSRuntime;

Defined in: https://github.com/ax-llm/ax/blob/71ea5064d766efdc031d375243a8e525911833e7/src/ax/funcs/jsRuntime.ts#L611

Parameters

ParameterType
options?Readonly<{ allowUnsafeNodeHostAccess?: boolean; captureConsole?: boolean; debugNodeWorkerPool?: boolean; nodeWorkerPoolSize?: number; outputMode?: AxJSRuntimeOutputMode; permissions?: readonly AxJSRuntimePermission[]; timeout?: number; }>

Returns

AxJSRuntime

Properties

PropertyModifierTypeDefault value
languagereadonly"JavaScript"'JavaScript'

Methods

createSession()

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

Defined in: https://github.com/ax-llm/ax/blob/71ea5064d766efdc031d375243a8e525911833e7/src/ax/funcs/jsRuntime.ts#L684

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:

Parameters

ParameterType
globals?Record<string, unknown>

Returns

AxCodeSession

Implementation of

AxCodeRuntime.createSession


getUsageInstructions()

getUsageInstructions(): string;

Defined in: https://github.com/ax-llm/ax/blob/71ea5064d766efdc031d375243a8e525911833e7/src/ax/funcs/jsRuntime.ts#L649

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()

toFunction(): AxFunction;

Defined in: https://github.com/ax-llm/ax/blob/71ea5064d766efdc031d375243a8e525911833e7/src/ax/funcs/jsRuntime.ts#L1007

Returns

AxFunction