@tangle-network/sandbox 1.0.485 → 1.0.487

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.
Files changed (72) hide show
  1. package/dist/agent/index.d.ts +4 -4
  2. package/dist/agent/index.js +5 -5
  3. package/dist/agent/preview.d.ts +1 -1
  4. package/dist/agent/preview.js +2 -2
  5. package/dist/{agent-run-outcome-wmOJkBuu.d.ts → agent-run-outcome-IWbQgIbt.d.ts} +1 -1
  6. package/dist/{api-request-DfzqU66n.js → api-request-BSleTpab.js} +9 -6
  7. package/dist/auth/index.js +2 -2
  8. package/dist/{browser-interactive-control-controller-BkrBBtE_.js → browser-interactive-control-controller-BfbyLri9.js} +1 -1
  9. package/dist/{browser-interactive-control-controller-DPZh8xys.d.ts → browser-interactive-control-controller-CNqYrsK-.d.ts} +1 -1
  10. package/dist/{chunked-upload-C44d_Ao7.js → chunked-upload-C84EiOec.js} +1 -1
  11. package/dist/{chunked-upload-file-qXxstMmc.js → chunked-upload-file-CtoNGE4S.js} +1 -1
  12. package/dist/cli-auth-bundle-BZRV0Sjw.js +2 -0
  13. package/dist/{cli-auth-bundle-B8bx652V-hMsdeLuq.js → cli-auth-bundle-z1X_k0lF-CHfKGrQ-.js} +3 -3
  14. package/dist/{client-bVAAm37K.js → client-B2_jLjYj.js} +10 -10
  15. package/dist/{client-D6e4vd90.d.ts → client-CIp8gol6.d.ts} +6 -5
  16. package/dist/collaboration/index.js +1 -1
  17. package/dist/{collaboration-DxHWb-GT.js → collaboration-YdSIT2fM.js} +2 -2
  18. package/dist/core.d.ts +6 -6
  19. package/dist/core.js +6 -6
  20. package/dist/{direct-http2-DJYOowWN.js → direct-http2-DiJOMM8k.js} +2 -2
  21. package/dist/{errors-BY7a-Hpw.js → errors-DVjaZqJT.js} +5 -1
  22. package/dist/{file-download-HPsIahnf.js → file-download-C6BO_rTp.js} +1 -1
  23. package/dist/gpu-lease/index.js +2 -2
  24. package/dist/{index-D3uEA1ED.d.ts → index-D7dMz_US.d.ts} +10 -9
  25. package/dist/index.d.ts +9 -9
  26. package/dist/index.js +13 -13
  27. package/dist/intelligence/index.js +4 -4
  28. package/dist/interactive-control.d.ts +1 -1
  29. package/dist/interactive-control.js +1 -1
  30. package/dist/{interactive-controller-DtGlf5GF.js → interactive-controller-BM65klVR.js} +6 -6
  31. package/dist/{interactive-controller-ezfsQCnx.d.ts → interactive-controller-RKI6dXBi.d.ts} +3 -3
  32. package/dist/{keep-alive-fetch-BQJJVjzW.js → keep-alive-fetch-D76rml5I.js} +1 -1
  33. package/dist/lib/prepared-evidence.js +1 -1
  34. package/dist/lib/prepared-process.js +1 -1
  35. package/dist/{lines-DB6fXGdG.d.ts → lines-DkfkbLSV.d.ts} +1 -1
  36. package/dist/{lines-BWUWIrxa.js → lines-N7p7PrZ1.js} +1 -1
  37. package/dist/lines.d.ts +1 -1
  38. package/dist/lines.js +1 -1
  39. package/dist/{local-cli-auth-DAJ9tyf-.js → local-cli-auth-CbldA52D.js} +1 -1
  40. package/dist/{mcp-local-DS4hFmzr.js → mcp-local-BXZul5nd.js} +3 -3
  41. package/dist/{prepared-evidence-u9A1AZdG.js → prepared-evidence-BMADfSad.js} +1 -1
  42. package/dist/{prepared-process-CD-MjClN.js → prepared-process-B4DuLmEg.js} +1 -1
  43. package/dist/{preview-csKniGVD.d.ts → preview-Bf1nPEqQ.d.ts} +3 -3
  44. package/dist/{public-templates-YC2MMA7v.d.ts → public-templates-maL22HQt.d.ts} +2 -2
  45. package/dist/public-templates.d.ts +1 -1
  46. package/dist/public-templates.js +1 -1
  47. package/dist/{raw-evidence-archive-C7eYWtMG.js → raw-evidence-archive-B7_0tFYq.js} +3 -3
  48. package/dist/retry-after-header-DyAWSQ4m.js +24 -0
  49. package/dist/runtime.d.ts +5 -5
  50. package/dist/runtime.js +5 -5
  51. package/dist/{sandbox-Dnmxn9U3.js → sandbox-BNlmFt8n.js} +140 -87
  52. package/dist/{secp256k1-B2arMxku.js → secp256k1-DIwypP5B.js} +1 -1
  53. package/dist/{select-seat-43fsQBjG.js → select-seat-Bm8THMSh.js} +3 -3
  54. package/dist/select-seat-command.d.ts +2 -2
  55. package/dist/select-seat-command.js +2 -2
  56. package/dist/session-gateway/index.js +3 -3
  57. package/dist/tangle/index.d.ts +1 -1
  58. package/dist/tangle/index.js +2 -2
  59. package/dist/{tangle-Brz73sjb.js → tangle-Dld1JKjX.js} +6 -6
  60. package/dist/{terminal-stream-types-BItnV5cg.d.ts → terminal-stream-types-RAsy75gD.d.ts} +2 -0
  61. package/dist/{trace-id-BTa6Db_2.js → trace-id-BwKjBM-q.js} +1 -1
  62. package/dist/{types-CD82H77t.d.ts → types-5by8R76_.d.ts} +8 -2
  63. package/package.json +4 -4
  64. package/dist/cli-auth-bundle-BtGqWSts.js +0 -2
  65. package/dist/retry-after-header-BZbs5rig.js +0 -13
  66. package/dist/sidecar-proxy-error-DVVfeGIP.js +0 -4
  67. /package/dist/{abi-CQYNCS4F.js → abi-pcDt2Adp.js} +0 -0
  68. /package/dist/{core-BWiEs9yv.js → core-CBWUEURz.js} +0 -0
  69. /package/dist/{preview-operations-DYH3y0cn.js → preview-operations-BTHZR1w2.js} +0 -0
  70. /package/dist/{raw-evidence-export-gCbAD5ZV.js → raw-evidence-export-Dog7W5zP.js} +0 -0
  71. /package/dist/{sse-parser-DTgSRcZC.js → sse-parser-BCG3iL9j.js} +0 -0
  72. /package/dist/{utils-fYi8g-M-.js → utils-BvN0Mk3j.js} +0 -0
@@ -1,24 +1,23 @@
1
- import { A as withoutRuntimeSecrets, B as normalizeEffectiveBackend, C as assertCurrentBackendType, D as requestedSecretProfilePublicDigest, E as requestedPublicProfileDigest, I as AgentRuntimeAttachmentsSchema, M as deriveAgentResultOutcome, S as applyRequestedModel, T as normalizeRuntimeBackendConfig, _ as encodePromptForWire, a as assertScopedTokenActive, b as canUseNodeHttp2, c as SandboxRuntimeApi, d as appendSessionIdQuery, f as callHeaders, g as validateAcceptedDispatchRunRef, h as resolveDispatchRunIdentity, i as terminalUpgradeHeadersSupported, j as createAgentRunOutcomeTracker, l as normalizeSessionInfo, m as assertFileWritePreconditions, n as InteractiveSessionController, p as sessionHeaders, r as TerminalStream, s as requestScopedToken, u as sessionMessageRequestBody, v as encodeTextForWire, w as mergeRuntimeBackendConfig, y as runtimeFilesystemPath } from "./interactive-controller-DtGlf5GF.js";
1
+ import { A as withoutRuntimeSecrets, B as normalizeEffectiveBackend, C as assertCurrentBackendType, D as requestedSecretProfilePublicDigest, E as requestedPublicProfileDigest, I as AgentRuntimeAttachmentsSchema, M as deriveAgentResultOutcome, S as applyRequestedModel, T as normalizeRuntimeBackendConfig, _ as encodePromptForWire, a as assertScopedTokenActive, b as canUseNodeHttp2, c as SandboxRuntimeApi, d as appendSessionIdQuery, f as callHeaders, g as validateAcceptedDispatchRunRef, h as resolveDispatchRunIdentity, i as terminalUpgradeHeadersSupported, j as createAgentRunOutcomeTracker, l as normalizeSessionInfo, m as assertFileWritePreconditions, n as InteractiveSessionController, p as sessionHeaders, r as TerminalStream, s as requestScopedToken, u as sessionMessageRequestBody, v as encodeTextForWire, w as mergeRuntimeBackendConfig, y as runtimeFilesystemPath } from "./interactive-controller-BM65klVR.js";
2
2
  import { O as boundedStringSchema, T as boundedIdentifierSchema, c as canonicalCandidateJson, s as canonicalCandidateDigest, v as sha256DigestSchema } from "./harness-QlDF8rzb.js";
