Files
deepagentsjs/libs/providers/quickjs
github-actions[bot] ff8cc5c4b4 chore: version packages (#607)
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @langchain/quickjs@0.6.0

### Minor Changes

- [#606](https://github.com/langchain-ai/deepagentsjs/pull/606)
[`3c8f8b2`](https://github.com/langchain-ai/deepagentsjs/commit/3c8f8b2ea6f0204353c63bf49c3fdc6655bf1069)
Thanks [@colifran](https://github.com/colifran)! - chore(quickjs):
disallow task as a configurable ptc tool
## deepagents-acp@0.1.16

### Patch Changes

- Updated dependencies
[[`d7ecab2`](https://github.com/langchain-ai/deepagentsjs/commit/d7ecab2d9f9d41321a043eed6edc3366a1381a67),
[`1a2b2df`](https://github.com/langchain-ai/deepagentsjs/commit/1a2b2df5528f0f61870b054fff8291355f6a2a0b),
[`42f34b6`](https://github.com/langchain-ai/deepagentsjs/commit/42f34b65ededf4a1fbf3cd4bbff486ddfeb320e9),
[`0ae10d7`](https://github.com/langchain-ai/deepagentsjs/commit/0ae10d7e26c84203a5273939c9ad7a9c8c8661c6)]:
  - deepagents@1.10.6
## deepagents@1.10.6

### Patch Changes

- [#608](https://github.com/langchain-ai/deepagentsjs/pull/608)
[`d7ecab2`](https://github.com/langchain-ai/deepagentsjs/commit/d7ecab2d9f9d41321a043eed6edc3366a1381a67)
Thanks [@aolsenjazz](https://github.com/aolsenjazz)! - fix(deepagents):
forward subagent results as text

Fixed a 400 `invalid_request_error` that occurred when a subagent used
an Anthropic server-side tool (web search, web fetch, or code
execution): the subagent's `server_tool_use`/`*_tool_result` blocks were
forwarded to the parent agent as `tool_result` content, which the API
rejects. Subagent results are now passed back to the parent as their
text content (matching the Python implementation), which resolves the
error and also handles a trailing empty `end_turn` message.

- [#656](https://github.com/langchain-ai/deepagentsjs/pull/656)
[`1a2b2df`](https://github.com/langchain-ai/deepagentsjs/commit/1a2b2df5528f0f61870b054fff8291355f6a2a0b)
Thanks [@colifran](https://github.com/colifran)! - fix(deepagents):
default unknown file extensions to text/plain

- [#611](https://github.com/langchain-ai/deepagentsjs/pull/611)
[`42f34b6`](https://github.com/langchain-ai/deepagentsjs/commit/42f34b65ededf4a1fbf3cd4bbff486ddfeb320e9)
Thanks [@aolsenjazz](https://github.com/aolsenjazz)! - feat(deepagents):
add bedrockPromptCachingMiddleware to default stack

Add bedrockPromptCachingMiddleware to default middleware stack. This
automatically opts-in to Bedrock prompt caching for Nova and Anthropic
models

- [#613](https://github.com/langchain-ai/deepagentsjs/pull/613)
[`0ae10d7`](https://github.com/langchain-ai/deepagentsjs/commit/0ae10d7e26c84203a5273939c9ad7a9c8c8661c6)
Thanks [@christian-bromann](https://github.com/christian-bromann)! -
fix(deepagents): declare LangChain runtime packages as peer dependencies

Move `@langchain/core`, `@langchain/langgraph`,
`@langchain/langgraph-sdk`, and
`langchain` from `dependencies` to `peerDependencies`, and also declare
`@langchain/langgraph-checkpoint` as a peer (its
`BaseCheckpointSaver`/`BaseStore`
types are part of the public API), so they resolve to a single shared
instance in
  the consumer's tree. Previously they were bundled as regular
dependencies, which let a consumer end up with two copies of
`@langchain/core`
(e.g. `1.2.0` vs `1.2.1`). Because these packages ship classes with
private/
protected fields, the duplicate copies are treated as nominally distinct
types,
producing errors like passing a `ChatOpenAI` model to `createDeepAgent`
or a
compiled graph to the local protocol helpers. As peers, the app controls
the
version and bumping `@langchain/core` no longer requires a `deepagents`
release.
## @langchain/daytona@0.2.1

### Patch Changes

- [#614](https://github.com/langchain-ai/deepagentsjs/pull/614)
[`5b462f2`](https://github.com/langchain-ai/deepagentsjs/commit/5b462f2ab2400fba52906e8f1485a500ec5b6e17)
Thanks [@christian-bromann](https://github.com/christian-bromann)! -
Replace deprecated `@daytonaio/sdk` dependency with `@daytona/sdk`.
## @langchain/modal@0.1.5

### Patch Changes

- [#657](https://github.com/langchain-ai/deepagentsjs/pull/657)
[`5f93c11`](https://github.com/langchain-ai/deepagentsjs/commit/5f93c114759399002a3981a93e3df13981514b1d)
Thanks [@colifran](https://github.com/colifran)! - fix(modal): modal low
level file handle api `sandbox.open` has been removed
## @deepagents/evals@0.0.15

### Patch Changes

- Updated dependencies
[[`d7ecab2`](https://github.com/langchain-ai/deepagentsjs/commit/d7ecab2d9f9d41321a043eed6edc3366a1381a67),
[`1a2b2df`](https://github.com/langchain-ai/deepagentsjs/commit/1a2b2df5528f0f61870b054fff8291355f6a2a0b),
[`42f34b6`](https://github.com/langchain-ai/deepagentsjs/commit/42f34b65ededf4a1fbf3cd4bbff486ddfeb320e9),
[`0ae10d7`](https://github.com/langchain-ai/deepagentsjs/commit/0ae10d7e26c84203a5273939c9ad7a9c8c8661c6)]:
  - deepagents@1.10.6

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Colin Francis <colin.francis@langchain.dev>
2026-07-08 09:16:25 -07:00
..
2026-03-06 08:49:17 +00:00
2026-07-08 09:16:25 -07:00
2026-03-06 08:49:17 +00:00
2026-07-08 09:16:25 -07:00

@langchain/quickjs

Sandboxed JavaScript/TypeScript REPL for deepagents, powered by QuickJS-NG through QuickJS-Emscripten

npm version License: MIT

Installation

npm install @langchain/quickjs deepagents

Quick Start

import { createDeepAgent } from "deepagents";
import { createQuickJSMiddleware } from "@langchain/quickjs";

const agent = createDeepAgent({
  model: "claude-sonnet-4-5",
  middleware: [createQuickJSMiddleware()],
});

const result = await agent.invoke({
  messages: [
    { role: "user", content: "Calculate the first 20 Fibonacci numbers" },
  ],
});

The agent now has a js_eval tool. It can write and execute JavaScript/TypeScript in a sandboxed REPL where variables persist across calls:

// Call 1: the agent writes
var fibs = [0, 1];
for (let i = 2; i < 20; i++) fibs.push(fibs[i - 1] + fibs[i - 2]);
console.log(fibs);

// Call 2: state persists — `fibs` is still available
console.log(`Sum: ${fibs.reduce((a, b) => a + b, 0)}`);

Features

WASM Sandbox

All code runs inside a QuickJS WASM interpreter. There is no require, no import, no fetch, no filesystem access — only the explicitly bridged helpers (readFile, writeFile, and optionally tools.*).

TypeScript Support

LLMs naturally produce TypeScript. An AST-based transform pipeline strips type annotations, interfaces, and generics before evaluation — the model doesn't need to write pure JavaScript.

Virtual Filesystem

The REPL has readFile(path) and writeFile(path, content) functions that read from and write to the agent's backend (LangGraph state by default):

const raw = await readFile("/data.json");
const data = JSON.parse(raw);
const summary = { total: data.items.length };
await writeFile("/summary.json", JSON.stringify(summary, null, 2));

Programmatic Tool Calling (PTC)

Any agent tool can be exposed inside the REPL as a typed async function. Instead of the LLM emitting tool calls one at a time, it writes code that calls tools directly — loops, conditionals, parallel execution, and result transformation all happen in code:

const agent = createDeepAgent({
  model: "claude-sonnet-4-5-20250929",
  middleware: [
    createQuickJSMiddleware({
      ptc: true, // expose all agent tools inside the REPL
    }),
  ],
});

Inside the REPL, the agent can then write:

const urls = ["/users", "/orders", "/products"];
const results = await Promise.all(
  urls.map((u) => tools.httpRequest({ url: "https://api.example.com" + u })),
);
const parsed = results.map((r) => JSON.parse(r));
console.log(`Users: ${parsed[0].length}, Orders: ${parsed[1].length}`);

PTC configuration is progressive:

Value Behavior
false Disabled (default)
true All agent tools except VFS builtins
string[] Only these tools
{ include: string[] } Only these tools
{ exclude: string[] } All tools except these

Recursive Language Model (RLM)

When the agent has subagents configured, a task() global is available inside the REPL (no PTC needed), so the agent can spawn sub-agents in parallel from within the REPL:

const agent = createDeepAgent({
  model: "claude-sonnet-4-5-20250929",
  subagents: [
    {
      name: "general-purpose",
      description: "Research agent",
      systemPrompt: "...",
    },
  ],
  middleware: [createQuickJSMiddleware()],
});

The agent then writes code like:

const topics = ["quantum computing", "fusion energy", "CRISPR"];
const results = await Promise.all(
  topics.map((topic) =>
    task({
      description: `Research ${topic} in depth`,
      subagentType: "general-purpose",
    }),
  ),
);
// Aggregate and return the report from the eval; the agent then writes it to a
// file with its own write_file tool.
const report = topics.map((t, i) => `## ${t}\n${results[i]}`).join("\n\n");
report;

task cannot be exposed via ptc — it is reserved for the task() global, so passing ptc: ["task"] throws.

API

createQuickJSMiddleware(options?)

Creates a middleware that adds the js_eval tool to your agent.

interface QuickJSMiddlewareOptions {
  backend?: BackendProtocol | BackendFactory; // File I/O backend (default: StateBackend)
  ptc?: boolean | string[] | { include: string[] } | { exclude: string[] }; // PTC config
  memoryLimitBytes?: number; // Default: 50MB
  maxStackSizeBytes?: number; // Default: 320KB
  executionTimeoutMs?: number; // Default: 30s (-1 to disable)
  systemPrompt?: string | null; // Override the built-in REPL system prompt
}

ReplSession

The underlying session class. Usually you don't interact with this directly — the middleware manages sessions per thread.

ReplSession.getOrCreate(id, options?)  // Get or create a session
ReplSession.get(id)                    // Look up existing session
session.eval(code, timeoutMs)          // Execute code
session.flushWrites(backend)           // Persist buffered file writes
session.toJSON() / ReplSession.fromJSON(data)  // Serialization

License

MIT — see LICENSE.