[PR #427] feat(providers): add @langchain/wasmsh — in-process shell + Python sandbox #452

Open
opened 2026-06-05 17:23:08 -04:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/deepagentsjs/pull/427
Author: @johannhartmann
Created: 4/5/2026
Status: 🔄 Open

Base: mainHead: feat/wasmsh-sandbox


📝 Commits (10+)

  • c723614 feat: expose filesystemOptions in createDeepAgent
  • 0c4e8de feat: add @langchain/wasmsh sandbox provider
  • 5ab594e feat: add browser build and LLM agent integration tests
  • edd04d7 deepagents: fix browser subagent state handling
  • cbe8fa5 chore: add changeset for wasmsh sandbox
  • 71ffad9 feat(wasmsh): Python REPL middleware + PTC + skills + filesystem backend
  • 290ddab chore(wasmsh): fix lint + apply oxfmt
  • e663f61 test(wasmsh): cover filesystem backend, skills loader, PTC dispatch, runPtc passthrough
  • 799d461 fix(wasmsh): close path-traversal escape in WasmshFilesystemBackend
  • 3741cef fix(wasmsh): act on PR review — propagate security errors, harden asBytes, cover skills seam

📊 Changes

45 files changed (+6087 additions, -19 deletions)

View changed files

.changeset/add-wasmsh-sandbox.md (+17 -0)
examples/sandbox/wasmsh-browser-sandbox.ts (+19 -0)
examples/sandbox/wasmsh-node-sandbox.ts (+49 -0)
📝 libs/deepagents/README.md (+19 -0)
📝 libs/deepagents/package.json (+5 -0)
📝 libs/deepagents/src/agent.ts (+3 -2)
libs/deepagents/src/backends/index.browser.ts (+42 -0)
libs/deepagents/src/index.browser.ts (+98 -0)
libs/deepagents/src/middleware/subagents.browser.test.ts (+104 -0)
📝 libs/deepagents/src/middleware/subagents.ts (+21 -8)
📝 libs/deepagents/src/types.ts (+6 -0)
📝 libs/deepagents/tsdown.config.ts (+15 -1)
libs/providers/wasmsh/README.md (+207 -0)
libs/providers/wasmsh/e2e/browser-agent.spec.ts (+109 -0)
libs/providers/wasmsh/e2e/fixture/browser-sandbox.ts (+250 -0)
libs/providers/wasmsh/e2e/fixture/index.html (+11 -0)
libs/providers/wasmsh/e2e/fixture/main.ts (+259 -0)
libs/providers/wasmsh/e2e/fixture/shims/async-hooks.ts (+30 -0)
libs/providers/wasmsh/e2e/fixture/vite.config.ts (+69 -0)
libs/providers/wasmsh/package.json (+86 -0)

...and 25 more files

📄 Description

Summary

Adds @langchain/wasmsh, a sandbox provider that runs a full Bash-compatible
shell (88 utilities including grep, sed, awk, jq, curl) and Python 3.13 with
pip — entirely in-process via WebAssembly. No containers, no cloud services,
no API keys.

  • Node.js: WasmshSandbox.createNode() — spawns a local host process
  • Browser: WasmshSandbox.createBrowserWorker() — runs in a Web Worker

Backed by wasmsh and
Pyodide, the shell and Python share a virtual
filesystem. Agents get execute, read_file, write_file, edit_file,
ls, grep, glob — same tools as remote sandboxes, zero infrastructure.

What's included

Commit Change
feat: expose filesystemOptions in createDeepAgent Allows tuning token eviction thresholds per agent
feat: add @langchain/wasmsh sandbox provider Main provider package with 32 unit + 97 integration tests
feat: add browser build and LLM agent integration tests Browser entry for deepagents core, Playwright e2e, agent tests
fix: browser subagent state handling Use runtime.state instead of getCurrentTaskInput() in browser environments
chore: add changeset Changeset for release

Why not just use containers?

Containers are the right choice for untrusted code or system-level operations.
Wasmsh is for the common case where agents need a filesystem, a shell, and
Python — and you don't want to spin up infrastructure for it. Tests run in
<1s, CI needs no secrets, and it works in the browser.

Test plan

  • 32 unit tests (mocked session, all sandbox operations)
  • 97 integration tests (standard test suite, LLM agent tests)
  • 821 core tests pass (no regressions, typecheck clean)
  • 125 node-vfs tests pass (no regressions to other providers)
  • Playwright browser e2e tests
  • pnpm format:check clean
  • pnpm lint clean (0 errors)
  • pnpm build succeeds

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langchain-ai/deepagentsjs/pull/427 **Author:** [@johannhartmann](https://github.com/johannhartmann) **Created:** 4/5/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/wasmsh-sandbox` --- ### 📝 Commits (10+) - [`c723614`](https://github.com/langchain-ai/deepagentsjs/commit/c723614c05abd36e870ab8069552d4410552fef2) feat: expose filesystemOptions in createDeepAgent - [`0c4e8de`](https://github.com/langchain-ai/deepagentsjs/commit/0c4e8dedf9a3fbbd6ea8bc594d036d3ae35401f8) feat: add @langchain/wasmsh sandbox provider - [`5ab594e`](https://github.com/langchain-ai/deepagentsjs/commit/5ab594e4bfe40f19146dc4b50fd7453f52135beb) feat: add browser build and LLM agent integration tests - [`edd04d7`](https://github.com/langchain-ai/deepagentsjs/commit/edd04d78d7b5b95ef5dae9ce718b5e6cc2cd1598) deepagents: fix browser subagent state handling - [`cbe8fa5`](https://github.com/langchain-ai/deepagentsjs/commit/cbe8fa58e5e7ef9a47ef7f5f9aee5f94815eacd7) chore: add changeset for wasmsh sandbox - [`71ffad9`](https://github.com/langchain-ai/deepagentsjs/commit/71ffad9362fdb5755ee46174abb10db5e783448b) feat(wasmsh): Python REPL middleware + PTC + skills + filesystem backend - [`290ddab`](https://github.com/langchain-ai/deepagentsjs/commit/290ddab438fb0e764e639b2a37ccc51b0def9beb) chore(wasmsh): fix lint + apply oxfmt - [`e663f61`](https://github.com/langchain-ai/deepagentsjs/commit/e663f61cc82905b7656a16a41a33e8f63ee2221c) test(wasmsh): cover filesystem backend, skills loader, PTC dispatch, runPtc passthrough - [`799d461`](https://github.com/langchain-ai/deepagentsjs/commit/799d4616938a0f06ea39d778bbc9bbc6fbdf457a) fix(wasmsh): close path-traversal escape in WasmshFilesystemBackend - [`3741cef`](https://github.com/langchain-ai/deepagentsjs/commit/3741cef9d53be84aab8f134153f4cd7106bdc0bb) fix(wasmsh): act on PR review — propagate security errors, harden asBytes, cover skills seam ### 📊 Changes **45 files changed** (+6087 additions, -19 deletions) <details> <summary>View changed files</summary> ➕ `.changeset/add-wasmsh-sandbox.md` (+17 -0) ➕ `examples/sandbox/wasmsh-browser-sandbox.ts` (+19 -0) ➕ `examples/sandbox/wasmsh-node-sandbox.ts` (+49 -0) 📝 `libs/deepagents/README.md` (+19 -0) 📝 `libs/deepagents/package.json` (+5 -0) 📝 `libs/deepagents/src/agent.ts` (+3 -2) ➕ `libs/deepagents/src/backends/index.browser.ts` (+42 -0) ➕ `libs/deepagents/src/index.browser.ts` (+98 -0) ➕ `libs/deepagents/src/middleware/subagents.browser.test.ts` (+104 -0) 📝 `libs/deepagents/src/middleware/subagents.ts` (+21 -8) 📝 `libs/deepagents/src/types.ts` (+6 -0) 📝 `libs/deepagents/tsdown.config.ts` (+15 -1) ➕ `libs/providers/wasmsh/README.md` (+207 -0) ➕ `libs/providers/wasmsh/e2e/browser-agent.spec.ts` (+109 -0) ➕ `libs/providers/wasmsh/e2e/fixture/browser-sandbox.ts` (+250 -0) ➕ `libs/providers/wasmsh/e2e/fixture/index.html` (+11 -0) ➕ `libs/providers/wasmsh/e2e/fixture/main.ts` (+259 -0) ➕ `libs/providers/wasmsh/e2e/fixture/shims/async-hooks.ts` (+30 -0) ➕ `libs/providers/wasmsh/e2e/fixture/vite.config.ts` (+69 -0) ➕ `libs/providers/wasmsh/package.json` (+86 -0) _...and 25 more files_ </details> ### 📄 Description ## Summary Adds `@langchain/wasmsh`, a sandbox provider that runs a full Bash-compatible shell (88 utilities including grep, sed, awk, jq, curl) and Python 3.13 with pip — entirely in-process via WebAssembly. No containers, no cloud services, no API keys. - **Node.js**: `WasmshSandbox.createNode()` — spawns a local host process - **Browser**: `WasmshSandbox.createBrowserWorker()` — runs in a Web Worker Backed by [wasmsh](https://github.com/mayflower/wasmsh) and [Pyodide](https://pyodide.org/), the shell and Python share a virtual filesystem. Agents get `execute`, `read_file`, `write_file`, `edit_file`, `ls`, `grep`, `glob` — same tools as remote sandboxes, zero infrastructure. ### What's included | Commit | Change | |--------|--------| | `feat: expose filesystemOptions in createDeepAgent` | Allows tuning token eviction thresholds per agent | | `feat: add @langchain/wasmsh sandbox provider` | Main provider package with 32 unit + 97 integration tests | | `feat: add browser build and LLM agent integration tests` | Browser entry for deepagents core, Playwright e2e, agent tests | | `fix: browser subagent state handling` | Use `runtime.state` instead of `getCurrentTaskInput()` in browser environments | | `chore: add changeset` | Changeset for release | ### Why not just use containers? Containers are the right choice for untrusted code or system-level operations. Wasmsh is for the common case where agents need a filesystem, a shell, and Python — and you don't want to spin up infrastructure for it. Tests run in <1s, CI needs no secrets, and it works in the browser. ## Test plan - [x] 32 unit tests (mocked session, all sandbox operations) - [x] 97 integration tests (standard test suite, LLM agent tests) - [x] 821 core tests pass (no regressions, typecheck clean) - [x] 125 node-vfs tests pass (no regressions to other providers) - [x] Playwright browser e2e tests - [x] `pnpm format:check` clean - [x] `pnpm lint` clean (0 errors) - [x] `pnpm build` succeeds --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-06-05 17:23:08 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/deepagentsjs#452