[PR #486] [MERGED] feat(quickjs): remove built-in VFS globals, add PTC instance injection and StateBackend read-your-writes #502

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

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/deepagentsjs/pull/486
Author: @colifran
Created: 4/23/2026
Status: Merged
Merged: 4/28/2026
Merged by: @colifran

Base: mainHead: colifran/pure-repl


📝 Commits (10+)

  • 88260fe remove readFile and writeFile as quickjs defaults, implement bring your own ptc outside of agent tools
  • 72f46fb implement in-memory write buffer for state backends to allow read-your-writes semantics within a single js_eval
  • 33ddc5c remove ptc boolean option
  • 74b5115 linting
  • 740fb2f changeset
  • b269010 read from pregel channel
  • 76b21e3 remove include and exclude from ptc
  • dc2ac92 clean up config
  • 2957266 formatting
  • 3573cb5 remove unneeded config

📊 Changes

10 files changed (+385 additions, -351 deletions)

View changed files

.changeset/fluffy-donkeys-wear.md (+6 -0)
libs/deepagents/src/backends/state.int.test.ts (+80 -0)
📝 libs/deepagents/src/backends/state.test.ts (+40 -41)
📝 libs/deepagents/src/backends/state.ts (+25 -16)
📝 libs/providers/quickjs/src/index.ts (+1 -6)
📝 libs/providers/quickjs/src/middleware.test.ts (+122 -7)
📝 libs/providers/quickjs/src/middleware.ts (+28 -85)
📝 libs/providers/quickjs/src/session.test.ts (+79 -60)
📝 libs/providers/quickjs/src/session.ts (+0 -119)
📝 libs/providers/quickjs/src/types.ts (+4 -17)

📄 Description

Summary

  • Removed built-in readFile/writeFile globals from the QuickJS REPL. File I/O is now exclusively through PTC tools, keeping the REPL a pure JS sandbox with no implicit side effects
  • ptc now accepts StructuredToolInterface instances directly alongside tool name strings. Custom tools can be injected into the REPL without being registered on the agent
  • StateBackend now provides read-your-writes semantics within a single js_eval superstep by reading via __pregel_read with fresh=true. Pregel already tracks pending sends in task.writes; asking for a fresh read applies them through the reducer, removing the need for a manual write buffer
  • Removed ptc: boolean shorthand from QuickJSMiddlewareOptions; use the array or object forms instead

Tests

  • Added 12 unit tests to state.test.ts covering write-then-read, chained edits, ls/grep/glob/readRaw visibility, upload/download, duplicate write error, edit-nonexistent, and superstep boundary behavior (commitSends/clearPending)
  • Expanded middleware.test.ts with PTC instance injection coverage
  • Verified end-to-end with createDeepAgent + createQuickJSMiddleware across 7 scenarios (write-read, write-edit-read, write-ls, write-grep, write-glob, cross-eval, upload-download); traces confirmed in LangSmith

🔄 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/486 **Author:** [@colifran](https://github.com/colifran) **Created:** 4/23/2026 **Status:** ✅ Merged **Merged:** 4/28/2026 **Merged by:** [@colifran](https://github.com/colifran) **Base:** `main` ← **Head:** `colifran/pure-repl` --- ### 📝 Commits (10+) - [`88260fe`](https://github.com/langchain-ai/deepagentsjs/commit/88260fe1f2ffd4e995148f345af354d6fa1eabf9) remove readFile and writeFile as quickjs defaults, implement bring your own ptc outside of agent tools - [`72f46fb`](https://github.com/langchain-ai/deepagentsjs/commit/72f46fbedcec96fa15ae4bc872ba77e22b79cf55) implement in-memory write buffer for state backends to allow read-your-writes semantics within a single js_eval - [`33ddc5c`](https://github.com/langchain-ai/deepagentsjs/commit/33ddc5c93fd1f759cf80e6094b20803d3a479251) remove ptc boolean option - [`74b5115`](https://github.com/langchain-ai/deepagentsjs/commit/74b51150aacc472793a3da5cd986d09872213895) linting - [`740fb2f`](https://github.com/langchain-ai/deepagentsjs/commit/740fb2fdd472f2eaa4af09e9a4f75b46ef113a87) changeset - [`b269010`](https://github.com/langchain-ai/deepagentsjs/commit/b269010ed4c02e03d3703d59d6a492a8f7e5678e) read from pregel channel - [`76b21e3`](https://github.com/langchain-ai/deepagentsjs/commit/76b21e3a687aed06521fb1b8bfbf7e279c6346c5) remove include and exclude from ptc - [`dc2ac92`](https://github.com/langchain-ai/deepagentsjs/commit/dc2ac92c9e0e751b5bd44a596f3dffd582b41adf) clean up config - [`2957266`](https://github.com/langchain-ai/deepagentsjs/commit/2957266f3698f0886f16af55fa7782ace1ce7e36) formatting - [`3573cb5`](https://github.com/langchain-ai/deepagentsjs/commit/3573cb5990cc54906bcc54b6c6f8bb1e6a9403d3) remove unneeded config ### 📊 Changes **10 files changed** (+385 additions, -351 deletions) <details> <summary>View changed files</summary> ➕ `.changeset/fluffy-donkeys-wear.md` (+6 -0) ➕ `libs/deepagents/src/backends/state.int.test.ts` (+80 -0) 📝 `libs/deepagents/src/backends/state.test.ts` (+40 -41) 📝 `libs/deepagents/src/backends/state.ts` (+25 -16) 📝 `libs/providers/quickjs/src/index.ts` (+1 -6) 📝 `libs/providers/quickjs/src/middleware.test.ts` (+122 -7) 📝 `libs/providers/quickjs/src/middleware.ts` (+28 -85) 📝 `libs/providers/quickjs/src/session.test.ts` (+79 -60) 📝 `libs/providers/quickjs/src/session.ts` (+0 -119) 📝 `libs/providers/quickjs/src/types.ts` (+4 -17) </details> ### 📄 Description ### Summary - Removed built-in readFile/writeFile globals from the QuickJS REPL. File I/O is now exclusively through PTC tools, keeping the REPL a pure JS sandbox with no implicit side effects - ptc now accepts StructuredToolInterface instances directly alongside tool name strings. Custom tools can be injected into the REPL without being registered on the agent - StateBackend now provides read-your-writes semantics within a single js_eval superstep by reading via __pregel_read with fresh=true. Pregel already tracks pending sends in task.writes; asking for a fresh read applies them through the reducer, removing the need for a manual write buffer - Removed ptc: boolean shorthand from QuickJSMiddlewareOptions; use the array or object forms instead ### Tests - Added 12 unit tests to state.test.ts covering write-then-read, chained edits, ls/grep/glob/readRaw visibility, upload/download, duplicate write error, edit-nonexistent, and superstep boundary behavior (commitSends/clearPending) - Expanded middleware.test.ts with PTC instance injection coverage - Verified end-to-end with createDeepAgent + createQuickJSMiddleware across 7 scenarios (write-read, write-edit-read, write-ls, write-grep, write-glob, cross-eval, upload-download); traces confirmed in LangSmith --- <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:28 -04:00
yindo closed this issue 2026-06-05 17:23:28 -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#502