@tangle-network/sandbox 1.0.208 → 1.0.210

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 (53) hide show
  1. package/README.md +1 -1
  2. package/dist/abort-signal-BbJTt2QJ.js +31 -0
  3. package/dist/agent/index.d.ts +4 -4
  4. package/dist/agent/index.js +4 -4
  5. package/dist/agent/preview.d.ts +1 -1
  6. package/dist/agent/preview.js +1 -1
  7. package/dist/{agent-run-outcome-1NHcTtoo.d.ts → agent-run-outcome-CP2N40aT.d.ts} +1 -1
  8. package/dist/api-request-CUIrVFhJ.js +173 -0
  9. package/dist/{browser-interactive-control-controller-BYbNLahH.js → browser-interactive-control-controller-BiP6TJFP.js} +1 -1
  10. package/dist/{chunked-upload-BTdDxWFj.js → chunked-upload-D6ZCQ-iN.js} +15 -11
  11. package/dist/{chunked-upload-file-5GlXGjhY.js → chunked-upload-file-D3YxQdAl.js} +2 -2
  12. package/dist/{client-Bp3Gqf0e.d.ts → client-DiLd0XGB.d.ts} +4 -4
  13. package/dist/{client-DN4Ug-ub.js → client-DyKdtYDZ.js} +24 -29
  14. package/dist/{core-7rGEb0lF.js → core-DDgUWBS7.js} +2 -2
  15. package/dist/core.d.ts +5 -5
  16. package/dist/core.js +3 -3
  17. package/dist/{direct-http2-Bqtn2jg3.js → direct-http2-DU2SK2Wo.js} +1 -1
  18. package/dist/{index-BVEpMspL.d.ts → index-DyFU9hy7.d.ts} +5 -6
  19. package/dist/index.d.ts +7 -7
  20. package/dist/index.js +7 -7
  21. package/dist/intelligence/index.js +1 -1
  22. package/dist/interactive-control.js +1 -1
  23. package/dist/{interactive-controller-DuyS5n9z.d.ts → interactive-controller-BzObb8aT.d.ts} +1 -1
  24. package/dist/{interactive-controller-B09YfFqP.js → interactive-controller-C-CuPVMA.js} +8 -6
  25. package/dist/lib/prepared-evidence.js +1 -1
  26. package/dist/lib/prepared-process.js +1 -1
  27. package/dist/{lines-DGke3URt.d.ts → lines-D0dHQ3X5.d.ts} +1 -1
  28. package/dist/lines.d.ts +1 -1
  29. package/dist/{mcp-local-BHCdMtdh.js → mcp-local-BW6W0Vh8.js} +3 -3
  30. package/dist/{prepared-evidence-4prvV0YK.js → prepared-evidence--rjwnXGD.js} +2 -12
  31. package/dist/{prepared-process-BSpZXDDw.js → prepared-process-N-y0xr9S.js} +2 -14
  32. package/dist/{preview-Din4zRB-.d.ts → preview-CrXG9Y8a.d.ts} +3 -3
  33. package/dist/{public-templates-k5rHh7Up.d.ts → public-templates-Ba-DTf2O.d.ts} +1 -1
  34. package/dist/public-templates.d.ts +1 -1
  35. package/dist/{raw-evidence-archive-C5H8BaHr.js → raw-evidence-archive-DrgeV9_0.js} +1 -1
  36. package/dist/retry-policy-0_NCh5OB.js +88 -0
  37. package/dist/runtime.d.ts +3 -3
  38. package/dist/runtime.js +4 -4
  39. package/dist/{sandbox-BQ_u_Fjy.js → sandbox-DRZ1nTd3.js} +123 -156
  40. package/dist/select-seat-command.d.ts +1 -1
  41. package/dist/session-gateway/index.js +3 -3
  42. package/dist/tangle/index.d.ts +1 -1
  43. package/dist/tangle/index.js +1 -1
  44. package/dist/{tangle-B-Sv_5XW.js → tangle-BPDYjDpX.js} +1 -1
  45. package/dist/{types-BVcWpKvF.d.ts → types-BE70nj5h.d.ts} +2 -2
  46. package/package.json +5 -5
  47. package/dist/abort-signal-Cu4F2VVz.js +0 -62
  48. package/dist/api-request-BBNFh7Zx.js +0 -92
  49. package/dist/response-rewrap-Cjoxh2wZ.js +0 -28
  50. /package/dist/{file-transfer-Cr9Ossea.js → file-transfer-BSe4ayU9.js} +0 -0
  51. /package/dist/{keep-alive-fetch-C2lFwrMA.js → keep-alive-fetch-BIaDMUtu.js} +0 -0
  52. /package/dist/{sidecar-proxy-error-DTJbOAWL.js → sidecar-proxy-error-DpBLxIof.js} +0 -0
  53. /package/dist/{sse-parser-DXRUx6gh.js → sse-parser-DOCszo1K.js} +0 -0
@@ -1,17 +1,18 @@
1
- import { A as normalizeRuntimeBackendConfig, C as encodeTextForWire, D as applyRequestedModel, F as withoutRuntimeSecrets, I as createAgentRunOutcomeTracker, L as deriveAgentResultOutcome, M as requestedSecretProfilePublicDigest, O as assertCurrentBackendType, S as encodePromptForWire, T as canUseNodeHttp2, W as normalizeEffectiveBackend, _ as isTraceId, a as assertScopedTokenActive, b as resolveDispatchRunIdentity, c as SandboxRuntimeApi, d as appendSessionIdQuery, f as callHeaders, g as TRACE_ID_HEADER, h as isRetryableCredentialRefusal, i as terminalUpgradeHeadersSupported, j as requestedPublicProfileDigest, k as mergeRuntimeBackendConfig, l as normalizeSessionInfo, m as assertFileWritePreconditions, n as InteractiveSessionController, p as sessionHeaders, r as TerminalStream, s as requestScopedToken, u as sessionMessageRequestBody, v as mintTraceId, w as runtimeFilesystemPath, x as validateAcceptedDispatchRunRef, y as resolveTraceId } from "./interactive-controller-B09YfFqP.js";
1
+ import { A as normalizeRuntimeBackendConfig, C as encodeTextForWire, D as applyRequestedModel, F as withoutRuntimeSecrets, I as createAgentRunOutcomeTracker, L as deriveAgentResultOutcome, M as requestedSecretProfilePublicDigest, O as assertCurrentBackendType, S as encodePromptForWire, T as canUseNodeHttp2, W as normalizeEffectiveBackend, _ as isTraceId, a as assertScopedTokenActive, b as resolveDispatchRunIdentity, c as SandboxRuntimeApi, d as appendSessionIdQuery, f as callHeaders, g as TRACE_ID_HEADER, h as isRetryableCredentialRefusal, i as terminalUpgradeHeadersSupported, j as requestedPublicProfileDigest, k as mergeRuntimeBackendConfig, l as normalizeSessionInfo, m as assertFileWritePreconditions, n as InteractiveSessionController, p as sessionHeaders, r as TerminalStream, s as requestScopedToken, u as sessionMessageRequestBody, v as mintTraceId, w as runtimeFilesystemPath, x as validateAcceptedDispatchRunRef, y as resolveTraceId } from "./interactive-controller-C-CuPVMA.js";
2
2
  import { C as boundedIdentifierSchema, E as boundedStringSchema, g as sha256DigestSchema$1, o as canonicalCandidateDigest$1, s as canonicalCandidateJson$1, u as isCanonicalJsonValue$1 } from "./harness-DMaNgn0S.js";