3
3
  import { o as ProxySecretReceiptSchema, r as agentProfileSchema } from "./profile-schema-BHeC7cOf.js";
4
- import { A as agentInteractiveSessionStatusMatchesRef, B as PlanContinuationSchema, C as AgentInteractiveSessionStopAcknowledgementSchema, D as agentInteractiveSessionControlClaimMatchesRef, E as agentInteractiveSessionControlClaimIsNewer, F as AgentRunCancellationAcknowledgementSchema, G as InteractionResponseSchema, H as InteractionBindingSchema, I as AgentRunCancellationRequestSchema, L as agentRunCancellationAcknowledgementMatchesRequest, M as agentInteractiveDimensionSchema, N as sameAgentExactRun, O as agentInteractiveSessionPromptAcknowledgementMatchesCommand, P as AgentExactRunControlRefSchema, S as AgentInteractiveSessionStatusSchema, T as agentInteractiveSessionControlClaimAcknowledgementMatchesRequest, U as InteractionRequestSchema, V as InteractionAcknowledgementSchema, W as InteractionResponseCommandSchema, _ as AgentInteractiveSessionControlClaimRequestSchema, b as AgentInteractiveSessionPromptCommandSchema, d as interactiveSessionControlClaimResponseSchema, f as interactiveSessionControlReleaseResponseSchema, g as AgentInteractiveSessionControlClaimAcknowledgementSchema, h as AgentInteractiveSessionAttachSchema, j as agentInteractiveSessionStopAcknowledgementMatchesCommand, l as createInteractiveControlHolderId, m as interactiveSessionStatusResponseSchema, p as interactiveSessionControlValidationResponseSchema, v as AgentInteractiveSessionControlClaimSchema, w as AgentInteractiveSessionStopCommandSchema, x as AgentInteractiveSessionRefSchema, y as AgentInteractiveSessionPromptAcknowledgementSchema } from "./browser-interactive-control-controller-BkrBBtE_.js";
4
+ import { A as agentInteractiveSessionStatusMatchesRef, B as PlanContinuationSchema, C as AgentInteractiveSessionStopAcknowledgementSchema, D as agentInteractiveSessionControlClaimMatchesRef, E as agentInteractiveSessionControlClaimIsNewer, F as AgentRunCancellationAcknowledgementSchema, G as InteractionResponseSchema, H as InteractionBindingSchema, I as AgentRunCancellationRequestSchema, L as agentRunCancellationAcknowledgementMatchesRequest, M as agentInteractiveDimensionSchema, N as sameAgentExactRun, O as agentInteractiveSessionPromptAcknowledgementMatchesCommand, P as AgentExactRunControlRefSchema, S as AgentInteractiveSessionStatusSchema, T as agentInteractiveSessionControlClaimAcknowledgementMatchesRequest, U as InteractionRequestSchema, V as InteractionAcknowledgementSchema, W as InteractionResponseCommandSchema, _ as AgentInteractiveSessionControlClaimRequestSchema, b as AgentInteractiveSessionPromptCommandSchema, d as interactiveSessionControlClaimResponseSchema, f as interactiveSessionControlReleaseResponseSchema, g as AgentInteractiveSessionControlClaimAcknowledgementSchema, h as AgentInteractiveSessionAttachSchema, j as agentInteractiveSessionStopAcknowledgementMatchesCommand, l as createInteractiveControlHolderId, m as interactiveSessionStatusResponseSchema, p as interactiveSessionControlValidationResponseSchema, v as AgentInteractiveSessionControlClaimSchema, w as AgentInteractiveSessionStopCommandSchema, x as AgentInteractiveSessionRefSchema, y as AgentInteractiveSessionPromptAcknowledgementSchema } from "./browser-interactive-control-controller-BfbyLri9.js";
5
5
  import { t as canonicalAgentProfileDigest } from "./agent-execution-preparation-B8PJuIsN.js";
6
- import { C as SandboxError, D as TimeoutError, E as StreamInterruptedError, O as ValidationError, T as StateError, _ as NetworkError, a as readResponseJson, b as ProfileFileMountPathError, c as AuthError, f as EdgeNotReadyError, i as parseResponseError, n as isTransientWrite, o as responseMetadata, r as parseErrorResponse, s as retryWhen, t as TerminalStreamError, u as CapabilityError, v as NotFoundError, w as ServerError, y as PartialFailureError } from "./errors-BY7a-Hpw.js";
7
- import { t as parseSandboxRetryAfterHeader } from "./retry-after-header-BZbs5rig.js";
6
+ import { C as SandboxError, D as TimeoutError, E as StreamInterruptedError, O as ValidationError, T as StateError, _ as NetworkError, a as readResponseJson, b as ProfileFileMountPathError, c as AuthError, f as EdgeNotReadyError, i as parseResponseError, n as isTransientWrite, o as responseMetadata, r as parseErrorResponse, s as retryWhen, t as TerminalStreamError, u as CapabilityError, v as NotFoundError, w as ServerError, y as PartialFailureError } from "./errors-DVjaZqJT.js";
7
+ import { n as plannedRestartDeadline, r as SIDECAR_PROXY_ERROR_HEADER, t as parseSandboxRetryAfterHeader } from "./retry-after-header-DyAWSQ4m.js";
8
8
  import { n as combineAbortSignals, t as awaitWithAbort } from "./abort-signal-BsriwJ8L.js";
9
9
  import { a as backoffDelayMs, o as isUndelivered, r as abortableSleep } from "./retry-policy-oW3_ljoc.js";
10
- import { a as isReplayableBody, i as fetchSandboxApi, n as SDK_TIMEOUTS, o as rewrapResponse, t as IDEMPOTENT_METHODS } from "./api-request-DfzqU66n.js";
10
+ import { a as isReplayableBody, i as fetchSandboxApi, n as SDK_TIMEOUTS, o as rewrapResponse, t as IDEMPOTENT_METHODS } from "./api-request-BSleTpab.js";
11
11
  import { a as SANDBOX_PROXY_REQUEST_MAX_BYTES, c as PROFILE_FILE_MOUNT_OUTSIDE_ROOTS_CODE, d as isProfileFileMountOutsideRoots, f as profileFileMountOutsideRootsMessage, l as SANDBOX_AGENT_HOME, o as FILE_OPERATION_LIMITS, t as isInsideReservedDir$1, u as SANDBOX_FILE_API_ABSOLUTE_ROOTS } from "./file-transfer-DOSTbUSR.js";
