Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Improve docstrings for timeout in JS

Jakub Novak4e315988cf73
diff --git a/packages/js-sdk/src/sandbox/index.ts b/packages/js-sdk/src/sandbox/index.ts
index e4de80c72..893a0fd0d 100644
--- a/packages/js-sdk/src/sandbox/index.ts
+++ b/packages/js-sdk/src/sandbox/index.ts
@@ -21,6 +21,7 @@ export type DownloadFileFormat =
export interface SandboxOpts extends SandboxConnectionOpts {
onScanPorts?: ScanOpenPortsHandler;
+ /** Timeout for sandbox to start */
timeout?: number;
onStdout?: (out: ProcessMessage) => Promise<void> | void;
onStderr?: (out: ProcessMessage) => Promise<void> | void;
@@ -45,7 +46,7 @@ export class Sandbox extends SandboxConnection {
* List files in a directory.
* @param path Path to a directory
* @param opts Call options
- * @param {timeout} [opts.timeout] Timeout in milliseconds (default is 60 seconds)
+ * @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) => {
@@ -60,7 +61,7 @@ export class Sandbox extends SandboxConnection {
* Reads the whole content of a file.
* @param path Path to a file
* @param opts Call options
- * @param {timeout} [opts.timeout] Timeout in milliseconds (default is 60 seconds)
+ * @param {timeout} [opts.timeout] Timeout for call in milliseconds (default is 60 seconds)
* @returns Content of a file
*/
read: async (path, opts?: CallOpts) => {
@@ -75,7 +76,7 @@ export class Sandbox extends SandboxConnection {
* Removes a file or a directory.
* @param path Path to a file or a directory
* @param opts Call options
- * @param {timeout} [opts.timeout] Timeout in milliseconds (default is 60 seconds)
+ * @param {timeout} [opts.timeout] Timeout for call in milliseconds (default is 60 seconds)
*/
remove: async (path, opts?: CallOpts) => {
await this._call(
@@ -90,7 +91,7 @@ export class Sandbox extends SandboxConnection {
* @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 in milliseconds (default is 60 seconds)
+ * @param {timeout} [opts.timeout] Timeout for call in milliseconds (default is 60 seconds)
*/
write: async (path, content, opts?: CallOpts) => {
await this._call(
@@ -135,7 +136,7 @@ export class Sandbox extends SandboxConnection {
* 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 in milliseconds (default is 60 seconds)
+ * @param {timeout} [opts.timeout] Timeout for call in milliseconds (default is 60 seconds)
*/
makeDir: async (path, opts?: CallOpts) => {
await this._call(
@@ -465,7 +466,7 @@ export class Sandbox extends SandboxConnection {
* ```
*/
static async reconnect(sandboxIDorOpts: string | Omit<SandboxOpts, 'id'> & { sandboxID: string }) {
- let sandboxID
+ let sandboxID: string
let opts: SandboxOpts
if (typeof sandboxIDorOpts === 'string'){
sandboxID = sandboxIDorOpts
diff --git a/packages/js-sdk/src/sandbox/process.ts b/packages/js-sdk/src/sandbox/process.ts
index d78d8765e..603ce9f1f 100644
--- a/packages/js-sdk/src/sandbox/process.ts
+++ b/packages/js-sdk/src/sandbox/process.ts
@@ -138,7 +138,7 @@ export class Process {
*
* @param data Data to send
* @param opts Call options
- * @param {timeout} [opts.timeout] Timeout in milliseconds (default is 60 seconds)
+ * @param {timeout} [opts.timeout] Timeout for call in milliseconds (default is 60 seconds)
*/
async sendStdin(data: string, opts?: CallOpts): Promise<void> {
await this.sandbox._call(
@@ -157,9 +157,10 @@ export interface ProcessOpts {
onExit?: (code: number) => Promise<void> | void;
envVars?: EnvVars;
cwd?: string;
- /** @deprecated use cwd instead */
+ /** @deprecated Use cwd instead */
rootDir?: string;
processID?: string;
+ /** Timeout for the process to start in milliseconds */
timeout?: number;
}
diff --git a/packages/js-sdk/src/sandbox/sandboxConnection.ts b/packages/js-sdk/src/sandbox/sandboxConnection.ts
index ec3747b46..a0b223bef 100644
--- a/packages/js-sdk/src/sandbox/sandboxConnection.ts
+++ b/packages/js-sdk/src/sandbox/sandboxConnection.ts
@@ -46,6 +46,7 @@ export interface SandboxConnectionOpts {
}
export interface CallOpts {
+ /** Timeout for the call in milliseconds */
timeout?: number;
}
@@ -272,7 +273,7 @@ export class SandboxConnection {
*
* `open` method requires `this` context - you may need to bind it.
* @param opts Call options
- * @param {timeout} [opts.timeout] Timeout in milliseconds (default is 60 seconds)
+ * @param {timeout} [opts.timeout] Timeout for sandbox to open in milliseconds (default is 60 seconds)
*/
protected async _open(opts: CallOpts) {
const open = async () => {
diff --git a/packages/js-sdk/src/sandbox/terminal.ts b/packages/js-sdk/src/sandbox/terminal.ts
index 4e4cb4e0b..5529e3d12 100644
--- a/packages/js-sdk/src/sandbox/terminal.ts
+++ b/packages/js-sdk/src/sandbox/terminal.ts
@@ -106,7 +106,7 @@ export type TerminalOpts = {
*/
envVars?: EnvVars;
/**
- * Timeout in milliseconds (default is 60 seconds)
+ * Timeout for terminal start in milliseconds (default is 60 seconds)
*/
timeout?: number;
};