MCPcopy Create free account
hub / github.com/e2b-dev/desktop / create

Method create

packages/js-sdk/src/sandbox.ts:177–204  ·  view source on GitHub ↗
(
    this: S,
    templateOrOpts?: SandboxOpts | string,
    opts?: SandboxOpts
  )

Source from the content-addressed store, hash-verified

175 opts?: SandboxOpts
176 ): Promise<InstanceType<S>>
177 static async create<S extends typeof Sandbox>(
178 this: S,
179 templateOrOpts?: SandboxOpts | string,
180 opts?: SandboxOpts
181 ): Promise<InstanceType<S>> {
182 const { template, sandboxOpts } =
183 typeof templateOrOpts === 'string'
184 ? { template: templateOrOpts, sandboxOpts: opts }
185 : { template: this.defaultTemplate, sandboxOpts: templateOrOpts }
186
187 // Add DISPLAY environment variable if not already set
188 const display = opts?.display || ':0'
189 const sandboxOptsWithDisplay = {
190 ...sandboxOpts,
191 envs: {
192 ...sandboxOpts?.envs,
193 DISPLAY: display,
194 },
195 }
196
197 const sbx = (await super.create(
198 template,
199 sandboxOptsWithDisplay
200 )) as InstanceType<S>
201 await sbx._start(display, sandboxOptsWithDisplay)
202
203 return sbx
204 }
205
206 /**
207 * Wait for a command to return a specific result.

Callers 3

setup.tsFile · 0.45
mainFunction · 0.45
mainFunction · 0.45

Calls 1

_startMethod · 0.80

Tested by

no test coverage detected