Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

README.md

67 lines1.9 KB

1<div align="center">
2 <picture>
3 <source
4 media="(prefers-color-scheme: dark)"
5 srcset="https://tanstack.com/api/readme/ai.png?theme=dark"
6 />
7 <source
8 media="(prefers-color-scheme: light)"
9 srcset="https://tanstack.com/api/readme/ai.png"
10 />
11 <img
12 src="https://tanstack.com/api/readme/ai.png"
13 alt="TanStack AI"
14 width="900"
15 />
16 </picture>
17</div>
18​
19<br />
20​
21# @tanstack/ai-isolate-node
22​
23Node.js V8 isolate driver for TanStack AI Code Mode. Uses [`isolated-vm`](https://github.com/nicolo-ribaudo/isolated-vm) for fast, secure sandboxed execution.
24​
25## Requirements
26​
27- Node.js >= 22 (matches [`isolated-vm`'s engine constraint](https://github.com/laverdet/isolated-vm/blob/main/package.json))
28- Native compilation toolchain (the `isolated-vm` package compiles a native addon)
29- Pass `--no-node-snapshot` when running `node` (required by `isolated-vm` on every supported Node.js version)
30​
31## Installation
32​
33```bash
34pnpm add @tanstack/ai-isolate-node
35```
36​
37## Usage
38​
39```typescript
40import { createNodeIsolateDriver } from '@tanstack/ai-isolate-node'
41import { createCodeModeTool } from '@tanstack/ai-code-mode'
42​
43const driver = createNodeIsolateDriver({
44 timeout: 30000, // execution timeout in ms (default: 30000)
45 memoryLimit: 128, // memory limit in MB (default: 128)
46})
47​
48const executeTypescript = createCodeModeTool({
49 driver,
50 tools: [myTool],
51})
52```
53​
54## Config Options
55​
56- `timeout` — Default execution timeout in milliseconds (default: 30000)
57- `memoryLimit` — V8 isolate memory limit in MB (default: 128)
58​
59`createContext()` can override these defaults per execution context via `IsolateConfig` (`timeout`, `memoryLimit`).
60​
61## How It Works
62​
63Each `execute_typescript` call creates a fresh V8 isolate via `isolated-vm`. Tool bindings are injected as global async functions. Console output is captured into execution logs, and the isolate is disposed after execution completes for full cleanup.
64​
65## License
66​
67MIT