3
3
  import { t as sha256 } from "./sha2-vu4U-x2L.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-BYbNLahH.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-BiP6TJFP.js";
5
5
  import { a as ProxySecretReceiptSchema, o as canonicalAgentProfileValue, r as agentProfileSchema } from "./profile-schema-C1KpT-wS.js";
6
6
  import { C as ServerError, D as ValidationError, E as TimeoutError, S as SandboxError, T as StreamInterruptedError, _ as NotFoundError, a as readResponseJson, d as EdgeNotReadyError, g as NetworkError, i as parseResponseError, l as CapabilityError, n as isTransientWrite, o as retryWhen, r as parseErrorResponse, s as AuthError, t as TerminalStreamError, w as StateError, y as ProfileFileMountPathError } from "./errors-CNszZUZ2.js";
7
- import { i as delayUntilAborted, n as awaitWithAbort, r as combineAbortSignals, t as abortableSleep } from "./abort-signal-Cu4F2VVz.js";
8
- 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, u as SANDBOX_FILE_API_ABSOLUTE_ROOTS } from "./file-transfer-Cr9Ossea.js";
9
- import { t as rewrapResponse } from "./response-rewrap-Cjoxh2wZ.js";
10
- import { n as fetchWithKeepAlive, t as emitTiming } from "./keep-alive-fetch-C2lFwrMA.js";
11
- import { t as SIDECAR_PROXY_ERROR_HEADER } from "./sidecar-proxy-error-DTJbOAWL.js";
12
- import { t as parseSSEStream } from "./sse-parser-DXRUx6gh.js";
13
- import { s as uploadChunked } from "./chunked-upload-BTdDxWFj.js";
14
- import { t as runPreparedProcess } from "./prepared-process-BSpZXDDw.js";
7
+ import { n as combineAbortSignals, t as awaitWithAbort } from "./abort-signal-BbJTt2QJ.js";
8
+ import { a as backoffDelayMs, r as abortableSleep } from "./retry-policy-0_NCh5OB.js";
9
+ 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, u as SANDBOX_FILE_API_ABSOLUTE_ROOTS } from "./file-transfer-BSe4ayU9.js";
10
+ import { c as awaitSdkResend, l as countSdkRequest, s as uploadChunked, u as takeSdkTurn } from "./chunked-upload-D6ZCQ-iN.js";
11
+ import { a as rewrapResponse, i as isReplayableBody, t as IDEMPOTENT_METHODS } from "./api-request-CUIrVFhJ.js";
12
+ import { n as fetchWithKeepAlive, t as emitTiming } from "./keep-alive-fetch-BIaDMUtu.js";
13
+ import { t as SIDECAR_PROXY_ERROR_HEADER } from "./sidecar-proxy-error-DpBLxIof.js";
14
+ import { t as parseSSEStream } from "./sse-parser-DOCszo1K.js";
15
+ import { t as runPreparedProcess } from "./prepared-process-N-y0xr9S.js";
15
16
  import { a as isBackendType, r as cliAuthReferenceSchema } from "./cli-auth-bundle-C6DtK7GX-BbbiAn-Z.js";
16
17
  import "./cli-auth-bundle-CMJWI99l.js";
17
18
  import { n as SandboxLines } from "./lines-DHOIUO-t.js";
@@ -261,13 +262,9 @@ const DEFAULT_CREATE_TIMEOUT_MS = 12e4;
261
262
  const DEFAULT_GPU_CREATE_TIMEOUT_MS = 900 * 1e3;
262
263
  const CREATE_RETRY_MAX_DELAY_MS = 4e3;
263
264
  /**
264
- * 503 classes that mean "the cell cannot place this right now, ask again":
265
- * placement refusals that started no provision, a keyed create whose ref the
266
- * Worker cannot yet verify, a ready lease whose transfer is pending, and an
267
- * internal owner paced behind customers. Re-POSTing is safe: the idempotency
268
- * key joins whichever provision did start. `SANDBOX_CREATE_RECONCILING` is
269
- * deliberately absent: it follows a retained real failure and outlasts any
270
- * budget here.
265
+ * 503s that mean "the cell cannot place this now, ask again"; re-POSTing is
266
+ * safe because the key joins any provision that did start.
267
+ * `SANDBOX_CREATE_RECONCILING` is absent: it outlasts any budget here.
271
268
  */
