{"version":3,"sources":["../src/api/index.ts","../src/api/metadata.ts","../package.json","../src/errors.ts","../src/logs.ts","../src/connectionConfig.ts","../src/sandbox/filesystem/index.ts","../src/envd/api.ts","../src/envd/rpc.ts","../src/envd/filesystem/filesystem_pb.ts","../src/sandbox/filesystem/watchHandle.ts","../src/envd/versions.ts","../src/sandbox/commands/commandHandle.ts","../src/sandbox/index.ts","../src/sandbox/commands/index.ts","../src/envd/process/process_pb.ts","../src/sandbox/commands/pty.ts","../src/sandbox/sandboxApi.ts","../src/index.ts"],"sourcesContent":["import createClient, { FetchResponse } from 'openapi-fetch'\n\nimport type { components, paths } from './schema.gen'\nimport { defaultHeaders } from './metadata'\nimport { ConnectionConfig } from '../connectionConfig'\nimport { AuthenticationError, RateLimitError, SandboxError } from '../errors'\nimport { createApiLogger } from '../logs'\n\nexport function handleApiError(\n  response: FetchResponse<any, any, any>\n): Error | undefined {\n  if (!response.error) {\n    return\n  }\n\n  if (response.response.status === 429) {\n    return new RateLimitError('Rate limit exceeded, please try again later.')\n  }\n\n  const message = response.error?.message ?? response.error\n  return new SandboxError(`${response.response.status}: ${message}`)\n}\n\n/**\n * Client for interacting with the E2B API.\n */\nclass ApiClient {\n  readonly api: ReturnType<typeof createClient<paths>>\n\n  constructor(\n    config: ConnectionConfig,\n    opts: {\n      requireAccessToken?: boolean\n      requireApiKey?: boolean\n    } = { requireAccessToken: false, requireApiKey: true }\n  ) {\n    if (!opts?.requireApiKey && !config.apiKey) {\n      throw new AuthenticationError(\n        'API key is required, please visit the Team tab at https://e2b.dev/dashboard to get your API key. ' +\n          'You can either set the environment variable `E2B_API_KEY` ' +\n          \"or you can pass it directly to the sandbox like Sandbox.create({ apiKey: 'e2b_...' })\"\n      )\n    }\n\n    if (opts?.requireAccessToken && !config.accessToken) {\n      throw new AuthenticationError(\n        'Access token is required, please visit the Personal tab at https://e2b.dev/dashboard to get your access token. ' +\n          'You can set the environment variable `E2B_ACCESS_TOKEN` or pass the `accessToken` in options.'\n      )\n    }\n\n    this.api = createClient<paths>({\n      baseUrl: config.apiUrl,\n      // keepalive: true, // TODO: Return keepalive\n      headers: {\n        ...defaultHeaders,\n        ...(config.apiKey && { 'X-API-KEY': config.apiKey }),\n        ...(config.accessToken && {\n          Authorization: `Bearer ${config.accessToken}`,\n        }),\n        ...config.headers,\n      },\n    })\n\n    if (config.logger) {\n      this.api.use(createApiLogger(config.logger))\n    }\n  }\n}\n\nexport type { components, paths }\nexport { ApiClient }\n","import platform from 'platform'\n\nimport { version } from '../../package.json'\n\ndeclare let window: any\n\ntype Runtime = 'node' | 'browser' | 'deno' | 'bun' | 'vercel-edge' | 'cloudflare-worker' | 'unknown'\n\nfunction getRuntime(): { runtime: Runtime; version: string } {\n  // @ts-ignore\n  if ((globalThis as any).Bun) {\n    // @ts-ignore\n    return { runtime: 'bun', version: globalThis.Bun.version }\n  }\n\n  // @ts-ignore\n  if ((globalThis as any).Deno) {\n    // @ts-ignore\n    return { runtime: 'deno', version: globalThis.Deno.version.deno }\n  }\n\n  if ((globalThis as any).process?.release?.name === 'node') {\n    return { runtime: 'node', version: platform.version || 'unknown' }\n  }\n\n  // @ts-ignore\n  if (typeof EdgeRuntime === 'string') {\n    return { runtime: 'vercel-edge', version: 'unknown' }\n  }\n\n  if ((globalThis as any).navigator?.userAgent === 'Cloudflare-Workers') {\n    return { runtime: 'cloudflare-worker', version: 'unknown' }\n  }\n\n  if (typeof window !== 'undefined') {\n    return { runtime: 'browser', version: platform.version || 'unknown' }\n  }\n\n  return { runtime: 'unknown', version: 'unknown' }\n}\n\nexport const { runtime, version: runtimeVersion } = getRuntime()\n\nexport const defaultHeaders = {\n  browser: (typeof window !== 'undefined' && platform.name) || 'unknown',\n  lang: 'js',\n  lang_version: runtimeVersion,\n  package_version: version,\n  publisher: 'e2b',\n  sdk_runtime: runtime,\n  system: platform.os?.family || 'unknown',\n}\n\nexport function getEnvVar(name: string) {\n  if (runtime === 'deno') {\n    // @ts-ignore\n    return Deno.env.get(name)\n  }\n\n  if (typeof process === 'undefined') {\n    return ''\n  }\n\n  return process.env[name]\n}\n","{\n  \"name\": \"e2b\",\n  \"version\": \"1.2.2\",\n  \"description\": \"E2B SDK that give agents cloud environments\",\n  \"homepage\": \"https://e2b.dev\",\n  \"license\": \"MIT\",\n  \"author\": {\n    \"name\": \"FoundryLabs, Inc.\",\n    \"email\": \"hello@e2b.dev\",\n    \"url\": \"https://e2b.dev\"\n  },\n  \"bugs\": \"https://github.com/e2b-dev/e2b/issues\",\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"https://github.com/e2b-dev/e2b\",\n    \"directory\": \"packages/js-sdk\"\n  },\n  \"publishConfig\": {\n    \"access\": \"public\"\n  },\n  \"sideEffects\": false,\n  \"main\": \"dist/index.js\",\n  \"module\": \"dist/index.mjs\",\n  \"types\": \"dist/index.d.ts\",\n  \"scripts\": {\n    \"prepublishOnly\": \"pnpm build\",\n    \"build\": \"tsc --noEmit && tsup\",\n    \"dev\": \"tsup --watch\",\n    \"example\": \"tsx example.mts\",\n    \"test\": \"vitest run\",\n    \"generate\": \"python ./../../spec/remove_extra_tags.py sandboxes templates && openapi-typescript ../../spec/openapi_generated.yml -x api_key --array-length --alphabetize --output src/api/schema.gen.ts\",\n    \"generate-envd-api\": \"openapi-typescript ../../spec/envd/envd.yaml -x api_key --array-length --alphabetize --output src/envd/schema.gen.ts\",\n    \"generate-ref\": \"./scripts/generate_sdk_ref.sh\",\n    \"check-deps\": \"knip\",\n    \"update-deps\": \"ncu -u && pnpm i\",\n    \"postPublish\": \"./scripts/post-publish.sh || true\",\n    \"test:bun\": \"bun test tests/runtimes/bun --env-file=.env\",\n    \"test:deno\": \"deno test tests/runtimes/deno/ --allow-net --allow-read --allow-env --unstable-sloppy-imports --trace-leaks\",\n    \"test:integration\": \"E2B_INTEGRATION_TEST=1 vitest run tests/integration/**\"\n  },\n  \"devDependencies\": {\n    \"@testing-library/react\": \"^16.2.0\",\n    \"@types/node\": \"^18.18.6\",\n    \"@types/platform\": \"^1.3.6\",\n    \"@types/react\": \"^18.3.11\",\n    \"@typescript-eslint/eslint-plugin\": \"^7.11.0\",\n    \"@typescript-eslint/parser\": \"^7.11.0\",\n    \"@vitejs/plugin-react\": \"^4.3.4\",\n    \"@vitest/browser\": \"^3.0.5\",\n    \"dotenv\": \"^16.4.5\",\n    \"knip\": \"^5.43.6\",\n    \"npm-check-updates\": \"^16.14.20\",\n    \"openapi-typescript\": \"^7.6.1\",\n    \"playwright\": \"^1.48.0\",\n    \"react\": \"^18.3.1\",\n    \"tsup\": \"^8.3.6\",\n    \"typedoc\": \"0.26.8\",\n    \"typedoc-plugin-markdown\": \"4.2.7\",\n    \"typescript\": \"^5.4.5\",\n    \"vitest\": \"^3.0.5\",\n    \"vitest-browser-react\": \"^0.0.4\"\n  },\n  \"files\": [\n    \"dist\",\n    \"README.md\",\n    \"package.json\"\n  ],\n  \"keywords\": [\n    \"e2b\",\n    \"ai-agents\",\n    \"agents\",\n    \"ai\",\n    \"code-interpreter\",\n    \"sandbox\",\n    \"code\",\n    \"runtime\",\n    \"vm\",\n    \"nodejs\",\n    \"javascript\",\n    \"typescript\"\n  ],\n  \"dependencies\": {\n    \"@bufbuild/protobuf\": \"^2.2.2\",\n    \"@connectrpc/connect\": \"2.0.0-rc.3\",\n    \"@connectrpc/connect-web\": \"2.0.0-rc.3\",\n    \"compare-versions\": \"^6.1.0\",\n    \"openapi-fetch\": \"^0.9.7\",\n    \"platform\": \"^1.3.6\"\n  },\n  \"engines\": {\n    \"node\": \">=18\"\n  },\n  \"browserslist\": [\n    \"defaults\"\n  ]\n}\n","// This is the message for the sandbox timeout error when the response code is 502/Unavailable\nexport function formatSandboxTimeoutError(message: string) {\n  return new TimeoutError(\n    `${message}: This error is likely due to sandbox timeout. You can modify the sandbox timeout by passing 'timeoutMs' when starting the sandbox or calling '.setTimeout' on the sandbox with the desired timeout.`\n  )\n}\n\n/**\n * Base class for all sandbox errors.\n *\n * Thrown when general sandbox errors occur.\n */\nexport class SandboxError extends Error {\n  constructor(message: any) {\n    super(message)\n    this.name = 'SandboxError'\n  }\n}\n\n/**\n * Thrown when a timeout error occurs.\n *\n * The [unavailable] error type is caused by sandbox timeout.\n *\n * The [canceled] error type is caused by exceeding request timeout.\n *\n * The [deadline_exceeded] error type is caused by exceeding the timeout for command execution, watch, etc.\n *\n * The [unknown] error type is sometimes caused by the sandbox timeout when the request is not processed correctly.\n */\nexport class TimeoutError extends SandboxError {\n  constructor(message: string) {\n    super(message)\n    this.name = 'TimeoutError'\n  }\n}\n\n/**\n * Thrown when an invalid argument is provided.\n */\nexport class InvalidArgumentError extends SandboxError {\n  constructor(message: string) {\n    super(message)\n    this.name = 'InvalidArgumentError'\n  }\n}\n\n/**\n * Thrown when there is not enough disk space.\n */\nexport class NotEnoughSpaceError extends SandboxError {\n  constructor(message: string) {\n    super(message)\n    this.name = 'NotEnoughSpaceError'\n  }\n}\n\n/**\n * Thrown when a resource is not found.\n */\nexport class NotFoundError extends SandboxError {\n  constructor(message: string) {\n    super(message)\n    this.name = 'NotFoundError'\n  }\n}\n\n/**\n * Thrown when authentication fails.\n */\nexport class AuthenticationError extends SandboxError {\n  constructor(message: any) {\n    super(message)\n    this.name = 'AuthenticationError'\n  }\n}\n\n/**\n * Thrown when the template uses old envd version. It isn't compatible with the new SDK.\n */\nexport class TemplateError extends SandboxError {\n  constructor(message: string) {\n    super(message)\n    this.name = 'TemplateError'\n  }\n}\n\n/**\n * Thrown when the API rate limit is exceeded.\n */\nexport class RateLimitError extends SandboxError {\n  constructor(message: any) {\n    super(message)\n    this.name = 'RateLimitError'\n  }\n}\n","import type { Interceptor } from '@connectrpc/connect'\nimport type { Middleware } from 'openapi-fetch'\n\n/**\n * Logger interface compatible with {@link console} used for logging Sandbox messages.\n */\nexport interface Logger {\n  /**\n   * Debug level logging method.\n   */\n  debug?: (...args: any[]) => void\n  /**\n   * Info level logging method.\n   */\n  info?: (...args: any[]) => void\n  /**\n   * Error level logging method.\n   */\n  error?: (...args: any[]) => void\n}\n\nfunction formatLog(log: any) {\n  return JSON.parse(JSON.stringify(log))\n}\n\nexport function createRpcLogger(logger: Logger): Interceptor {\n  async function* logEach(stream: AsyncIterable<any>) {\n    for await (const m of stream) {\n      logger.debug?.('Response stream:', formatLog(m))\n      yield m\n    }\n  }\n\n  return (next) => async (req) => {\n    logger.info?.(`Request: POST ${req.url}`)\n\n    const res = await next(req)\n    if (res.stream) {\n      return {\n        ...res,\n        message: logEach(res.message),\n      }\n    } else {\n      logger.info?.('Response:', formatLog(res.message))\n    }\n\n    return res\n  }\n}\n\nexport function createApiLogger(logger: Logger): Middleware {\n  return {\n    async onRequest(req) {\n      logger.info?.(`Request ${req.method} ${req.url}`)\n\n      return req\n    },\n    async onResponse(res) {\n      if (res.status >= 400) {\n        logger.error?.('Response:', res.status, res.statusText)\n      } else {\n        logger.info?.('Response:', res.status, res.statusText)\n      }\n\n      return res\n    },\n  }\n}\n","import { Logger } from './logs'\nimport { getEnvVar } from './api/metadata'\n\nconst REQUEST_TIMEOUT_MS = 30_000 // 30 seconds\nexport const KEEPALIVE_PING_INTERVAL_SEC = 50 // 50 seconds\n\nexport const KEEPALIVE_PING_HEADER = 'Keepalive-Ping-Interval'\n\n/**\n * Connection options for requests to the API.\n */\nexport interface ConnectionOpts {\n  /**\n   * E2B API key to use for authentication.\n   *\n   * @default E2B_API_KEY // environment variable\n   */\n  apiKey?: string\n  /**\n   * E2B access token to use for authentication.\n   *\n   * @default E2B_ACCESS_TOKEN // environment variable\n   */\n  accessToken?: string\n  /**\n   * Domain to use for the API.\n   *\n   * @default E2B_DOMAIN // environment variable or `e2b.app`\n   */\n  domain?: string\n  /**\n   * If true the SDK starts in the debug mode and connects to the local envd API server.\n   * @internal\n   * @default E2B_DEBUG // environment variable or `false`\n   */\n  debug?: boolean\n  /**\n   * Timeout for requests to the API in **milliseconds**.\n   *\n   * @default 30_000 // 30 seconds\n   */\n  requestTimeoutMs?: number\n  /**\n   * Logger to use for logging messages. It can accept any object that implements `Logger` interface—for example, {@link console}.\n   */\n  logger?: Logger\n\n  /**\n   * Additional headers to send with the request.\n   */\n  headers?: Record<string, string>\n}\n\n/**\n * Configuration for connecting to the API.\n */\nexport class ConnectionConfig {\n  readonly debug: boolean\n  readonly domain: string\n  readonly apiUrl: string\n  readonly logger?: Logger\n\n  readonly requestTimeoutMs: number\n\n  readonly apiKey?: string\n  readonly accessToken?: string\n\n  readonly headers?: Record<string, string>\n\n  constructor(opts?: ConnectionOpts) {\n    this.apiKey = opts?.apiKey || ConnectionConfig.apiKey\n    this.debug = opts?.debug || ConnectionConfig.debug\n    this.domain = opts?.domain || ConnectionConfig.domain\n    this.accessToken = opts?.accessToken || ConnectionConfig.accessToken\n    this.requestTimeoutMs = opts?.requestTimeoutMs ?? REQUEST_TIMEOUT_MS\n    this.logger = opts?.logger\n    this.headers = opts?.headers\n\n    this.apiUrl = this.debug\n      ? 'http://localhost:3000'\n      : `https://api.${this.domain}`\n  }\n\n  private static get domain() {\n    return getEnvVar('E2B_DOMAIN') || 'e2b.app'\n  }\n\n  private static get debug() {\n    return (getEnvVar('E2B_DEBUG') || 'false').toLowerCase() === 'true'\n  }\n\n  private static get apiKey() {\n    return getEnvVar('E2B_API_KEY')\n  }\n\n  private static get accessToken() {\n    return getEnvVar('E2B_ACCESS_TOKEN')\n  }\n\n  getSignal(requestTimeoutMs?: number) {\n    const timeout = requestTimeoutMs ?? this.requestTimeoutMs\n\n    return timeout ? AbortSignal.timeout(timeout) : undefined\n  }\n}\n\n/**\n * User used for the operation in the sandbox.\n */\nexport type Username = 'root' | 'user'\n\nexport const defaultUsername: Username = 'user'\n","import {\n  createClient,\n  Transport,\n  Client,\n  ConnectError,\n  Code,\n} from '@connectrpc/connect'\nimport {\n  ConnectionConfig,\n  ConnectionOpts,\n  defaultUsername,\n  KEEPALIVE_PING_HEADER,\n  KEEPALIVE_PING_INTERVAL_SEC,\n  Username,\n} from '../../connectionConfig'\n\nimport { handleEnvdApiError, handleWatchDirStartEvent } from '../../envd/api'\nimport { authenticationHeader, handleRpcError } from '../../envd/rpc'\n\nimport { EnvdApiClient } from '../../envd/api'\nimport {\n  FileType as FsFileType,\n  Filesystem as FilesystemService,\n} from '../../envd/filesystem/filesystem_pb'\n\nimport { FilesystemEvent, WatchHandle } from './watchHandle'\n\nimport { compareVersions } from 'compare-versions'\nimport { TemplateError } from '../../errors'\nimport { ENVD_VERSION_RECURSIVE_WATCH } from '../../envd/versions'\n\n/**\n * Sandbox filesystem object information.\n */\nexport interface EntryInfo {\n  /**\n   * Name of the filesystem object.\n   */\n  name: string\n  /**\n   * Type of the filesystem object.\n   */\n  type?: FileType\n  /**\n   * Path to the filesystem object.\n   */\n  path: string\n}\n\n/**\n * Sandbox filesystem object type.\n */\nexport const enum FileType {\n  /**\n   * Filesystem object is a file.\n   */\n  FILE = 'file',\n  /**\n   * Filesystem object is a directory.\n   */\n  DIR = 'dir',\n}\n\nexport type WriteEntry = {\n  path: string\n  data: string | ArrayBuffer | Blob | ReadableStream\n}\n\nfunction mapFileType(fileType: FsFileType) {\n  switch (fileType) {\n    case FsFileType.DIRECTORY:\n      return FileType.DIR\n    case FsFileType.FILE:\n      return FileType.FILE\n  }\n}\n\n/**\n * Options for the sandbox filesystem operations.\n */\nexport interface FilesystemRequestOpts\n  extends Partial<Pick<ConnectionOpts, 'requestTimeoutMs'>> {\n  /**\n   * User to use for the operation in the sandbox.\n   * This affects the resolution of relative paths and ownership of the created filesystem objects.\n   */\n  user?: Username\n}\n\n/**\n * Options for watching a directory.\n */\nexport interface WatchOpts extends FilesystemRequestOpts {\n  /**\n   * Timeout for the watch operation in **milliseconds**.\n   * You can pass `0` to disable the timeout.\n   *\n   * @default 60_000 // 60 seconds\n   */\n  timeoutMs?: number\n  /**\n   * Callback to call when the watch operation stops.\n   */\n  onExit?: (err?: Error) => void | Promise<void>\n  /**\n   * Watch the directory recursively\n   */\n  recursive?: boolean\n}\n\n/**\n * Module for interacting with the sandbox filesystem.\n */\nexport class Filesystem {\n  private readonly rpc: Client<typeof FilesystemService>\n\n  private readonly defaultWatchTimeout = 60_000 // 60 seconds\n  private readonly defaultWatchRecursive = false\n\n  constructor(\n    transport: Transport,\n    private readonly envdApi: EnvdApiClient,\n    private readonly connectionConfig: ConnectionConfig\n  ) {\n    this.rpc = createClient(FilesystemService, transport)\n  }\n\n  /**\n   * Read file content as a `string`.\n   *\n   * You can pass `text`, `bytes`, `blob`, or `stream` to `opts.format` to change the return type.\n   *\n   * @param path path to the file.\n   * @param opts connection options.\n   * @param [opts.format] format of the file content—`text` by default.\n   *\n   * @returns file content as string\n   */\n  async read(\n    path: string,\n    opts?: FilesystemRequestOpts & { format?: 'text' }\n  ): Promise<string>\n  /**\n   * Read file content as a `Uint8Array`.\n   *\n   * You can pass `text`, `bytes`, `blob`, or `stream` to `opts.format` to change the return type.\n   *\n   * @param path path to the file.\n   * @param opts connection options.\n   * @param [opts.format] format of the file content—`bytes`.\n   *\n   * @returns file content as `Uint8Array`\n   */\n  async read(\n    path: string,\n    opts?: FilesystemRequestOpts & { format: 'bytes' }\n  ): Promise<Uint8Array>\n  /**\n   * Read file content as a `Blob`.\n   *\n   * You can pass `text`, `bytes`, `blob`, or `stream` to `opts.format` to change the return type.\n   *\n   * @param path path to the file.\n   * @param opts connection options.\n   * @param [opts.format] format of the file content—`blob`.\n   *\n   * @returns file content as `Blob`\n   */\n  async read(\n    path: string,\n    opts?: FilesystemRequestOpts & { format: 'blob' }\n  ): Promise<Blob>\n  /**\n   * Read file content as a `ReadableStream`.\n   *\n   * You can pass `text`, `bytes`, `blob`, or `stream` to `opts.format` to change the return type.\n   *\n   * @param path path to the file.\n   * @param opts connection options.\n   * @param [opts.format] format of the file content—`stream`.\n   *\n   * @returns file content as `ReadableStream`\n   */\n  async read(\n    path: string,\n    opts?: FilesystemRequestOpts & { format: 'stream' }\n  ): Promise<ReadableStream<Uint8Array>>\n  async read(\n    path: string,\n    opts?: FilesystemRequestOpts & {\n      format?: 'text' | 'stream' | 'bytes' | 'blob'\n    }\n  ): Promise<unknown> {\n    const format = opts?.format ?? 'text'\n\n    const res = await this.envdApi.api.GET('/files', {\n      params: {\n        query: {\n          path,\n          username: opts?.user || defaultUsername,\n        },\n      },\n      parseAs: format === 'bytes' ? 'arrayBuffer' : format,\n      signal: this.connectionConfig.getSignal(opts?.requestTimeoutMs),\n    })\n\n    const err = await handleEnvdApiError(res)\n    if (err) {\n      throw err\n    }\n\n    if (format === 'bytes') {\n      return new Uint8Array(res.data as ArrayBuffer)\n    }\n\n    // When the file is empty, res.data is parsed as `{}`. This is a workaround to return an empty string.\n    if (res.response.headers.get('content-length') === '0') {\n      return ''\n    }\n\n    return res.data\n  }\n\n  /**\n   * Write content to a file.\n   *\n   *\n   * Writing to a file that doesn't exist creates the file.\n   *\n   * Writing to a file that already exists overwrites the file.\n   *\n   * Writing to a file at path that doesn't exist creates the necessary directories.\n   *\n   * @param path path to file.\n   * @param data data to write to the file. Data can be a string, `ArrayBuffer`, `Blob`, or `ReadableStream`.\n   * @param opts connection options.\n   *\n   * @returns information about the written file\n   */\n  async write(\n    path: string,\n    data: string | ArrayBuffer | Blob | ReadableStream,\n    opts?: FilesystemRequestOpts\n  ): Promise<EntryInfo>\n  async write(\n    files: WriteEntry[],\n    opts?: FilesystemRequestOpts\n  ): Promise<EntryInfo[]>\n  async write(\n    pathOrFiles: string | WriteEntry[],\n    dataOrOpts?:\n      | string\n      | ArrayBuffer\n      | Blob\n      | ReadableStream\n      | FilesystemRequestOpts,\n    opts?: FilesystemRequestOpts\n  ): Promise<EntryInfo | EntryInfo[]> {\n    if (typeof pathOrFiles !== 'string' && !Array.isArray(pathOrFiles)) {\n      throw new Error('Path or files are required')\n    }\n\n    if (typeof pathOrFiles === 'string' && Array.isArray(dataOrOpts)) {\n      throw new Error(\n        'Cannot specify both path and array of files. You have to specify either path and data for a single file or an array for multiple files.'\n      )\n    }\n\n    const { path, writeOpts, writeFiles } =\n      typeof pathOrFiles === 'string'\n        ? {\n            path: pathOrFiles,\n            writeOpts: opts as FilesystemRequestOpts,\n            writeFiles: [\n              {\n                data: dataOrOpts as\n                  | string\n                  | ArrayBuffer\n                  | Blob\n                  | ReadableStream,\n              },\n            ],\n          }\n        : {\n            path: undefined,\n            writeOpts: dataOrOpts as FilesystemRequestOpts,\n            writeFiles: pathOrFiles as WriteEntry[],\n          }\n\n    if (writeFiles.length === 0) return [] as EntryInfo[]\n\n    const blobs = await Promise.all(\n      writeFiles.map((f) => new Response(f.data).blob())\n    )\n\n    const res = await this.envdApi.api.POST('/files', {\n      params: {\n        query: {\n          path,\n          username: writeOpts?.user || defaultUsername,\n        },\n      },\n      bodySerializer() {\n        return blobs.reduce((fd, blob, i) => {\n          // Important: RFC 7578, Section 4.2 requires that if a filename is provided,\n          // the directory path information must not be used.\n          // BUT in our case we need to use the directory path information with a custom\n          // muktipart part name getter in envd.\n          fd.append('file', blob, writeFiles[i].path)\n\n          return fd\n        }, new FormData())\n      },\n      body: {},\n      headers: {\n        'Content-Type': 'multipart/form-data',\n        'Bun-Content-Type': 'temporary-fix', // https://github.com/oven-sh/bun/issues/14988\n      },\n    })\n\n    const err = await handleEnvdApiError(res)\n    if (err) {\n      throw err\n    }\n\n    const files = res.data as EntryInfo[]\n    if (!files) {\n      throw new Error('Expected to receive information about written file')\n    }\n\n    return files.length === 1 && path ? files[0] : files\n  }\n\n  /**\n   * List entries in a directory.\n   *\n   * @param path path to the directory.\n   * @param opts connection options.\n   *\n   * @returns list of entries in the sandbox filesystem directory.\n   */\n  async list(path: string, opts?: FilesystemRequestOpts): Promise<EntryInfo[]> {\n    try {\n      const res = await this.rpc.listDir(\n        { path },\n        {\n          headers: authenticationHeader(opts?.user),\n          signal: this.connectionConfig.getSignal(opts?.requestTimeoutMs),\n        }\n      )\n\n      const entries: EntryInfo[] = []\n\n      for (const e of res.entries) {\n        const type = mapFileType(e.type)\n\n        if (type) {\n          entries.push({\n            name: e.name,\n            type,\n            path: e.path,\n          })\n        }\n      }\n\n      return entries\n    } catch (err) {\n      throw handleRpcError(err)\n    }\n  }\n\n  /**\n   * Create a new directory and all directories along the way if needed on the specified path.\n   *\n   * @param path path to a new directory. For example '/dirA/dirB' when creating 'dirB'.\n   * @param opts connection options.\n   *\n   * @returns `true` if the directory was created, `false` if it already exists.\n   */\n  async makeDir(path: string, opts?: FilesystemRequestOpts): Promise<boolean> {\n    try {\n      await this.rpc.makeDir(\n        { path },\n        {\n          headers: authenticationHeader(opts?.user),\n          signal: this.connectionConfig.getSignal(opts?.requestTimeoutMs),\n        }\n      )\n\n      return true\n    } catch (err) {\n      if (err instanceof ConnectError) {\n        if (err.code === Code.AlreadyExists) {\n          return false\n        }\n      }\n\n      throw handleRpcError(err)\n    }\n  }\n\n  /**\n   * Rename a file or directory.\n   *\n   * @param oldPath path to the file or directory to rename.\n   * @param newPath new path for the file or directory.\n   * @param opts connection options.\n   *\n   * @returns information about renamed file or directory.\n   */\n  async rename(\n    oldPath: string,\n    newPath: string,\n    opts?: FilesystemRequestOpts\n  ): Promise<EntryInfo> {\n    try {\n      const res = await this.rpc.move(\n        {\n          source: oldPath,\n          destination: newPath,\n        },\n        {\n          headers: authenticationHeader(opts?.user),\n          signal: this.connectionConfig.getSignal(opts?.requestTimeoutMs),\n        }\n      )\n\n      const entry = res.entry\n      if (!entry) {\n        throw new Error('Expected to receive information about moved object')\n      }\n\n      return {\n        name: entry.name,\n        type: mapFileType(entry.type),\n        path: entry.path,\n      }\n    } catch (err) {\n      throw handleRpcError(err)\n    }\n  }\n\n  /**\n   * Remove a file or directory.\n   *\n   * @param path path to a file or directory.\n   * @param opts connection options.\n   */\n  async remove(path: string, opts?: FilesystemRequestOpts): Promise<void> {\n    try {\n      await this.rpc.remove(\n        { path },\n        {\n          headers: authenticationHeader(opts?.user),\n          signal: this.connectionConfig.getSignal(opts?.requestTimeoutMs),\n        }\n      )\n    } catch (err) {\n      throw handleRpcError(err)\n    }\n  }\n\n  /**\n   * Check if a file or a directory exists.\n   *\n   * @param path path to a file or a directory\n   * @param opts connection options.\n   *\n   * @returns `true` if the file or directory exists, `false` otherwise\n   */\n  async exists(path: string, opts?: FilesystemRequestOpts): Promise<boolean> {\n    try {\n      await this.rpc.stat(\n        { path },\n        {\n          headers: authenticationHeader(opts?.user),\n          signal: this.connectionConfig.getSignal(opts?.requestTimeoutMs),\n        }\n      )\n\n      return true\n    } catch (err) {\n      if (err instanceof ConnectError) {\n        if (err.code === Code.NotFound) {\n          return false\n        }\n      }\n\n      throw handleRpcError(err)\n    }\n  }\n\n  /**\n   * Start watching a directory for filesystem events.\n   *\n   * @param path path to directory to watch.\n   * @param onEvent callback to call when an event in the directory occurs.\n   * @param opts connection options.\n   *\n   * @returns `WatchHandle` object for stopping watching directory.\n   */\n  async watchDir(\n    path: string,\n    onEvent: (event: FilesystemEvent) => void | Promise<void>,\n    opts?: WatchOpts & {\n      timeout?: number\n      onExit?: (err?: Error) => void | Promise<void>\n    }\n  ): Promise<WatchHandle> {\n    if (\n      opts?.recursive &&\n      this.envdApi.version &&\n      compareVersions(this.envdApi.version, ENVD_VERSION_RECURSIVE_WATCH) < 0\n    ) {\n      throw new TemplateError(\n        'You need to update the template to use recursive watching. ' +\n          'You can do this by running `e2b template build` in the directory with the template.'\n      )\n    }\n\n    const requestTimeoutMs =\n      opts?.requestTimeoutMs ?? this.connectionConfig.requestTimeoutMs\n\n    const controller = new AbortController()\n\n    const reqTimeout = requestTimeoutMs\n      ? setTimeout(() => {\n          controller.abort()\n        }, requestTimeoutMs)\n      : undefined\n\n    const events = this.rpc.watchDir(\n      {\n        path,\n        recursive: opts?.recursive ?? this.defaultWatchRecursive,\n      },\n      {\n        headers: {\n          ...authenticationHeader(opts?.user),\n          [KEEPALIVE_PING_HEADER]: KEEPALIVE_PING_INTERVAL_SEC.toString(),\n        },\n        signal: controller.signal,\n        timeoutMs: opts?.timeoutMs ?? this.defaultWatchTimeout,\n      }\n    )\n\n    try {\n      await handleWatchDirStartEvent(events)\n\n      clearTimeout(reqTimeout)\n\n      return new WatchHandle(\n        () => controller.abort(),\n        events,\n        onEvent,\n        opts?.onExit\n      )\n    } catch (err) {\n      throw handleRpcError(err)\n    }\n  }\n}\n","import createClient, { FetchResponse } from 'openapi-fetch'\n\nimport type { components, paths } from './schema.gen'\nimport { ConnectionConfig } from '../connectionConfig'\nimport { createApiLogger } from '../logs'\nimport {\n  SandboxError,\n  InvalidArgumentError,\n  NotFoundError,\n  NotEnoughSpaceError,\n  formatSandboxTimeoutError,\n  AuthenticationError,\n} from '../errors'\nimport { StartResponse, ConnectResponse } from './process/process_pb'\nimport { Code, ConnectError } from '@connectrpc/connect'\nimport { WatchDirResponse } from './filesystem/filesystem_pb'\n\nexport async function handleEnvdApiError<A, B, C extends `${string}/${string}`>(\n  res: FetchResponse<A, B, C>\n) {\n  if (!res.error) {\n    return\n  }\n\n  const message: string =\n    typeof res.error == 'string'\n      ? res.error\n      : res.error?.message || (await res.response.text())\n\n  switch (res.response.status) {\n    case 400:\n      return new InvalidArgumentError(message)\n    case 401:\n      return new AuthenticationError(message)\n    case 404:\n      return new NotFoundError(message)\n    case 429:\n      return new SandboxError(\n        `${res.response.status}: ${message}: The requests are being rate limited.`\n      )\n    case 502:\n      return formatSandboxTimeoutError(message)\n    case 507:\n      return new NotEnoughSpaceError(message)\n    default:\n      return new SandboxError(`${res.response.status}: ${message}`)\n  }\n}\n\nexport async function handleProcessStartEvent(\n  events: AsyncIterable<StartResponse | ConnectResponse>\n) {\n  let startEvent: StartResponse | ConnectResponse\n\n  try {\n    startEvent = (await events[Symbol.asyncIterator]().next()).value\n  } catch (err) {\n    if (err instanceof ConnectError) {\n      if (err.code === Code.Unavailable) {\n        throw new NotFoundError('Sandbox is probably not running anymore')\n      }\n    }\n\n    throw err\n  }\n  if (startEvent.event?.event.case !== 'start') {\n    throw new Error('Expected start event')\n  }\n\n  return startEvent.event.event.value.pid\n}\n\nexport async function handleWatchDirStartEvent(\n  events: AsyncIterable<WatchDirResponse>\n) {\n  let startEvent: WatchDirResponse\n\n  try {\n    startEvent = (await events[Symbol.asyncIterator]().next()).value\n  } catch (err) {\n    if (err instanceof ConnectError) {\n      if (err.code === Code.Unavailable) {\n        throw new NotFoundError('Sandbox is probably not running anymore')\n      }\n    }\n\n    throw err\n  }\n  if (startEvent.event?.case !== 'start') {\n    throw new Error('Expected start event')\n  }\n\n  return startEvent.event.value\n}\n\nclass EnvdApiClient {\n  readonly api: ReturnType<typeof createClient<paths>>\n  readonly version: string | undefined\n\n  constructor(\n    config: Pick<ConnectionConfig, 'apiUrl' | 'logger'>,\n    metadata: {\n      version?: string\n    }\n  ) {\n    this.api = createClient({\n      baseUrl: config.apiUrl,\n      // keepalive: true, // TODO: Return keepalive\n    })\n    this.version = metadata.version\n\n    if (config.logger) {\n      this.api.use(createApiLogger(config.logger))\n    }\n  }\n}\n\nexport type { components, paths }\nexport { EnvdApiClient }\n","import { Code, ConnectError } from '@connectrpc/connect'\nimport { runtime } from '../api/metadata'\nimport { defaultUsername } from '../connectionConfig'\n\nimport { SandboxError, TimeoutError, formatSandboxTimeoutError, InvalidArgumentError, NotFoundError, AuthenticationError } from '../errors'\n\n\nexport function handleRpcError(err: unknown): Error {\n  if (err instanceof ConnectError) {\n    switch (err.code) {\n      case Code.InvalidArgument:\n        return new InvalidArgumentError(err.message)\n      case Code.Unauthenticated:\n        return new AuthenticationError(err.message)\n      case Code.NotFound:\n        return new NotFoundError(err.message)\n      case Code.Unavailable:\n        return formatSandboxTimeoutError(err.message)\n      case Code.Canceled:\n        return new TimeoutError(\n          `${err.message}: This error is likely due to exceeding 'requestTimeoutMs'. You can pass the request timeout value as an option when making the request.`\n        )\n      case Code.DeadlineExceeded:\n        return new TimeoutError(\n          `${err.message}: This error is likely due to exceeding 'timeoutMs' — the total time a long running request (like command execution or directory watch) can be active. It can be modified by passing 'timeoutMs' when making the request. Use '0' to disable the timeout.`\n        )\n      default:\n        return new SandboxError(`${err.code}: ${err.message}`)\n    }\n  }\n\n  return err as Error\n}\n\nfunction encode64(value: string): string {\n  switch (runtime) {\n    case 'deno':\n      return btoa(value)\n    case 'node':\n      return Buffer.from(value).toString('base64')\n    case 'bun':\n      return Buffer.from(value).toString('base64')\n    default:\n      return btoa(value)\n  }\n}\n\nexport function authenticationHeader(username?: string): Record<string, string> {\n  const value = `${username || defaultUsername}:`\n\n  const encoded = encode64(value)\n\n  return { 'Authorization': `Basic ${encoded}` }\n}\n","// @generated by protoc-gen-es v2.2.2 with parameter \"target=ts\"\n// @generated from file filesystem/filesystem.proto (package filesystem, syntax proto3)\n/* eslint-disable */\n\nimport type { GenEnum, GenFile, GenMessage, GenService } from \"@bufbuild/protobuf/codegenv1\";\nimport { enumDesc, fileDesc, messageDesc, serviceDesc } from \"@bufbuild/protobuf/codegenv1\";\nimport type { Message } from \"@bufbuild/protobuf\";\n\n/**\n * Describes the file filesystem/filesystem.proto.\n */\nexport const file_filesystem_filesystem: GenFile = /*@__PURE__*/\n  fileDesc(\"ChtmaWxlc3lzdGVtL2ZpbGVzeXN0ZW0ucHJvdG8SCmZpbGVzeXN0ZW0iMgoLTW92ZVJlcXVlc3QSDgoGc291cmNlGAEgASgJEhMKC2Rlc3RpbmF0aW9uGAIgASgJIjQKDE1vdmVSZXNwb25zZRIkCgVlbnRyeRgBIAEoCzIVLmZpbGVzeXN0ZW0uRW50cnlJbmZvIh4KDk1ha2VEaXJSZXF1ZXN0EgwKBHBhdGgYASABKAkiNwoPTWFrZURpclJlc3BvbnNlEiQKBWVudHJ5GAEgASgLMhUuZmlsZXN5c3RlbS5FbnRyeUluZm8iHQoNUmVtb3ZlUmVxdWVzdBIMCgRwYXRoGAEgASgJIhAKDlJlbW92ZVJlc3BvbnNlIhsKC1N0YXRSZXF1ZXN0EgwKBHBhdGgYASABKAkiNAoMU3RhdFJlc3BvbnNlEiQKBWVudHJ5GAEgASgLMhUuZmlsZXN5c3RlbS5FbnRyeUluZm8iSwoJRW50cnlJbmZvEgwKBG5hbWUYASABKAkSIgoEdHlwZRgCIAEoDjIULmZpbGVz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zUmVzcG9uc2USVAoNUmVtb3ZlV2F0Y2hlchIgLmZpbGVzeXN0ZW0uUmVtb3ZlV2F0Y2hlclJlcXVlc3QaIS5maWxlc3lzdGVtLlJlbW92ZVdhdGNoZXJSZXNwb25zZUJpCg5jb20uZmlsZXN5c3RlbUIPRmlsZXN5c3RlbVByb3RvUAGiAgNGWFiqAgpGaWxlc3lzdGVtygIKRmlsZXN5c3RlbeICFkZpbGVzeXN0ZW1cR1BCTWV0YWRhdGHqAgpGaWxlc3lzdGVtYgZwcm90bzM\");\n\n/**\n * @generated from message filesystem.MoveRequest\n */\nexport type MoveRequest = Message<\"filesystem.MoveRequest\"> & {\n  /**\n   * @generated from field: string source = 1;\n   */\n  source: string;\n\n  /**\n   * @generated from field: string destination = 2;\n   */\n  destination: string;\n};\n\n/**\n * Describes the message filesystem.MoveRequest.\n * Use `create(MoveRequestSchema)` to create a new message.\n */\nexport const MoveRequestSchema: GenMessage<MoveRequest> = /*@__PURE__*/\n  messageDesc(file_filesystem_filesystem, 0);\n\n/**\n * @generated from message filesystem.MoveResponse\n */\nexport type MoveResponse = Message<\"filesystem.MoveResponse\"> & {\n  /**\n   * @generated from field: filesystem.EntryInfo entry = 1;\n   */\n  entry?: EntryInfo;\n};\n\n/**\n * Describes the message filesystem.MoveResponse.\n * Use `create(MoveResponseSchema)` to create a new message.\n */\nexport const MoveResponseSchema: GenMessage<MoveResponse> = /*@__PURE__*/\n  messageDesc(file_filesystem_filesystem, 1);\n\n/**\n * @generated from message filesystem.MakeDirRequest\n */\nexport type MakeDirRequest = Message<\"filesystem.MakeDirRequest\"> & {\n  /**\n   * @generated from field: string path = 1;\n   */\n  path: string;\n};\n\n/**\n * Describes the message filesystem.MakeDirRequest.\n * Use `create(MakeDirRequestSchema)` to create a new message.\n */\nexport const MakeDirRequestSchema: GenMessage<MakeDirRequest> = /*@__PURE__*/\n  messageDesc(file_filesystem_filesystem, 2);\n\n/**\n * @generated from message filesystem.MakeDirResponse\n */\nexport type MakeDirResponse = Message<\"filesystem.MakeDirResponse\"> & {\n  /**\n   * @generated from field: filesystem.EntryInfo entry = 1;\n   */\n  entry?: EntryInfo;\n};\n\n/**\n * Describes the message filesystem.MakeDirResponse.\n * Use `create(MakeDirResponseSchema)` to create a new message.\n */\nexport const MakeDirResponseSchema: GenMessage<MakeDirResponse> = /*@__PURE__*/\n  messageDesc(file_filesystem_filesystem, 3);\n\n/**\n * @generated from message filesystem.RemoveRequest\n */\nexport type RemoveRequest = Message<\"filesystem.RemoveRequest\"> & {\n  /**\n   * @generated from field: string path = 1;\n   */\n  path: string;\n};\n\n/**\n * Describes the message filesystem.RemoveRequest.\n * Use `create(RemoveRequestSchema)` to create a new message.\n */\nexport const RemoveRequestSchema: GenMessage<RemoveRequest> = /*@__PURE__*/\n  messageDesc(file_filesystem_filesystem, 4);\n\n/**\n * @generated from message filesystem.RemoveResponse\n */\nexport type RemoveResponse = Message<\"filesystem.RemoveResponse\"> & {\n};\n\n/**\n * Describes the message filesystem.RemoveResponse.\n * Use `create(RemoveResponseSchema)` to create a new message.\n */\nexport const RemoveResponseSchema: GenMessage<RemoveResponse> = /*@__PURE__*/\n  messageDesc(file_filesystem_filesystem, 5);\n\n/**\n * @generated from message filesystem.StatRequest\n */\nexport type StatRequest = Message<\"filesystem.StatRequest\"> & {\n  /**\n   * @generated from field: string path = 1;\n   */\n  path: string;\n};\n\n/**\n * Describes the message filesystem.StatRequest.\n * Use `create(StatRequestSchema)` to create a new message.\n */\nexport const StatRequestSchema: GenMessage<StatRequest> = /*@__PURE__*/\n  messageDesc(file_filesystem_filesystem, 6);\n\n/**\n * @generated from message filesystem.StatResponse\n */\nexport type StatResponse = Message<\"filesystem.StatResponse\"> & {\n  /**\n   * @generated from field: filesystem.EntryInfo entry = 1;\n   */\n  entry?: EntryInfo;\n};\n\n/**\n * Describes the message filesystem.StatResponse.\n * Use `create(StatResponseSchema)` to create a new message.\n */\nexport const StatResponseSchema: GenMessage<StatResponse> = /*@__PURE__*/\n  messageDesc(file_filesystem_filesystem, 7);\n\n/**\n * @generated from message filesystem.EntryInfo\n */\nexport type EntryInfo = Message<\"filesystem.EntryInfo\"> & {\n  /**\n   * @generated from field: string name = 1;\n   */\n  name: string;\n\n  /**\n   * @generated from field: filesystem.FileType type = 2;\n   */\n  type: FileType;\n\n  /**\n   * @generated from field: string path = 3;\n   */\n  path: string;\n};\n\n/**\n * Describes the message filesystem.EntryInfo.\n * Use `create(EntryInfoSchema)` to create a new message.\n */\nexport const EntryInfoSchema: GenMessage<EntryInfo> = /*@__PURE__*/\n  messageDesc(file_filesystem_filesystem, 8);\n\n/**\n * @generated from message filesystem.ListDirRequest\n */\nexport type ListDirRequest = Message<\"filesystem.ListDirRequest\"> & {\n  /**\n   * @generated from field: string path = 1;\n   */\n  path: string;\n};\n\n/**\n * Describes the message filesystem.ListDirRequest.\n * Use `create(ListDirRequestSchema)` to create a new message.\n */\nexport const ListDirRequestSchema: GenMessage<ListDirRequest> = /*@__PURE__*/\n  messageDesc(file_filesystem_filesystem, 9);\n\n/**\n * @generated from message filesystem.ListDirResponse\n */\nexport type ListDirResponse = Message<\"filesystem.ListDirResponse\"> & {\n  /**\n   * @generated from field: repeated filesystem.EntryInfo entries = 1;\n   */\n  entries: EntryInfo[];\n};\n\n/**\n * Describes the message filesystem.ListDirResponse.\n * Use `create(ListDirResponseSchema)` to create a new message.\n */\nexport const ListDirResponseSchema: GenMessage<ListDirResponse> = /*@__PURE__*/\n  messageDesc(file_filesystem_filesystem, 10);\n\n/**\n * @generated from message filesystem.WatchDirRequest\n */\nexport type WatchDirRequest = Message<\"filesystem.WatchDirRequest\"> & {\n  /**\n   * @generated from field: string path = 1;\n   */\n  path: string;\n\n  /**\n   * @generated from field: bool recursive = 2;\n   */\n  recursive: boolean;\n};\n\n/**\n * Describes the message filesystem.WatchDirRequest.\n * Use `create(WatchDirRequestSchema)` to create a new message.\n */\nexport const WatchDirRequestSchema: GenMessage<WatchDirRequest> = /*@__PURE__*/\n  messageDesc(file_filesystem_filesystem, 11);\n\n/**\n * @generated from message filesystem.FilesystemEvent\n */\nexport type FilesystemEvent = Message<\"filesystem.FilesystemEvent\"> & {\n  /**\n   * @generated from field: string name = 1;\n   */\n  name: string;\n\n  /**\n   * @generated from field: filesystem.EventType type = 2;\n   */\n  type: EventType;\n};\n\n/**\n * Describes the message filesystem.FilesystemEvent.\n * Use `create(FilesystemEventSchema)` to create a new message.\n */\nexport const FilesystemEventSchema: GenMessage<FilesystemEvent> = /*@__PURE__*/\n  messageDesc(file_filesystem_filesystem, 12);\n\n/**\n * @generated from message filesystem.WatchDirResponse\n */\nexport type WatchDirResponse = Message<\"filesystem.WatchDirResponse\"> & {\n  /**\n   * @generated from oneof filesystem.WatchDirResponse.event\n   */\n  event: {\n    /**\n     * @generated from field: filesystem.WatchDirResponse.StartEvent start = 1;\n     */\n    value: WatchDirResponse_StartEvent;\n    case: \"start\";\n  } | {\n    /**\n     * @generated from field: filesystem.FilesystemEvent filesystem = 2;\n     */\n    value: FilesystemEvent;\n    case: \"filesystem\";\n  } | {\n    /**\n     * @generated from field: filesystem.WatchDirResponse.KeepAlive keepalive = 3;\n     */\n    value: WatchDirResponse_KeepAlive;\n    case: \"keepalive\";\n  } | { case: undefined; value?: undefined };\n};\n\n/**\n * Describes the message filesystem.WatchDirResponse.\n * Use `create(WatchDirResponseSchema)` to create a new message.\n */\nexport const WatchDirResponseSchema: GenMessage<WatchDirResponse> = /*@__PURE__*/\n  messageDesc(file_filesystem_filesystem, 13);\n\n/**\n * @generated from message filesystem.WatchDirResponse.StartEvent\n */\nexport type WatchDirResponse_StartEvent = Message<\"filesystem.WatchDirResponse.StartEvent\"> & {\n};\n\n/**\n * Describes the message filesystem.WatchDirResponse.StartEvent.\n * Use `create(WatchDirResponse_StartEventSchema)` to create a new message.\n */\nexport const WatchDirResponse_StartEventSchema: GenMessage<WatchDirResponse_StartEvent> = /*@__PURE__*/\n  messageDesc(file_filesystem_filesystem, 13, 0);\n\n/**\n * @generated from message filesystem.WatchDirResponse.KeepAlive\n */\nexport type WatchDirResponse_KeepAlive = Message<\"filesystem.WatchDirResponse.KeepAlive\"> & {\n};\n\n/**\n * Describes the message filesystem.WatchDirResponse.KeepAlive.\n * Use `create(WatchDirResponse_KeepAliveSchema)` to create a new message.\n */\nexport const WatchDirResponse_KeepAliveSchema: GenMessage<WatchDirResponse_KeepAlive> = /*@__PURE__*/\n  messageDesc(file_filesystem_filesystem, 13, 1);\n\n/**\n * @generated from message filesystem.CreateWatcherRequest\n */\nexport type CreateWatcherRequest = Message<\"filesystem.CreateWatcherRequest\"> & {\n  /**\n   * @generated from field: string path = 1;\n   */\n  path: string;\n\n  /**\n   * @generated from field: bool recursive = 2;\n   */\n  recursive: boolean;\n};\n\n/**\n * Describes the message filesystem.CreateWatcherRequest.\n * Use `create(CreateWatcherRequestSchema)` to create a new message.\n */\nexport const CreateWatcherRequestSchema: GenMessage<CreateWatcherRequest> = /*@__PURE__*/\n  messageDesc(file_filesystem_filesystem, 14);\n\n/**\n * @generated from message filesystem.CreateWatcherResponse\n */\nexport type CreateWatcherResponse = Message<\"filesystem.CreateWatcherResponse\"> & {\n  /**\n   * @generated from field: string watcher_id = 1;\n   */\n  watcherId: string;\n};\n\n/**\n * Describes the message filesystem.CreateWatcherResponse.\n * Use `create(CreateWatcherResponseSchema)` to create a new message.\n */\nexport const CreateWatcherResponseSchema: GenMessage<CreateWatcherResponse> = /*@__PURE__*/\n  messageDesc(file_filesystem_filesystem, 15);\n\n/**\n * @generated from message filesystem.GetWatcherEventsRequest\n */\nexport type GetWatcherEventsRequest = Message<\"filesystem.GetWatcherEventsRequest\"> & {\n  /**\n   * @generated from field: string watcher_id = 1;\n   */\n  watcherId: string;\n};\n\n/**\n * Describes the message filesystem.GetWatcherEventsRequest.\n * Use `create(GetWatcherEventsRequestSchema)` to create a new message.\n */\nexport const GetWatcherEventsRequestSchema: GenMessage<GetWatcherEventsRequest> = /*@__PURE__*/\n  messageDesc(file_filesystem_filesystem, 16);\n\n/**\n * @generated from message filesystem.GetWatcherEventsResponse\n */\nexport type GetWatcherEventsResponse = Message<\"filesystem.GetWatcherEventsResponse\"> & {\n  /**\n   * @generated from field: repeated filesystem.FilesystemEvent events = 1;\n   */\n  events: FilesystemEvent[];\n};\n\n/**\n * Describes the message filesystem.GetWatcherEventsResponse.\n * Use `create(GetWatcherEventsResponseSchema)` to create a new message.\n */\nexport const GetWatcherEventsResponseSchema: GenMessage<GetWatcherEventsResponse> = /*@__PURE__*/\n  messageDesc(file_filesystem_filesystem, 17);\n\n/**\n * @generated from message filesystem.RemoveWatcherRequest\n */\nexport type RemoveWatcherRequest = Message<\"filesystem.RemoveWatcherRequest\"> & {\n  /**\n   * @generated from field: string watcher_id = 1;\n   */\n  watcherId: string;\n};\n\n/**\n * Describes the message filesystem.RemoveWatcherRequest.\n * Use `create(RemoveWatcherRequestSchema)` to create a new message.\n */\nexport const RemoveWatcherRequestSchema: GenMessage<RemoveWatcherRequest> = /*@__PURE__*/\n  messageDesc(file_filesystem_filesystem, 18);\n\n/**\n * @generated from message filesystem.RemoveWatcherResponse\n */\nexport type RemoveWatcherResponse = Message<\"filesystem.RemoveWatcherResponse\"> & {\n};\n\n/**\n * Describes the message filesystem.RemoveWatcherResponse.\n * Use `create(RemoveWatcherResponseSchema)` to create a new message.\n */\nexport const RemoveWatcherResponseSchema: GenMessage<RemoveWatcherResponse> = /*@__PURE__*/\n  messageDesc(file_filesystem_filesystem, 19);\n\n/**\n * @generated from enum filesystem.FileType\n */\nexport enum FileType {\n  /**\n   * @generated from enum value: FILE_TYPE_UNSPECIFIED = 0;\n   */\n  UNSPECIFIED = 0,\n\n  /**\n   * @generated from enum value: FILE_TYPE_FILE = 1;\n   */\n  FILE = 1,\n\n  /**\n   * @generated from enum value: FILE_TYPE_DIRECTORY = 2;\n   */\n  DIRECTORY = 2,\n}\n\n/**\n * Describes the enum filesystem.FileType.\n */\nexport const FileTypeSchema: GenEnum<FileType> = /*@__PURE__*/\n  enumDesc(file_filesystem_filesystem, 0);\n\n/**\n * @generated from enum filesystem.EventType\n */\nexport enum EventType {\n  /**\n   * @generated from enum value: EVENT_TYPE_UNSPECIFIED = 0;\n   */\n  UNSPECIFIED = 0,\n\n  /**\n   * @generated from enum value: EVENT_TYPE_CREATE = 1;\n   */\n  CREATE = 1,\n\n  /**\n   * @generated from enum value: EVENT_TYPE_WRITE = 2;\n   */\n  WRITE = 2,\n\n  /**\n   * @generated from enum value: EVENT_TYPE_REMOVE = 3;\n   */\n  REMOVE = 3,\n\n  /**\n   * @generated from enum value: EVENT_TYPE_RENAME = 4;\n   */\n  RENAME = 4,\n\n  /**\n   * @generated from enum value: EVENT_TYPE_CHMOD = 5;\n   */\n  CHMOD = 5,\n}\n\n/**\n * Describes the enum filesystem.EventType.\n */\nexport const EventTypeSchema: GenEnum<EventType> = /*@__PURE__*/\n  enumDesc(file_filesystem_filesystem, 1);\n\n/**\n * @generated from service filesystem.Filesystem\n */\nexport const Filesystem: GenService<{\n  /**\n   * @generated from rpc filesystem.Filesystem.Stat\n   */\n  stat: {\n    methodKind: \"unary\";\n    input: typeof StatRequestSchema;\n    output: typeof StatResponseSchema;\n  },\n  /**\n   * @generated from rpc filesystem.Filesystem.MakeDir\n   */\n  makeDir: {\n    methodKind: \"unary\";\n    input: typeof MakeDirRequestSchema;\n    output: typeof MakeDirResponseSchema;\n  },\n  /**\n   * @generated from rpc filesystem.Filesystem.Move\n   */\n  move: {\n    methodKind: \"unary\";\n    input: typeof MoveRequestSchema;\n    output: typeof MoveResponseSchema;\n  },\n  /**\n   * @generated from rpc filesystem.Filesystem.ListDir\n   */\n  listDir: {\n    methodKind: \"unary\";\n    input: typeof ListDirRequestSchema;\n    output: typeof ListDirResponseSchema;\n  },\n  /**\n   * @generated from rpc filesystem.Filesystem.Remove\n   */\n  remove: {\n    methodKind: \"unary\";\n    input: typeof RemoveRequestSchema;\n    output: typeof RemoveResponseSchema;\n  },\n  /**\n   * @generated from rpc filesystem.Filesystem.WatchDir\n   */\n  watchDir: {\n    methodKind: \"server_streaming\";\n    input: typeof WatchDirRequestSchema;\n    output: typeof WatchDirResponseSchema;\n  },\n  /**\n   * Non-streaming versions of WatchDir\n   *\n   * @generated from rpc filesystem.Filesystem.CreateWatcher\n   */\n  createWatcher: {\n    methodKind: \"unary\";\n    input: typeof CreateWatcherRequestSchema;\n    output: typeof CreateWatcherResponseSchema;\n  },\n  /**\n   * @generated from rpc filesystem.Filesystem.GetWatcherEvents\n   */\n  getWatcherEvents: {\n    methodKind: \"unary\";\n    input: typeof GetWatcherEventsRequestSchema;\n    output: typeof GetWatcherEventsResponseSchema;\n  },\n  /**\n   * @generated from rpc filesystem.Filesystem.RemoveWatcher\n   */\n  removeWatcher: {\n    methodKind: \"unary\";\n    input: typeof RemoveWatcherRequestSchema;\n    output: typeof RemoveWatcherResponseSchema;\n  },\n}> = /*@__PURE__*/\n  serviceDesc(file_filesystem_filesystem, 0);\n\n","import { handleRpcError } from '../../envd/rpc'\nimport {\n  EventType,\n  WatchDirResponse,\n} from '../../envd/filesystem/filesystem_pb'\n\n/**\n * Sandbox filesystem event types.\n */\nexport const enum FilesystemEventType {\n  /**\n   * Filesystem object permissions were changed.\n   */\n  CHMOD = 'chmod',\n  /**\n   * Filesystem object was created.\n   */\n  CREATE = 'create',\n  /**\n   * Filesystem object was removed.\n   */\n  REMOVE = 'remove',\n  /**\n   * Filesystem object was renamed.\n   */\n  RENAME = 'rename',\n  /**\n   * Filesystem object was written to.\n   */\n  WRITE = 'write',\n}\n\nfunction mapEventType(type: EventType) {\n  switch (type) {\n    case EventType.CHMOD:\n      return FilesystemEventType.CHMOD\n    case EventType.CREATE:\n      return FilesystemEventType.CREATE\n    case EventType.REMOVE:\n      return FilesystemEventType.REMOVE\n    case EventType.RENAME:\n      return FilesystemEventType.RENAME\n    case EventType.WRITE:\n      return FilesystemEventType.WRITE\n  }\n}\n\n/**\n * Information about a filesystem event.\n */\nexport interface FilesystemEvent {\n  /**\n   * Relative path to the filesystem object.\n   */\n  name: string\n  /**\n   * Filesystem operation event type.\n   */\n  type: FilesystemEventType\n}\n\n/**\n * Handle for watching a directory in the sandbox filesystem.\n *\n * Use {@link WatchHandle.stop} to stop watching the directory.\n */\nexport class WatchHandle {\n  constructor(\n    private readonly handleStop: () => void,\n    private readonly events: AsyncIterable<WatchDirResponse>,\n    private readonly onEvent?: (event: FilesystemEvent) => void | Promise<void>,\n    private readonly onExit?: (err?: Error) => void | Promise<void>\n  ) {\n    this.handleEvents()\n  }\n\n  /**\n   * Stop watching the directory.\n   */\n  async stop() {\n    this.handleStop()\n  }\n\n  private async *iterateEvents() {\n    try {\n      for await (const event of this.events) {\n        switch (event.event.case) {\n          case 'filesystem':\n            yield event.event\n            break\n        }\n      }\n    } catch (err) {\n      throw handleRpcError(err)\n    }\n  }\n\n  private async handleEvents() {\n    try {\n      for await (const event of this.iterateEvents()) {\n        const eventType = mapEventType(event.value.type)\n        if (eventType === undefined) {\n          continue\n        }\n\n        this.onEvent?.({\n          name: event.value.name,\n          type: eventType,\n        })\n      }\n      this.onExit?.()\n    } catch (err) {\n      this.onExit?.(err as Error)\n    }\n  }\n}\n","export const ENVD_VERSION_RECURSIVE_WATCH = '0.1.4'","import { handleRpcError } from '../../envd/rpc'\nimport { SandboxError } from '../../errors'\nimport { ConnectResponse, StartResponse } from '../../envd/process/process_pb'\n\ndeclare const __brand: unique symbol\ntype Brand<B> = { [__brand]: B }\nexport type Branded<T, B> = T & Brand<B>\n\nexport type Stdout = Branded<string, 'stdout'>\nexport type Stderr = Branded<string, 'stderr'>\nexport type PtyOutput = Branded<Uint8Array, 'pty'>\n\n/**\n * Command execution result.\n */\nexport interface CommandResult {\n  /**\n   * Command execution exit code.\n   * `0` if the command finished successfully.\n   */\n  exitCode: number\n  /**\n   * Error message from command execution if it failed.\n   */\n  error?: string\n  /**\n   * Command stdout output.\n   */\n  stdout: string\n  /**\n   * Command stderr output.\n   */\n  stderr: string\n}\n\n/**\n * Error thrown when a command exits with a non-zero exit code.\n */\nexport class CommandExitError extends SandboxError implements CommandResult {\n  constructor(private readonly result: CommandResult) {\n    super(result.error)\n    this.name = 'CommandExitError'\n  }\n\n  /**\n   * Command execution exit code.\n   * `0` if the command finished successfully.\n   */\n  get exitCode() {\n    return this.result.exitCode\n  }\n\n  /**\n   * Error message from command execution.\n   */\n  get error() {\n    return this.result.error\n  }\n\n  /**\n   * Command execution stdout output.\n   */\n  get stdout() {\n    return this.result.stdout\n  }\n\n  /**\n   * Command execution stderr output.\n   */\n  get stderr() {\n    return this.result.stderr\n  }\n}\n\n/**\n * Command execution handle.\n *\n * It provides methods for waiting for the command to finish, retrieving stdout/stderr, and killing the command.\n *\n * @property {number} pid process ID of the command.\n */\nexport class CommandHandle\n  implements\n  Omit<CommandResult, 'exitCode' | 'error'>,\n  Partial<Pick<CommandResult, 'exitCode' | 'error'>>\n{\n  private _stdout = ''\n  private _stderr = ''\n\n  private result?: CommandResult\n  private iterationError?: Error\n\n  private readonly _wait: Promise<void>\n\n  /**\n   * @hidden\n   * @internal\n   * @access protected\n   */\n  constructor(\n    readonly pid: number,\n    private readonly handleDisconnect: () => void,\n    private readonly handleKill: () => Promise<boolean>,\n    private readonly events: AsyncIterable<ConnectResponse | StartResponse>,\n    private readonly onStdout?: (stdout: string) => void | Promise<void>,\n    private readonly onStderr?: (stderr: string) => void | Promise<void>,\n    private readonly onPty?: (pty: Uint8Array) => void | Promise<void>\n  ) {\n    this._wait = this.handleEvents()\n  }\n\n  /**\n   * Command execution exit code.\n   * `0` if the command finished successfully.\n   * \n   * It is `undefined` if the command is still running.\n   */\n  get exitCode() {\n    return this.result?.exitCode\n  }\n\n  /**\n   * Error message from command execution.\n   */\n  get error() {\n    return this.result?.error\n  }\n\n  /**\n   * Command execution stderr output.\n   */\n  get stderr() {\n    return this._stderr\n  }\n\n  /**\n   * Command execution stdout output.\n   */\n  get stdout() {\n    return this._stdout\n  }\n\n  /**\n   * Wait for the command to finish and return the result.\n   * If the command exits with a non-zero exit code, it throws a `CommandExitError`.\n   * \n   * @returns `CommandResult` result of command execution.\n   */\n  async wait() {\n    await this._wait\n\n    if (this.iterationError) {\n      throw this.iterationError\n    }\n\n    if (!this.result) {\n      throw new SandboxError('Process exited without a result')\n    }\n\n    if (this.result.exitCode !== 0) {\n      throw new CommandExitError(this.result)\n    }\n\n    return this.result\n  }\n\n  /**\n   * Disconnect from the command.\n   * \n   * The command is not killed, but SDK stops receiving events from the command.\n   * You can reconnect to the command using {@link Commands.connect}.\n   */\n  async disconnect() {\n    this.handleDisconnect()\n  }\n\n  /**\n   * Kill the command.\n   * It uses `SIGKILL` signal to kill the command.\n   * \n   * @returns `true` if the command was killed successfully, `false` if the command was not found.\n   */\n  async kill() {\n    return await this.handleKill()\n  }\n\n  private async *iterateEvents(): AsyncGenerator<\n    [Stdout, null, null] | [null, Stderr, null] | [null, null, PtyOutput]\n  > {\n    for await (const event of this.events) {\n      const e = event?.event?.event\n      let out: string | undefined\n\n      switch (e?.case) {\n        case 'data':\n          switch (e.value.output.case) {\n            case 'stdout':\n              out = new TextDecoder().decode(e.value.output.value)\n              this._stdout += out\n              yield [out as Stdout, null, null]\n              break\n            case 'stderr':\n              out = new TextDecoder().decode(e.value.output.value)\n              this._stderr += out\n              yield [null, out as Stderr, null]\n              break\n            case 'pty':\n              yield [null, null, e.value.output.value as PtyOutput]\n              break\n          }\n          break\n        case 'end':\n          this.result = {\n            exitCode: e.value.exitCode,\n            error: e.value.error,\n            stdout: this.stdout,\n            stderr: this.stderr,\n          }\n          break\n      }\n      // TODO: Handle empty events like in python SDK\n    }\n  }\n\n  private async handleEvents() {\n    try {\n      for await (const [stdout, stderr, pty] of this.iterateEvents()) {\n        if (stdout !== null) {\n          this.onStdout?.(stdout)\n        } else if (stderr !== null) {\n          this.onStderr?.(stderr)\n        } else if (pty) {\n          this.onPty?.(pty)\n        }\n      }\n    } catch (e) {\n      this.iterationError = handleRpcError(e)\n    }\n  }\n}\n","import { createConnectTransport } from '@connectrpc/connect-web'\n\nimport {\n  ConnectionConfig,\n  ConnectionOpts,\n  defaultUsername,\n} from '../connectionConfig'\nimport { EnvdApiClient, handleEnvdApiError } from '../envd/api'\nimport { createRpcLogger } from '../logs'\nimport { Commands, Pty } from './commands'\nimport { Filesystem } from './filesystem'\nimport { SandboxApi } from './sandboxApi'\n\n/**\n * Options for creating a new Sandbox.\n */\nexport interface SandboxOpts extends ConnectionOpts {\n  /**\n   * Custom metadata for the sandbox.\n   *\n   * @default {}\n   */\n  metadata?: Record<string, string>\n  /**\n   * Custom environment variables for the sandbox.\n   *\n   * Used when executing commands and code in the sandbox.\n   * Can be overridden with the `envs` argument when executing commands or code.\n   *\n   * @default {}\n   */\n  envs?: Record<string, string>\n  /**\n   * Timeout for the sandbox in **milliseconds**.\n   * Maximum time a sandbox can be kept alive is 24 hours (86_400_000 milliseconds) for Pro users and 1 hour (3_600_000 milliseconds) for Hobby users.\n   *\n   * @default 300_000 // 5 minutes\n   */\n  timeoutMs?: number\n}\n\n/**\n * E2B cloud sandbox is a secure and isolated cloud environment.\n *\n * The sandbox allows you to:\n * - Access Linux OS\n * - Create, list, and delete files and directories\n * - Run commands\n * - Run isolated code\n * - Access the internet\n *\n * Check docs [here](https://e2b.dev/docs).\n *\n * Use {@link Sandbox.create} to create a new sandbox.\n *\n * @example\n * ```ts\n * import { Sandbox } from 'e2b'\n *\n * const sandbox = await Sandbox.create()\n * ```\n */\nexport class Sandbox extends SandboxApi {\n  protected static readonly defaultTemplate: string = 'base'\n  protected static readonly defaultSandboxTimeoutMs = 300_000\n\n  /**\n   * Module for interacting with the sandbox filesystem\n   */\n  readonly files: Filesystem\n  /**\n   * Module for running commands in the sandbox\n   */\n  readonly commands: Commands\n  /**\n   * Module for interacting with the sandbox pseudo-terminals\n   */\n  readonly pty: Pty\n\n  /**\n   * Unique identifier of the sandbox.\n   */\n  readonly sandboxId: string\n\n  protected readonly envdPort = 49983\n\n  protected readonly connectionConfig: ConnectionConfig\n  private readonly envdApiUrl: string\n  private readonly envdApi: EnvdApiClient\n\n  /**\n   * Use {@link Sandbox.create} to create a new Sandbox instead.\n   *\n   * @hidden\n   * @hide\n   * @internal\n   * @access protected\n   */\n  constructor(\n    opts: Omit<SandboxOpts, 'timeoutMs' | 'envs' | 'metadata'> & {\n      sandboxId: string\n      envdVersion?: string\n    }\n  ) {\n    super()\n\n    this.sandboxId = opts.sandboxId\n    this.connectionConfig = new ConnectionConfig(opts)\n    this.envdApiUrl = `${\n      this.connectionConfig.debug ? 'http' : 'https'\n    }://${this.getHost(this.envdPort)}`\n\n    const rpcTransport = createConnectTransport({\n      baseUrl: this.envdApiUrl,\n      useBinaryFormat: false,\n      interceptors: opts?.logger ? [createRpcLogger(opts.logger)] : undefined,\n    })\n\n    this.envdApi = new EnvdApiClient(\n      {\n        apiUrl: this.envdApiUrl,\n        logger: opts?.logger,\n      },\n      {\n        version: opts?.envdVersion,\n      }\n    )\n    this.files = new Filesystem(\n      rpcTransport,\n      this.envdApi,\n      this.connectionConfig\n    )\n    this.commands = new Commands(rpcTransport, this.connectionConfig)\n    this.pty = new Pty(rpcTransport, this.connectionConfig)\n  }\n\n  /**\n   * Create a new sandbox from the default `base` sandbox template.\n   *\n   * @param opts connection options.\n   *\n   * @returns sandbox instance for the new sandbox.\n   *\n   * @example\n   * ```ts\n   * const sandbox = await Sandbox.create()\n   * ```\n   * @constructs Sandbox\n   */\n  static async create<S extends typeof Sandbox>(\n    this: S,\n    opts?: SandboxOpts\n  ): Promise<InstanceType<S>>\n\n  /**\n   * Create a new sandbox from the specified sandbox template.\n   *\n   * @param template sandbox template name or ID.\n   * @param opts connection options.\n   *\n   * @returns sandbox instance for the new sandbox.\n   *\n   * @example\n   * ```ts\n   * const sandbox = await Sandbox.create('<template-name-or-id>')\n   * ```\n   * @constructs Sandbox\n   */\n  static async create<S extends typeof Sandbox>(\n    this: S,\n    template: string,\n    opts?: SandboxOpts\n  ): Promise<InstanceType<S>>\n  static async create<S extends typeof Sandbox>(\n    this: S,\n    templateOrOpts?: SandboxOpts | string,\n    opts?: SandboxOpts\n  ): Promise<InstanceType<S>> {\n    const { template, sandboxOpts } =\n      typeof templateOrOpts === 'string'\n        ? { template: templateOrOpts, sandboxOpts: opts }\n        : { template: this.defaultTemplate, sandboxOpts: templateOrOpts }\n\n    const config = new ConnectionConfig(sandboxOpts)\n\n    if (config.debug) {\n      return new this({\n        sandboxId: 'debug_sandbox_id',\n        ...config,\n      }) as InstanceType<S>\n    } else {\n      const sandbox = await this.createSandbox(\n        template,\n        sandboxOpts?.timeoutMs ?? this.defaultSandboxTimeoutMs,\n        sandboxOpts\n      )\n      return new this({ ...sandbox, ...config }) as InstanceType<S>\n    }\n  }\n\n  /**\n   * Connect to an existing sandbox.\n   * With sandbox ID you can connect to the same sandbox from different places or environments (serverless functions, etc).\n   *\n   * @param sandboxId sandbox ID.\n   * @param opts connection options.\n   *\n   * @returns sandbox instance for the existing sandbox.\n   *\n   * @example\n   * ```ts\n   * const sandbox = await Sandbox.create()\n   * const sandboxId = sandbox.sandboxId\n   *\n   * // Connect to the same sandbox.\n   * const sameSandbox = await Sandbox.connect(sandboxId)\n   * ```\n   */\n  static async connect<S extends typeof Sandbox>(\n    this: S,\n    sandboxId: string,\n    opts?: Omit<SandboxOpts, 'metadata' | 'envs' | 'timeoutMs'>\n  ): Promise<InstanceType<S>> {\n    const config = new ConnectionConfig(opts)\n\n    const sbx = new this({ sandboxId, ...config }) as InstanceType<S>\n    return sbx\n  }\n\n  /**\n   * Get the host address for the specified sandbox port.\n   * You can then use this address to connect to the sandbox port from outside the sandbox via HTTP or WebSocket.\n   *\n   * @param port number of the port in the sandbox.\n   *\n   * @returns host address of the sandbox port.\n   *\n   * @example\n   * ```ts\n   * const sandbox = await Sandbox.create()\n   * // Start an HTTP server\n   * await sandbox.commands.exec('python3 -m http.server 3000')\n   * // Get the hostname of the HTTP server\n   * const serverURL = sandbox.getHost(3000)\n   * ```\n   */\n  getHost(port: number) {\n    if (this.connectionConfig.debug) {\n      return `localhost:${port}`\n    }\n\n    return `${port}-${this.sandboxId}.${this.connectionConfig.domain}`\n  }\n\n  /**\n   * Check if the sandbox is running.\n   *\n   * @returns `true` if the sandbox is running, `false` otherwise.\n   *\n   * @example\n   * ```ts\n   * const sandbox = await Sandbox.create()\n   * await sandbox.isRunning() // Returns true\n   *\n   * await sandbox.kill()\n   * await sandbox.isRunning() // Returns false\n   * ```\n   */\n  async isRunning(\n    opts?: Pick<ConnectionOpts, 'requestTimeoutMs'>\n  ): Promise<boolean> {\n    const signal = this.connectionConfig.getSignal(opts?.requestTimeoutMs)\n\n    const res = await this.envdApi.api.GET('/health', {\n      signal,\n    })\n\n    if (res.response.status == 502) {\n      return false\n    }\n\n    const err = await handleEnvdApiError(res)\n    if (err) {\n      throw err\n    }\n\n    return true\n  }\n\n  /**\n   * Set the timeout of the sandbox.\n   * After the timeout expires the sandbox will be automatically killed.\n   *\n   * This method can extend or reduce the sandbox timeout set when creating the sandbox or from the last call to `.setTimeout`.\n   * Maximum time a sandbox can be kept alive is 24 hours (86_400_000 milliseconds) for Pro users and 1 hour (3_600_000 milliseconds) for Hobby users.\n   *\n   * @param timeoutMs timeout in **milliseconds**.\n   * @param opts connection options.\n   */\n  async setTimeout(\n    timeoutMs: number,\n    opts?: Pick<SandboxOpts, 'requestTimeoutMs'>\n  ) {\n    if (this.connectionConfig.debug) {\n      // Skip timeout in debug mode\n      return\n    }\n\n    await Sandbox.setTimeout(this.sandboxId, timeoutMs, {\n      ...this.connectionConfig,\n      ...opts,\n    })\n  }\n\n  /**\n   * Kill the sandbox.\n   *\n   * @param opts connection options.\n   */\n  async kill(opts?: Pick<SandboxOpts, 'requestTimeoutMs'>) {\n    if (this.connectionConfig.debug) {\n      // Skip killing in debug mode\n      return\n    }\n\n    await Sandbox.kill(this.sandboxId, { ...this.connectionConfig, ...opts })\n  }\n\n  /**\n   * Get the URL to upload a file to the sandbox.\n   *\n   * You have to send a POST request to this URL with the file as multipart/form-data.\n   *\n   * @param path the directory where to upload the file, defaults to user's home directory.\n   *\n   * @returns URL for uploading file.\n   */\n  uploadUrl(path?: string) {\n    return this.fileUrl(path)\n  }\n\n  /**\n   * Get the URL to download a file from the sandbox.\n   *\n   * @param path path to the file to download.\n   *\n   * @returns URL for downloading file.\n   */\n  downloadUrl(path: string) {\n    return this.fileUrl(path)\n  }\n\n  private fileUrl(path?: string) {\n    const url = new URL('/files', this.envdApiUrl)\n    url.searchParams.set('username', defaultUsername)\n    if (path) {\n      url.searchParams.set('path', path)\n    }\n\n    return url.toString()\n  }\n\n  /**\n   * Get sandbox information like sandbox ID, template, metadata, started at/end at date.\n   *\n   * @param opts connection options.\n   *\n   * @returns information about the sandbox\n   */\n  async getInfo(opts?: Pick<SandboxOpts, 'requestTimeoutMs'>) {\n    return await Sandbox.getInfo(this.sandboxId, {\n      ...this.connectionConfig,\n      ...opts,\n    })\n  }\n}\n","import {\n  Code,\n  ConnectError,\n  createClient,\n  Client,\n  Transport,\n} from '@connectrpc/connect'\n\nimport { Signal, Process as ProcessService } from '../../envd/process/process_pb'\nimport {\n  ConnectionConfig,\n  Username,\n  ConnectionOpts,\n  KEEPALIVE_PING_INTERVAL_SEC,\n  KEEPALIVE_PING_HEADER,\n} from '../../connectionConfig'\nimport { authenticationHeader, handleRpcError } from '../../envd/rpc'\nimport { CommandHandle, CommandResult } from './commandHandle'\nimport { handleProcessStartEvent } from '../../envd/api'\nexport { Pty } from './pty'\n\n/**\n * Options for sending a command request.\n */\nexport interface CommandRequestOpts\n  extends Partial<Pick<ConnectionOpts, 'requestTimeoutMs'>> { }\n\n/**\n * Options for starting a new command.\n */\nexport interface CommandStartOpts extends CommandRequestOpts {\n  /**\n   * If true, starts command in the background and the method returns immediately.\n   * You can use {@link CommandHandle.wait} to wait for the command to finish.\n   */\n  background?: boolean\n  /**\n   * Working directory for the command.\n   * \n   * @default // home directory of the user used to start the command\n   */\n  cwd?: string\n  /**\n   * User to run the command as.\n   * \n   * @default `user`\n   */\n  user?: Username\n  /**\n   * Environment variables used for the command.\n   * \n   * This overrides the default environment variables from `Sandbox` constructor.\n   * \n   * @default `{}`\n   */\n  envs?: Record<string, string>\n  /**\n   * Callback for command stdout output.\n   */\n  onStdout?: (data: string) => void | Promise<void>\n  /**\n   * Callback for command stderr output.\n   */\n  onStderr?: (data: string) => void | Promise<void>\n  /**\n   * Timeout for the command in **milliseconds**.\n   * \n   * @default 60_000 // 60 seconds\n   */\n  timeoutMs?: number\n}\n\n/**\n * Options for connecting to a command.\n */\nexport type CommandConnectOpts = Pick<\n  CommandStartOpts,\n  'onStderr' | 'onStdout' | 'timeoutMs'\n> &\n  CommandRequestOpts\n\n/**\n * Information about a command, PTY session or start command running in the sandbox as process.\n */\nexport interface ProcessInfo {\n  /**\n   * Process ID.\n   */\n  pid: number\n  /**\n   * Custom tag used for identifying special commands like start command in the custom template.\n   */\n  tag?: string\n  /**\n   * Command that was executed.\n   */\n  cmd: string\n  /**\n   * Command arguments.\n   */\n  args: string[]\n  /**\n   * Environment variables used for the command.\n   */\n  envs: Record<string, string>\n  /**\n   * Executed command working directory.\n   */\n  cwd?: string\n}\n\n\n/**\n * Module for starting and interacting with commands in the sandbox.\n */\nexport class Commands {\n  protected readonly rpc: Client<typeof ProcessService>\n\n  private readonly defaultProcessConnectionTimeout = 60_000 // 60 seconds\n\n  constructor(\n    transport: Transport,\n    private readonly connectionConfig: ConnectionConfig\n  ) {\n    this.rpc = createClient(ProcessService, transport)\n  }\n\n  /**\n   * List all running commands and PTY sessions.\n   *\n   * @param opts connection options.\n   * \n   * @returns list of running commands and PTY sessions.\n   */\n  async list(opts?: CommandRequestOpts): Promise<ProcessInfo[]> {\n    try {\n      const res = await this.rpc.list(\n        {},\n        {\n          signal: this.connectionConfig.getSignal(opts?.requestTimeoutMs),\n        }\n      )\n\n      return res.processes.map((p) => ({\n        pid: p.pid,\n        ...(p.tag && { tag: p.tag }),\n        args: p.config!.args,\n        envs: p.config!.envs,\n        cmd: p.config!.cmd,\n        ...(p.config!.cwd && { cwd: p.config!.cwd }),\n      }))\n    } catch (err) {\n      throw handleRpcError(err)\n    }\n  }\n\n  /**\n   * Send data to command stdin.\n   *\n   * @param pid process ID of the command. You can get the list of running commands using {@link Commands.list}.\n   * @param data data to send to the command.\n   * @param opts connection options.\n   */\n  async sendStdin(\n    pid: number,\n    data: string,\n    opts?: CommandRequestOpts\n  ): Promise<void> {\n    try {\n      await this.rpc.sendInput(\n        {\n          process: {\n            selector: {\n              case: 'pid',\n              value: pid,\n            },\n          },\n          input: {\n            input: {\n              case: 'stdin',\n              value: new TextEncoder().encode(data),\n            },\n          },\n        },\n        {\n          signal: this.connectionConfig.getSignal(opts?.requestTimeoutMs),\n        }\n      )\n    } catch (err) {\n      throw handleRpcError(err)\n    }\n  }\n\n  /**\n   * Kill a running command specified by its process ID.\n   * It uses `SIGKILL` signal to kill the command.\n   *\n   * @param pid process ID of the command. You can get the list of running commands using {@link Commands.list}.\n   * @param opts connection options.\n   * \n   * @returns `true` if the command was killed, `false` if the command was not found.\n   */\n  async kill(pid: number, opts?: CommandRequestOpts): Promise<boolean> {\n    try {\n      await this.rpc.sendSignal(\n        {\n          process: {\n            selector: {\n              case: 'pid',\n              value: pid,\n            },\n          },\n          signal: Signal.SIGKILL,\n        },\n        {\n          signal: this.connectionConfig.getSignal(opts?.requestTimeoutMs),\n        }\n      )\n\n      return true\n    } catch (err) {\n      if (err instanceof ConnectError) {\n        if (err.code === Code.NotFound) {\n          return false\n        }\n      }\n\n      throw handleRpcError(err)\n    }\n  }\n\n  /**\n   * Connect to a running command.\n   * You can use {@link CommandHandle.wait} to wait for the command to finish and get execution results.\n   *\n   * @param pid process ID of the command to connect to. You can get the list of running commands using {@link Commands.list}.\n   * @param opts connection options.\n   * \n   * @returns `CommandHandle` handle to interact with the running command.\n   */\n  async connect(\n    pid: number,\n    opts?: CommandConnectOpts\n  ): Promise<CommandHandle> {\n    const requestTimeoutMs =\n      opts?.requestTimeoutMs ?? this.connectionConfig.requestTimeoutMs\n\n    const controller = new AbortController()\n\n    const reqTimeout = requestTimeoutMs\n      ? setTimeout(() => {\n        controller.abort()\n      }, requestTimeoutMs)\n      : undefined\n\n    const events = this.rpc.connect(\n      {\n        process: {\n          selector: {\n            case: 'pid',\n            value: pid,\n          },\n        },\n      },\n      {\n        signal: controller.signal,\n        headers: {\n          [KEEPALIVE_PING_HEADER]: KEEPALIVE_PING_INTERVAL_SEC.toString(),\n        },\n        timeoutMs: opts?.timeoutMs ?? this.defaultProcessConnectionTimeout,\n      }\n    )\n\n    try {\n      const pid = await handleProcessStartEvent(events)\n\n      clearTimeout(reqTimeout)\n\n      return new CommandHandle(\n        pid,\n        () => controller.abort(),\n        () => this.kill(pid),\n        events,\n        opts?.onStdout,\n        opts?.onStderr,\n        undefined\n      )\n    } catch (err) {\n      throw handleRpcError(err)\n    }\n  }\n\n  /**\n   * Start a new command and wait until it finishes executing.\n   * \n   * @param cmd command to execute.\n   * @param opts options for starting the command.\n   * \n   * @returns `CommandResult` result of the command execution.\n   */\n  async run(\n    cmd: string,\n    opts?: CommandStartOpts & { background?: false }\n  ): Promise<CommandResult>\n  /**\n   * Start a new command in the background.\n   * You can use {@link CommandHandle.wait} to wait for the command to finish and get its result.\n   * \n   * @param cmd command to execute.\n   * @param opts options for starting the command\n   * \n   * @returns `CommandHandle` handle to interact with the running command.\n   */\n  async run(\n    cmd: string,\n    opts?: CommandStartOpts & { background: true }\n  ): Promise<CommandHandle>\n  async run(\n    cmd: string,\n    opts?: CommandStartOpts & { background?: boolean }\n  ): Promise<unknown> {\n    const proc = await this.start(cmd, opts)\n\n    return opts?.background ? proc : proc.wait()\n  }\n\n  private async start(\n    cmd: string,\n    opts?: CommandStartOpts\n  ): Promise<CommandHandle> {\n    const requestTimeoutMs =\n      opts?.requestTimeoutMs ?? this.connectionConfig.requestTimeoutMs\n\n    const controller = new AbortController()\n\n    const reqTimeout = requestTimeoutMs\n      ? setTimeout(() => {\n        controller.abort()\n      }, requestTimeoutMs)\n      : undefined\n\n    const events = this.rpc.start(\n      {\n        process: {\n          cmd: '/bin/bash',\n          cwd: opts?.cwd,\n          envs: opts?.envs,\n          args: ['-l', '-c', cmd],\n        },\n      },\n      {\n        headers: {\n          ...authenticationHeader(opts?.user),\n          [KEEPALIVE_PING_HEADER]: KEEPALIVE_PING_INTERVAL_SEC.toString(),\n        },\n        signal: controller.signal,\n        timeoutMs: opts?.timeoutMs ?? this.defaultProcessConnectionTimeout,\n      }\n    )\n\n    try {\n      const pid = await handleProcessStartEvent(events)\n\n      clearTimeout(reqTimeout)\n\n      return new CommandHandle(\n        pid,\n        () => controller.abort(),\n        () => this.kill(pid),\n        events,\n        opts?.onStdout,\n        opts?.onStderr,\n        undefined\n      )\n    } catch (err) {\n      throw handleRpcError(err)\n    }\n  }\n}\n","// @generated by protoc-gen-es v2.2.2 with parameter \"target=ts\"\n// @generated from file process/process.proto (package process, syntax proto3)\n/* eslint-disable */\n\nimport type { GenEnum, GenFile, GenMessage, GenService } from \"@bufbuild/protobuf/codegenv1\";\nimport { enumDesc, fileDesc, messageDesc, serviceDesc } from \"@bufbuild/protobuf/codegenv1\";\nimport type { Message } from \"@bufbuild/protobuf\";\n\n/**\n * Describes the file process/process.proto.\n */\nexport const file_process_process: GenFile = /*@__PURE__*/\n  fileDesc(\"ChVwcm9jZXNzL3Byb2Nlc3MucHJvdG8SB3Byb2Nlc3MiSgoDUFRZEh8KBHNpemUYASABKAsyES5wcm9jZXNzLlBUWS5TaXplGiIKBFNpemUSDAoEY29scxgBIAEoDRIMCgRyb3dzGAIgASgNIqEBCg1Qcm9jZXNzQ29uZmlnEgsKA2NtZBgBIAEoCRIMCgRhcmdzGAIgAygJEi4KBGVudnMYAyADKAsyIC5wcm9jZXNzLlByb2Nlc3NDb25maWcuRW52c0VudHJ5EhAKA2N3ZBgEIAEoCUgAiAEBGisKCUVudnNFbnRyeRILCgNrZXkYASABKAkSDQoFdmFsdWUYAiABKAk6AjgBQgYKBF9jd2QiDQoLTGlzdFJlcXVlc3Qi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Y = Message<\"process.PTY\"> & {\n  /**\n   * @generated from field: process.PTY.Size size = 1;\n   */\n  size?: PTY_Size;\n};\n\n/**\n * Describes the message process.PTY.\n * Use `create(PTYSchema)` to create a new message.\n */\nexport const PTYSchema: GenMessage<PTY> = /*@__PURE__*/\n  messageDesc(file_process_process, 0);\n\n/**\n * @generated from message process.PTY.Size\n */\nexport type PTY_Size = Message<\"process.PTY.Size\"> & {\n  /**\n   * @generated from field: uint32 cols = 1;\n   */\n  cols: number;\n\n  /**\n   * @generated from field: uint32 rows = 2;\n   */\n  rows: number;\n};\n\n/**\n * Describes the message process.PTY.Size.\n * Use `create(PTY_SizeSchema)` to create a new message.\n */\nexport const PTY_SizeSchema: GenMessage<PTY_Size> = /*@__PURE__*/\n  messageDesc(file_process_process, 0, 0);\n\n/**\n * @generated from message process.ProcessConfig\n */\nexport type ProcessConfig = Message<\"process.ProcessConfig\"> & {\n  /**\n   * @generated from field: string cmd = 1;\n   */\n  cmd: string;\n\n  /**\n   * @generated from field: repeated string args = 2;\n   */\n  args: string[];\n\n  /**\n   * @generated from field: map<string, string> envs = 3;\n   */\n  envs: { [key: string]: string };\n\n  /**\n   * @generated from field: optional string cwd = 4;\n   */\n  cwd?: string;\n};\n\n/**\n * Describes the message process.ProcessConfig.\n * Use `create(ProcessConfigSchema)` to create a new message.\n */\nexport const ProcessConfigSchema: GenMessage<ProcessConfig> = /*@__PURE__*/\n  messageDesc(file_process_process, 1);\n\n/**\n * @generated from message process.ListRequest\n */\nexport type ListRequest = Message<\"process.ListRequest\"> & {\n};\n\n/**\n * Describes the message process.ListRequest.\n * Use `create(ListRequestSchema)` to create a new message.\n */\nexport const ListRequestSchema: GenMessage<ListRequest> = /*@__PURE__*/\n  messageDesc(file_process_process, 2);\n\n/**\n * @generated from message process.ProcessInfo\n */\nexport type ProcessInfo = Message<\"process.ProcessInfo\"> & {\n  /**\n   * @generated from field: process.ProcessConfig config = 1;\n   */\n  config?: ProcessConfig;\n\n  /**\n   * @generated from field: uint32 pid = 2;\n   */\n  pid: number;\n\n  /**\n   * @generated from field: optional string tag = 3;\n   */\n  tag?: string;\n};\n\n/**\n * Describes the message process.ProcessInfo.\n * Use `create(ProcessInfoSchema)` to create a new message.\n */\nexport const ProcessInfoSchema: GenMessage<ProcessInfo> = /*@__PURE__*/\n  messageDesc(file_process_process, 3);\n\n/**\n * @generated from message process.ListResponse\n */\nexport type ListResponse = Message<\"process.ListResponse\"> & {\n  /**\n   * @generated from field: repeated process.ProcessInfo processes = 1;\n   */\n  processes: ProcessInfo[];\n};\n\n/**\n * Describes the message process.ListResponse.\n * Use `create(ListResponseSchema)` to create a new message.\n */\nexport const ListResponseSchema: GenMessage<ListResponse> = /*@__PURE__*/\n  messageDesc(file_process_process, 4);\n\n/**\n * @generated from message process.StartRequest\n */\nexport type StartRequest = Message<\"process.StartRequest\"> & {\n  /**\n   * @generated from field: process.ProcessConfig process = 1;\n   */\n  process?: ProcessConfig;\n\n  /**\n   * @generated from field: optional process.PTY pty = 2;\n   */\n  pty?: PTY;\n\n  /**\n   * @generated from field: optional string tag = 3;\n   */\n  tag?: string;\n};\n\n/**\n * Describes the message process.StartRequest.\n * Use `create(StartRequestSchema)` to create a new message.\n */\nexport const StartRequestSchema: GenMessage<StartRequest> = /*@__PURE__*/\n  messageDesc(file_process_process, 5);\n\n/**\n * @generated from message process.UpdateRequest\n */\nexport type UpdateRequest = Message<\"process.UpdateRequest\"> & {\n  /**\n   * @generated from field: process.ProcessSelector process = 1;\n   */\n  process?: ProcessSelector;\n\n  /**\n   * @generated from field: optional process.PTY pty = 2;\n   */\n  pty?: PTY;\n};\n\n/**\n * Describes the message process.UpdateRequest.\n * Use `create(UpdateRequestSchema)` to create a new message.\n */\nexport const UpdateRequestSchema: GenMessage<UpdateRequest> = /*@__PURE__*/\n  messageDesc(file_process_process, 6);\n\n/**\n * @generated from message process.UpdateResponse\n */\nexport type UpdateResponse = Message<\"process.UpdateResponse\"> & {\n};\n\n/**\n * Describes the message process.UpdateResponse.\n * Use `create(UpdateResponseSchema)` to create a new message.\n */\nexport const UpdateResponseSchema: GenMessage<UpdateResponse> = /*@__PURE__*/\n  messageDesc(file_process_process, 7);\n\n/**\n * @generated from message process.ProcessEvent\n */\nexport type ProcessEvent = Message<\"process.ProcessEvent\"> & {\n  /**\n   * @generated from oneof process.ProcessEvent.event\n   */\n  event: {\n    /**\n     * @generated from field: process.ProcessEvent.StartEvent start = 1;\n     */\n    value: ProcessEvent_StartEvent;\n    case: \"start\";\n  } | {\n    /**\n     * @generated from field: process.ProcessEvent.DataEvent data = 2;\n     */\n    value: ProcessEvent_DataEvent;\n    case: \"data\";\n  } | {\n    /**\n     * @generated from field: process.ProcessEvent.EndEvent end = 3;\n     */\n    value: ProcessEvent_EndEvent;\n    case: \"end\";\n  } | {\n    /**\n     * @generated from field: process.ProcessEvent.KeepAlive keepalive = 4;\n     */\n    value: ProcessEvent_KeepAlive;\n    case: \"keepalive\";\n  } | { case: undefined; value?: undefined };\n};\n\n/**\n * Describes the message process.ProcessEvent.\n * Use `create(ProcessEventSchema)` to create a new message.\n */\nexport const ProcessEventSchema: GenMessage<ProcessEvent> = /*@__PURE__*/\n  messageDesc(file_process_process, 8);\n\n/**\n * @generated from message process.ProcessEvent.StartEvent\n */\nexport type ProcessEvent_StartEvent = Message<\"process.ProcessEvent.StartEvent\"> & {\n  /**\n   * @generated from field: uint32 pid = 1;\n   */\n  pid: number;\n};\n\n/**\n * Describes the message process.ProcessEvent.StartEvent.\n * Use `create(ProcessEvent_StartEventSchema)` to create a new message.\n */\nexport const ProcessEvent_StartEventSchema: GenMessage<ProcessEvent_StartEvent> = /*@__PURE__*/\n  messageDesc(file_process_process, 8, 0);\n\n/**\n * @generated from message process.ProcessEvent.DataEvent\n */\nexport type ProcessEvent_DataEvent = Message<\"process.ProcessEvent.DataEvent\"> & {\n  /**\n   * @generated from oneof process.ProcessEvent.DataEvent.output\n   */\n  output: {\n    /**\n     * @generated from field: bytes stdout = 1;\n     */\n    value: Uint8Array;\n    case: \"stdout\";\n  } | {\n    /**\n     * @generated from field: bytes stderr = 2;\n     */\n    value: Uint8Array;\n    case: \"stderr\";\n  } | {\n    /**\n     * @generated from field: bytes pty = 3;\n     */\n    value: Uint8Array;\n    case: \"pty\";\n  } | { case: undefined; value?: undefined };\n};\n\n/**\n * Describes the message process.ProcessEvent.DataEvent.\n * Use `create(ProcessEvent_DataEventSchema)` to create a new message.\n */\nexport const ProcessEvent_DataEventSchema: GenMessage<ProcessEvent_DataEvent> = /*@__PURE__*/\n  messageDesc(file_process_process, 8, 1);\n\n/**\n * @generated from message process.ProcessEvent.EndEvent\n */\nexport type ProcessEvent_EndEvent = Message<\"process.ProcessEvent.EndEvent\"> & {\n  /**\n   * @generated from field: sint32 exit_code = 1;\n   */\n  exitCode: number;\n\n  /**\n   * @generated from field: bool exited = 2;\n   */\n  exited: boolean;\n\n  /**\n   * @generated from field: string status = 3;\n   */\n  status: string;\n\n  /**\n   * @generated from field: optional string error = 4;\n   */\n  error?: string;\n};\n\n/**\n * Describes the message process.ProcessEvent.EndEvent.\n * Use `create(ProcessEvent_EndEventSchema)` to create a new message.\n */\nexport const ProcessEvent_EndEventSchema: GenMessage<ProcessEvent_EndEvent> = /*@__PURE__*/\n  messageDesc(file_process_process, 8, 2);\n\n/**\n * @generated from message process.ProcessEvent.KeepAlive\n */\nexport type ProcessEvent_KeepAlive = Message<\"process.ProcessEvent.KeepAlive\"> & {\n};\n\n/**\n * Describes the message process.ProcessEvent.KeepAlive.\n * Use `create(ProcessEvent_KeepAliveSchema)` to create a new message.\n */\nexport const ProcessEvent_KeepAliveSchema: GenMessage<ProcessEvent_KeepAlive> = /*@__PURE__*/\n  messageDesc(file_process_process, 8, 3);\n\n/**\n * @generated from message process.StartResponse\n */\nexport type StartResponse = Message<\"process.StartResponse\"> & {\n  /**\n   * @generated from field: process.ProcessEvent event = 1;\n   */\n  event?: ProcessEvent;\n};\n\n/**\n * Describes the message process.StartResponse.\n * Use `create(StartResponseSchema)` to create a new message.\n */\nexport const StartResponseSchema: GenMessage<StartResponse> = /*@__PURE__*/\n  messageDesc(file_process_process, 9);\n\n/**\n * @generated from message process.ConnectResponse\n */\nexport type ConnectResponse = Message<\"process.ConnectResponse\"> & {\n  /**\n   * @generated from field: process.ProcessEvent event = 1;\n   */\n  event?: ProcessEvent;\n};\n\n/**\n * Describes the message process.ConnectResponse.\n * Use `create(ConnectResponseSchema)` to create a new message.\n */\nexport const ConnectResponseSchema: GenMessage<ConnectResponse> = /*@__PURE__*/\n  messageDesc(file_process_process, 10);\n\n/**\n * @generated from message process.SendInputRequest\n */\nexport type SendInputRequest = Message<\"process.SendInputRequest\"> & {\n  /**\n   * @generated from field: process.ProcessSelector process = 1;\n   */\n  process?: ProcessSelector;\n\n  /**\n   * @generated from field: process.ProcessInput input = 2;\n   */\n  input?: ProcessInput;\n};\n\n/**\n * Describes the message process.SendInputRequest.\n * Use `create(SendInputRequestSchema)` to create a new message.\n */\nexport const SendInputRequestSchema: GenMessage<SendInputRequest> = /*@__PURE__*/\n  messageDesc(file_process_process, 11);\n\n/**\n * @generated from message process.SendInputResponse\n */\nexport type SendInputResponse = Message<\"process.SendInputResponse\"> & {\n};\n\n/**\n * Describes the message process.SendInputResponse.\n * Use `create(SendInputResponseSchema)` to create a new message.\n */\nexport const SendInputResponseSchema: GenMessage<SendInputResponse> = /*@__PURE__*/\n  messageDesc(file_process_process, 12);\n\n/**\n * @generated from message process.ProcessInput\n */\nexport type ProcessInput = Message<\"process.ProcessInput\"> & {\n  /**\n   * @generated from oneof process.ProcessInput.input\n   */\n  input: {\n    /**\n     * @generated from field: bytes stdin = 1;\n     */\n    value: Uint8Array;\n    case: \"stdin\";\n  } | {\n    /**\n     * @generated from field: bytes pty = 2;\n     */\n    value: Uint8Array;\n    case: \"pty\";\n  } | { case: undefined; value?: undefined };\n};\n\n/**\n * Describes the message process.ProcessInput.\n * Use `create(ProcessInputSchema)` to create a new message.\n */\nexport const ProcessInputSchema: GenMessage<ProcessInput> = /*@__PURE__*/\n  messageDesc(file_process_process, 13);\n\n/**\n * @generated from message process.StreamInputRequest\n */\nexport type StreamInputRequest = Message<\"process.StreamInputRequest\"> & {\n  /**\n   * @generated from oneof process.StreamInputRequest.event\n   */\n  event: {\n    /**\n     * @generated from field: process.StreamInputRequest.StartEvent start = 1;\n     */\n    value: StreamInputRequest_StartEvent;\n    case: \"start\";\n  } | {\n    /**\n     * @generated from field: process.StreamInputRequest.DataEvent data = 2;\n     */\n    value: StreamInputRequest_DataEvent;\n    case: \"data\";\n  } | {\n    /**\n     * @generated from field: process.StreamInputRequest.KeepAlive keepalive = 3;\n     */\n    value: StreamInputRequest_KeepAlive;\n    case: \"keepalive\";\n  } | { case: undefined; value?: undefined };\n};\n\n/**\n * Describes the message process.StreamInputRequest.\n * Use `create(StreamInputRequestSchema)` to create a new message.\n */\nexport const StreamInputRequestSchema: GenMessage<StreamInputRequest> = /*@__PURE__*/\n  messageDesc(file_process_process, 14);\n\n/**\n * @generated from message process.StreamInputRequest.StartEvent\n */\nexport type StreamInputRequest_StartEvent = Message<\"process.StreamInputRequest.StartEvent\"> & {\n  /**\n   * @generated from field: process.ProcessSelector process = 1;\n   */\n  process?: ProcessSelector;\n};\n\n/**\n * Describes the message process.StreamInputRequest.StartEvent.\n * Use `create(StreamInputRequest_StartEventSchema)` to create a new message.\n */\nexport const StreamInputRequest_StartEventSchema: GenMessage<StreamInputRequest_StartEvent> = /*@__PURE__*/\n  messageDesc(file_process_process, 14, 0);\n\n/**\n * @generated from message process.StreamInputRequest.DataEvent\n */\nexport type StreamInputRequest_DataEvent = Message<\"process.StreamInputRequest.DataEvent\"> & {\n  /**\n   * @generated from field: process.ProcessInput input = 2;\n   */\n  input?: ProcessInput;\n};\n\n/**\n * Describes the message process.StreamInputRequest.DataEvent.\n * Use `create(StreamInputRequest_DataEventSchema)` to create a new message.\n */\nexport const StreamInputRequest_DataEventSchema: GenMessage<StreamInputRequest_DataEvent> = /*@__PURE__*/\n  messageDesc(file_process_process, 14, 1);\n\n/**\n * @generated from message process.StreamInputRequest.KeepAlive\n */\nexport type StreamInputRequest_KeepAlive = Message<\"process.StreamInputRequest.KeepAlive\"> & {\n};\n\n/**\n * Describes the message process.StreamInputRequest.KeepAlive.\n * Use `create(StreamInputRequest_KeepAliveSchema)` to create a new message.\n */\nexport const StreamInputRequest_KeepAliveSchema: GenMessage<StreamInputRequest_KeepAlive> = /*@__PURE__*/\n  messageDesc(file_process_process, 14, 2);\n\n/**\n * @generated from message process.StreamInputResponse\n */\nexport type StreamInputResponse = Message<\"process.StreamInputResponse\"> & {\n};\n\n/**\n * Describes the message process.StreamInputResponse.\n * Use `create(StreamInputResponseSchema)` to create a new message.\n */\nexport const StreamInputResponseSchema: GenMessage<StreamInputResponse> = /*@__PURE__*/\n  messageDesc(file_process_process, 15);\n\n/**\n * @generated from message process.SendSignalRequest\n */\nexport type SendSignalRequest = Message<\"process.SendSignalRequest\"> & {\n  /**\n   * @generated from field: process.ProcessSelector process = 1;\n   */\n  process?: ProcessSelector;\n\n  /**\n   * @generated from field: process.Signal signal = 2;\n   */\n  signal: Signal;\n};\n\n/**\n * Describes the message process.SendSignalRequest.\n * Use `create(SendSignalRequestSchema)` to create a new message.\n */\nexport const SendSignalRequestSchema: GenMessage<SendSignalRequest> = /*@__PURE__*/\n  messageDesc(file_process_process, 16);\n\n/**\n * @generated from message process.SendSignalResponse\n */\nexport type SendSignalResponse = Message<\"process.SendSignalResponse\"> & {\n};\n\n/**\n * Describes the message process.SendSignalResponse.\n * Use `create(SendSignalResponseSchema)` to create a new message.\n */\nexport const SendSignalResponseSchema: GenMessage<SendSignalResponse> = /*@__PURE__*/\n  messageDesc(file_process_process, 17);\n\n/**\n * @generated from message process.ConnectRequest\n */\nexport type ConnectRequest = Message<\"process.ConnectRequest\"> & {\n  /**\n   * @generated from field: process.ProcessSelector process = 1;\n   */\n  process?: ProcessSelector;\n};\n\n/**\n * Describes the message process.ConnectRequest.\n * Use `create(ConnectRequestSchema)` to create a new message.\n */\nexport const ConnectRequestSchema: GenMessage<ConnectRequest> = /*@__PURE__*/\n  messageDesc(file_process_process, 18);\n\n/**\n * @generated from message process.ProcessSelector\n */\nexport type ProcessSelector = Message<\"process.ProcessSelector\"> & {\n  /**\n   * @generated from oneof process.ProcessSelector.selector\n   */\n  selector: {\n    /**\n     * @generated from field: uint32 pid = 1;\n     */\n    value: number;\n    case: \"pid\";\n  } | {\n    /**\n     * @generated from field: string tag = 2;\n     */\n    value: string;\n    case: \"tag\";\n  } | { case: undefined; value?: undefined };\n};\n\n/**\n * Describes the message process.ProcessSelector.\n * Use `create(ProcessSelectorSchema)` to create a new message.\n */\nexport const ProcessSelectorSchema: GenMessage<ProcessSelector> = /*@__PURE__*/\n  messageDesc(file_process_process, 19);\n\n/**\n * @generated from enum process.Signal\n */\nexport enum Signal {\n  /**\n   * @generated from enum value: SIGNAL_UNSPECIFIED = 0;\n   */\n  UNSPECIFIED = 0,\n\n  /**\n   * @generated from enum value: SIGNAL_SIGTERM = 15;\n   */\n  SIGTERM = 15,\n\n  /**\n   * @generated from enum value: SIGNAL_SIGKILL = 9;\n   */\n  SIGKILL = 9,\n}\n\n/**\n * Describes the enum process.Signal.\n */\nexport const SignalSchema: GenEnum<Signal> = /*@__PURE__*/\n  enumDesc(file_process_process, 0);\n\n/**\n * @generated from service process.Process\n */\nexport const Process: GenService<{\n  /**\n   * @generated from rpc process.Process.List\n   */\n  list: {\n    methodKind: \"unary\";\n    input: typeof ListRequestSchema;\n    output: typeof ListResponseSchema;\n  },\n  /**\n   * @generated from rpc process.Process.Connect\n   */\n  connect: {\n    methodKind: \"server_streaming\";\n    input: typeof ConnectRequestSchema;\n    output: typeof ConnectResponseSchema;\n  },\n  /**\n   * @generated from rpc process.Process.Start\n   */\n  start: {\n    methodKind: \"server_streaming\";\n    input: typeof StartRequestSchema;\n    output: typeof StartResponseSchema;\n  },\n  /**\n   * @generated from rpc process.Process.Update\n   */\n  update: {\n    methodKind: \"unary\";\n    input: typeof UpdateRequestSchema;\n    output: typeof UpdateResponseSchema;\n  },\n  /**\n   * Client input stream ensures ordering of messages\n   *\n   * @generated from rpc process.Process.StreamInput\n   */\n  streamInput: {\n    methodKind: \"client_streaming\";\n    input: typeof StreamInputRequestSchema;\n    output: typeof StreamInputResponseSchema;\n  },\n  /**\n   * @generated from rpc process.Process.SendInput\n   */\n  sendInput: {\n    methodKind: \"unary\";\n    input: typeof SendInputRequestSchema;\n    output: typeof SendInputResponseSchema;\n  },\n  /**\n   * @generated from rpc process.Process.SendSignal\n   */\n  sendSignal: {\n    methodKind: \"unary\";\n    input: typeof SendSignalRequestSchema;\n    output: typeof SendSignalResponseSchema;\n  },\n}> = /*@__PURE__*/\n  serviceDesc(file_process_process, 0);\n\n","import {\n  Code,\n  ConnectError,\n  createClient,\n  Client,\n  Transport,\n} from '@connectrpc/connect'\n\nimport { Signal, Process as ProcessService } from '../../envd/process/process_pb'\nimport {\n  ConnectionConfig,\n  ConnectionOpts,\n  Username,\n  KEEPALIVE_PING_HEADER,\n  KEEPALIVE_PING_INTERVAL_SEC,\n} from '../../connectionConfig'\nimport { CommandHandle } from './commandHandle'\nimport { authenticationHeader, handleRpcError } from '../../envd/rpc'\nimport { handleProcessStartEvent } from '../../envd/api'\n\nexport interface PtyCreateOpts\n  extends Pick<ConnectionOpts, 'requestTimeoutMs'> {\n  /**\n   * Number of columns for the PTY.\n   */\n  cols: number\n  /**\n   * Number of rows for the PTY.\n   */\n  rows: number\n  /**\n   * Callback to handle PTY data.\n   */\n  onData: (data: Uint8Array) => void | Promise<void>\n  /**\n   * Timeout for the PTY in **milliseconds**.\n   * \n   * @default 60_000 // 60 seconds\n   */\n  timeoutMs?: number\n  /**\n   * User to use for the PTY.\n   * \n   * @default `user`\n   */\n  user?: Username\n  /**\n   * Environment variables for the PTY.\n   * \n   * @default {}\n   */\n  envs?: Record<string, string>\n  /**\n   * Working directory for the PTY.\n   * \n   * @default // home directory of the user used to start the PTY\n   */\n  cwd?: string\n}\n\n/**\n * Module for interacting with PTYs (pseudo-terminals) in the sandbox.\n */\nexport class Pty {\n  private readonly rpc: Client<typeof ProcessService>\n\n  constructor(\n    private readonly transport: Transport,\n    private readonly connectionConfig: ConnectionConfig\n  ) {\n    this.rpc = createClient(ProcessService, this.transport)\n  }\n\n  /**\n   * Create a new PTY (pseudo-terminal).\n   *\n   * @param opts options for creating the PTY.\n   * \n   * @returns handle to interact with the PTY.\n   */\n  async create(opts: PtyCreateOpts) {\n    const requestTimeoutMs =\n      opts?.requestTimeoutMs ?? this.connectionConfig.requestTimeoutMs\n    const envs = opts?.envs ?? {}\n    envs.TERM = 'xterm-256color'\n    const controller = new AbortController()\n\n    const reqTimeout = setTimeout(() => {\n      controller.abort()\n    }, requestTimeoutMs)\n\n    const events = this.rpc.start(\n      {\n        process: {\n          cmd: '/bin/bash',\n          args: ['-i', '-l'],\n          envs: envs,\n          cwd: opts?.cwd,\n        },\n        pty: {\n          size: {\n            cols: opts.cols,\n            rows: opts.rows,\n          },\n        },\n      },\n      {\n        headers: {\n          ...authenticationHeader(opts?.user),\n          [KEEPALIVE_PING_HEADER]: KEEPALIVE_PING_INTERVAL_SEC.toString(),\n        },\n        signal: controller.signal,\n        timeoutMs: opts?.timeoutMs ?? 60_000,\n      }\n    )\n\n    try {\n      const pid = await handleProcessStartEvent(events)\n\n      clearTimeout(reqTimeout)\n\n      return new CommandHandle(\n        pid,\n        () => controller.abort(),\n        () => this.kill(pid),\n        events,\n        undefined,\n        undefined,\n        opts.onData\n      )\n    } catch (err) {\n      throw handleRpcError(err)\n    }\n  }\n\n  /**\n   * Send input to a PTY.\n   *\n   * @param pid process ID of the PTY.\n   * @param data input data to send to the PTY.\n   * @param opts connection options.\n   */\n  async sendInput(\n    pid: number,\n    data: Uint8Array,\n    opts?: Pick<ConnectionOpts, 'requestTimeoutMs'>\n  ): Promise<void> {\n    try {\n      await this.rpc.sendInput(\n        {\n          input: {\n            input: {\n              case: 'pty',\n              value: data,\n            },\n          },\n          process: {\n            selector: {\n              case: 'pid',\n              value: pid,\n            },\n          },\n        },\n        {\n          signal: this.connectionConfig.getSignal(opts?.requestTimeoutMs),\n        }\n      )\n    } catch (err) {\n      throw handleRpcError(err)\n    }\n  }\n\n  /**\n   * Resize PTY.\n   * Call this when the terminal window is resized and the number of columns and rows has changed.\n   *\n   * @param pid process ID of the PTY.\n   * @param size new size of the PTY.\n   * @param opts connection options.\n   */\n  async resize(\n    pid: number,\n    size: {\n      cols: number\n      rows: number\n    },\n    opts?: Pick<ConnectionOpts, 'requestTimeoutMs'>\n  ): Promise<void> {\n    try {\n      await this.rpc.update(\n        {\n          process: {\n            selector: {\n              case: 'pid',\n              value: pid,\n            },\n          },\n          pty: {\n            size,\n          },\n        },\n        {\n          signal: this.connectionConfig.getSignal(opts?.requestTimeoutMs),\n        }\n      )\n    } catch (err) {\n      throw handleRpcError(err)\n    }\n  }\n\n  /**\n   * Kill a running PTY specified by process ID.\n   * It uses `SIGKILL` signal to kill the PTY.\n   *\n   * @param pid process ID of the PTY.\n   * @param opts connection options.\n   * \n   * @returns `true` if the PTY was killed, `false` if the PTY was not found.\n   */\n  async kill(\n    pid: number,\n    opts?: Pick<ConnectionOpts, 'requestTimeoutMs'>\n  ): Promise<boolean> {\n    try {\n      await this.rpc.sendSignal(\n        {\n          process: {\n            selector: {\n              case: 'pid',\n              value: pid,\n            },\n          },\n          signal: Signal.SIGKILL,\n        },\n        {\n          signal: this.connectionConfig.getSignal(opts?.requestTimeoutMs),\n        }\n      )\n\n      return true\n    } catch (err) {\n      if (err instanceof ConnectError) {\n        if (err.code === Code.NotFound) {\n          return false\n        }\n      }\n\n      throw handleRpcError(err)\n    }\n  }\n}\n","import { ApiClient, components, handleApiError } from '../api'\nimport { ConnectionConfig, ConnectionOpts } from '../connectionConfig'\nimport { compareVersions } from 'compare-versions'\nimport { TemplateError } from '../errors'\n\n/**\n * Options for request to the Sandbox API.\n */\nexport interface SandboxApiOpts\n  extends Partial<\n    Pick<ConnectionOpts, 'apiKey' | 'debug' | 'domain' | 'requestTimeoutMs'>\n  > {}\n\nexport interface SandboxListOpts extends SandboxApiOpts {\n  /**\n   * Filter the list of sandboxes, e.g. by metadata `metadata:{\"key\": \"value\"}`, if there are multiple filters they are combined with AND.\n   */\n  query?: { metadata?: Record<string, string> }\n}\n\n/**\n * Information about a sandbox.\n */\nexport interface SandboxInfo {\n  /**\n   * Sandbox ID.\n   */\n  sandboxId: string\n\n  /**\n   * Template ID.\n   */\n  templateId: string\n\n  /**\n   * Template name.\n   */\n  name?: string\n\n  /**\n   * Saved sandbox metadata.\n   */\n  metadata: Record<string, string>\n\n  /**\n   * Sandbox start time.\n   */\n  startedAt: Date\n\n  /**\n   * Sandbox expiration date.\n   */\n  endAt: Date\n}\n\nexport class SandboxApi {\n  protected constructor() {}\n\n  /**\n   * Kill the sandbox specified by sandbox ID.\n   *\n   * @param sandboxId sandbox ID.\n   * @param opts connection options.\n   *\n   * @returns `true` if the sandbox was found and killed, `false` otherwise.\n   */\n  static async kill(\n    sandboxId: string,\n    opts?: SandboxApiOpts\n  ): Promise<boolean> {\n    const config = new ConnectionConfig(opts)\n    const client = new ApiClient(config)\n\n    const res = await client.api.DELETE('/sandboxes/{sandboxID}', {\n      params: {\n        path: {\n          sandboxID: sandboxId,\n        },\n      },\n      signal: config.getSignal(opts?.requestTimeoutMs),\n    })\n\n    if (res.error?.code === 404) {\n      return false\n    }\n\n    const err = handleApiError(res)\n    if (err) {\n      throw err\n    }\n\n    return true\n  }\n\n  /**\n   * List all running sandboxes.\n   *\n   * @param opts connection options.\n   *\n   * @returns list of running sandboxes.\n   */\n  static async list(opts?: SandboxListOpts): Promise<SandboxInfo[]> {\n    const config = new ConnectionConfig(opts)\n    const client = new ApiClient(config)\n\n    let metadata = undefined\n    if (opts?.query) {\n      if (opts.query.metadata) {\n        const encodedPairs: Record<string, string> = Object.fromEntries(\n          Object.entries(opts.query.metadata).map(([key, value]) => [\n            encodeURIComponent(key),\n            encodeURIComponent(value),\n          ])\n        )\n        metadata = new URLSearchParams(encodedPairs).toString()\n      }\n    }\n\n    const res = await client.api.GET('/sandboxes', {\n      params: {\n        query: { metadata },\n      },\n      signal: config.getSignal(opts?.requestTimeoutMs),\n    })\n\n    const err = handleApiError(res)\n    if (err) {\n      throw err\n    }\n\n    return (\n      res.data?.map((sandbox: components['schemas']['RunningSandbox']) => ({\n        sandboxId: this.getSandboxId({\n          sandboxId: sandbox.sandboxID,\n          clientId: sandbox.clientID,\n        }),\n        templateId: sandbox.templateID,\n        ...(sandbox.alias && { name: sandbox.alias }),\n        metadata: sandbox.metadata ?? {},\n        startedAt: new Date(sandbox.startedAt),\n        endAt: new Date(sandbox.endAt),\n      })) ?? []\n    )\n  }\n\n  /**\n   * Get sandbox information like sandbox ID, template, metadata, started at/end at date.\n   *\n   * @param sandboxId sandbox ID.\n   * @param opts connection options.\n   *\n   * @returns sandbox information.\n   */\n  static async getInfo(\n    sandboxId: string,\n    opts?: SandboxApiOpts\n  ): Promise<SandboxInfo> {\n    const config = new ConnectionConfig(opts)\n    const client = new ApiClient(config)\n\n    const res = await client.api.GET('/sandboxes/{sandboxID}', {\n      params: {\n        path: {\n          sandboxID: sandboxId,\n        },\n      },\n      signal: config.getSignal(opts?.requestTimeoutMs),\n    })\n\n    const err = handleApiError(res)\n    if (err) {\n      throw err\n    }\n\n    if (!res.data) {\n      throw new Error('Sandbox not found')\n    }\n\n    return {\n      sandboxId: this.getSandboxId({\n        sandboxId: res.data.sandboxID,\n        clientId: res.data.clientID,\n      }),\n      templateId: res.data.templateID,\n      ...(res.data.alias && { name: res.data.alias }),\n      metadata: res.data.metadata ?? {},\n      startedAt: new Date(res.data.startedAt),\n      endAt: new Date(res.data.endAt),\n    }\n  }\n\n  /**\n   * Set the timeout of the specified sandbox.\n   * After the timeout expires the sandbox will be automatically killed.\n   *\n   * This method can extend or reduce the sandbox timeout set when creating the sandbox or from the last call to {@link Sandbox.setTimeout}.\n   *\n   * Maximum time a sandbox can be kept alive is 24 hours (86_400_000 milliseconds) for Pro users and 1 hour (3_600_000 milliseconds) for Hobby users.\n   *\n   * @param sandboxId sandbox ID.\n   * @param timeoutMs timeout in **milliseconds**.\n   * @param opts connection options.\n   */\n  static async setTimeout(\n    sandboxId: string,\n    timeoutMs: number,\n    opts?: SandboxApiOpts\n  ): Promise<void> {\n    const config = new ConnectionConfig(opts)\n    const client = new ApiClient(config)\n\n    const res = await client.api.POST('/sandboxes/{sandboxID}/timeout', {\n      params: {\n        path: {\n          sandboxID: sandboxId,\n        },\n      },\n      body: {\n        timeout: this.timeoutToSeconds(timeoutMs),\n      },\n      signal: config.getSignal(opts?.requestTimeoutMs),\n    })\n\n    const err = handleApiError(res)\n    if (err) {\n      throw err\n    }\n  }\n\n  protected static async createSandbox(\n    template: string,\n    timeoutMs: number,\n    opts?: SandboxApiOpts & {\n      metadata?: Record<string, string>\n      envs?: Record<string, string>\n    }\n  ): Promise<{\n    sandboxId: string\n    envdVersion: string\n  }> {\n    const config = new ConnectionConfig(opts)\n    const client = new ApiClient(config)\n\n    const res = await client.api.POST('/sandboxes', {\n      body: {\n        autoPause: false,\n        templateID: template,\n        metadata: opts?.metadata,\n        envVars: opts?.envs,\n        timeout: this.timeoutToSeconds(timeoutMs),\n      },\n      signal: config.getSignal(opts?.requestTimeoutMs),\n    })\n\n    const err = handleApiError(res)\n    if (err) {\n      throw err\n    }\n\n    if (compareVersions(res.data!.envdVersion, '0.1.0') < 0) {\n      await this.kill(\n        this.getSandboxId({\n          sandboxId: res.data!.sandboxID,\n          clientId: res.data!.clientID,\n        }),\n        opts\n      )\n      throw new TemplateError(\n        'You need to update the template to use the new SDK. ' +\n          'You can do this by running `e2b template build` in the directory with the template.'\n      )\n    }\n    return {\n      sandboxId: this.getSandboxId({\n        sandboxId: res.data!.sandboxID,\n        clientId: res.data!.clientID,\n      }),\n      envdVersion: res.data!.envdVersion,\n    }\n  }\n\n  private static timeoutToSeconds(timeout: number): number {\n    return Math.ceil(timeout / 1000)\n  }\n\n  private static getSandboxId({\n    sandboxId,\n    clientId,\n  }: {\n    sandboxId: string\n    clientId: string\n  }): string {\n    return `${sandboxId}-${clientId}`\n  }\n}\n","export { ApiClient } from './api'\nexport type { components, paths } from './api'\n\nexport { ConnectionConfig } from './connectionConfig'\nexport type { ConnectionOpts, Username } from './connectionConfig'\nexport {\n  AuthenticationError,\n  InvalidArgumentError,\n  NotEnoughSpaceError,\n  NotFoundError,\n  SandboxError,\n  TemplateError,\n  TimeoutError,\n} from './errors'\nexport type { Logger } from './logs'\n\nexport { FileType } from './sandbox/filesystem'\nexport type { EntryInfo, Filesystem } from './sandbox/filesystem'\nexport { FilesystemEventType } from './sandbox/filesystem/watchHandle'\nexport type { FilesystemEvent, WatchHandle } from './sandbox/filesystem/watchHandle'\n\nexport { CommandExitError } from './sandbox/commands/commandHandle'\nexport type {\n  CommandResult,\n  Stdout,\n  Stderr,\n  PtyOutput,\n  CommandHandle,\n} from './sandbox/commands/commandHandle'\nexport type { SandboxApiOpts } from './sandbox/sandboxApi'\n\nexport type {\n  ProcessInfo,\n  CommandRequestOpts,\n  CommandConnectOpts,\n  CommandStartOpts,\n  Commands,\n  Pty,\n} from './sandbox/commands'\n\nexport type { SandboxOpts } from './sandbox'\nexport type { SandboxInfo } from './sandbox/sandboxApi'\nexport { Sandbox }\nimport { Sandbox } from './sandbox'\nexport default Sandbox\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,kBAAqC;;;ACA5C,OAAO,cAAc;;;ACEnB,cAAW;;;ADMb,SAAS,aAAoD;AAR7D,MAAAA,KAAA;AAUE,MAAK,WAAmB,KAAK;AAE3B,WAAO,EAAE,SAAS,OAAO,SAAS,WAAW,IAAI,QAAQ;AAAA,EAC3D;AAGA,MAAK,WAAmB,MAAM;AAE5B,WAAO,EAAE,SAAS,QAAQ,SAAS,WAAW,KAAK,QAAQ,KAAK;AAAA,EAClE;AAE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e,0BAA0B;AAF/C,IAAM,UAAN;;;AKlBP,IAAO,cAAQ;","names":["_a","_a","_a","_a","createClient","ConnectError","Code","createClient","_a","createClient","Code","ConnectError","ConnectError","Code","FilesystemEventType","_a","FileType","Filesystem","createClient","_a","ConnectError","Code","_a","Code","ConnectError","createClient","enumDesc","fileDesc","messageDesc","serviceDesc","serviceDesc","Code","ConnectError","createClient","createClient","_a","ConnectError","Code","createClient","ConnectError","Code","_a","pid","compareVersions","_a","compareVersions","Filesystem","_a"]}