12
- import { c as uploadChunked, l as awaitSdkResend, u as takeSdkTurn } from "./chunked-upload-C44d_Ao7.js";
13
- import { i as resolveTraceId, n as isTraceId, r as mintTraceId, t as TRACE_ID_HEADER } from "./trace-id-BTa6Db_2.js";
14
- import { n as fetchWithKeepAlive, t as emitTiming } from "./keep-alive-fetch-BQJJVjzW.js";
15
- import { t as SIDECAR_PROXY_ERROR_HEADER } from "./sidecar-proxy-error-DVVfeGIP.js";
16
- import { t as parseSSEStream } from "./sse-parser-DTgSRcZC.js";
17
- import { t as runPreparedProcess } from "./prepared-process-CD-MjClN.js";
18
- import { a as isBackendType, r as cliAuthReferenceSchema } from "./cli-auth-bundle-B8bx652V-hMsdeLuq.js";
19
- import "./cli-auth-bundle-BtGqWSts.js";
20
- import { n as SandboxLines } from "./lines-BWUWIrxa.js";
21
- import { t as downloadFile } from "./file-download-HPsIahnf.js";
12
+ import { c as uploadChunked, l as awaitSdkResend, u as takeSdkTurn } from "./chunked-upload-C84EiOec.js";
13
+ import { i as resolveTraceId, n as isTraceId, r as mintTraceId, t as TRACE_ID_HEADER } from "./trace-id-BwKjBM-q.js";
14
+ import { n as fetchWithKeepAlive, t as emitTiming } from "./keep-alive-fetch-D76rml5I.js";
15
+ import { t as parseSSEStream } from "./sse-parser-BCG3iL9j.js";
16
+ import { t as runPreparedProcess } from "./prepared-process-B4DuLmEg.js";
17
+ import { a as isBackendType, r as cliAuthReferenceSchema } from "./cli-auth-bundle-z1X_k0lF-CHfKGrQ-.js";
18
+ import "./cli-auth-bundle-BZRV0Sjw.js";
19
+ import { n as SandboxLines } from "./lines-N7p7PrZ1.js";
20
+ import { t as downloadFile } from "./file-download-C6BO_rTp.js";
22
21
  import { z } from "zod";
23
22
  import { createHash } from "node:crypto";
24
23
  import { constants } from "node:fs";
@@ -3035,7 +3034,7 @@ var DirectRuntimeHttpClient = class {
3035
3034
  const connection = this.getConnection();
3036
3035
  const origin = connection?.authToken ? connection.hostUrl : void 0;
3037
3036
  if (!origin || !canUseNodeHttp2()) return;
3038
- import("./direct-http2-DJYOowWN.js").then(({ preconnectDirectHttp2 }) => preconnectDirectHttp2(origin)).catch(() => {});
3037
+ import("./direct-http2-DiJOMM8k.js").then(({ preconnectDirectHttp2 }) => preconnectDirectHttp2(origin)).catch(() => {});
3039
3038
  }
3040
3039
  async fetch(path, options, fetchOptions) {
3041
3040
  const throughApi = () => this.baseClient.fetch(path, options, fetchOptions);
@@ -3096,9 +3095,12 @@ var DirectRuntimeHttpClient = class {
3096
3095
  if (route?.bearer) headers.set("Authorization", `Bearer ${route.bearer}`);
3097
3096
  };
3098
3097
  authenticate();
3098
+ const selectApiForRetry = () => {
3099
+ this.edgeCooldownUntil = Date.now() + EDGE_COOLDOWN_MS;
3100
+ return fetchOptions?.attempts !== 1;
3101
+ };
3099
3102
  const resendThroughApi = async (refused) => {
3100
3103
  await refused?.body?.cancel().catch(() => {});
3101
- this.edgeCooldownUntil = Date.now() + EDGE_COOLDOWN_MS;
3102
3104
  return throughApi();
3103
3105
  };
3104
3106
  const init = {
@@ -3117,7 +3119,7 @@ var DirectRuntimeHttpClient = class {
3117
3119
  };
3118
3120
  const observe = this.onDirectRuntimeResponse;
3119
3121
  if (!route) throw new NetworkError("Direct runtime route was withdrawn");
3120
- const { fetchDirectHttp2: transport } = (route.useHost || route.useExec) && canUseNodeHttp2() ? await import("./direct-http2-DJYOowWN.js") : { fetchDirectHttp2: fetchWithKeepAlive };
3122
+ const { fetchDirectHttp2: transport } = (route.useHost || route.useExec) && canUseNodeHttp2() ? await import("./direct-http2-DiJOMM8k.js") : { fetchDirectHttp2: fetchWithKeepAlive };
3121
3123
  return fetchSandboxApi({
3122
3124
  baseUrl: route.origin,
3123
3125
  timeoutMs: this.baseClient.timeoutMs,
@@ -3149,14 +3151,14 @@ var DirectRuntimeHttpClient = class {
3149
3151
  } : (url, init) => transport(url, init, timing)
3150
3152
  }, route.path, request, {
3151
3153
  ...fetchOptions,
3152
- attempts: canResendThroughApi ? 1 : void 0
3154
+ attempts: canResendThroughApi ? 1 : fetchOptions?.attempts
3153
3155
  });
3154
3156
  };
3155
3157
  const sendOrResend = async (request) => {
3156
3158
  try {
3157
3159
  return { sent: await send(request) };
3158
3160
  } catch (error) {
3159
- if (canResendThroughApi && !init.signal?.aborted && !(error instanceof TimeoutError) && !headers.has("x-no-retry") && (replaySafe || isUndelivered(error))) return { resent: await resendThroughApi() };
3161
+ if (canResendThroughApi && !init.signal?.aborted && !(error instanceof TimeoutError) && !headers.has("x-no-retry") && (replaySafe || isUndelivered(error)) && selectApiForRetry()) return { resent: await resendThroughApi() };
3160
3162
  throw error;
3161
3163
  }
3162
3164
  };
@@ -3188,7 +3190,7 @@ var DirectRuntimeHttpClient = class {
3188
3190
  }
3189
3191
  if (canResendThroughApi && !headers.has("x-no-retry")) {
3190
3192
  const verdict = await edgeVerdict(response);
3191
- if (verdict === "undelivered" || verdict === "unknown" && replaySafe && (await parseResponseError(response.clone())).retryable) return resendThroughApi(response);
3193
+ if ((verdict === "undelivered" || verdict === "unknown" && replaySafe && (await parseResponseError(response.clone())).retryable) && selectApiForRetry()) return resendThroughApi(response);
3192
3194
  }
3193
3195
  if (this.onUnreachable && await isRuntimeUnreachable(response)) await this.onUnreachable();
3194
3196
  const responseHeaders = new Headers(response.headers);
@@ -10575,7 +10577,8 @@ var ProfileFileMountExecTimeoutError = class extends Error {
10575
10577
  this.name = "ProfileFileMountExecTimeoutError";
10576
10578
  }
10577
10579
  };