272
269
  const DEPLOY_WINDOW_RETRY_CODES = new Set([
273
270
  "INTERNAL_CREATE_PACED",
@@ -311,32 +308,28 @@ function isDeployWindowCreateError(cause) {
311
308
  }
312
309
  /** A no-room refusal allocated nothing, so a create giving up on one reports this typed 503. */
313
310
  const isCapacityShortageCreateError = (cause) => isDeployWindowCreateError(cause) && (cause.code === "CAPACITY_EXHAUSTED" || cause.code === "HOST_PRESSURE");
314
- /**
315
- * The plan rate limiter's 429 (a quota 429 is final). Answered right after a
316
- * capacity refusal on the same key it is part of that pacing: retried on its
317
- * own `Retry-After` on the time budget, spending none of the attempt budget.
318
- */
311
+ /** The plan limiter's 429 (a quota 429 is final), paced on its own `Retry-After` within the time budget. */
319
312
  function isRateLimitCreateError(cause) {
320
313
  return retryWhen(cause) && cause.status === 429;
321
314
  }
322
- /**
323
- * Create retries what the catalog marks retryable (a 524 is a `TIMEOUT`, so a
324
- * key that a proxy cut off is joined), except a 409, which create never
325
- * retried, and a customer-floor hold: the cell keeps that room for customers
326
- * and a re-POST meets the same hold.
327
- */
315
+ /** Create retries what the catalog marks retryable (a 524 `TIMEOUT` joins its key), except a 409 and a customer-floor hold. */
328
316
  function isRetryableCreateError(cause) {
329
317
  return retryWhen(cause) && cause.status !== 409 && !cause.capacityHold;
330
318
  }
331
- /**
332
- * Longest wait on an `IDEMPOTENT_CREATE_PROBE_FAILED` `Retry-After`: the
333
- * probe answers again within seconds, and an upstream 11.8 s hint ended a
334
- * create on 10-26 instead of re-probing.
335
- */
319
+ /** Longest wait on an `IDEMPOTENT_CREATE_PROBE_FAILED` `Retry-After`: the probe answers again within seconds. */
336
320
  const PROBE_FAILED_MAX_DELAY_MS = 5e3;
321
+ function createRetryAfterMs(cause) {
322
+ if (!(cause instanceof SandboxError) || cause.retryAfterMs === void 0) return void 0;
323
+ return cause.code === "IDEMPOTENT_CREATE_PROBE_FAILED" ? Math.min(cause.retryAfterMs, PROBE_FAILED_MAX_DELAY_MS) : cause.retryAfterMs;
324
+ }
337
325
  function createRetryDelayMs(cause, failedAttempt) {
338
- if (cause instanceof SandboxError && cause.retryAfterMs !== void 0) return cause.code === "IDEMPOTENT_CREATE_PROBE_FAILED" ? Math.min(cause.retryAfterMs, PROBE_FAILED_MAX_DELAY_MS) : cause.retryAfterMs;
339
- return Math.min(250 * 2 ** Math.max(0, failedAttempt - 1), CREATE_RETRY_MAX_DELAY_MS);
326
+ return backoffDelayMs(failedAttempt, createRetryAfterMs(cause), CREATE_RETRY_MAX_DELAY_MS);
327
+ }
328
+ /** Wait `delayMs`, and a re-send the server did not pace also its budget turn; throws when that falls past `deadline`. */
329
+ async function awaitCreateResend(delayMs, deadline, signal, cause) {
330
+ const turnMs = createRetryAfterMs(cause) !== void 0 ? 0 : takeSdkTurn(deadline - Date.now() - delayMs);
331
+ if (turnMs === void 0) throw new Error("No retry turn before deadline");
332
+ await abortableSleep(Math.max(delayMs, turnMs), signal);
340
333
  }
341
334
  function generateIdempotencyKey() {
342
335
  const c = globalThis.crypto;
@@ -347,21 +340,21 @@ function generateIdempotencyKey() {
347
340
  }
348
341
  throw new Error("idempotency key generation requires global crypto");
349
342
  }
350
- const FORK_OUTAGE_CODES = new Set(["UNAVAILABLE", "STORAGE_UNAVAILABLE"]);
351
343
  /**
352
- * A fork re-POSTs the refusals a create waits out, plus an `UNAVAILABLE` or
353
- * `STORAGE_UNAVAILABLE` 503 and a gateway 502/504: none started a fan-out,
354
- * and the keyed re-POST joins one that did.
344
+ * A fork re-POSTs the refusals a create waits out: none started a fan-out,
345
+ * and the keyed re-POST joins one that did. The transport already resends
346
+ * the keyed POST through a gateway 502, 503 or 504.
355
347
  */
356
348
  async function retryForkRefusal(post) {
357
- const deadline = Date.now() + DEPLOY_WINDOW_RETRY_MS;
349
+ const deadlineAt = Date.now() + DEPLOY_WINDOW_RETRY_MS;
358
350
  for (let failed = 1;; failed++) try {
359
351
  return await post();
360
352
  } catch (cause) {
361
- const retryable = isDeployWindowCreateError(cause) || cause instanceof SandboxError && (cause.status === 502 || cause.status === 504 || cause.status === 503 && FORK_OUTAGE_CODES.has(cause.code));
362
- const delayMs = Math.max(createRetryDelayMs(cause, failed), 250);
363
- if (!retryable || delayMs >= deadline - Date.now()) throw cause;
364
- await abortableSleep(delayMs);
353
+ if (!isDeployWindowCreateError(cause) || !await awaitSdkResend(failed, {
354
+ retryAfterMs: createRetryAfterMs(cause),
355
+ deadlineAt,
356
+ capMs: 4e3
357
+ })) throw cause;
365
358
  }
366
359
  }
367
360
  //#endregion
@@ -2789,14 +2782,6 @@ const READ_METHODS = new Set([
2789
2782
  function apiOwnedRuntimeRoute(method, path) {
2790
2783
  return !READ_METHODS.has(method) && /^(?:agents|session)(?:\/|$)/.test(path);
2791
2784
  }
2792
- /** RFC 9110 idempotent methods: applying one twice leaves what once did. */
2793
- const IDEMPOTENT_METHODS = new Set([
2794
- "GET",
2795
- "HEAD",
2796
- "OPTIONS",
2797
- "PUT",
2798
- "DELETE"
2799
- ]);
2800
2785
  /** POST routes that only read: the body carries the query, not a change. */
2801
2786
  const READ_ONLY_POSTS = new Set([
2802
2787
  "files/read",
@@ -2807,12 +2792,6 @@ const READ_ONLY_POSTS = new Set([
2807
2792
  function isReplaySafe(method, path) {
2808
2793
  return IDEMPOTENT_METHODS.has(method) || method === "POST" && READ_ONLY_POSTS.has(path);
2809
2794
  }
2810
- /** Whether fetch can send this body twice. A stream is read once. */
2811
- function isReplayableBody(body) {
2812
- if (body === void 0 || body === null || typeof body === "string") return true;
2813
- if (typeof ReadableStream !== "undefined" && body instanceof ReadableStream) return false;
2814
- return !(Symbol.asyncIterator in body);
2815
- }
2816
2795
  /**
2817
2796
  * Host-agent refusals written before it forwards anything to the sidecar
2818
2797
  * (apps/host-agent/src/routes/runtime-sidecar-proxy-request.ts): the box is
@@ -3071,8 +3050,9 @@ var DirectRuntimeHttpClient = class {
3071
3050
  path
3072
3051
  };
3073
3052
  if (!route) throw new NetworkError("Direct runtime route was withdrawn");
3053
+ countSdkRequest();
3074
3054
  if ((route.useHost || route.useExec) && canUseNodeHttp2()) {
3075
- const { fetchDirectHttp2 } = await import("./direct-http2-Bqtn2jg3.js");
3055
+ const { fetchDirectHttp2 } = await import("./direct-http2-DU2SK2Wo.js");
3076
3056
  return fetchDirectHttp2(route.url, request, timing);
3077
3057
  }
3078
3058
  return fetchWithKeepAlive(route.url, request, timing);
@@ -3405,16 +3385,14 @@ function profileFileBundleKey(mounts) {
3405
3385
  files: profileBundleFileTable(mounts)
3406
3386
  });
3407
3387
  }
3388
+ //#endregion
3389
+ //#region src/profile-file-failure.ts
3408
3390
  const PROFILE_FILE_MOUNT_RETRY_MAX_MS = 2e3;
3409
3391
  /**
3410
- * Wall-clock ceiling for retrying one file API batch write that got no decided
3411
- * answer, waits included. A gateway can answer 502 after waiting out its own
3412
- * 3 s key-verification budget, so this admits about three such attempts: it
3413
- * rides out a stall of a few seconds without holding create() through a
3414
- * platform restart, which the caller is better told about.
3392
+ * Wall-clock ceiling for re-sending one undecided file API batch write: it
3393
+ * rides a stall of a few seconds, not a platform restart the caller should hear of.
3415
3394
  */
3416
3395
  const PROFILE_FILE_MOUNT_WRITE_RETRY_BUDGET_MS = 1e4;
3417
- const waitForProfileFileMount = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
3418
3396
  var ProfileFileMountExecTimeoutError = class extends Error {
3419
3397
  constructor(timeoutMs) {
3420
3398
  super(`exec exceeded ${timeoutMs}ms`);
@@ -3581,10 +3559,11 @@ async function writeBatchRidingOutUndecided(write, maxRetries) {
3581
3559
  await write();
3582
3560
  return;
3583
3561
  } catch (err) {
3584
- if (!(retryWhen(err) && (err instanceof NetworkError || err.status >= 502 && !(err instanceof TimeoutError))) || attempt >= maxRetries) throw err;
3585
- const waitMs = retryAfterMs(err) ?? Math.min(250 * 2 ** attempt, 2e3);
3586
- if (Date.now() - startedAt + waitMs >= PROFILE_FILE_MOUNT_WRITE_RETRY_BUDGET_MS) throw err;
3587
- await waitForProfileFileMount(waitMs);
3562
+ if (!(retryWhen(err) && (err instanceof NetworkError || err.status >= 502 && !(err instanceof TimeoutError))) || attempt >= maxRetries || !await awaitSdkResend(attempt + 1, {
3563
+ retryAfterMs: retryAfterMs(err),
3564
+ deadlineAt: startedAt + PROFILE_FILE_MOUNT_WRITE_RETRY_BUDGET_MS,
3565
+ capMs: 2e3
3566
+ })) throw err;
3588
3567
  }
3589
3568
  }
3590
3569
  //#endregion
@@ -3776,7 +3755,7 @@ function isFileApiRootOnlyError(error) {
3776
3755
  //#endregion
3777
3756
  //#region src/profile-file-mounts.ts
3778
3757
  const PROFILE_FILE_MOUNT_B64_CHUNK_CHARS = 3e3;
3779
- const PROFILE_FILE_MOUNT_MAX_RETRIES = 4;
3758
+ const PROFILE_FILE_MOUNT_MAX_RETRIES = 6;
3780
3759
  const PROFILE_FILE_MOUNT_EXEC_TIMEOUT_MS = 3e4;
3781
3760
  async function execProfileFileMount(box, mount, content, options, execState) {
3782
3761
  const maxRetries = options.maxRetries ?? PROFILE_FILE_MOUNT_MAX_RETRIES;
@@ -3794,17 +3773,17 @@ async function execProfileFileMount(box, mount, content, options, execState) {
3794
3773
  const homeGuard = path.startsWith("~/") ? `[ -n "$HOME" ] || { echo ${shellSingleQuote(`materializeProfileFileMounts: HOME is unset for ${path}`)} >&2; exit 1; }; ` : "";
3795
3774
  const run = async (cmd) => {
3796
3775
  for (let attempt = 0;; attempt++) {
3797
- if (execState.started && options.paceMs > 0) await waitForProfileFileMount(options.paceMs);
3776
+ if (execState.started && options.paceMs > 0) await abortableSleep(options.paceMs);
3798
3777
  execState.started = true;
3799
3778
  try {
3800
3779
  return await execWithTimeout(box, cmd, options.execTimeoutMs);
3801
3780
  } catch (err) {
3802
3781
  const { retryable, retryAfterMs: retryAfter } = transientExecError(err);
3803
- if (retryable && attempt < maxRetries) {
3804
- const backoff = Math.min(250 * 2 ** attempt, PROFILE_FILE_MOUNT_RETRY_MAX_MS);
3805
- await waitForProfileFileMount(Math.min(retryAfter ?? backoff, PROFILE_FILE_MOUNT_RETRY_MAX_MS));
3806
- continue;
3807
- }
3782
+ const capMs = PROFILE_FILE_MOUNT_RETRY_MAX_MS;
3783
+ if (retryable && attempt < maxRetries && await awaitSdkResend(attempt + 1, {
3784
+ retryAfterMs: retryAfter === void 0 ? void 0 : Math.min(retryAfter, capMs),
3785
+ capMs
3786
+ })) continue;
3808
3787
  throw new ProfileFileMaterializeError(`materializeProfileFileMounts: exec failed for ${path}`, { cause: err });
3809
3788
  }
3810
3789
  }
@@ -4378,26 +4357,40 @@ var SandboxOperation = class SandboxOperation {
4378
4357
  * with a succeeded operation; throws {@link SandboxOperationFailedError} on
4379
4358
  * a failed one and {@link TimeoutError} past `timeoutMs` (default 10 min).
4380
4359
  * The verb was accepted, so a read that was lost, timed out or refused
4381
- * retryably says nothing about it: read again after a full-jitter wait no
4382
- * shorter than its Retry-After.
4360
+ * retryably says nothing about it: read again on the shared retry pacing
4361
+ * (the server's Retry-After, else full jitter, and the client's retry budget).
4383
4362
  */
4384
4363
  async wait(options = {}) {
4385
4364
  const timeoutMs = options.timeoutMs ?? DEFAULT_WAIT_TIMEOUT_MS;
4386
4365
  const startedAt = Date.now();
4387
4366
  const { signal } = options;
4388
- let [delayMs, capMs] = [0, 0];
4367
+ let [delayMs, capMs, failedReads] = [
4368
+ 0,
4369
+ 0,
4370
+ 0
4371
+ ];
4389
4372
  let info;
4373
+ const timedOut = (cause) => new TimeoutError(`Timed out waiting for ${this.#info.kind} operation ${this.#info.id} (last state ${this.#info.state})`, {
4374
+ timeoutMs,
4375
+ cause
4376
+ });
4390
4377
  while (!info || !isTerminalOperation(info)) {
4391
- if (Date.now() - startedAt + delayMs > timeoutMs) throw new TimeoutError(`Timed out waiting for ${this.#info.kind} operation ${this.#info.id} (last state ${this.#info.state})`, { timeoutMs });
4392
- signal?.throwIfAborted();
4393
- if (delayMs > 0) await delayUntilAborted(delayMs, signal);
4378
+ if (Date.now() - startedAt + delayMs > timeoutMs) throw timedOut();
4379
+ await abortableSleep(delayMs, signal);
4394
4380
  capMs = Math.min(Math.max(capMs * 2, FIRST_POLL_MS), MAX_POLL_MS);
4395
4381
  try {
4396
4382
  info = await this.refresh({ signal });
4397
- delayMs = capMs;
4383
+ [delayMs, failedReads] = [capMs, 0];
4398
4384
  } catch (error) {
4399
4385
  if (!retryWhen(error) || error.code === "UPSTREAM_CONTRACT_VIOLATION") throw error;
4400
- delayMs = Math.max(error.retryAfterMs ?? 0, Math.random() * capMs);
4386
+ const deadlineAt = startedAt + timeoutMs;
4387
+ const pacing = {
4388
+ retryAfterMs: error.retryAfterMs,
4389
+ signal,
4390
+ deadlineAt
4391
+ };
4392
+ if (!await awaitSdkResend(++failedReads, pacing)) throw timedOut(error);
4393
+ delayMs = 0;
4401
4394
  }
4402
4395
  }
4403
4396
  signal?.throwIfAborted();
@@ -5202,7 +5195,7 @@ var SandboxPreviewCapabilities = class extends SandboxGpuCapabilities {
5202
5195
  endpoint
5203
5196
  });
5204
5197
  try {
5205
- await delayUntilAborted(Math.min(pollIntervalMs, remainingAfterCheckMs), options?.signal);
5198
+ await abortableSleep(Math.min(pollIntervalMs, remainingAfterCheckMs), options?.signal);
5206
5199
  } catch {
5207
5200
  throw new TimeoutError("Aborted", {
5208
5201
  timeoutMs: 0,
@@ -5388,7 +5381,7 @@ var SandboxLifecycleEventsCapabilities = class extends SandboxPreviewCapabilitie
5388
5381
  if (this.hasReachedWaitTarget(statuses)) return;
5389
5382
  if (this.status === "failed") throw new StateError(this.error ?? "Sandbox failed", { currentState: this.status });
5390
5383
  if (Date.now() - startTime > timeoutMs) throw new TimeoutError(`Timed out waiting for sandbox to reach ${statuses.join(" or ")}`, { timeoutMs });
5391
- await delayUntilAborted(pollIntervalMs, signal).catch(rethrowWaitError);
5384
+ await abortableSleep(pollIntervalMs, signal).catch(rethrowWaitError);
5392
5385
  }
5393
5386
  }
5394
5387
  /**
@@ -5464,9 +5457,6 @@ var SandboxLifecycleEventsCapabilities = class extends SandboxPreviewCapabilitie
5464
5457
  });
5465
5458
  return connection?.edgeStatus !== "pending" && Boolean(connection?.hostUrl || connection?.execHost || connection?.runtimeUrl);
5466
5459
  }
5467
- sleep(ms) {
5468
- return new Promise((resolve) => setTimeout(resolve, ms));
5469
- }
5470
5460
  };
5471
5461
  //#endregion
5472
5462
  //#region src/sandbox-lifecycle.ts
@@ -5552,7 +5542,10 @@ var SandboxLifecycleCapabilities = class extends SandboxLifecycleEventsCapabilit
5552
5542
  response = await withLifecycleConflictRetry(() => state(this).client.fetch(path, {
5553
5543
  method: "DELETE",
5554
5544
  ...options?.signal ? { signal: options.signal } : {},
5555
- ...options?.wait === false && options.idempotencyKey ? { headers: { "Idempotency-Key": options.idempotencyKey } } : {}
5545
+ headers: {
5546
+ "x-no-retry": "1",
5547
+ ...options?.wait === false && options.idempotencyKey ? { "Idempotency-Key": options.idempotencyKey } : {}
5548
+ }
5556
5549
  }), options, (error) => {
5557
5550
  const retry = isDeleteRetry(error);
5558
5551
  retried ||= retry;
@@ -5596,19 +5589,13 @@ var SandboxLifecycleCapabilities = class extends SandboxLifecycleEventsCapabilit
5596
5589
  }
5597
5590
  };
5598
5591
  /**
5599
- * How long a lifecycle call re-attempts a refusal that only asks it to wait.
5600
- * `resume`, `stop` and `delete` share one lease per sandbox, `lifecycle-<id>`,
5601
- * held past a response while its deferred cleanup runs (the workflow smoke
5602
- * hand-rolls the same retry), so a second call in that window is refused 409
5603
- * `SANDBOX_LIFECYCLE_IN_PROGRESS` by `withSandboxLifecycleClaim`; 2 of 2
5604
- * provider-seam runs (agent-sdk#280) lost a completed turn to it. A
5605
- * lease-store or storage outage answers 503 (us1 2026-11-01: 16/16 child
5606
- * deletes failed through a Platform deploy that had removed every child). The
5607
- * ceiling (~11 s) is short: a longer conflict is a real concurrent operation.
5592
+ * How long a lifecycle call re-attempts a refusal that only asks it to wait:
5593
+ * `resume`, `stop` and `delete` share one lease per sandbox, held past a
5594
+ * response while its deferred cleanup runs, and a lease-store outage answers
5595
+ * 503. 15 s of the SDK's own waits rides a release roll, however long the
5596
+ * server held each attempt; a longer conflict is a real operation.
5608
5597
  */
5609
- const LIFECYCLE_CONFLICT_MAX_ATTEMPTS = 6;
5610
- const LIFECYCLE_CONFLICT_BASE_DELAY_MS = 500;
5611
- const LIFECYCLE_CONFLICT_MAX_DELAY_MS = 4e3;
5598
+ const LIFECYCLE_CONFLICT_WINDOW_MS = 15e3;
5612
5599
  /** A lease-store or storage outage the API answers 503 before or after its effect: a retry is safe. */
5613
5600
  const LIFECYCLE_OUTAGE_CODES = new Set(["SANDBOX_LIFECYCLE_COORDINATION_UNAVAILABLE", "STORAGE_UNAVAILABLE"]);
5614
5601
  function isLifecycleConflict(cause) {
@@ -5618,10 +5605,6 @@ function isLifecycleConflict(cause) {
5618
5605
  function isDeleteRetry(cause) {
5619
5606
  return isLifecycleConflict(cause) || cause instanceof NetworkError || cause instanceof SandboxError && [502, 503].includes(cause.status);
5620
5607
  }
5621
- function lifecycleConflictDelayMs(cause, failedAttempt) {
5622
- if (cause instanceof SandboxError && cause.retryAfterMs !== void 0) return cause.retryAfterMs;
5623
- return Math.min(LIFECYCLE_CONFLICT_BASE_DELAY_MS * 2 ** Math.max(0, failedAttempt - 1), LIFECYCLE_CONFLICT_MAX_DELAY_MS);
5624
- }
5625
5608
  /**
5626
5609
  * Run one lifecycle mutation, re-attempting only the failures `retry` names
5627
5610
  * (by default the lifecycle refusals above).
@@ -5630,13 +5613,18 @@ function lifecycleConflictDelayMs(cause, failedAttempt) {
5630
5613
  * error class, and a caller abort ends the wait immediately.
5631
5614
  */
5632
5615
  async function withLifecycleConflictRetry(run, options, retry = isLifecycleConflict) {
5633
- for (let attempt = 1;; attempt += 1) try {
5616
+ let windowMs = LIFECYCLE_CONFLICT_WINDOW_MS;
5617
+ for (let resend = 1;; resend += 1) try {
5634
5618
  const response = await run();
5635
5619
  if (!response.ok) throw await parseResponseError(response);
5636
5620
  return response;
5637
5621
  } catch (error) {
5638
- if (!retry(error) || attempt >= LIFECYCLE_CONFLICT_MAX_ATTEMPTS || options?.signal?.aborted) throw error;
5639
- await delayUntilAborted(lifecycleConflictDelayMs(error, attempt), options?.signal);
5622
+ if (!retry(error) || options?.signal?.aborted || !await awaitSdkResend(resend, {
5623
+ retryAfterMs: error instanceof SandboxError ? error.retryAfterMs : void 0,
5624
+ deadlineAt: Date.now() + windowMs,
5625
+ signal: options?.signal,
5626
+ spent: (waitedMs) => windowMs -= waitedMs
5627
+ })) throw error;
5640
5628
  }
5641
5629
  }
5642
5630
  /** The largest delay `setTimeout` holds: past this it overflows its 32-bit
@@ -7132,7 +7120,7 @@ var SandboxFileWriteCapabilities = class extends SandboxFileOperations {
7132
7120
  async writeManySequential(files, paceMs, maxRetries) {
7133
7121
  let started = false;
7134
7122
  for (const file of files) for (let attempt = 0;; attempt++) {
7135
- if (started && paceMs > 0) await delay(paceMs);
7123
+ if (started && paceMs > 0) await abortableSleep(paceMs);
7136
7124
  started = true;
7137
7125
  try {
7138
7126
  await this.writeFileRequest(file.path, file.content, {
@@ -7143,11 +7131,10 @@ var SandboxFileWriteCapabilities = class extends SandboxFileOperations {
7143
7131
  });
7144
7132
  break;
7145
7133
  } catch (err) {
7146
- if (isTransientWrite(err) && attempt < maxRetries) {
7147
- const backoff = Math.min(WRITE_MANY_RETRY_BASE_MS * 2 ** attempt, WRITE_MANY_RETRY_MAX_MS);
7148
- await delay((err instanceof SandboxError ? err.retryAfterMs : void 0) ?? backoff);
7149
- continue;
7150
- }
7134
+ if (isTransientWrite(err) && attempt < maxRetries && await awaitSdkResend(attempt + 1, {
7135
+ retryAfterMs: err instanceof SandboxError ? err.retryAfterMs : void 0,
7136
+ capMs: WRITE_MANY_RETRY_MAX_MS
7137
+ })) continue;
7151
7138
  throw err;
7152
7139
  }
7153
7140
  }
@@ -7167,7 +7154,7 @@ var SandboxFileWriteCapabilities = class extends SandboxFileOperations {
7167
7154
  }
7168
7155
  const batches = splitWriteManyBatches(files.map(toWriteManyWireFile));
7169
7156
  for (const [index, batch] of batches.entries()) {
7170
- if (index > 0 && paceMs > 0) await delay(paceMs);
7157
+ if (index > 0 && paceMs > 0) await abortableSleep(paceMs);
7171
7158
  await this.writeBatchRequest(batch.files, batch.body);
7172
7159
  }
7173
7160
  }
@@ -7205,8 +7192,7 @@ var SandboxFileWriteCapabilities = class extends SandboxFileOperations {
7205
7192
  }
7206
7193
  };
7207
7194
  const WRITE_MANY_DEFAULT_PACE_MS = 0;
7208
- const WRITE_MANY_DEFAULT_MAX_RETRIES = 4;
7209
- const WRITE_MANY_RETRY_BASE_MS = 250;
7195
+ const WRITE_MANY_DEFAULT_MAX_RETRIES = 6;
7210
7196
  const WRITE_MANY_RETRY_MAX_MS = 2e3;
7211
7197
  const WRITE_MANY_BATCH_WIRE_BUDGET_BYTES = SANDBOX_PROXY_REQUEST_MAX_BYTES - 8 * 1024;
7212
7198
  function toWriteManyWireFile(file) {
@@ -7247,7 +7233,6 @@ function splitWriteManyBatches(files) {
7247
7233
  function hasDuplicateWriteManyPaths(files) {
7248
7234
  return new Set(files.map((file) => file.path)).size !== files.length;
7249
7235
  }
7250
- const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
7251
7236
  //#endregion
7252
7237
  //#region src/sandbox-profile.ts
7253
7238
  function isProfileNotCachedError(err) {
@@ -7633,24 +7618,6 @@ function numericEventId(eventId) {
7633
7618
  if (!/^\d{1,15}$/u.test(eventId)) return void 0;
7634
7619
  return Number(eventId);
7635
7620
  }
7636
- /** Resolve after `ms`, or as soon as the signal aborts; the caller checks it. */
7637
- function waitForReconnect(ms, signal) {
7638
- return new Promise((resolve) => {
7639
- if (signal?.aborted) {
7640
- resolve();
7641
- return;
7642
- }
7643
- const timer = setTimeout(() => {
7644
- signal?.removeEventListener("abort", onAbort);
7645
- resolve();
7646
- }, ms);
7647
- const onAbort = () => {
7648
- clearTimeout(timer);
7649
- resolve();
7650
- };
7651
- signal?.addEventListener("abort", onAbort, { once: true });
7652
- });
7653
- }
7654
7621
  //#endregion
7655
7622
  //#region ../../../packages/runtime-contracts/dist/interaction-response.js
7656
7623
  /** Durable states reported for a recorded interaction response. */
@@ -8194,7 +8161,7 @@ var SandboxPromptTransportCapabilities = class extends SandboxSessionAdmissionCa
8194
8161
  requestEndpoint: explicitReplay ? `/agents/run/${encodeURIComponent(options?.executionId ?? "")}/events?${replaySearch}` : `/agents/run/stream?${PART_TEXT}=${PART_TEXT_SUFFIX}`,
8195
8162
  traceHeaders: options?.traceId ? { [TRACE_ID_HEADER]: options.traceId } : {},
8196
8163
  lastEventId: options?.lastEventId,
8197
- executionId: options?.executionId,
8164
+ executionId: options?.executionId ?? `exec-${crypto.randomUUID()}`,
8198
8165
  sessionId: options?.sessionId,
8199
8166
  receivedTerminal: false,
8200
8167
  reconnectWindowMs: resolveReconnectWindowMs(options?.reconnectWindowMs),
@@ -8209,7 +8176,8 @@ var SandboxPromptTransportCapabilities = class extends SandboxSessionAdmissionCa
8209
8176
  path: `/v1/sandboxes/${encodeURIComponent(this.id)}/runtime${state.requestEndpoint}`
8210
8177
  }, response.headers);
8211
8178
  if (!isProfileNotCachedError(responseError)) await state.reconcileRuntimeRefusal(response.status);
8212
- if (!state.explicitReplay) throw responseError;
8179
+ const landed = !state.options?.executionId && responseError.code === "EXECUTION_ALREADY_EXISTS";
8180
+ if (!state.explicitReplay && !landed) throw responseError;
8213
8181
  state.lastReplayStatus = response.status;
8214
8182
  } else try {
8215
8183
  yield* this.readPromptStream(response, state, false);
@@ -8238,7 +8206,8 @@ var SandboxPromptTransportCapabilities = class extends SandboxSessionAdmissionCa
8238
8206
  signal: state.streamSignal,
8239
8207
  headers: {
8240
8208
  ...state.traceHeaders,
8241
- ...state.options?.executionId ? { "X-Execution-ID": state.options.executionId } : {},
8209
+ "X-Execution-ID": state.executionId,
8210
+ ...state.options?.executionId ? {} : { "Idempotency-Key": state.executionId },
8242
8211
  ...state.options?.detach ? { "x-agent-detach": "true" } : {}
8243
8212
  },
8244
8213
  body: JSON.stringify({
@@ -8267,8 +8236,10 @@ var SandboxPromptTransportCapabilities = class extends SandboxSessionAdmissionCa
8267
8236
  method: request.method,
8268
8237
  path: `/v1/sandboxes/${encodeURIComponent(this.id)}/runtime${state.requestEndpoint}`
8269
8238
  }, response.headers);
8270
- if (!isRetryableCredentialRefusal(refusal)) break;
8271
- await abortableSleep(refusal.retryAfterMs ?? 1e3, state.streamSignal);
8239
+ if (!isRetryableCredentialRefusal(refusal) || !await awaitSdkResend(attempt, {
8240
+ retryAfterMs: refusal.retryAfterMs ?? 1e3,
8241
+ signal: state.streamSignal
8242
+ })) break;
8272
8243
  response = await this.runtimeFetch(state.requestEndpoint, request, state.internal?.forceFullProfile ? { skipProfileReference: true } : void 0);
8273
8244
  }
8274
8245
  } catch (err) {
@@ -8283,7 +8254,7 @@ var SandboxPromptTransportCapabilities = class extends SandboxSessionAdmissionCa
8283
8254
  type: "done",
8284
8255
  data: {
8285
8256
  ...state.sessionId ? { sessionId: state.sessionId } : {},
8286
- ...state.executionId ? { executionId: state.executionId } : {},
8257
+ executionId: state.executionId,
8287
8258
  status: end.status,
8288
8259
  ...end.status === "completed" ? { outcome: { type: "completed" } } : {},
8289
8260
  ...end.code ? { code: end.code } : {},
@@ -8313,10 +8284,6 @@ var SandboxPromptTransportCapabilities = class extends SandboxSessionAdmissionCa
8313
8284
  }
8314
8285
  }
8315
8286
  async *rejoinPromptStream(state) {
8316
- if (!state.executionId) throw new NetworkError("Prompt stream dropped before execution.started; cannot reconnect", {
8317
- endpoint: "/agents/run/stream",
8318
- origin: "runtime"
8319
- });
8320
8287
  const resumeExecutionId = state.executionId;
8321
8288
  const interrupted = (reason, detail, cause) => {
8322
8289
  return new StreamInterruptedError(`Prompt stream for execution ${resumeExecutionId} ended before a terminal event and could not be rejoined (${detail}); the execution's outcome is unknown${state.lastReplayStatus !== void 0 ? `; last replay status ${state.lastReplayStatus}` : ""}${state.lastExecutionStatus ? `; last known execution status ${state.lastExecutionStatus}` : ""}`, {
@@ -8340,7 +8307,7 @@ var SandboxPromptTransportCapabilities = class extends SandboxSessionAdmissionCa
8340
8307
  const outageMs = Date.now() - outageStartedAt;
8341
8308
  if (outageMs >= state.reconnectWindowMs) throw interrupted("reconnect-window-elapsed", `unreachable for ${outageMs}ms of a ${state.reconnectWindowMs}ms reconnect window`);
8342
8309
  consecutiveFailures += 1;
8343
- await waitForReconnect(Math.min(reconnectDelayMs(consecutiveFailures), state.reconnectWindowMs - outageMs), state.streamSignal);
8310
+ await abortableSleep(Math.min(reconnectDelayMs(consecutiveFailures), state.reconnectWindowMs - outageMs), state.streamSignal).catch(() => {});
8344
8311
  state.throwIfTimedOut();
8345
8312
  if (state.options?.signal?.aborted || state.streamSignal?.aborted) return;
8346
8313
  let connectedAt;
@@ -8860,7 +8827,7 @@ var SandboxInteractiveCapabilities = class extends SandboxPromptCapabilities {
8860
8827
  var SandboxSessionEvidenceCapabilities = class extends SandboxInteractiveCapabilities {
8861
8828
  /** @internal — invoked before the sandbox is deleted. */
8862
8829
  async _sessionExportRawEvidence(id, destination, options) {
8863
- const { exportRawEvidenceDirectory } = await import("./raw-evidence-archive-C5H8BaHr.js");
8830
+ const { exportRawEvidenceDirectory } = await import("./raw-evidence-archive-DrgeV9_0.js");
8864
8831
  await this.ensureRunning();
8865
8832
  await this.refresh();
8866
8833
  return exportRawEvidenceDirectory((signal, archiveId, cancel) => this.runtimeFetch(`/agents/sessions/${encodeURIComponent(id)}/raw-evidence/archive?${new URLSearchParams([
@@ -8891,7 +8858,7 @@ var SandboxSessionEvidenceCapabilities = class extends SandboxInteractiveCapabil
8891
8858
  * and the byte and file bounds are verified before the directory appears.
8892
8859
  */
8893
8860
  async exportRawEvidence(destination, options) {
8894
- const { exportRawEvidenceDirectory } = await import("./raw-evidence-archive-C5H8BaHr.js");
8861
+ const { exportRawEvidenceDirectory } = await import("./raw-evidence-archive-DrgeV9_0.js");
8895
8862
  await this.ensureRunning();
8896
8863
  await this.refresh();
8897
8864
  return exportRawEvidenceDirectory((signal, archiveId, cancel) => this.runtimeFetch(`/agents/raw-evidence/archive?${new URLSearchParams({
@@ -10057,7 +10024,7 @@ var SandboxSnapshotCapabilities = class extends SandboxTurnCapabilities {
10057
10024
  const error = await parseResponseError(response);
10058
10025
  const remainingMs = budgetMs - (Date.now() - started);
10059
10026
  if (!isRetainedHold(error, reason) || remainingMs <= 0) throw error;
10060
- await new Promise((resolve) => setTimeout(resolve, Math.min(error.retryAfterMs ?? SNAPSHOT_DELETE_RETAINED_RETRY_MS, CREATE_RETRY_MAX_DELAY_MS, remainingMs)));
10027
+ await abortableSleep(Math.min(error.retryAfterMs ?? SNAPSHOT_DELETE_RETAINED_RETRY_MS, CREATE_RETRY_MAX_DELAY_MS, remainingMs));
10061
10028
  heldUntil = Date.now();
10062
10029
  }
10063
10030
  const body = await response.json().catch(() => ({}));
@@ -10133,7 +10100,7 @@ var SandboxSnapshotCapabilities = class extends SandboxTurnCapabilities {
10133
10100
  return await this.waitForSnapshotVisible(snapshotId, status.completedAt ? { createdAt: new Date(status.completedAt) } : void 0);
10134
10101
  }
10135
10102
  const heldMs = Date.now() - polledAt;
10136
- if (heldMs < SNAPSHOT_RESTORE_POLL_FLOOR_MS) await this.sleep(SNAPSHOT_RESTORE_POLL_FLOOR_MS - heldMs);
10103
+ if (heldMs < SNAPSHOT_RESTORE_POLL_FLOOR_MS) await abortableSleep(SNAPSHOT_RESTORE_POLL_FLOOR_MS - heldMs);
10137
10104
  polledAt = Date.now();
10138
10105
  status = await readResponseJson(await state(this).client.fetch(`/v1/sandboxes/${this.id}/snapshots/jobs/${encodeURIComponent(accepted.jobId)}?waitMs=${SNAPSHOT_RESTORE_HOLD_MS}`));
10139
10106
  }
@@ -10156,7 +10123,7 @@ var SandboxSnapshotCapabilities = class extends SandboxTurnCapabilities {
10156
10123
  if (!isTransientSnapshotVisibilityError(error)) throw error;
10157
10124
  lastError = error;
10158
10125
  }
10159
- await this.sleep(SNAPSHOT_VISIBILITY_POLL_INTERVAL_MS);
10126
+ await abortableSleep(SNAPSHOT_VISIBILITY_POLL_INTERVAL_MS);
10160
10127
  }
10161
10128
  if (fallback) return {
10162
10129
  snapshotId,
@@ -10308,7 +10275,7 @@ var SandboxBranchCapabilities = class extends SandboxSnapshotCapabilities {
10308
10275
  const record = await this.getRollout(rolloutId);
10309
10276
  if (record.status !== "running") return record;
10310
10277
  if (Date.now() - startTime > timeoutMs) throw new TimeoutError(`Timed out waiting for rollout ${rolloutId} to settle`, { timeoutMs });
10311
- await this.sleep(pollIntervalMs);
10278
+ await abortableSleep(pollIntervalMs);
10312
10279
  }
10313
10280
  }
10314
10281
  };
@@ -11023,7 +10990,7 @@ var SandboxFilesystemOperations = class extends DeclaredFilesystemOperations {
11023
10990
  totalBytes: size,
11024
10991
  percentage: 0
11025
10992
  });
11026
- const { uploadChunkedFromFile } = await import("./chunked-upload-file-5GlXGjhY.js");
10993
+ const { uploadChunkedFromFile } = await import("./chunked-upload-file-D3YxQdAl.js");
11027
10994
  await uploadChunkedFromFile({ fetch: (path, init) => this.host.runtimeFetch(path, init) }, remotePath, localPath, {
11028
10995
  mode: options?.permissions,
11029
10996
  onProgress: options?.onProgress ? (progress) => {
@@ -11931,4 +11898,4 @@ var SandboxInstance = class SandboxInstance extends SandboxEgressCapabilities {
11931
11898
  }
11932
11899
  };
11933
11900
  //#endregion
11934
- export { normalizeSandboxCreateReceipt as A, CAPACITY_ETA_WAIT_MAX_MS as B, SandboxOperationFailedError as C, validateDeferredProfileFileMounts as D, splitInlineProfileSkills as E, normalizeConnection as F, extendableDeadline as G, DEFAULT_GPU_CREATE_TIMEOUT_MS as H, normalizeEgressPolicyFields as I, isDeployWindowCreateError as J, generateIdempotencyKey as K, normalizeProxySecretReceipt as L, readFilesystemIncarnationTuple as M, dateOf as N, isRetryableProfileFileMaterializeFailure as O, parseLifecycleTimes as P, normalizeSandboxShape as R, SandboxOperation as S, splitInlineProfileFileMounts as T, DEPLOY_WINDOW_RETRY_MS as U, DEFAULT_CREATE_TIMEOUT_MS as V, createRetryDelayMs as W, isRetryableCreateError as X, isRateLimitCreateError as Y, canonicalAgentProfileDigest as Z, collectAgentFinalMessageText as _, buildTraceExportPayload as a, isToolBearingEvent as b, toOtelJson as c, sandboxLedgerUsd as d, InteractiveSessionHandle as f, applySandboxEventText as g, createInteractiveTerminalSession as h, MAX_EGRESS_DENIALS_LIMIT as i, normalizeStartupDiagnostics as j, normalizeCaptureProof as k, SandboxTaskSession as l, createInteractiveTerminalCapture as m, createSandboxInstanceFromResponse as n, exportTraceBundle as o, InteractiveTerminalFrameLog as p, isCapacityShortageCreateError as q, WorkspaceImages as r, otelTraceIdForTangleTrace as s, SandboxInstance as t, SandboxSession as u, collectAgentResponseText as v, materializeProfileFileMounts as w, ManagedProcessClient as x, getSandboxEventText as y, CAPACITY_ETA_MARGIN_MS as z };
11901
+ export { normalizeSandboxCreateReceipt as A, CAPACITY_ETA_WAIT_MAX_MS as B, SandboxOperationFailedError as C, validateDeferredProfileFileMounts as D, splitInlineProfileSkills as E, normalizeConnection as F, createRetryDelayMs as G, DEFAULT_GPU_CREATE_TIMEOUT_MS as H, normalizeEgressPolicyFields as I, isCapacityShortageCreateError as J, extendableDeadline as K, normalizeProxySecretReceipt as L, readFilesystemIncarnationTuple as M, dateOf as N, isRetryableProfileFileMaterializeFailure as O, parseLifecycleTimes as P, canonicalAgentProfileDigest as Q, normalizeSandboxShape as R, SandboxOperation as S, splitInlineProfileFileMounts as T, DEPLOY_WINDOW_RETRY_MS as U, DEFAULT_CREATE_TIMEOUT_MS as V, awaitCreateResend as W, isRateLimitCreateError as X, isDeployWindowCreateError as Y, isRetryableCreateError as Z, collectAgentFinalMessageText as _, buildTraceExportPayload as a, isToolBearingEvent as b, toOtelJson as c, sandboxLedgerUsd as d, InteractiveSessionHandle as f, applySandboxEventText as g, createInteractiveTerminalSession as h, MAX_EGRESS_DENIALS_LIMIT as i, normalizeStartupDiagnostics as j, normalizeCaptureProof as k, SandboxTaskSession as l, createInteractiveTerminalCapture as m, createSandboxInstanceFromResponse as n, exportTraceBundle as o, InteractiveTerminalFrameLog as p, generateIdempotencyKey as q, WorkspaceImages as r, otelTraceIdForTangleTrace as s, SandboxInstance as t, SandboxSession as u, collectAgentResponseText as v, materializeProfileFileMounts as w, ManagedProcessClient as x, getSandboxEventText as y, CAPACITY_ETA_MARGIN_MS as z };
@@ -1,4 +1,4 @@
1
- import { ft as SeatOwnerTransport } from "./client-Bp3Gqf0e.js";
1
+ import { ft as SeatOwnerTransport } from "./client-DiLd0XGB.js";
2
2
 
3
3
  //#region src/select-seat-command.d.ts
4
4
  /** Public reply bound; the owner prints one metadata object. */
@@ -1,6 +1,6 @@
1
- import { r as combineAbortSignals } from "../abort-signal-Cu4F2VVz.js";
2
- import "../sidecar-proxy-error-DTJbOAWL.js";
3
- import { t as parseSSEStream } from "../sse-parser-DXRUx6gh.js";
1
+ import { n as combineAbortSignals } from "../abort-signal-BbJTt2QJ.js";
2
+ import "../sidecar-proxy-error-DpBLxIof.js";
3
+ import { t as parseSSEStream } from "../sse-parser-DOCszo1K.js";
4
4
  import { PART_TEXT, PART_TEXT_SUFFIX } from "@tangle-network/agent-core/sse";
5
5
  //#region ../../../packages/runtime-contracts/dist/session-gateway.js
6
6
  /**
@@ -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-BVEpMspL.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-DyFU9hy7.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,2 +1,2 @@
1
- import { _ as SandboxCreateParamTypes, a as parseQuoteResponse, c as OperatorSession, d as TANGLE_JOBS_CONTRACT, f as ITangleJobsAbi, g as JsonResponseParamTypes, h as JOB_SANDBOX_DELETE, i as jobQuoteDigest, l as OperatorSessionError, m as JOB_SANDBOX_CREATE, n as fetchQuote, o as validateQuote, p as AgentSandboxBlueprintAbi, r as inputsHashOf, s as BlueprintSandboxClient, t as QuoteError, u as TANGLE_CHAIN_ID, v as SandboxCreateResponseParamTypes, y as SandboxIdParamTypes } from "../tangle-B-Sv_5XW.js";
1
+ import { _ as SandboxCreateParamTypes, a as parseQuoteResponse, c as OperatorSession, d as TANGLE_JOBS_CONTRACT, f as ITangleJobsAbi, g as JsonResponseParamTypes, h as JOB_SANDBOX_DELETE, i as jobQuoteDigest, l as OperatorSessionError, m as JOB_SANDBOX_CREATE, n as fetchQuote, o as validateQuote, p as AgentSandboxBlueprintAbi, r as inputsHashOf, s as BlueprintSandboxClient, t as QuoteError, u as TANGLE_CHAIN_ID, v as SandboxCreateResponseParamTypes, y as SandboxIdParamTypes } from "../tangle-BPDYjDpX.js";
2
2
  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 };