Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Add recursive directory watching to the web documentation
Jakub Dobrýca85407b8e74
diff --git a/apps/web/src/app/(docs)/docs/filesystem/watch/page.mdx b/apps/web/src/app/(docs)/docs/filesystem/watch/page.mdxindex 48bd3e346..86fb26f92 100644--- a/apps/web/src/app/(docs)/docs/filesystem/watch/page.mdx+++ b/apps/web/src/app/(docs)/docs/filesystem/watch/page.mdx@@ -39,3 +39,49 @@ for event in events: # $HighlightLineprint(f"wrote to file {event.name}") # $HighlightLine```</CodeGroup>+++## Recursive Watching++You can enable recursive watching using the parameter `recursive`.+++<CodeGroup>+```js+import { Sandbox, FilesystemEventType } from '@e2b/code-interpreter'++const sandbox = await Sandbox.create()+const dirname = '/home/user'++// Start watching directory for changes+const handle = await sandbox.files.watchDir(dirname, async (event) => {+ console.log(event)+ if (event.type === FilesystemEventType.WRITE) {+ console.log(`wrote to file ${event.name}`)+ }+}, {+ recursive: true // $HighlightLine+})++// Trigger file write event+await sandbox.files.write(`${dirname}/my-folder/my-file`, 'hello')+```+```python+from e2b_code_interpreter import Sandbox++sandbox = Sandbox()+dirname = '/home/user'++# Watch directory for changes+handle = sandbox.files.watch_dir(dirname, recursive=True) # $HighlightLine+# Trigger file write event+sandbox.files.write(f"{dirname}/my-folder/my-file", "hello")++# Retrieve the latest new events since the last `get_new_events()` call+events = handle.get_new_events()+for event in events:+ print(event)+ if event.type == FilesystemEventType.Write:+ print(f"wrote to file {event.name}")+```+</CodeGroup>\ No newline at end of file