Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Add missing docstring for managers; Add properties docstrings; Move docstring to interfaces; Fix interface methods declarations
Tomas Valenta9e4489088218
diff --git a/packages/js-sdk/src/sandbox/filesystem.ts b/packages/js-sdk/src/sandbox/filesystem.tsindex 22adfc326..b826d40fe 100644--- a/packages/js-sdk/src/sandbox/filesystem.ts+++ b/packages/js-sdk/src/sandbox/filesystem.ts@@ -8,17 +8,69 @@ export interface FileInfo {name: string}+/**+ * Manager for interacting with the filesystem in the sandbox.+ */export interface FilesystemManager {- readonly write: (- path: string,- content: string,- opts?: CallOpts,- ) => Promise<void>;- readonly writeBytes: (path: string, content: Uint8Array) => Promise<void>;- readonly read: (path: string, opts?: CallOpts) => Promise<string>;- readonly readBytes: (path: string) => Promise<Uint8Array>;- readonly remove: (path: string, opts?: CallOpts) => Promise<void>;- readonly list: (path: string, opts?: CallOpts) => Promise<FileInfo[]>;- readonly makeDir: (path: string, opts?: CallOpts) => Promise<void>;- readonly watchDir: (path: string) => FilesystemWatcher;+ /**+ * Writes content to a new file on path.+ * @param path Path to a new file. For example '/dirA/dirB/newFile.txt' when creating 'newFile.txt'+ * @param content Content to write to a new file+ * @param opts Call options+ * @param {timeout} [opts.timeout] Timeout for call in milliseconds (default is 60 seconds)+ */+ write(path: string, content: string, opts?: CallOpts): Promise<void>;+ /**+ * Write array of bytes to a file.+ * This can be used when you cannot represent the data as an UTF-8 string.+ *+ * A new file will be created if it doesn't exist.+ * If the file already exists, it will be overwritten.+ *+ * @param path path to a file+ * @param content byte array representing the content to write+ */+ writeBytes(path: string, content: Uint8Array): Promise<void>;+ /**+ * Reads the whole content of a file.+ * @param path Path to a file+ * @param opts Call options+ * @param {timeout} [opts.timeout] Timeout for call in milliseconds (default is 60 seconds)+ * @returns Content of a file+ */+ read(path: string, opts?: CallOpts): Promise<string>;+ /**+ * Reads the whole content of a file as an array of bytes.+ * @param path path to a file+ * @returns byte array representing the content of a file+ */+ readBytes(path: string): Promise<Uint8Array>;+ /**+ * Removes a file or a directory.+ * @param path Path to a file or a directory+ * @param opts Call options+ * @param {timeout} [opts.timeout] Timeout for call in milliseconds (default is 60 seconds)+ */+ remove(path: string, opts?: CallOpts): Promise<void>;+ /**+ * List files in a directory.+ * @param path Path to a directory+ * @param opts Call options+ * @param {timeout} [opts.timeout] Timeout for call in milliseconds (default is 60 seconds)+ * @returns Array of files in a directory+ */+ list(path: string, opts?: CallOpts): Promise<FileInfo[]>;+ /**+ * Creates a new directory and all directories along the way if needed on the specified pth.+ * @param path Path to a new directory. For example '/dirA/dirB' when creating 'dirB'.+ * @param opts Call options+ * @param {timeout} [opts.timeout] Timeout for call in milliseconds (default is 60 seconds)+ */+ makeDir(path: string, opts?: CallOpts): Promise<void>;+ /**+ * Watches directory for filesystem events.+ * @param path Path to a directory that will be watched+ * @returns New watcher+ */+ watchDir(path: string): FilesystemWatcher;}diff --git a/packages/js-sdk/src/sandbox/index.ts b/packages/js-sdk/src/sandbox/index.tsindex 4bdab1b9c..adaa6ef32 100644--- a/packages/js-sdk/src/sandbox/index.ts+++ b/packages/js-sdk/src/sandbox/index.ts@@ -60,8 +60,17 @@ export interface Action<T = { [key: string]: any }> {**/export class Sandbox extends SandboxConnection {+ /**+ * Terminal manager used to create interactive terminals.+ */readonly terminal: TerminalManager+ /**+ * Filesystem manager used to manage files.+ */readonly filesystem: FilesystemManager+ /**+ * Process manager used to run commands.+ */readonly process: ProcessManagerreadonly _actions: Map<string, Action<any>> = new Map()@@ -75,13 +84,6 @@ export class Sandbox extends SandboxConnection {// Init Filesystem handlerthis.filesystem = {- /**- * List files in a directory.- * @param path Path to a directory- * @param opts Call options- * @param {timeout} [opts.timeout] Timeout for call in milliseconds (default is 60 seconds)- * @returns Array of files in a directory- */list: async (path, opts?: CallOpts) => {return (await this._call(filesystemService,@@ -90,13 +92,6 @@ export class Sandbox extends SandboxConnection {opts,)) as FileInfo[]},- /**- * Reads the whole content of a file.- * @param path Path to a file- * @param opts Call options- * @param {timeout} [opts.timeout] Timeout for call in milliseconds (default is 60 seconds)- * @returns Content of a file- */read: async (path, opts?: CallOpts) => {return (await this._call(filesystemService,@@ -105,12 +100,6 @@ export class Sandbox extends SandboxConnection {opts,)) as string},- /**- * Removes a file or a directory.- * @param path Path to a file or a directory- * @param opts Call options- * @param {timeout} [opts.timeout] Timeout for call in milliseconds (default is 60 seconds)- */remove: async (path, opts?: CallOpts) => {await this._call(filesystemService,@@ -119,15 +108,6 @@ export class Sandbox extends SandboxConnection {opts,)},- /**- * Writes content to a new file on path.- *-- * @param path Path to a new file. For example '/dirA/dirB/newFile.txt' when creating 'newFile.txt'- * @param content Content to write to a new file- * @param opts Call options- * @param {timeout} [opts.timeout] Timeout for call in milliseconds (default is 60 seconds)- */write: async (path, content, opts?: CallOpts) => {await this._call(filesystemService,@@ -136,16 +116,6 @@ export class Sandbox extends SandboxConnection {opts,)},- /**- * Write array of bytes to a file.- * This can be used when you cannot represent the data as an UTF-8 string.- *- * A new file will be created if it doesn't exist.- * If the file already exists, it will be overwritten.- *- * @param path path to a file- * @param content byte array representing the content to write- */writeBytes: async (path: string, content: Uint8Array) => {// We need to convert the byte array to base64 string without using browser or node specific APIs.// This should be achieved by the node polyfills.@@ -155,11 +125,6 @@ export class Sandbox extends SandboxConnection {base64Content,])},- /**- * Reads the whole content of a file as an array of bytes.- * @param path path to a file- * @returns byte array representing the content of a file- */readBytes: async (path: string) => {const base64Content = (await this._call(filesystemService,@@ -170,12 +135,6 @@ export class Sandbox extends SandboxConnection {// This should be achieved by the node polyfills.return Buffer.from(base64Content, 'base64')},- /**- * Creates a new directory and all directories along the way if needed on the specified pth.- * @param path Path to a new directory. For example '/dirA/dirB' when creating 'dirB'.- * @param opts Call options- * @param {timeout} [opts.timeout] Timeout for call in milliseconds (default is 60 seconds)- */makeDir: async (path, opts?: CallOpts) => {await this._call(filesystemService,@@ -184,11 +143,6 @@ export class Sandbox extends SandboxConnection {opts,)},- /**- * Watches directory for filesystem events.- * @param path Path to a directory that will be watched- * @returns New watcher- */watchDir: (path: string) => {this.logger.debug?.(`Watching directory "${path}"`)const npath = normalizePath(_resolvePath(path))diff --git a/packages/js-sdk/src/sandbox/process.ts b/packages/js-sdk/src/sandbox/process.tsindex de361f915..2e660daf0 100644--- a/packages/js-sdk/src/sandbox/process.ts+++ b/packages/js-sdk/src/sandbox/process.ts@@ -164,6 +164,9 @@ export interface ProcessOpts {timeout?: number;}+/**+ * Manager for starting and interacting with processes in the sandbox.+ */export interface ProcessManager {/*** Starts a new process.diff --git a/packages/js-sdk/src/sandbox/terminal.ts b/packages/js-sdk/src/sandbox/terminal.tsindex 5529e3d12..394e9c322 100644--- a/packages/js-sdk/src/sandbox/terminal.ts+++ b/packages/js-sdk/src/sandbox/terminal.ts@@ -111,6 +111,9 @@ export type TerminalOpts = {timeout?: number;};+/**+ * Manager for starting and interacting with terminal sessions in the sandbox.+ */export interface TerminalManager {- readonly start: (opts: TerminalOpts) => Promise<Terminal>;+ start(opts: TerminalOpts): Promise<Terminal>;}