sandbox 3.0.0 → 3.0.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.0.0";
7293
+ var version = "3.0.2";
7294
7294
 
7295
7295
  //#endregion
7296
7296
  //#region src/error.ts
@@ -11383,11 +11383,13 @@ async function attach({ progress, listener, printCommand: printCommand$1, sandbo
11383
11383
  const url = `wss://${sandbox.domain(sandbox.interactivePort).replace(/^https?:\/\//, "")}`;
11384
11384
  debug$1("Connecting to WebSocket URL:", url);
11385
11385
  const stdoutPipe = messageReader(process.stdout);
11386
- const client = details.createClient(url);
11387
- client.addEventListener("message", async ({ data }) => {
11388
- stdoutPipe.next(data);
11386
+ const client = await openWithRetry(() => {
11387
+ const c$1 = details.createClient(url);
11388
+ c$1.addEventListener("message", async ({ data }) => {
11389
+ stdoutPipe.next(data);
11390
+ });
11391
+ return c$1;
11389
11392
  });
11390
- await client.waitForOpen();
11391
11393
  progress.stop();
11392
11394
  const extensionController = _usingCtx4.u(createAbortController("stopped extensions"));
11393
11395
  if (!skipExtendingTimeout) extendSandboxTimeoutPeriodically(sandbox, extensionController.signal).catch(extensionController.ignoreInterruptions);
@@ -11457,6 +11459,37 @@ async function connect$1(command$1, listener, signal) {
11457
11459
  _usingCtx5.d();
11458
11460
  }
11459
11461
  }
11462
+ async function openWithRetry(create$1) {
11463
+ return retry(async (_bail, attempt) => {
11464
+ const client = create$1();
11465
+ try {
11466
+ await withTimeout(client.waitForOpen(), 2500);
11467
+ return client;
11468
+ } catch (err$1) {
11469
+ debug$1("WebSocket open attempt %d failed: %o", attempt, err$1);
11470
+ try {
11471
+ client.close();
11472
+ } catch (closeErr) {
11473
+ debug$1("WebSocket close after failed open errored: %o", closeErr);
11474
+ }
11475
+ throw err$1;
11476
+ }
11477
+ }, {
11478
+ retries: 2,
11479
+ minTimeout: 500,
11480
+ factor: 0
11481
+ });
11482
+ }
11483
+ function withTimeout(promise, ms$6) {
11484
+ promise.catch(() => {});
11485
+ let timer;
11486
+ const timeout$1 = new Promise((_, reject) => {
11487
+ timer = setTimeout(() => reject(/* @__PURE__ */ new Error(`Operation timed out after ${ms$6}ms`)), ms$6);
11488
+ });
11489
+ return Promise.race([promise, timeout$1]).finally(() => {
11490
+ if (timer) clearTimeout(timer);
11491
+ });
11492
+ }
11460
11493
  function getStderrStream() {
11461
11494
  return acquireRelease(() => {
11462
11495
  if (INTERACTIVE_BIN_OUTPUT) {
@@ -14783,11 +14816,11 @@ function renderSiblings(siblings, count) {
14783
14816
  const remaining = totalCount - 1 - shown.length;
14784
14817
  for (let i = 0; i < shown.length; i++) {
14785
14818
  const connector = i === shown.length - 1 && remaining <= 0 ? "╰──" : "├──";
14786
- lines.push(`│ ${connector} ${source_default.gray(shown[i].sourceSessionId)}`);
14819
+ lines.push(`│ ${connector} ${source_default.gray(shown[i].id)}`);
14787
14820
  }
14788
14821
  if (remaining > 0) {
14789
14822
  const suffix = hasPlus ? "+" : "";
14790
- lines.push(`│ ╰── ${source_default.gray(`+${remaining}${suffix} more sandboxes`)}`);
14823
+ lines.push(`│ ╰── ${source_default.gray(`+${remaining}${suffix} more snapshots`)}`);
14791
14824
  }
14792
14825
  return lines;
14793
14826
  }
@@ -14805,7 +14838,7 @@ function renderSnapshotTree(params) {
14805
14838
  if (descendantNodes.length > 0) for (const node of [...descendantNodes].reverse()) pushNode(node, false);
14806
14839
  if (!hideCurrent) {
14807
14840
  const { currentSnapshotId: id, currentSnapshotExpiresAt } = params;
14808
- pushNode(ancestors.snapshots.find((n) => n.snapshot.id === id) ?? descendants.snapshots.find((n) => n.snapshot.id === id) ?? {
14841
+ pushNode(params.current ?? ancestors.snapshots.find((n) => n.snapshot.id === id) ?? descendants.snapshots.find((n) => n.snapshot.id === id) ?? {
14809
14842
  snapshot: {
14810
14843
  id,
14811
14844
  sourceSessionId: "",
@@ -15097,7 +15130,8 @@ const tree = import_cjs$4.command({
15097
15130
  currentSnap,
15098
15131
  currentSnapshotId,
15099
15132
  ancestors,
15100
- descendants
15133
+ descendants,
15134
+ current: ancestors.anchor ?? descendants.anchor
15101
15135
  };
15102
15136
  } catch (_) {
15103
15137
  _usingCtx5.e = _;
@@ -15113,7 +15147,8 @@ const tree = import_cjs$4.command({
15113
15147
  currentSnapshotId: result.currentSnapshotId,
15114
15148
  currentSnapshotExpiresAt: result.currentSnap.expiresAt?.getTime(),
15115
15149
  ancestors: result.ancestors,
15116
- descendants: result.descendants
15150
+ descendants: result.descendants,
15151
+ current: result.current
15117
15152
  }));
15118
15153
  const limitArg = limit !== void 0 ? ` --limit ${limit}` : "";
15119
15154
  if (result.ancestors.pagination.next !== null) console.log(`\nMore ancestors: sandbox snapshots tree ${name} --sort-order desc${limitArg} --cursor ${result.ancestors.pagination.next}`);
@@ -15825,4 +15860,4 @@ const app = (opts) => (0, import_cjs.subcommands)({
15825
15860
 
15826
15861
  //#endregion
15827
15862
  export { source_exports as a, init_source as i, StyledError as n, require_cjs as r, app as t };
15828
- //# sourceMappingURL=app-BaHpC2zy.mjs.map
15863
+ //# sourceMappingURL=app-C9tVyCZD.mjs.map