Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Add watch dir recursive option (missing python client regeneration)
Jakub Dobrý25c4539de62b
diff --git a/packages/js-sdk/src/envd/filesystem/filesystem_pb.ts b/packages/js-sdk/src/envd/filesystem/filesystem_pb.tsindex 10082f531..bf3763f36 100644--- a/packages/js-sdk/src/envd/filesystem/filesystem_pb.ts+++ b/packages/js-sdk/src/envd/filesystem/filesystem_pb.ts@@ -10,7 +10,7 @@ import type { Message } from "@bufbuild/protobuf";* Describes the file filesystem/filesystem.proto.*/export const file_filesystem_filesystem: GenFile = /*@__PURE__*/- fileDesc("ChtmaWxlc3lzdGVtL2ZpbGVzeXN0ZW0ucHJvdG8SCmZpbGVzeXN0ZW0iMgoLTW92ZVJlcXVlc3QSDgoGc291cmNlGAEgASgJEhMKC2Rlc3RpbmF0aW9uGAIgASgJIjQKDE1vdmVSZXNwb25zZRIkCgVlbnRyeRgBIAEoCzIVLmZpbGVzeXN0ZW0uRW50cnlJbmZvIh4KDk1ha2VEaXJSZXF1ZXN0EgwKBHBhdGgYASABKAkiNwoPTWFrZURpclJlc3BvbnNlEiQKBWVudHJ5GAEgASgLMhUuZmlsZXN5c3RlbS5FbnRyeUluZm8iHQoNUmVtb3ZlUmVxdWVzdBIMCgRwYXRoGAEgASgJIhAKDlJlbW92ZVJlc3BvbnNlIhsKC1N0YXRSZXF1ZXN0EgwKBHBhdGgYASABKAkiNAoMU3RhdFJlc3BvbnNlEiQKBWVudHJ5GAEgASgLMhUuZmlsZXN5c3RlbS5FbnRyeUluZm8iSwoJRW50cnlJbmZvEgwKBG5hbWUYASABKAkSIgoEdHlwZRgCIAEoDjIULmZpbGVzeXN0ZW0uRmlsZVR5cGUSDAoEcGF0aBgDIAEoCSIeCg5MaXN0RGlyUmVxdWVzdBIMCgRwYXRoGAEgASgJIjkKD0xpc3REaXJSZXNwb25z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@generated from field: string path = 1;*/path: string;++ /**+ * @generated from field: bool recursive = 2;+ */+ recursive: boolean;};/**@@ -318,6 +323,11 @@ export type CreateWatcherRequest = Message<"filesystem.CreateWatcherRequest"> &* @generated from field: string path = 1;*/path: string;++ /**+ * @generated from field: bool recursive = 2;+ */+ recursive: boolean;};/**diff --git a/packages/js-sdk/src/sandbox/filesystem/index.ts b/packages/js-sdk/src/sandbox/filesystem/index.tsindex f65003ae8..ccba155bc 100644--- a/packages/js-sdk/src/sandbox/filesystem/index.ts+++ b/packages/js-sdk/src/sandbox/filesystem/index.ts@@ -90,6 +90,10 @@ export interface WatchOpts extends FilesystemRequestOpts {* Callback to call when the watch operation stops.*/onExit?: (err?: Error) => void | Promise<void>+ /**+ * Watch the directory recursively+ */+ recursive?: boolean}/**@@ -446,7 +450,10 @@ export class Filesystem {: undefinedconst events = this.rpc.watchDir(- { path },+ {+ path,+ recursive: opts?.recursive ?? false,+ },{headers: {...authenticationHeader(opts?.user),diff --git a/packages/js-sdk/tests/sandbox/files/watch.test.ts b/packages/js-sdk/tests/sandbox/files/watch.test.tsindex 4cb9251f9..9a4127061 100644--- a/packages/js-sdk/tests/sandbox/files/watch.test.ts+++ b/packages/js-sdk/tests/sandbox/files/watch.test.ts@@ -31,6 +31,71 @@ sandboxTest('watch directory changes', async ({ sandbox }) => {await handle.stop()})+sandboxTest('watch recursive directory changes', async ({ sandbox }) => {+ const dirname = 'test_watch_dir'+ const nestedDirname = 'test_nested_watch_dir'+ const filename = 'test_watch.txt'+ const content = 'This file will be watched.'+ const newContent = 'This file has been modified.'++ await sandbox.files.remove(dirname)+ await sandbox.files.makeDir(`${dirname}/${nestedDirname}`)+ await sandbox.files.write(`${dirname}/${nestedDirname}/${filename}`, content)++ let trigger: () => void++ const eventPromise = new Promise<void>((resolve) => {+ trigger = resolve+ })++ const expectedFileName = `${nestedDirname}/${filename}`+ const handle = await sandbox.files.watchDir(dirname, async (event) => {+ if (event.type === FilesystemEventType.WRITE && event.name === expectedFileName) {+ trigger()+ }+ }, {+ recursive: true+ })++ await sandbox.files.write(`${dirname}/${nestedDirname}/${filename}`, newContent)++ await eventPromise++ await handle.stop()+})++sandboxTest('watch recursive directory folder addition', async ({ sandbox }) => {+ const dirname = 'test_watch_dir'+ const nestedDirname = 'test_nested_watch_dir'+ const filename = 'test_watch.txt'+ const content = 'This file will be watched.'++ await sandbox.files.remove(dirname)+ await sandbox.files.makeDir(dirname)++ let trigger: () => void++ const eventPromise = new Promise<void>((resolve) => {+ trigger = resolve+ })++ const expectedFileName = `${nestedDirname}/${filename}`+ const handle = await sandbox.files.watchDir(dirname, async (event) => {+ if (event.type === FilesystemEventType.WRITE && event.name === expectedFileName) {+ trigger()+ }+ }, {+ recursive: true+ })++ await sandbox.files.makeDir(`${dirname}/${nestedDirname}`)+ await sandbox.files.write(`${dirname}/${nestedDirname}/${filename}`, content)++ await eventPromise++ await handle.stop()+})+sandboxTest('watch non-existing directory', async ({ sandbox }) => {const dirname = 'non_existing_watch_dir'diff --git a/packages/python-sdk/e2b/sandbox_async/filesystem/filesystem.py b/packages/python-sdk/e2b/sandbox_async/filesystem/filesystem.pyindex 216147c78..404faf21d 100644--- a/packages/python-sdk/e2b/sandbox_async/filesystem/filesystem.py+++ b/packages/python-sdk/e2b/sandbox_async/filesystem/filesystem.py@@ -343,6 +343,7 @@ class Filesystem:user: Username = "user",request_timeout: Optional[float] = None,timeout: Optional[float] = 60,+ recursive: bool = False,) -> AsyncWatchHandle:"""Watch directory for filesystem events.@@ -353,11 +354,12 @@ class Filesystem::param user: Run the operation as this user:param request_timeout: Timeout for the request in **seconds**:param timeout: Timeout for the watch operation in **seconds**. Using `0` will not limit the watch time+ :param recursive: Watch directory recursively:return: `AsyncWatchHandle` object for stopping watching directory"""events = self._rpc.awatch_dir(- filesystem_pb2.WatchDirRequest(path=path),+ filesystem_pb2.WatchDirRequest(path=path, recursive=recursive),request_timeout=self._connection_config.get_request_timeout(request_timeout),diff --git a/packages/python-sdk/e2b/sandbox_sync/filesystem/filesystem.py b/packages/python-sdk/e2b/sandbox_sync/filesystem/filesystem.pyindex 094d82a71..68a8d606e 100644--- a/packages/python-sdk/e2b/sandbox_sync/filesystem/filesystem.py+++ b/packages/python-sdk/e2b/sandbox_sync/filesystem/filesystem.py@@ -336,6 +336,7 @@ class Filesystem:path: str,user: Username = "user",request_timeout: Optional[float] = None,+ recursive: bool = False,) -> WatchHandle:"""Watch directory for filesystem events.@@ -343,12 +344,13 @@ class Filesystem::param path: Path to a directory to watch:param user: Run the operation as this user:param request_timeout: Timeout for the request in **seconds**+ :param recursive: Watch directory recursively:return: `WatchHandle` object for stopping watching directory"""try:r = self._rpc.create_watcher(- filesystem_pb2.CreateWatcherRequest(path=path),+ filesystem_pb2.CreateWatcherRequest(path=path, recursive=recursive),request_timeout=self._connection_config.get_request_timeout(request_timeout),diff --git a/packages/python-sdk/tests/async/sandbox_async/files/test_watch.py b/packages/python-sdk/tests/async/sandbox_async/files/test_watch.pyindex 19d319a95..0b3dcb211 100644--- a/packages/python-sdk/tests/async/sandbox_async/files/test_watch.py+++ b/packages/python-sdk/tests/async/sandbox_async/files/test_watch.py@@ -35,6 +35,57 @@ async def test_watch_directory_changes(async_sandbox: AsyncSandbox):await handle.stop()+async def test_watch_recursive_directory_changes(async_sandbox: AsyncSandbox):+ dirname = "test_watch_dir"+ nested_dirname = "test_nested_watch_dir"+ filename = "test_watch.txt"+ content = "This file will be watched."++ await async_sandbox.files.remove(dirname)+ await async_sandbox.files.make_dir(f"{dirname}/{nested_dirname}")++ event_triggered = Event()++ expected_filename = f"{nested_dirname}/{filename}"+ def handle_event(e: FilesystemEvent):+ if e.type == FilesystemEventType.WRITE and e.name == expected_filename:+ event_triggered.set()++ handle = await async_sandbox.files.watch_dir(dirname, on_event=handle_event, recursive=True)++ await async_sandbox.files.write(f"{dirname}/{nested_dirname}/{filename}", content)++ await event_triggered.wait()++ await handle.stop()+++async def test_watch_recursive_directory_folder_addition(async_sandbox: AsyncSandbox):+ dirname = "test_watch_dir"+ nested_dirname = "test_nested_watch_dir"+ filename = "test_watch.txt"+ content = "This file will be watched."++ await async_sandbox.files.remove(dirname)+ await async_sandbox.files.make_dir(dirname)++ event_triggered = Event()++ expected_filename = f"{nested_dirname}/{filename}"+ def handle_event(e: FilesystemEvent):+ if e.type == FilesystemEventType.WRITE and e.name == expected_filename:+ event_triggered.set()++ handle = await async_sandbox.files.watch_dir(dirname, on_event=handle_event, recursive=True)++ await async_sandbox.files.make_dir(f"{dirname}/{nested_dirname}")+ await async_sandbox.files.write(f"{dirname}/{nested_dirname}/{filename}", content)++ await event_triggered.wait()++ await handle.stop()++async def test_watch_non_existing_directory(async_sandbox: AsyncSandbox):dirname = "non_existing_watch_dir"diff --git a/packages/python-sdk/tests/sync/sandbox_sync/files/test_watch.py b/packages/python-sdk/tests/sync/sandbox_sync/files/test_watch.pyindex e9fc5faf1..6c701ef89 100644--- a/packages/python-sdk/tests/sync/sandbox_sync/files/test_watch.py+++ b/packages/python-sdk/tests/sync/sandbox_sync/files/test_watch.py@@ -8,7 +8,9 @@ def test_watch_directory_changes(sandbox: Sandbox):filename = "test_watch.txt"content = "This file will be watched."+ sandbox.files.remove(dirname)sandbox.files.make_dir(dirname)+handle = sandbox.files.watch_dir(dirname)sandbox.files.write(f"{dirname}/{filename}", content)@@ -46,6 +48,55 @@ def test_watch_iterated(sandbox: Sandbox):handle.stop()+def test_watch_recursive_directory_changes(sandbox: Sandbox):+ dirname = "test_watch_dir"+ nested_dirname = "test_nested_watch_dir"+ filename = "test_watch.txt"+ content = "This file will be watched."++ sandbox.files.remove(dirname)+ sandbox.files.make_dir(f"{dirname}/{nested_dirname}")++ handle = sandbox.files.watch_dir(dirname, recursive=True)+ sandbox.files.write(f"{dirname}/{nested_dirname}/{filename}", content)++ events = handle.get_new_events()+ assert len(events) == 3+ expected_filename = f"{nested_dirname}/{filename}"+ assert events[0].type == FilesystemEventType.CREATE+ assert events[0].name == expected_filename++ handle.stop()+++def test_watch_recursive_directory_folder_addition(sandbox: Sandbox):+ dirname = "test_watch_dir"+ nested_dirname = "test_nested_watch_dir"+ filename = "test_watch.txt"+ content = "This file will be watched."++ sandbox.files.remove(dirname)+ sandbox.files.make_dir(dirname)++ handle = sandbox.files.watch_dir(dirname, recursive=True)++ sandbox.files.make_dir(f"{dirname}/{nested_dirname}")+ sandbox.files.write(f"{dirname}/{nested_dirname}/{filename}", content)++ expected_filename = f"{nested_dirname}/{filename}"++ events = handle.get_new_events()+ file_changed = False+ for event in events:+ if event.type == FilesystemEventType.WRITE and event.name == expected_filename:+ file_changed = True+ break++ assert file_changed++ handle.stop()++def test_watch_non_existing_directory(sandbox: Sandbox):dirname = "non_existing_watch_dir"diff --git a/spec/envd/filesystem/filesystem.proto b/spec/envd/filesystem/filesystem.protoindex 05694cb20..8c71c4f20 100644--- a/spec/envd/filesystem/filesystem.proto+++ b/spec/envd/filesystem/filesystem.proto@@ -70,6 +70,7 @@ message ListDirResponse {message WatchDirRequest {string path = 1;+ bool recursive = 2;}message FilesystemEvent {@@ -91,6 +92,7 @@ message WatchDirResponse {message CreateWatcherRequest {string path = 1;+ bool recursive = 2;}message CreateWatcherResponse {@@ -106,7 +108,7 @@ message GetWatcherEventsResponse {}message RemoveWatcherRequest {- string watcher_id = 1;+ string watcher_id = 1;}message RemoveWatcherResponse {}