You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* feat: add Daytona Code Mode isolate driver
* fix: clear Daytona timeout timers
* docs: clarify Daytona isolate driver positioning
* chore(ai-isolate-daytona): use oxlint to match repo lint convention
The package shipped eslint lint scripts (lint:fix/test:eslint) while the
rest of the monorepo standardized on oxlint. This left the package's
source outside the CI lint gate (nx affected --target=test:oxlint skipped
it) and tripped knip with an unlisted 'eslint' binary. Align with sibling
drivers (oxlint src --type-aware).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(ai-isolate-daytona): align @daytona/sdk to ^0.191.0 to satisfy sherif
Merging main brought in @tanstack/ai-sandbox-daytona, which depends on
@daytona/sdk@^0.191.0. This package still pinned ^0.180.0, so sherif's
multiple-dependency-versions rule failed the Test job (single-version policy
across the workspace).
Bump the devDependency to ^0.191.0 to match. It stays a devDependency: this
driver is bring-your-own-SDK (the caller passes a Daytona sandbox via the
`DaytonaSandboxLike` structural type and the driver never imports @daytona/sdk
at runtime), so the SDK is only needed for dev/type-checking. Build, types,
oxlint, and the unit suite all pass against 0.191.0.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Jack Herrington <jherr@pobox.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Alem Tuzlak <t.zlak@hotmail.com>
Copy file name to clipboardExpand all lines: docs/code-mode/code-mode-isolates.md
+71-11Lines changed: 71 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
title: Code Mode Isolate Drivers
3
3
id: code-mode-isolates
4
4
order: 4
5
-
description: "Compare Code Mode sandbox drivers — Node isolated-vm, QuickJS WASM, QuickJS Bun (bun:ffi), and Cloudflare Workers — and choose the right runtime for your deployment."
5
+
description: "Compare Code Mode sandbox drivers — Node isolated-vm, QuickJS WASM, QuickJS Bun (bun:ffi), Cloudflare Workers, and Daytona sandboxes — and choose the right runtime for your deployment."
6
6
keywords:
7
7
- tanstack ai
8
8
- code mode
@@ -13,6 +13,7 @@ keywords:
13
13
- bun
14
14
- bun:ffi
15
15
- cloudflare workers
16
+
- daytona
16
17
- sandbox
17
18
- secure execution
18
19
---
@@ -22,15 +23,15 @@ Isolate drivers provide the secure sandbox runtimes that [Code Mode](./code-mode
Runs generated code inside a Daytona sandbox through `sandbox.process.codeRun`. Your application process still owns TanStack tool implementations; the Daytona sandbox only receives wrapped generated code plus replayed tool results.
243
+
244
+
### Installation
245
+
246
+
```bash
247
+
pnpm add @tanstack/ai-isolate-daytona
248
+
```
249
+
250
+
If your application creates sandboxes with the official Daytona SDK, also install it:
|`sandbox`|`DaytonaSandboxLike`| — |**Required.** A caller-owned Daytona sandbox-like object with `process.codeRun(code, params?, timeout?)`. |
277
+
|`timeout`|`number`|`30000`| Maximum wall-clock time for the entire execution, including replay rounds, in milliseconds. |
278
+
|`maxToolRounds`|`number`|`10`| Maximum number of sandbox <-> host tool callback rounds. Prevents infinite loops when generated code repeatedly asks for tools. |
279
+
280
+
### How it works
281
+
282
+
The driver uses the same host-owned tool replay shape as the Cloudflare driver without Cloudflare's parent Worker / Dynamic Worker split:
283
+
284
+
```text
285
+
Driver (your server) Daytona sandbox
286
+
───────────────────── ───────────────
287
+
Send: wrapped code ──────▶ Execute with process.codeRun
288
+
◀────── Return: need_tools with tool requests
289
+
Execute tools locally
290
+
Replay with toolResults ──────▶ Continue execution
291
+
◀────── Return: final result / more tool requests
292
+
...repeat until done...
293
+
```
294
+
295
+
Use this driver when you want Code Mode execution in a full Daytona sandbox instead of an in-process isolate, QuickJS WASM runtime, or Cloudflare Worker. The sandbox should use a language/runtime capable of executing the JavaScript emitted by Code Mode, and your application remains responsible for sandbox lifecycle, filesystem, network, cleanup, and secret policy. Creating a Code Mode context does not create or delete a Daytona sandbox.
296
+
297
+
---
298
+
239
299
## The `IsolateDriver` Interface
240
300
241
-
All four drivers satisfy this interface, exported from `@tanstack/ai-code-mode`:
301
+
All provided drivers satisfy this interface, exported from `@tanstack/ai-code-mode`:
Copy file name to clipboardExpand all lines: docs/code-mode/code-mode.md
+7-3Lines changed: 7 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,7 +35,7 @@ Tools you pass to Code Mode are converted to typed function stubs that appear in
35
35
36
36
### Secure sandboxing
37
37
38
-
Generated code runs in an isolated environment (V8 isolate, QuickJS WASM, native QuickJS on Bun, or Cloudflare Worker) with no access to the host file system, network, or process. The sandbox has configurable timeouts and memory limits.
38
+
Generated code runs in an isolated environment (V8 isolate, QuickJS WASM, native QuickJS on Bun, Cloudflare Worker, or Daytona sandbox) with no access to the host file system, network, or process. The sandbox has configurable timeouts and memory limits.
39
39
40
40
## Getting Started
41
41
@@ -59,6 +59,9 @@ bun add @tanstack/ai-isolate-quickjs-bun
59
59
60
60
# Cloudflare Workers — run on the edge
61
61
pnpm add @tanstack/ai-isolate-cloudflare
62
+
63
+
# Daytona sandboxes — run in a remote Daytona sandbox
For full configuration options for each driver, see [Isolate Drivers](./code-mode-isolates.md).
220
224
@@ -230,7 +234,7 @@ These utilities are used internally and are exported for custom pipelines:
230
234
231
235
For a full comparison of drivers with all configuration options, see [Isolate Drivers](./code-mode-isolates.md).
232
236
233
-
In brief: use the **Node driver** for server-side Node.js (fastest, V8 JIT), **QuickJS** for browsers or portable edge deployments (no native deps), **QuickJS Bun** for Bun servers (native QuickJS via `bun:ffi`), and the **Cloudflare driver** when you deploy to Cloudflare Workers.
237
+
In brief: use the **Node driver** for server-side Node.js (fastest, V8 JIT), **QuickJS** for browsers or portable edge deployments (no native deps), **QuickJS Bun** for Bun servers (native QuickJS via `bun:ffi`), the **Cloudflare driver** when you deploy to Cloudflare Workers, and the **Daytona driver** when you want execution inside a full remote Linux sandbox.
This package runs generated JavaScript or TypeScript in a caller-provided Daytona sandbox and keeps TanStack tool implementations in your host process. When generated code calls an `external_*` tool, the sandbox returns a `need_tools` payload, the host executes the matching `ToolBinding.execute` callbacks, and the driver replays the code with accumulated tool results until it completes.
The driver accepts a structural sandbox object with `sandbox.process.codeRun(...)`; it does not require `@daytona/sdk` as a package dependency.
42
+
43
+
## API
44
+
45
+
### `createDaytonaIsolateDriver(config)`
46
+
47
+
Creates an isolate driver that delegates Code Mode execution to a Daytona sandbox.
48
+
49
+
-`sandbox` (required): caller-owned object with `process.codeRun(code, params?, timeout?)`
50
+
-`timeout` (optional): total execution timeout across replay rounds, in milliseconds (default: `30000`)
51
+
-`maxToolRounds` (optional): maximum `need_tools` replay rounds per execution (default: `10`)
52
+
53
+
## Requirements
54
+
55
+
- Use a sandbox language/runtime that can execute the JavaScript emitted by Code Mode.
56
+
- Tool inputs and outputs must be JSON-serializable.
57
+
- Sandbox lifecycle, network access, filesystem contents, secrets, and cleanup are owned by your application. Creating a Code Mode context does not create or delete a Daytona sandbox.
58
+
59
+
## How It Works
60
+
61
+
```text
62
+
Host process Daytona sandbox
63
+
------------ ---------------
64
+
createCodeMode + tools
65
+
wrap generated code ---------> run with process.codeRun
66
+
execute host tools <--------- need_tools requests
67
+
replay with toolResults ---------> continue execution
68
+
final result/logs <--------- done or error envelope
69
+
```
70
+
71
+
The host process talks directly to a Daytona sandbox through `process.codeRun`, while tool execution stays host-owned.
72
+
73
+
## Validation
74
+
75
+
Run the package checks once the implementation files are present:
0 commit comments