@tangle-network/agent-app 0.50.7 → 0.50.8

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.
@@ -42,7 +42,7 @@ import {
42
42
  flattenHistory,
43
43
  readSandboxBinaryBytes,
44
44
  statSandboxFileSize
45
- } from "../chunk-P5ZJQKOI.js";
45
+ } from "../chunk-2TZLCQ5U.js";
46
46
  import "../chunk-MCYJON3F.js";
47
47
  import "../chunk-LWSJK546.js";
48
48
  import "../chunk-FZOGDD2E.js";
@@ -1757,17 +1757,20 @@ function stoppedBoxResumeError(box, cause) {
1757
1757
  ...typeof code === "number" || typeof code === "string" ? { code } : {}
1758
1758
  });
1759
1759
  }
1760
- async function resumeStoppedBox(box, timeoutMs, onProgress) {
1760
+ async function resumeStoppedBox(box, timeoutMs, runtimeEnv, onProgress) {
1761
1761
  try {
1762
1762
  livenessVerifiedAt.delete(box.id);
1763
- await box.resume({ timeoutMs });
1763
+ await box.resume({
1764
+ timeoutMs,
1765
+ ...Object.keys(runtimeEnv).length > 0 ? { env: runtimeEnv } : {}
1766
+ });
1764
1767
  await box.waitFor("running", { timeoutMs, ...onProgress ? { onProgress } : {} });
1765
1768
  return ok(box);
1766
1769
  } catch (cause) {
1767
1770
  return fail(stoppedBoxResumeError(box, cause));
1768
1771
  }
1769
1772
  }
1770
- async function recoverUnresponsiveBox(client, box, probe, stage, name, resumeTimeout, onProgress) {
1773
+ async function recoverUnresponsiveBox(client, box, probe, stage, name, resumeTimeout, runtimeEnv, onProgress) {
1771
1774
  try {
1772
1775
  await box.stop();
1773
1776
  } catch (err) {
@@ -1779,7 +1782,7 @@ async function recoverUnresponsiveBox(client, box, probe, stage, name, resumeTim
1779
1782
  err
1780
1783
  );
1781
1784
  }
1782
- const resumed = await resumeStoppedBox(box, resumeTimeout, onProgress);
1785
+ const resumed = await resumeStoppedBox(box, resumeTimeout, runtimeEnv, onProgress);
1783
1786
  if (!resumed.succeeded) {
1784
1787
  throw new SandboxRecoveryFailedError(
1785
1788
  stage,
@@ -1832,7 +1835,7 @@ async function resolveWorkspaceRuntimeEnv(shell, scope) {
1832
1835
  assertEnvWithinLimits(env);
1833
1836
  return env;
1834
1837
  }
1835
- async function finalizeExistingBox(shell, client, box, stage, name, workspaceId, userId, harness, scope) {
1838
+ async function finalizeExistingBox(shell, client, box, stage, name, workspaceId, userId, harness, scope, runtimeEnv) {
1836
1839
  await assertExistingBoxEgress(box, shell.egressPolicy, shell.migrateEgressPolicy, stage, name);
1837
1840
  const written = await materializeDeferredFilesForExistingBox(
1838
1841
  shell,
@@ -1848,7 +1851,6 @@ async function finalizeExistingBox(shell, client, box, stage, name, workspaceId,
1848
1851
  throw deferredProfileWriteFailed(stage, name, written.error);
1849
1852
  }
1850
1853
  const finalBox = written.value;
1851
- const runtimeEnv = await resolveWorkspaceRuntimeEnv(shell, scope);
1852
1854
  if (Object.keys(runtimeEnv).length > 0) {
1853
1855
  await finalBox.setRuntimeEnv(runtimeEnv);
1854
1856
  }
@@ -2017,10 +2019,11 @@ async function provisionWorkspaceSandbox(shell, options) {
2017
2019
  throw new Error(`forceNew: sandbox ${name} could not be deleted`, { cause: dropped.error });
2018
2020
  }
2019
2021
  } else if (found.metadata?.harness === harness) {
2022
+ const runtimeEnv2 = await resolveWorkspaceRuntimeEnv(shell, scope);
2020
2023
  try {
2021
2024
  const ready = await refreshRuntimeConnection(client, found);
2022
2025
  if ((await isReusableBox(ready, shell.livenessProbe)).succeeded) {
2023
- return await finalizeExistingBox(shell, client, ready, "reused", name, workspaceId, userId, harness, scope);
2026
+ return await finalizeExistingBox(shell, client, ready, "reused", name, workspaceId, userId, harness, scope, runtimeEnv2);
2024
2027
  }
2025
2028
  const recovered = await recoverUnresponsiveBox(
2026
2029
  client,
@@ -2029,9 +2032,10 @@ async function provisionWorkspaceSandbox(shell, options) {
2029
2032
  "reused",
2030
2033
  name,
2031
2034
  resumeTimeout,
2035
+ runtimeEnv2,
2032
2036
  onProgress
2033
2037
  );
2034
- return await finalizeExistingBox(shell, client, recovered, "reused", name, workspaceId, userId, harness, scope);
2038
+ return await finalizeExistingBox(shell, client, recovered, "reused", name, workspaceId, userId, harness, scope, runtimeEnv2);
2035
2039
  } catch (cause) {
2036
2040
  const error = cause instanceof Error ? cause : new Error(String(cause));
2037
2041
  const recovery = await requestMissingSandboxReplacement(shell, {
@@ -2059,7 +2063,8 @@ async function provisionWorkspaceSandbox(shell, options) {
2059
2063
  const stopped = await listStopped(client, name);
2060
2064
  if (!stopped.succeeded) throw stopped.error;
2061
2065
  if (stopped.value) {
2062
- const resumed = await resumeStoppedBox(stopped.value, resumeTimeout, onProgress);
2066
+ const runtimeEnv2 = await resolveWorkspaceRuntimeEnv(shell, scope);
2067
+ const resumed = await resumeStoppedBox(stopped.value, resumeTimeout, runtimeEnv2, onProgress);
2063
2068
  if (!resumed.succeeded) {
2064
2069
  const recovery = await requestSandboxReplacement(
2065
2070
  shell.recoverStoppedSandbox,
@@ -2072,7 +2077,7 @@ async function provisionWorkspaceSandbox(shell, options) {
2072
2077
  try {
2073
2078
  const box2 = await refreshRuntimeConnection(client, resumed.value);
2074
2079
  if ((await isReusableBox(box2, shell.livenessProbe)).succeeded) {
2075
- return await finalizeExistingBox(shell, client, box2, "resumed", name, workspaceId, userId, harness, scope);
2080
+ return await finalizeExistingBox(shell, client, box2, "resumed", name, workspaceId, userId, harness, scope, runtimeEnv2);
2076
2081
  }
2077
2082
  const recovered = await recoverUnresponsiveBox(
2078
2083
  client,
@@ -2081,9 +2086,10 @@ async function provisionWorkspaceSandbox(shell, options) {
2081
2086
  "resumed",
2082
2087
  name,
2083
2088
  resumeTimeout,
2089
+ runtimeEnv2,
2084
2090
  onProgress
2085
2091
  );
2086
- return await finalizeExistingBox(shell, client, recovered, "resumed", name, workspaceId, userId, harness, scope);
2092
+ return await finalizeExistingBox(shell, client, recovered, "resumed", name, workspaceId, userId, harness, scope, runtimeEnv2);
2087
2093
  } catch (cause) {
2088
2094
  const error = cause instanceof Error ? cause : new Error(String(cause));
2089
2095
  const recovery = await requestMissingSandboxReplacement(shell, {
@@ -2836,4 +2842,4 @@ export {
2836
2842
  isTerminalPromptEvent,
2837
2843
  detectInteractiveQuestion
2838
2844
  };
2839
- //# sourceMappingURL=chunk-P5ZJQKOI.js.map
2845
+ //# sourceMappingURL=chunk-2TZLCQ5U.js.map