A TypeScript implementation of Recursive Language Models for processing large contexts with LLMs.
Inspired by Cloudflare's Code Mode approach.
The V8 isolate provides these bindings to LLM-generated code:
| Binding | Description |
|---|---|
context |
The loaded context data |
llm_query(prompt, model?) |
Query sub-LLM |
llm_query_batched(prompts, model?) |
Batch query sub-LLMs |
giveFinalAnswer({ message, data? }) |
Return final answer |
print(...) |
Console output |
┌─────────────────────────────────────────────────────────────┐
│ RLLM TypeScript │
│ │
│ ┌─────────────┐ ┌──────────────────────────────────┐ │
│ │ RLLM │ │ V8 Isolate (Sandbox) │ │
│ │ Class │───▶│ │ │
│ └─────────────┘ │ • context (injected data) │ │
│ │ │ • llm_query() ──┐ │ │
│ │ │ • llm_query_batched() │ │
│ ▼ │ • print() / console │ │
│ ┌─────────────┐ │ • giveFinalAnswer() │ │
│ │ LLMClient │◀───┼──────────────────┘ │ │
│ │ (OpenAI) │ │ │ │
│ └─────────────┘ │ LLM-generated JS code runs here │ │
│ └──────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
No TCP. No subprocess. Direct function calls via bindings.
# Install dependencies
pnpm install
# Build
pnpm build
# Run example
pnpm example
# Run tests
pnpm test