10578
- function execWithTimeout(box, cmd, timeoutMs) {
10580
+ function execWithTimeout(box, cmd, timeoutMs, signal) {
10581
+ signal?.throwIfAborted();
10579
10582
  return new Promise((resolve, reject) => {
10580
10583
  let settled = false;
10581
10584
  const timer = setTimeout(() => {
@@ -10583,7 +10586,10 @@ function execWithTimeout(box, cmd, timeoutMs) {
10583
10586
  settled = true;
10584
10587
  reject(new ProfileFileMountExecTimeoutError(timeoutMs));
10585
10588
  }, timeoutMs);
10586
- box.exec(cmd, { timeoutMs }).then((res) => {
10589
+ box.exec(cmd, {
10590
+ timeoutMs,
10591
+ signal
10592
+ }).then((res) => {
10587
10593
  if (settled) return;
10588
10594
  settled = true;
10589
10595
  clearTimeout(timer);
@@ -10723,24 +10729,31 @@ function isRetryableProfileFileMaterializeFailure(err) {
10723
10729
  return !decided;
10724
10730
  }
10725
10731
  /**
10726
- * Run one file API batch write, sending it again after an undecided answer.
10727
- *
10728
- * Only a batch without write preconditions comes here, so a repeat after a
10729
- * write that did land leaves the same files with the same content and mode.
10730
- * A decided refusal is thrown at once. Retries stop at `maxRetries`, or when
10731
- * the next attempt would start past {@link PROFILE_FILE_MOUNT_WRITE_RETRY_BUDGET_MS}.
10732
+ * One resend budget for an unconditional profile batch. The host's attestation
10733
+ * permits a resend after a long hold. A write whose outcome is unknown gets
10734
+ * only the ordinary short window. Neither kind renews a prior deadline.
10732
10735
  */
10733
- async function writeBatchRidingOutUndecided(write, maxRetries) {
10734
- const startedAt = Date.now();
10735
- for (let attempt = 0;; attempt += 1) try {
10736
- await write();
10737
- return;
10738
- } catch (err) {
10739
- if (!(retryWhen(err) && (err instanceof NetworkError || err.status >= 502 && !(err instanceof TimeoutError))) || attempt >= maxRetries || !await awaitSdkResend(attempt + 1, {
10740
- retryAfterMs: retryAfterMs(err),
10741
- deadlineAt: startedAt + PROFILE_FILE_MOUNT_WRITE_RETRY_BUDGET_MS,
10742
- capMs: 2e3
10743
- })) throw err;
10736
+ async function writeProfileFileBatch(sendOnce, maxRetries, signal, deadlineAt = Number.POSITIVE_INFINITY) {
10737
+ const undecidedUntil = Date.now() + PROFILE_FILE_MOUNT_WRITE_RETRY_BUDGET_MS;
10738
+ let restartUntil = deadlineAt;
10739
+ for (let attempt = 0;; attempt++) {
10740
+ signal?.throwIfAborted();
10741
+ try {
10742
+ await sendOnce();
10743
+ return;
10744
+ } catch (err) {
10745
+ signal?.throwIfAborted();
10746
+ if (!retryWhen(err) || attempt >= maxRetries) throw err;
10747
+ const restart = err.retryUntil;
10748
+ if (restart !== void 0) restartUntil = Math.min(restartUntil, restart);
10749
+ else if (!(err instanceof NetworkError) && (err.status < 502 || err.status > 504 || err instanceof TimeoutError)) throw err;
10750
+ if (!await awaitSdkResend(attempt + 1, {
10751
+ retryAfterMs: err.retryAfterMs ?? (restart === void 0 ? void 0 : 1e3),
10752
+ deadlineAt: restart === void 0 ? Math.min(undecidedUntil, restartUntil) : restartUntil,
10753
+ signal,
10754
+ capMs: 2e3
10755
+ })) throw err;
10756
+ }
10744
10757
  }
10745
10758
  }
10746
10759
  //#endregion
@@ -10948,16 +10961,17 @@ async function execProfileFileMount(box, mount, content, options, execState) {
10948
10961
  const homeGuard = path.startsWith("~/") ? `[ -n "$HOME" ] || { echo ${shellSingleQuote(`materializeProfileFileMounts: HOME is unset for ${path}`)} >&2; exit 1; }; ` : "";
10949
10962
  const run = async (cmd) => {
10950
10963
  for (let attempt = 0;; attempt++) {
10951
- if (execState.started && options.paceMs > 0) await abortableSleep(options.paceMs);
10964
+ if (execState.started && options.paceMs > 0) await abortableSleep(options.paceMs, options.signal);
10952
10965
  execState.started = true;
10953
10966
  try {
10954
- return await execWithTimeout(box, cmd, options.execTimeoutMs);
10967
+ return await execWithTimeout(box, cmd, options.execTimeoutMs, options.signal);
10955
10968
  } catch (err) {
10956
10969
  const { retryable, retryAfterMs: retryAfter } = transientExecError(err);
10957
10970
  const capMs = PROFILE_FILE_MOUNT_RETRY_MAX_MS;
10958
10971
  if (retryable && attempt < maxRetries && await awaitSdkResend(attempt + 1, {
10959
10972
  retryAfterMs: retryAfter === void 0 ? void 0 : Math.min(retryAfter, capMs),
10960
- capMs
10973
+ capMs,
10974
+ signal: options.signal
10961
10975
  })) continue;
10962
10976
  throw new ProfileFileMaterializeError(`materializeProfileFileMounts: exec failed for ${path}`, { cause: err });
10963
10977
  }
@@ -11012,7 +11026,8 @@ async function materializeProfileFileMounts(box, files, options = {}) {
11012
11026
  upload: () => uploadDataFn(target, content, {
11013
11027
  ...mode !== void 0 ? { mode } : {},
11014
11028
  paceMs,
11015
- maxRetries
11029
+ maxRetries,
11030
+ signal: options.signal
11016
11031
  })
11017
11032
  });
11018
11033
  continue;
@@ -11032,12 +11047,16 @@ async function materializeProfileFileMounts(box, files, options = {}) {
11032
11047
  content
11033
11048
  });
11034
11049
  }
11050
+ const writeBatch = (files) => writeProfileFileBatch(async () => fs?.writeMany(files, {
11051
+ paceMs,
11052
+ maxRetries: 0,
11053
+ signal: options.signal,
11054
+ deadlineAt: options.deadlineAt
11055
+ }), maxRetries, options.signal, options.deadlineAt);
11035
11056
  if (viaFileApi.length > 0) try {
11036
- await writeBatchRidingOutUndecided(async () => fs?.writeMany(viaFileApi, {
11037
- paceMs,
11038
- maxRetries
11039
- }), maxRetries);
11057
+ await writeBatch(viaFileApi);
11040
11058
  } catch (err) {
11059
+ if (err instanceof SandboxError && err.retryUntil !== void 0) throw err;
11041
11060
  throw new ProfileFileMaterializeError("materializeProfileFileMounts: file API batch write failed", { cause: err });
11042
11061
  }
11043
11062
  let homeFilesWrittenByApi = 0;
@@ -11048,12 +11067,10 @@ async function materializeProfileFileMounts(box, files, options = {}) {
11048
11067
  ...mode !== void 0 ? { mode } : {}
11049
11068
  }));
11050
11069
  try {
11051
- await writeBatchRidingOutUndecided(async () => fs?.writeMany(homeWrites, {
11052
- paceMs,
11053
- maxRetries
11054
- }), maxRetries);
11070
+ await writeBatch(homeWrites);
11055
11071
  homeFilesWrittenByApi = viaHomeFileApi.length;
11056
11072
  } catch (err) {
11073
+ if (err instanceof SandboxError && err.retryUntil !== void 0) throw err;
11057
11074
  if (!isFileApiRootOnlyError(err)) throw new ProfileFileMaterializeError("materializeProfileFileMounts: home file API batch write failed", { cause: err });
11058
11075
  viaExec.push(...viaHomeFileApi.map(({ mount, content }) => ({
11059
11076
  mount,
@@ -11070,7 +11087,8 @@ async function materializeProfileFileMounts(box, files, options = {}) {
11070
11087
  for (const item of viaExec) await execProfileFileMount(box, item.mount, item.content, {
11071
11088
  execTimeoutMs,
11072
11089
  paceMs,
11073
- maxRetries
11090
+ maxRetries,
11091
+ signal: options.signal
11074
11092
  }, execState);
11075
11093
  return {
11076
11094
  written: viaFileApi.length + homeFilesWrittenByApi + viaExec.length + viaUpload.length,
@@ -11187,10 +11205,10 @@ async function materializeAbsentProfileFiles(box, files, options) {
11187
11205
  existingFiles: "replace"
11188
11206
  });
11189
11207
  } catch (error) {
11190
- await execWithTimeout(box, `rm -rf -- ${shellSingleQuote(stage)}`, options.execTimeoutMs ?? PROFILE_FILE_MOUNT_EXEC_TIMEOUT_MS).catch(() => void 0);
11208
+ await execWithTimeout(box, `rm -rf -- ${shellSingleQuote(stage)}`, options.execTimeoutMs ?? PROFILE_FILE_MOUNT_EXEC_TIMEOUT_MS, options.signal).catch(() => void 0);
11191
11209
  throw error;
11192
11210
  }
11193
- const applied = await execWithTimeout(box, `node -e ${shellSingleQuote(APPLY_STAGED_PROFILE_FILES)} ${shellSingleQuote(stage)}`, options.execTimeoutMs ?? PROFILE_FILE_MOUNT_EXEC_TIMEOUT_MS);
11211
+ const applied = await execWithTimeout(box, `node -e ${shellSingleQuote(APPLY_STAGED_PROFILE_FILES)} ${shellSingleQuote(stage)}`, options.execTimeoutMs ?? PROFILE_FILE_MOUNT_EXEC_TIMEOUT_MS, options.signal);
11194
11212
  if (applied.exitCode !== 0) {
11195
11213
  const stderr = applied.stderr.slice(0, 1500);
11196
11214
  const conflict = /^PROFILE_FILE_CONFLICT (.+)$/m.exec(stderr)?.[1];
@@ -11259,7 +11277,7 @@ var ProfileFileDelivery = class {
11259
11277
  /** The most recent successful preparation with file mounts; undefined until one. */
11260
11278
  lastReport;
11261
11279
  pending = Promise.resolve();
11262
- prepare(box, profile, signal, existingFiles = "allow-identical") {
11280
+ prepare(box, profile, signal, existingFiles = "allow-identical", deadlineAt) {
11263
11281
  const split = splitInlineProfileFileMounts(structuredClone(profile));
11264
11282
  const { leanProfile } = split;
11265
11283
  const deferredFiles = validateDeferredProfileFileMounts(split.deferredFiles, { failOnError: profile.resources?.failOnError !== false });
@@ -11275,7 +11293,10 @@ var ProfileFileDelivery = class {
11275
11293
  const incarnation = box.filesystemIncarnationId;
11276
11294
  if (incarnation === void 0 || this.delivered?.incarnation !== incarnation || this.delivered.fingerprint !== bundle) {
11277
11295
  this.delivered = void 0;
11278
- delivery = await this.deliverProfileFiles(box, deferredFiles, bundle, existingFiles);
11296
+ delivery = await this.deliverProfileFiles(box, deferredFiles, bundle, existingFiles, {
11297
+ signal,
11298
+ deadlineAt
11299
+ });
11279
11300
  if (box.filesystemIncarnationId !== incarnation) throw new StateError("Filesystem incarnation changed during profile file delivery", {
11280
11301
  currentState: box.filesystemIncarnationId ?? "unknown",
11281
11302
  requiredState: incarnation ?? "unknown"
@@ -11296,15 +11317,24 @@ var ProfileFileDelivery = class {
11296
11317
  this.pending = prepared.then(() => {}, () => {});
11297
11318
  return prepared;
11298
11319
  }
11299
- async deliverProfileFiles(box, deferredFiles, bundle, existingFiles) {
11320
+ async deliverProfileFiles(box, deferredFiles, bundle, existingFiles, timing) {
11300
11321
  const claim = existingFiles === "replace" ? await this.claimProfileBundle(box, deferredFiles, bundle) : { kind: "direct" };
11301
11322
  const remaining = claim.kind === "direct" ? deferredFiles : deferredFiles.filter((mount) => claim.missing.has(mount.path));
11302
11323
  const manifest = buildPublishManifest(box, deferredFiles, bundle);
11303
11324
  const records = profileFileMountRecords(manifest.files);
11304
- if (existingFiles === "replace") await materializeProfileFileMounts(box, [...remaining, ...records], { existingFiles });
11325
+ if (existingFiles === "replace") await materializeProfileFileMounts(box, [...remaining, ...records], {
11326
+ ...timing,
11327
+ existingFiles
11328
+ });
11305
11329
  else {
11306
- if (remaining.length > 0) await materializeProfileFileMounts(box, remaining, { existingFiles });
11307
- await materializeProfileFileMounts(box, records, { existingFiles: "replace" });
11330
+ if (remaining.length > 0) await materializeProfileFileMounts(box, remaining, {
11331
+ ...timing,
11332
+ existingFiles
11333
+ });
11334
+ await materializeProfileFileMounts(box, records, {
11335
+ ...timing,
11336
+ existingFiles: "replace"
11337
+ });
11308
11338
  }
11309
11339
  if (claim.kind === "direct") return {
11310
11340
  outcome: "direct",
@@ -13967,7 +13997,7 @@ var SandboxExecCapabilities = class extends SandboxCodeOperations {
13967
13997
  //#region src/generated/sandbox-file-operations.ts
13968
13998
  var SandboxFileOperations = class extends SandboxExecCapabilities {
13969
13999
  async write(path, content, options) {
13970
- await this.ensureRunning();
14000
+ await this.ensureRunning(options?.signal);
13971
14001
  return this.writeFileRequest(path, content, options);
13972
14002
  }
13973
14003
  async writeFileRequest(path, content, options) {
@@ -13977,6 +14007,7 @@ var SandboxFileOperations = class extends SandboxExecCapabilities {
13977
14007
  const data = await readResponseJson(await this.runtimeFetch("/files/write" + (query ? "?" + query : ""), {
13978
14008
  method: "POST",
13979
14009
  headers: callHeaders({ traceId: options?.traceId }),
14010
+ signal: options?.signal,
13980
14011
  body: JSON.stringify({
13981
14012
  path,
13982
14013
  content,
@@ -14030,10 +14061,16 @@ var SandboxFileWriteCapabilities = class extends SandboxFileOperations {
14030
14061
  assertWritePreconditions(result, requested) {
14031
14062
  assertFileWritePreconditions(result, requested);
14032
14063
  }
14033
- async writeBatchRequest(files, body) {
14064
+ async writeBatchRequest(files, body, options) {
14065
+ const remainingMs = options.deadlineAt === void 0 ? void 0 : options.deadlineAt - Date.now();
14066
+ if (remainingMs !== void 0 && remainingMs <= 0) throw new TimeoutError("File batch deadline elapsed");
14034
14067
  const response = await this.runtimeFetch("/files/write-batch", {
14035
14068
  method: "POST",
14036
- body
14069
+ body,
14070
+ signal: options.signal
14071
+ }, {
14072
+ timeoutMs: remainingMs,
14073
+ attempts: options.maxRetries === void 0 ? void 0 : options.maxRetries + 1
14037
14074
  });
14038
14075
  if (!response.ok) {
14039
14076
  const errorBody = await response.text();
@@ -14070,13 +14107,15 @@ var SandboxFileWriteCapabilities = class extends SandboxFileOperations {
14070
14107
  });
14071
14108
  }
14072
14109
  }
14073
- async writeManySequential(files, paceMs, maxRetries) {
14110
+ async writeManySequential(files, paceMs, maxRetries, signal) {
14074
14111
  let started = false;
14075
14112
  for (const file of files) for (let attempt = 0;; attempt++) {
14076
- if (started && paceMs > 0) await abortableSleep(paceMs);
14113
+ signal?.throwIfAborted();
14114
+ if (started && paceMs > 0) await abortableSleep(paceMs, signal);
14077
14115
  started = true;
14078
14116
  try {
14079
14117
  await this.writeFileRequest(file.path, file.content, {
14118
+ signal,
14080
14119
  mode: file.mode,
14081
14120
  encoding: file.encoding,
14082
14121
  ifHash: file.ifHash,
@@ -14086,7 +14125,8 @@ var SandboxFileWriteCapabilities = class extends SandboxFileOperations {
14086
14125
  } catch (err) {
14087
14126
  if (isTransientWrite(err) && attempt < maxRetries && await awaitSdkResend(attempt + 1, {
14088
14127
  retryAfterMs: err instanceof SandboxError ? err.retryAfterMs : void 0,
14089
- capMs: WRITE_MANY_RETRY_MAX_MS
14128
+ capMs: WRITE_MANY_RETRY_MAX_MS,
14129
+ signal
14090
14130
  })) continue;
14091
14131
  throw err;
14092
14132
  }
@@ -14100,15 +14140,22 @@ var SandboxFileWriteCapabilities = class extends SandboxFileOperations {
14100
14140
  if (files.length === 0) return;
14101
14141
  const paceMs = options.paceMs ?? WRITE_MANY_DEFAULT_PACE_MS;
14102
14142
  const maxRetries = options.maxRetries ?? WRITE_MANY_DEFAULT_MAX_RETRIES;
14103
- await this.ensureRunning();
14143
+ const remainingMs = options.deadlineAt === void 0 ? void 0 : options.deadlineAt - Date.now();
14144
+ if (remainingMs !== void 0 && (!Number.isFinite(remainingMs) || remainingMs <= 0)) throw new TimeoutError("File batch deadline elapsed");
14145
+ const timeout = remainingMs === void 0 ? void 0 : AbortSignal.timeout(Math.min(Math.ceil(remainingMs), 2147483647));
14146
+ const signal = timeout && options.signal ? AbortSignal.any([options.signal, timeout]) : timeout ?? options.signal;
14147
+ await this.ensureRunning(signal);
14104
14148
  if (hasDuplicateWriteManyPaths(files)) {
14105
- await this.writeManySequential(files, paceMs, maxRetries);
14149
+ await this.writeManySequential(files, paceMs, maxRetries, signal);
14106
14150
  return;
14107
14151
  }
14108
14152
  const batches = splitWriteManyBatches(files.map(toWriteManyWireFile));
14109
14153
  for (const [index, batch] of batches.entries()) {
14110
- if (index > 0 && paceMs > 0) await abortableSleep(paceMs);
14111
- await this.writeBatchRequest(batch.files, batch.body);
14154
+ if (index > 0 && paceMs > 0) await abortableSleep(paceMs, signal);
14155
+ await this.writeBatchRequest(batch.files, batch.body, {
14156
+ ...options,
14157
+ signal
14158
+ });
14112
14159
  }
14113
14160
  }
14114
14161
  /**
@@ -14290,8 +14337,8 @@ var SandboxProfileCapabilities = class extends SandboxFileWriteCapabilities {
14290
14337
  return state(this).profileFiles.lastReport;
14291
14338
  }
14292
14339
  /** @internal Create/turn delivery; skipped while this incarnation holds the bundle's receipt, even for "replace". Remount with materializeProfileFileMounts. */
14293
- materializeProfileFiles(profile, signal, existingFiles = "allow-identical") {
14294
- return state(this).profileFiles.prepare(this, profile, signal, existingFiles);
14340
+ materializeProfileFiles(profile, signal, existingFiles = "allow-identical", deadlineAt) {
14341
+ return state(this).profileFiles.prepare(this, profile, signal, existingFiles, deadlineAt);
14295
14342
  }
14296
14343
  /**
14297
14344
  * @internal What create()'s lean POST left out. The handle's first runtime
@@ -14341,7 +14388,7 @@ var SandboxProfileCapabilities = class extends SandboxFileWriteCapabilities {
14341
14388
  console.warn(`[sandbox.create] Profile priming failed for ${this.id}; turns will send the full profile inline. Cause: ${err instanceof Error ? err.message : String(err)}`);
14342
14389
  }
14343
14390
  }
14344
- async buildRunBackendBody(overrideBackend, forceFullProfile, requestedModel, signal, preserveManagedProfile = false) {
14391
+ async buildRunBackendBody(overrideBackend, forceFullProfile, requestedModel, signal, preserveManagedProfile = false, deadlineAt) {
14345
14392
  const backend = mergeRuntimeBackendConfig(state(this).defaultRuntimeBackend, applyRequestedModel(overrideBackend, requestedModel));
14346
14393
  let normalized = normalizeRuntimeBackendConfig(backend, { allowRuntimeSecrets: true });
14347
14394
  if (!normalized) return normalized;
@@ -14357,7 +14404,7 @@ var SandboxProfileCapabilities = class extends SandboxFileWriteCapabilities {
14357
14404
  if (backend?.profile !== void 0 && !preserveManagedProfile) try {
14358
14405
  normalized = {
14359
14406
  ...normalized,
14360
- profile: await this.materializeProfileFiles(backend.profile, signal)
14407
+ profile: await this.materializeProfileFiles(backend.profile, signal, "allow-identical", deadlineAt)
14361
14408
  };
14362
14409
  } catch (error) {
14363
14410
  if (signal?.aborted || backend.profile.resources?.failOnError !== false) throw error;
@@ -15046,11 +15093,11 @@ var SandboxSessionAdmissionCapabilities = class extends SandboxProfileCapabiliti
15046
15093
  };
15047
15094
  //#endregion
15048
15095
  //#region src/sandbox-prompt-transport.ts
15049
- /** Ms to wait before resending past a restart 503 whose `retryUntil` is still ahead of the server's `Date`; undefined otherwise. */
15050
- async function restartWaitMs(response) {
15051
- const body = response.status === 503 ? await response.clone().json().catch(() => null) : null;
15052
- const sentAt = Date.parse(response.headers.get("date") ?? "") || Date.now();
15053
- return body?.code === "HOST_AGENT_RESTARTING" && (body.retryUntil ?? 0) > sentAt ? parseSandboxRetryAfterHeader(response.headers.get("retry-after")) ?? 1e3 : void 0;
15096
+ /** Only a host-confirmed restart can extend ordinary dispatch retries. */
15097
+ async function promptRestartDeadline(response) {
15098
+ if (response.status !== 503) return void 0;
15099
+ const body = await response.clone().json().catch(() => null);
15100
+ return plannedRestartDeadline(response.status, response.headers, body);
15054
15101
  }
15055
15102
  function validatePromptDispatchOptions(sandboxId, options) {
15056
15103
  if (options?.nativeResume !== void 0) {
@@ -15101,17 +15148,19 @@ var SandboxPromptTransportCapabilities = class extends SandboxSessionAdmissionCa
15101
15148
  [PART_TEXT]: PART_TEXT_SUFFIX
15102
15149
  });
15103
15150
  appendSessionIdQuery(replaySearch, internal?.replaySessionId);
15151
+ const requestEndpoint = explicitReplay ? `/agents/run/${encodeURIComponent(options?.executionId ?? "")}/events?${replaySearch}` : `/agents/run/stream?${PART_TEXT}=${PART_TEXT_SUFFIX}`;
15104
15152
  const state = {
15105
15153
  options,
15106
15154
  internal,
15107
15155
  runControlRef,
15108
15156
  ttlMs,
15109
15157
  timeoutMs,
15158
+ deadlineAt: timeoutMs === void 0 ? void 0 : Date.now() + timeoutMs,
15110
15159
  streamSignal,
15111
15160
  throwIfTimedOut,
15112
15161
  reconcileRuntimeRefusal,
15113
15162
  explicitReplay,
15114
- requestEndpoint: explicitReplay ? `/agents/run/${encodeURIComponent(options?.executionId ?? "")}/events?${replaySearch}` : `/agents/run/stream?${PART_TEXT}=${PART_TEXT_SUFFIX}`,
15163
+ requestEndpoint,
15115
15164
  traceHeaders: options?.traceId ? { [TRACE_ID_HEADER]: options.traceId } : {},
15116
15165
  lastEventId: options?.lastEventId,
15117
15166
  executionId: options?.executionId ?? `exec-${crypto.randomUUID()}`,
@@ -15179,14 +15228,18 @@ var SandboxPromptTransportCapabilities = class extends SandboxSessionAdmissionCa
15179
15228
  ...state.options?.expectedPublicProfileRequestDigest ? { expectedPublicProfileRequestDigest: state.options.expectedPublicProfileRequestDigest } : {},
15180
15229
  ...state.options?.expectedPublicProfileRevision !== void 0 ? { expectedPublicProfileRevision: state.options.expectedPublicProfileRevision } : {},
15181
15230
  ...state.options?.expectedSecretProfileReceipt ? { expectedSecretProfileReceipt: state.options.expectedSecretProfileReceipt } : {},
15182
- backend: await this.buildRunBackendBody(state.options?.backend, state.internal?.forceFullProfile ?? false, state.options?.model, state.streamSignal, state.options?.expectedPublicProfileRequestDigest !== void 0)
15231
+ backend: await this.buildRunBackendBody(state.options?.backend, state.internal?.forceFullProfile ?? false, state.options?.model, state.streamSignal, state.options?.expectedPublicProfileRequestDigest !== void 0, state.deadlineAt)
15183
15232
  })
15184
15233
  };
15185
15234
  if (typeof request.body === "string" && new TextEncoder().encode(request.body).byteLength > 1048576) throw new ValidationError("Agent run request exceeds the gateway request bound; place large content in resources.files");
15235
+ let restartDeadline = state.deadlineAt ?? Number.POSITIVE_INFINITY;
15186
15236
  for (;;) {
15187
15237
  response = await this.runtimeFetch(state.requestEndpoint, request, state.internal?.forceFullProfile ? { skipProfileReference: true } : void 0);
15188
- const waitMs = state.explicitReplay ? void 0 : await restartWaitMs(response);
15189
- if (waitMs === void 0) break;
15238
+ const restart = state.explicitReplay ? void 0 : await promptRestartDeadline(response);
15239
+ if (restart === void 0) break;
15240
+ restartDeadline = Math.min(restartDeadline, restart);
15241
+ const waitMs = parseSandboxRetryAfterHeader(response.headers.get("retry-after")) ?? 1e3;
15242
+ if (Date.now() + waitMs >= restartDeadline) break;
15190
15243
  await response.body?.cancel();
15191
15244
  await abortableSleep(waitMs, state.streamSignal);
15192
15245
  }
@@ -15776,7 +15829,7 @@ var SandboxInteractiveCapabilities = class extends SandboxPromptCapabilities {
15776
15829
  var SandboxSessionEvidenceCapabilities = class extends SandboxInteractiveCapabilities {
15777
15830
  /** @internal — invoked before the sandbox is deleted. */
15778
15831
  async _sessionExportRawEvidence(id, destination, options) {
15779
- const { exportRawEvidenceDirectory } = await import("./raw-evidence-archive-C7eYWtMG.js");
15832
+ const { exportRawEvidenceDirectory } = await import("./raw-evidence-archive-B7_0tFYq.js");
15780
15833
  await this.ensureRunning();
15781
15834
  await this.refresh();
15782
15835
  return exportRawEvidenceDirectory((signal, archiveId, cancel) => this.runtimeFetch(`/agents/sessions/${encodeURIComponent(id)}/raw-evidence/archive?${new URLSearchParams([
@@ -15807,7 +15860,7 @@ var SandboxSessionEvidenceCapabilities = class extends SandboxInteractiveCapabil
15807
15860
  * and the byte and file bounds are verified before the directory appears.
15808
15861
  */
15809
15862
  async exportRawEvidence(destination, options) {
15810
- const { exportRawEvidenceDirectory } = await import("./raw-evidence-archive-C7eYWtMG.js");
15863
+ const { exportRawEvidenceDirectory } = await import("./raw-evidence-archive-B7_0tFYq.js");
15811
15864
  await this.ensureRunning();
15812
15865
  await this.refresh();
15813
15866
  return exportRawEvidenceDirectory((signal, archiveId, cancel) => this.runtimeFetch(`/agents/raw-evidence/archive?${new URLSearchParams({
@@ -17921,7 +17974,7 @@ var SandboxFilesystemOperations = class extends DeclaredFilesystemOperations {
17921
17974
  totalBytes: size,
17922
17975
  percentage: 0
17923
17976
  });
17924
- const { uploadChunkedFromFile } = await import("./chunked-upload-file-qXxstMmc.js");
17977
+ const { uploadChunkedFromFile } = await import("./chunked-upload-file-CtoNGE4S.js");
17925
17978
  await uploadChunkedFromFile({ fetch: (path, init) => this.host.runtimeFetch(path, init) }, remotePath, localPath, {
17926
17979
  mode: options?.permissions,
17927
17980
  onProgress: options?.onProgress ? (progress) => {
@@ -1,4 +1,4 @@
1
- import { a as anumber, c as concatBytes$1, f as randomBytes, h as toBytes, i as ahash, l as createHasher$1, n as abytes$1, o as aoutput, p as rotr, r as aexists, s as clean, t as Hash, u as createView, x as split } from "./utils-fYi8g-M-.js";
1
+ import { a as anumber, c as concatBytes$1, f as randomBytes, h as toBytes, i as ahash, l as createHasher$1, n as abytes$1, o as aoutput, p as rotr, r as aexists, s as clean, t as Hash, u as createView, x as split } from "./utils-BvN0Mk3j.js";
2
2
  //#region ../../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/_md.js
3
3
  /**
4
4
  * Internal Merkle-Damgard hash utils.
@@ -1,9 +1,9 @@
1
1
  import { r as agentProfileSchema } from "./profile-schema-BHeC7cOf.js";
2
2
  import { t as canonicalAgentProfileDigest } from "./agent-execution-preparation-B8PJuIsN.js";
3
- import { C as SandboxError, O as ValidationError, u as CapabilityError } from "./errors-BY7a-Hpw.js";
3
+ import { C as SandboxError, O as ValidationError, u as CapabilityError } from "./errors-DVjaZqJT.js";
4
4
  import { n as combineAbortSignals, t as awaitWithAbort } from "./abort-signal-BsriwJ8L.js";
5
- import { r as cliAuthReferenceSchema } from "./cli-auth-bundle-B8bx652V-hMsdeLuq.js";
6
- import "./cli-auth-bundle-BtGqWSts.js";
5
+ import { r as cliAuthReferenceSchema } from "./cli-auth-bundle-z1X_k0lF-CHfKGrQ-.js";
6
+ import "./cli-auth-bundle-BZRV0Sjw.js";
7
7
  import { z } from "zod";
8
8
  //#region ../../../packages/runtime-contracts/dist/seat-selection.js
9
9
  /**
@@ -1,5 +1,5 @@
1
- import { R as SandboxError } from "./terminal-stream-types-BItnV5cg.js";
2
- import { _t as SeatOwnerTransport, bt as SeatSelectionRequest, ft as SEAT_COMMAND_TIMEOUT_MS } from "./client-D6e4vd90.js";
1
+ import { R as SandboxError } from "./terminal-stream-types-RAsy75gD.js";
2
+ import { _t as SeatOwnerTransport, bt as SeatSelectionRequest, ft as SEAT_COMMAND_TIMEOUT_MS } from "./client-CIp8gol6.js";
3
3
 
4
4
  //#region src/select-seat-command.d.ts
5
5
  /** Public reply bound; the owner prints one metadata object. */
@@ -1,5 +1,5 @@
1
- import { C as SandboxError, O as ValidationError } from "./errors-BY7a-Hpw.js";
2
- import { r as SEAT_OWNER_MAX_RESPONSE_BYTES, s as seatOwnerTimeoutMs, t as SEAT_COMMAND_TIMEOUT_MS } from "./select-seat-43fsQBjG.js";
1
+ import { C as SandboxError, O as ValidationError } from "./errors-DVjaZqJT.js";
2
+ import { r as SEAT_OWNER_MAX_RESPONSE_BYTES, s as seatOwnerTimeoutMs, t as SEAT_COMMAND_TIMEOUT_MS } from "./select-seat-Bm8THMSh.js";
3
3
  import { spawn } from "node:child_process";
4
4
  //#region src/select-seat-command.ts
5
5
  /**
@@ -1,7 +1,7 @@
1
+ import "../retry-after-header-DyAWSQ4m.js";
1
2
  import { n as combineAbortSignals } from "../abort-signal-BsriwJ8L.js";
2
- import { i as fetchSandboxApi } from "../api-request-DfzqU66n.js";
3
- import "../sidecar-proxy-error-DVVfeGIP.js";
4
- import { t as parseSSEStream } from "../sse-parser-DTgSRcZC.js";
3
+ import { i as fetchSandboxApi } from "../api-request-BSleTpab.js";
4
+ import { t as parseSSEStream } from "../sse-parser-BCG3iL9j.js";
5
5
  import { PART_TEXT, PART_TEXT_SUFFIX } from "@tangle-network/agent-core/sse";
6
6
  //#region ../../../packages/runtime-contracts/dist/session-gateway.js
7
7
  /**
@@ -1,2 +1,2 @@
1
- import { C as JsonResponseParamTypes, E as SandboxIdParamTypes, S as JOB_SANDBOX_DELETE, T as SandboxCreateResponseParamTypes, _ as TANGLE_CHAIN_ID, a as fetchQuote, b as AgentSandboxBlueprintAbi, c as parseQuoteResponse, d as OperatorSession, f as OperatorSessionError, g as BlueprintSandboxClientConfig, h as BlueprintSandboxClient, i as SignedQuote, l as validateQuote, m as SignMessage, n as QuoteDomain, o as inputsHashOf, p as OperatorSessionToken, r as QuoteError, s as jobQuoteDigest, t as JobQuoteDetails, u as OperatorChallenge, v as TANGLE_JOBS_CONTRACT, w as SandboxCreateParamTypes, x as JOB_SANDBOX_CREATE, y as ITangleJobsAbi } from "../index-D3uEA1ED.js";
1
+ import { C as JsonResponseParamTypes, E as SandboxIdParamTypes, S as JOB_SANDBOX_DELETE, T as SandboxCreateResponseParamTypes, _ as TANGLE_CHAIN_ID, a as fetchQuote, b as AgentSandboxBlueprintAbi, c as parseQuoteResponse, d as OperatorSession, f as OperatorSessionError, g as BlueprintSandboxClientConfig, h as BlueprintSandboxClient, i as SignedQuote, l as validateQuote, m as SignMessage, n as QuoteDomain, o as inputsHashOf, p as OperatorSessionToken, r as QuoteError, s as jobQuoteDigest, t as JobQuoteDetails, u as OperatorChallenge, v as TANGLE_JOBS_CONTRACT, w as SandboxCreateParamTypes, x as JOB_SANDBOX_CREATE, y as ITangleJobsAbi } from "../index-D7dMz_US.js";
2
2
  export { AgentSandboxBlueprintAbi, BlueprintSandboxClient, BlueprintSandboxClientConfig, ITangleJobsAbi, JOB_SANDBOX_CREATE, JOB_SANDBOX_DELETE, JobQuoteDetails, JsonResponseParamTypes, OperatorChallenge, OperatorSession, OperatorSessionError, OperatorSessionToken, QuoteDomain, QuoteError, SandboxCreateParamTypes, SandboxCreateResponseParamTypes, SandboxIdParamTypes, SignMessage, SignedQuote, TANGLE_CHAIN_ID, TANGLE_JOBS_CONTRACT, fetchQuote, inputsHashOf, jobQuoteDigest, parseQuoteResponse, validateQuote };
@@ -1,3 +1,3 @@
1
- import { _ as SandboxCreateResponseParamTypes, a as parseQuoteResponse, c as OperatorSession, d as TANGLE_JOBS_CONTRACT, f as AgentSandboxBlueprintAbi, g as SandboxCreateParamTypes, h as JsonResponseParamTypes, i as jobQuoteDigest, l as OperatorSessionError, m as JOB_SANDBOX_DELETE, n as fetchQuote, o as validateQuote, p as JOB_SANDBOX_CREATE, r as inputsHashOf, s as BlueprintSandboxClient, t as QuoteError, u as TANGLE_CHAIN_ID, v as SandboxIdParamTypes } from "../tangle-Brz73sjb.js";
2
- import { t as ITangleJobsAbi } from "../abi-CQYNCS4F.js";
1
+ import { _ as SandboxCreateResponseParamTypes, a as parseQuoteResponse, c as OperatorSession, d as TANGLE_JOBS_CONTRACT, f as AgentSandboxBlueprintAbi, g as SandboxCreateParamTypes, h as JsonResponseParamTypes, i as jobQuoteDigest, l as OperatorSessionError, m as JOB_SANDBOX_DELETE, n as fetchQuote, o as validateQuote, p as JOB_SANDBOX_CREATE, r as inputsHashOf, s as BlueprintSandboxClient, t as QuoteError, u as TANGLE_CHAIN_ID, v as SandboxIdParamTypes } from "../tangle-Dld1JKjX.js";
2
+ import { t as ITangleJobsAbi } from "../abi-pcDt2Adp.js";
3
3
  export { AgentSandboxBlueprintAbi, BlueprintSandboxClient, ITangleJobsAbi, JOB_SANDBOX_CREATE, JOB_SANDBOX_DELETE, JsonResponseParamTypes, OperatorSession, OperatorSessionError, QuoteError, SandboxCreateParamTypes, SandboxCreateResponseParamTypes, SandboxIdParamTypes, TANGLE_CHAIN_ID, TANGLE_JOBS_CONTRACT, fetchQuote, inputsHashOf, jobQuoteDigest, parseQuoteResponse, validateQuote };
@@ -1,8 +1,8 @@
1
- import { R as readFilesystemIncarnationTuple, n as createSandboxInstanceFromResponse } from "./sandbox-Dnmxn9U3.js";
2
- import { a as readResponseJson } from "./errors-BY7a-Hpw.js";
3
- import { i as fetchSandboxApi } from "./api-request-DfzqU66n.js";
4
- import { t as ITangleJobsAbi } from "./abi-CQYNCS4F.js";
5
- import { _ as rotlBH, a as anumber, b as rotlSL, d as createXOFer, g as u32, h as toBytes$1, l as createHasher, m as swap32IfBE, n as abytes, o as aoutput, r as aexists, s as clean, t as Hash, v as rotlBL, x as split, y as rotlSH } from "./utils-fYi8g-M-.js";
1
+ import { R as readFilesystemIncarnationTuple, n as createSandboxInstanceFromResponse } from "./sandbox-BNlmFt8n.js";
2
+ import { a as readResponseJson } from "./errors-DVjaZqJT.js";
3
+ import { i as fetchSandboxApi } from "./api-request-BSleTpab.js";
4
+ import { t as ITangleJobsAbi } from "./abi-pcDt2Adp.js";
5
+ import { _ as rotlBH, a as anumber, b as rotlSL, d as createXOFer, g as u32, h as toBytes$1, l as createHasher, m as swap32IfBE, n as abytes, o as aoutput, r as aexists, s as clean, t as Hash, v as rotlBL, x as split, y as rotlSH } from "./utils-BvN0Mk3j.js";
6
6
  //#region ../../../packages/runtime-contracts/dist/tangle-blueprint-abi.js
7
7
  /**
8
8
  * Tangle blueprint wire contract shared by the orchestrator's Tangle driver and
@@ -2586,7 +2586,7 @@ function isAddressEqual(a, b) {
2586
2586
  //#region ../../../node_modules/.pnpm/viem@2.57.16_bufferutil@4.1.0_typescript@6.0.3_utf-8-validate@5.0.10_zod@4.6.7/node_modules/viem/_esm/utils/signature/recoverPublicKey.js
2587
2587
  async function recoverPublicKey({ hash, signature }) {
2588
2588
  const hashHex = isHex(hash) ? hash : toHex(hash);
2589
- const { secp256k1 } = await import("./secp256k1-B2arMxku.js");
2589
+ const { secp256k1 } = await import("./secp256k1-DIwypP5B.js");
2590
2590
  return `0x${(() => {
2591
2591
  if (typeof signature === "object" && "r" in signature && "s" in signature) {
2592
2592
  const { r, s, v, yParity } = signature;
@@ -1399,6 +1399,8 @@ interface SandboxErrorMetadata {
1399
1399
  traceId?: string;
1400
1400
  retryAfterMs?: number;
1401
1401
  restartKind?: HostAgentRestartKind;
1402
+ /** Local epoch ms until which the host attests an undelivered planned-restart refusal may be retried. */
1403
+ retryUntil?: number;
1402
1404
  sidecarVersion?: string;
1403
1405
  containerImage?: string;
1404
1406
  /** Cell-measured capacity wait; retryAfterMs only paces retries. */
@@ -1,4 +1,4 @@
1
- import { O as ValidationError } from "./errors-BY7a-Hpw.js";
1
+ import { O as ValidationError } from "./errors-DVjaZqJT.js";
2
2
  //#region src/lib/trace-id.ts
3
3
  /**
4
4
  * Request header that carries one turn's trace id. The Sandbox API adopts it