sandbox 3.1.0 → 3.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7290,7 +7290,7 @@ const scope = {
7290
7290
 
7291
7291
  //#endregion
7292
7292
  //#region package.json
7293
- var version = "3.1.0";
7293
+ var version = "3.1.2";
7294
7294
 
7295
7295
  //#endregion
7296
7296
  //#region src/error.ts
@@ -11225,7 +11225,6 @@ const debugPty = createDebugger("sandbox:interactive-shell:pty");
11225
11225
  * That way, applications like `vim` and `nano` will work properly.
11226
11226
  */
11227
11227
  const TERM = "xterm-256color";
11228
- const neverResolvedPromise = new Promise(() => {});
11229
11228
  /**
11230
11229
  * Prepares the sandbox environment for interactive shell by installing required dependencies
11231
11230
  * and copying the TTY server script.
@@ -11234,18 +11233,17 @@ const neverResolvedPromise = new Promise(() => {});
11234
11233
  * @returns Promise that resolves when environment is ready
11235
11234
  */
11236
11235
  async function setupSandboxEnvironment(sandbox, ora$1) {
11236
+ let alreadyInstalled = false;
11237
11237
  try {
11238
- var _usingCtx$1 = _usingCtx();
11239
- const installed = _usingCtx$1.u(createAbortController(`Finished installation`));
11240
- const waitUntilInstalled = checkIfServerInstalled(sandbox, installed.signal).then((installed$1) => installed$1 ? void 0 : neverResolvedPromise, (err$1) => {
11241
- debug$1("Error checking if server is installed:", err$1);
11242
- });
11243
- await Promise.race([installServerBinary(sandbox, ora$1, installed.signal), waitUntilInstalled.then(() => debug$1("Server binary already installed"))]).catch(installed.ignoreInterruptions);
11244
- } catch (_) {
11245
- _usingCtx$1.e = _;
11246
- } finally {
11247
- _usingCtx$1.d();
11238
+ alreadyInstalled = await checkIfServerInstalled(sandbox);
11239
+ } catch (err$1) {
11240
+ debug$1("Error checking if server is installed:", err$1);
11248
11241
  }
11242
+ if (alreadyInstalled) {
11243
+ debug$1("Server binary already installed");
11244
+ return;
11245
+ }
11246
+ await installServerBinary(sandbox, ora$1);
11249
11247
  }
11250
11248
  async function checkIfServerInstalled(sandbox, signal) {
11251
11249
  return (await sandbox.runCommand({
@@ -11316,7 +11314,7 @@ async function startServerCommand(sandbox, _listener, execution, sudo, env$2, cw
11316
11314
  */
11317
11315
  async function startInteractiveShell(options) {
11318
11316
  try {
11319
- var _usingCtx3 = _usingCtx();
11317
+ var _usingCtx$1 = _usingCtx();
11320
11318
  const listener = createListener();
11321
11319
  let command$1 = null;
11322
11320
  let cleaned = false;
@@ -11332,14 +11330,14 @@ async function startInteractiveShell(options) {
11332
11330
  cleaned = true;
11333
11331
  };
11334
11332
  process.once("beforeExit", cleanup);
11335
- const _cleanup = _usingCtx3.u(defer(cleanup));
11336
- const progress = _usingCtx3.u(acquireRelease(() => ora({ discardStdin: false }).start(), (s$1) => s$1.clear()));
11333
+ const _cleanup = _usingCtx$1.u(defer(cleanup));
11334
+ const progress = _usingCtx$1.u(acquireRelease(() => ora({ discardStdin: false }).start(), (s$1) => s$1.stop()));
11337
11335
  progress.text = "Setting up sandbox environment";
11338
11336
  await setupSandboxEnvironment(options.sandbox, progress);
11339
11337
  progress.text = "Booting up interactive listener...";
11340
11338
  command$1 = await startServerCommand(options.sandbox, listener, options.execution, options.sudo, options.envVars, options.cwd);
11341
11339
  debug$1("startServerCommand completed, cmdId=%s, interactivePort=%s", command$1.cmdId, options.sandbox.interactivePort);
11342
- const waitForProcess = _usingCtx3.u(createAbortController("Connection established successfully"));
11340
+ const waitForProcess = _usingCtx$1.u(createAbortController("Connection established successfully"));
11343
11341
  listener.connection.then(() => {
11344
11342
  debug$1("listener.connection resolved");
11345
11343
  waitForProcess.abort();
@@ -11348,35 +11346,41 @@ async function startInteractiveShell(options) {
11348
11346
  if (waitForProcess.signal.aborted) return;
11349
11347
  listener.stdoutStream.destroy(err$1 instanceof Error ? err$1 : new Error(String(err$1)));
11350
11348
  });
11351
- await Promise.all([throwIfCommandPrematurelyExited(command$1, waitForProcess.signal), attach({
11349
+ await Promise.all([throwIfCommandPrematurelyExited(command$1, waitForProcess.signal).catch(waitForProcess.ignoreInterruptions), attach({
11352
11350
  sandbox: options.sandbox,
11353
11351
  progress,
11354
11352
  listener,
11355
11353
  skipExtendingTimeout: options.skipExtendingTimeout,
11356
11354
  printCommand: () => console.error(printCommand(options.execution[0], options.execution.slice(1)))
11357
- })]).catch(waitForProcess.ignoreInterruptions);
11355
+ })]);
11358
11356
  } catch (_) {
11359
- _usingCtx3.e = _;
11357
+ _usingCtx$1.e = _;
11360
11358
  } finally {
11361
- _usingCtx3.d();
11359
+ _usingCtx$1.d();
11362
11360
  }
11363
11361
  }
11364
11362
  async function throwIfCommandPrematurelyExited(command$1, signal) {
11363
+ let exitCode;
11365
11364
  try {
11366
- const { exitCode } = await command$1.wait({ signal });
11367
- throw new Error([
11368
- `Interactive shell failed to start (exit code: ${exitCode}).`,
11369
- `${source_default.bold("hint:")} The sandbox may have timed out or encountered an error.`,
11370
- "╰▶ Check sandbox status with `sandbox list` or view logs for details."
11371
- ].join("\n"));
11365
+ ({exitCode} = await command$1.wait({ signal }));
11372
11366
  } catch (err$1) {
11373
11367
  if (signal.aborted) return;
11374
11368
  throw err$1;
11375
11369
  }
11370
+ let serverError = "";
11371
+ try {
11372
+ serverError = (await command$1.stderr({ signal })).trim();
11373
+ } catch {}
11374
+ throw new Error([
11375
+ `Interactive shell failed to start (exit code: ${exitCode}).`,
11376
+ `${source_default.bold("hint:")} The sandbox may have timed out or encountered an error.`,
11377
+ ...serverError ? [source_default.dim(serverError)] : [],
11378
+ "╰▶ Check sandbox status with `sandbox list` or view logs for details."
11379
+ ].join("\n"));
11376
11380
  }
11377
11381
  async function attach({ progress, listener, printCommand: printCommand$1, sandbox, skipExtendingTimeout }) {
11378
11382
  try {
11379
- var _usingCtx4 = _usingCtx();
11383
+ var _usingCtx3 = _usingCtx();
11380
11384
  progress.text = "Waiting for connection...";
11381
11385
  const details = await listener.connection;
11382
11386
  assert(sandbox.interactivePort, "Sandbox interactive port is not defined");
@@ -11391,7 +11395,7 @@ async function attach({ progress, listener, printCommand: printCommand$1, sandbo
11391
11395
  return c$1;
11392
11396
  });
11393
11397
  progress.stop();
11394
- const extensionController = _usingCtx4.u(createAbortController("stopped extensions"));
11398
+ const extensionController = _usingCtx3.u(createAbortController("stopped extensions"));
11395
11399
  if (!skipExtendingTimeout) extendSandboxTimeoutPeriodically(sandbox, extensionController.signal).catch(extensionController.ignoreInterruptions);
11396
11400
  client.sendMessage({ type: "ready" });
11397
11401
  client.sendMessage({
@@ -11417,9 +11421,9 @@ async function attach({ progress, listener, printCommand: printCommand$1, sandbo
11417
11421
  client.close();
11418
11422
  console.error(source_default.dim(`\n╰▶ connection to ▲ ${sandbox.name} closed.`));
11419
11423
  } catch (_) {
11420
- _usingCtx4.e = _;
11424
+ _usingCtx3.e = _;
11421
11425
  } finally {
11422
- _usingCtx4.d();
11426
+ _usingCtx3.d();
11423
11427
  }
11424
11428
  }
11425
11429
  /**
@@ -11447,16 +11451,16 @@ async function* messageReader(stream) {
11447
11451
  */
11448
11452
  async function connect$1(command$1, listener, signal) {
11449
11453
  try {
11450
- var _usingCtx5 = _usingCtx();
11451
- const logs = _usingCtx5.u(command$1.logs({ signal }));
11452
- const stderrStream = _usingCtx5.u(getStderrStream());
11454
+ var _usingCtx4 = _usingCtx();
11455
+ const logs = _usingCtx4.u(command$1.logs({ signal }));
11456
+ const stderrStream = _usingCtx4.u(getStderrStream());
11453
11457
  for await (const chunk of logs) if (chunk.stream === "stdout") listener.stdoutStream.write(chunk.data);
11454
11458
  else stderrStream.write(chunk.data);
11455
11459
  listener.stdoutStream.end();
11456
11460
  } catch (_) {
11457
- _usingCtx5.e = _;
11461
+ _usingCtx4.e = _;
11458
11462
  } finally {
11459
- _usingCtx5.d();
11463
+ _usingCtx4.d();
11460
11464
  }
11461
11465
  }
11462
11466
  async function openWithRetry(create$1) {
@@ -11614,6 +11618,7 @@ const exec = import_cjs$17.command({
11614
11618
  projectId: project$1,
11615
11619
  teamId: team$1,
11616
11620
  token: token$1,
11621
+ resume: true,
11617
11622
  __includeSystemRoutes: true
11618
11623
  });
11619
11624
  if (!interactive) {
@@ -15872,4 +15877,4 @@ const app = (opts) => (0, import_cjs.subcommands)({
15872
15877
 
15873
15878
  //#endregion
15874
15879
  export { source_exports as a, init_source as i, StyledError as n, require_cjs as r, app as t };
15875
- //# sourceMappingURL=app-CUphjb1B.mjs.map
15880
+ //# sourceMappingURL=app-BPs0T7SC.mjs.map