Agents - Real-time file watching in Sandboxes
4mo ago
Source
CloudflareAgents - Real-time file watching in Sandboxescloudflare.comSandboxes now support real-time filesystem watching via sandbox.watch() . The method returns a Server-Sent Events stream backed by native inotify, so your Worker receives create , modify , delete , and move events as they happen inside the container. sandbox.watch(path, options) Pass a directory path and optional filters. The returned stream is a standard ReadableStream you can proxy directly to a browser client or consume server-side. JavaScript // Stream events to a browser client const stream = await sandbox . watch ( "/workspace/src" , { recursive : true , include : [ "*.ts" , "*.js" ] , } ) ; return new Response ( stream , { headers : { "Content-Type" : "text/event-stream" }, } ) ; TypeScript // Stream events to a browser client const stream = await sandbox . watch ( "/workspace/src" , { recursive : true , include : [ "*.ts" , "*.js" ] , } ) ; return new Response ( stream , { headers : { "Content-Type" : "text/event-stream" }, } ) ; Server-side consumption with parseSSEStream Use parseSSEStream to iterate over events inside a Worker without forwarding them to a client. JavaScript import { parseSSEStream } from "@cloudflare/sandbox" ; const stream = await sandbox . watch ( "/workspace/src" , { recursive : true } ) ; for await ( const event of parseSSEStream ( stream )) { console . log ( event . type , event . path ) ; } TypeScript import { parseSSEStream } from "@cloudflare/sandbox" ; import type { FileWatchSSEEvent } from "@cloudflare/sandbox" ; const stream = await sandbox . watch ( "/workspace/src" , { recursive : true } ) ; for await ( const event of parseSSEStream < FileWatchSSEEvent > ( stream )) { console . log ( event . type , event . path ) ; } Each event includes a type field ( create , modify , delete , or move ) and the affected path . Move events also include a from field with the original path. Options Option Type Description recursive boolean Watch subdirectories. Defaults to false . include string[] Glob patterns to filter events. Omit to receive all events. Upgrade To update to the latest version: npm i @cloudflare/sandbox@latest For full API details, refer to the Sandbox file watching reference .
You might also wanna read
Sandbox-agent: Remote Control Server for Coding AI Agents via HTTP
Sandbox-agent is a server tool that enables remote control of coding AI agents (Claude Code, Codex, OpenCode, Cursor, Amp, Pi) within sandbo
Realtime agent demo
vimeo.com·11mo ago
Agent Sandbox: A Tool for AI Agents to Run Code and Generate Files Locally
Agent Sandbox is a tool that provides AI agents with sandboxed computing capabilities, allowing them to run Python/Bash scripts, install pac
Sandbox Agent: Run AI Coding Agents in Sandboxes with HTTP Control
The article describes Sandbox Agent, a tool for running coding agents in sandboxes with HTTP control. It supports multiple AI coding models
Developer creates filesystem sandbox for coding agents using Linux user namespaces
A developer shares their approach to sandboxing coding agents by implementing a filesystem sandbox using unprivileged user namespaces and ov
Reverse-Engineering Docker's Undocumented MicroVM API for Sandbox Orchestration
Docker ships with an undocumented API for spawning microVMs, which the author reverse-engineered to build the open-source Sandbox Agent SDK.

Comments
Sign in to join the conversation.
No comments yet. Be the first.