@tangle-network/agent-app 0.46.18 → 0.46.19

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.
@@ -112,7 +112,7 @@ import {
112
112
  flattenHistory,
113
113
  readSandboxBinaryBytes,
114
114
  statSandboxFileSize
115
- } from "../chunk-47LN6Q2U.js";
115
+ } from "../chunk-HDQWY5AY.js";
116
116
  import "../chunk-TH7L265V.js";
117
117
  import "../chunk-LWSJK546.js";
118
118
  import "../chunk-P5PIAQVS.js";
@@ -511,15 +511,24 @@ function isSandboxApiBearerAuthFailure(diagnostics) {
511
511
  return /^\/v1\/sandboxes\/[^/?#]+(?:\/(?!runtime(?:[/?#]|$))[^?#]*)?(?:[?#].*)?$/.test(endpointPath);
512
512
  });
513
513
  }
514
+ function isSandboxBackingContainerMissingMessage(message) {
515
+ return /host-agent startcontainer failed \(404\):/i.test(message) && /container not found/i.test(message) && /"code"\s*:\s*"not_found"/i.test(message);
516
+ }
514
517
  function isSandboxApiSandboxMissingFailure(diagnostics) {
515
518
  return diagnostics.causes.some((cause) => {
516
519
  const status = typeof cause.status === "number" ? cause.status : typeof cause.status === "string" ? Number.parseInt(cause.status, 10) : void 0;
517
- if (status !== 404) return false;
518
520
  if (cause.origin !== "sandbox-api") return false;
519
521
  if (typeof cause.endpoint !== "string") return false;
520
522
  const endpointPath = sandboxApiEndpointPath(cause.endpoint);
521
523
  if (!endpointPath) return false;
522
- return /^\/v1\/sandboxes\/[^/?#]+(?:\/(?!runtime(?:[/?#]|$))[^?#]*)?(?:[?#].*)?$/.test(endpointPath);
524
+ const sandboxResource = /^\/v1\/sandboxes\/[^/?#]+(?:\/(?!runtime(?:[/?#]|$))[^?#]*)?(?:[?#].*)?$/.test(endpointPath);
525
+ if (!sandboxResource) return false;
526
+ if (status === 404) return true;
527
+ if (status !== 500 || !/^\/v1\/sandboxes\/[^/?#]+\/resume(?:[?#].*)?$/.test(endpointPath)) {
528
+ return false;
529
+ }
530
+ const message = typeof cause.message === "string" ? cause.message : "";
531
+ return isSandboxBackingContainerMissingMessage(message);
523
532
  });
524
533
  }
525
534
  function isSandboxHostCapacityFailure(diagnostics) {
@@ -1605,14 +1614,29 @@ async function isReusableBox(box, harness, probe) {
1605
1614
  else livenessVerifiedAt.delete(box.id);
1606
1615
  return alive;
1607
1616
  }
1617
+ function stoppedBoxResumeError(box, cause) {
1618
+ const error = cause instanceof Error ? cause : new Error(String(cause));
1619
+ if (!isSandboxBackingContainerMissingMessage(error.message)) return cause;
1620
+ const status = typeof cause === "object" && cause !== null ? cause.status : void 0;
1621
+ if (typeof status !== "number" && typeof status !== "string") return cause;
1622
+ const code = error.code;
1623
+ const wrapped = new Error(error.message, { cause: error });
1624
+ wrapped.name = error.name;
1625
+ return Object.assign(wrapped, {
1626
+ status,
1627
+ origin: "sandbox-api",
1628
+ endpoint: `/v1/sandboxes/${encodeURIComponent(box.id)}/resume`,
1629
+ ...typeof code === "number" || typeof code === "string" ? { code } : {}
1630
+ });
1631
+ }
1608
1632
  async function resumeStoppedBox(box, timeoutMs, onProgress) {
1609
1633
  try {
1610
1634
  livenessVerifiedAt.delete(box.id);
1611
1635
  await box.resume({ timeoutMs });
1612
1636
  await box.waitFor("running", { timeoutMs, ...onProgress ? { onProgress } : {} });
1613
1637
  return ok(box);
1614
- } catch (err) {
1615
- return fail(err);
1638
+ } catch (cause) {
1639
+ return fail(stoppedBoxResumeError(box, cause));
1616
1640
  }
1617
1641
  }
1618
1642
  async function recoverUnresponsiveBox(client, box, harness, probe, stage, name, resumeTimeout, onProgress) {
@@ -2448,4 +2472,4 @@ export {
2448
2472
  isTerminalPromptEvent,
2449
2473
  detectInteractiveQuestion
2450
2474
  };
2451
- //# sourceMappingURL=chunk-47LN6Q2U.js.map
2475
+ //# sourceMappingURL=chunk-HDQWY5AY.js.map