Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Map types; Ensure compatibility
Tomas Valentaed9ae8b0b824
diff --git a/packages/js-sdk/src/index.ts b/packages/js-sdk/src/index.tsindex aac3447df..d3992916f 100644--- a/packages/js-sdk/src/index.ts+++ b/packages/js-sdk/src/index.ts@@ -7,8 +7,7 @@ export type { components, paths } from './api'export { ConnectionConfig, SandboxError } from './connectionConfig'export type { ConnectionOpts, Username } from './connectionConfig'-export { EventType } from './envd/filesystem/filesystem_pb'-export type { FilesystemEvent, WatchHandle } from './sandbox/filesystem/watchHandle'+export type { FilesystemEvent, WatchHandle, FilesystemEventType, } from './sandbox/filesystem/watchHandle'export type {EntryInfo,} from './sandbox/filesystem'diff --git a/packages/js-sdk/src/sandbox/filesystem/watchHandle.ts b/packages/js-sdk/src/sandbox/filesystem/watchHandle.tsindex b99f3ee24..28362ce31 100644--- a/packages/js-sdk/src/sandbox/filesystem/watchHandle.ts+++ b/packages/js-sdk/src/sandbox/filesystem/watchHandle.ts@@ -1,12 +1,39 @@-import { PlainMessage } from '@bufbuild/protobuf'import { ConnectError } from '@connectrpc/connect'import { FilesystemError } from '.'import {- WatchDirResponse, WatchDirResponse_FilesystemEvent,+ EventType,+ WatchDirResponse,} from '../../envd/filesystem/filesystem_pb'-export type FilesystemEvent = PlainMessage<WatchDirResponse_FilesystemEvent>++export enum FilesystemEventType {+ CHMOD = 'chmod',+ CREATE = 'create',+ REMOVE = 'remove',+ RENAME = 'rename',+ WRITE = 'write',+}++function mapEventType(type: EventType) {+ switch (type) {+ case EventType.CHMOD:+ return FilesystemEventType.CHMOD+ case EventType.CREATE:+ return FilesystemEventType.CREATE+ case EventType.REMOVE:+ return FilesystemEventType.REMOVE+ case EventType.RENAME:+ return FilesystemEventType.RENAME+ case EventType.WRITE:+ return FilesystemEventType.WRITE+ }+}++export interface FilesystemEvent {+ name: string+ type: FilesystemEventType+}export class WatchHandle {private readonly _wait: Promise<void>@@ -53,7 +80,15 @@ export class WatchHandle {private async handleEvents() {try {for await (const event of this.iterateEvents()) {- this.onEvent?.(event.value)+ const eventType = mapEventType(event.value.type)+ if (eventType === undefined) {+ continue+ }++ this.onEvent?.({+ name: event.value.name,+ type: eventType,+ })}this.onExit?.()} catch (err) {