@tangle-network/sandbox 1.0.207 → 1.0.209

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 (73) hide show
  1. package/README.md +1 -1
  2. package/dist/abort-signal-C0_9B1Hm.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 +2 -2
  7. package/dist/{agent-run-outcome-1NHcTtoo.d.ts → agent-run-outcome-DdYlpMUM.d.ts} +2 -2
  8. package/dist/api-request-DJKK0J5o.js +183 -0
  9. package/dist/auth/index.d.ts +2 -2
  10. package/dist/auth/index.js +2 -2
  11. package/dist/{browser-interactive-control-controller-7wyaNSvi.d.ts → browser-interactive-control-controller-BGxBBCcH.d.ts} +1 -1
  12. package/dist/{browser-interactive-control-controller-BYbNLahH.js → browser-interactive-control-controller-uNdUXYAZ.js} +1 -1
  13. package/dist/{chunked-upload-BTdDxWFj.js → chunked-upload-C_8f9f5N.js} +3 -2
  14. package/dist/{chunked-upload-file-5GlXGjhY.js → chunked-upload-file-Cpz3hZns.js} +2 -2
  15. package/dist/cli-auth-bundle-jlkQA2D8.js +2 -0
  16. package/dist/{client-_77vseDK.js → client-CUgcOsHm.js} +20 -26
  17. package/dist/{client-Bp3Gqf0e.d.ts → client-x02QUDSJ.d.ts} +5 -5
  18. package/dist/collaboration/index.d.ts +1 -1
  19. package/dist/collaboration/index.js +1 -1
  20. package/dist/{core-7rGEb0lF.js → core-Dzkfkveq.js} +4 -4
  21. package/dist/core.d.ts +6 -6
  22. package/dist/core.js +4 -4
  23. package/dist/{direct-http2-Bqtn2jg3.js → direct-http2-Bojg02xf.js} +1 -1
  24. package/dist/{index-BVEpMspL.d.ts → index-CfUk7Yhe.d.ts} +6 -6
  25. package/dist/index.d.ts +11 -11
  26. package/dist/index.js +10 -10
  27. package/dist/intelligence/index.js +2 -2
  28. package/dist/interactive-control.d.ts +1 -1
  29. package/dist/interactive-control.js +1 -1
  30. package/dist/{interactive-controller-B09YfFqP.js → interactive-controller-CGiztnGI.js} +5 -4
  31. package/dist/{interactive-controller-DuyS5n9z.d.ts → interactive-controller-CGlW4Qfp.d.ts} +3 -3
  32. package/dist/lib/prepared-evidence.js +1 -1
  33. package/dist/lib/prepared-process.js +1 -1
  34. package/dist/{lines-DGke3URt.d.ts → lines-fyzHzsrx.d.ts} +1 -1
  35. package/dist/lines.d.ts +1 -1
  36. package/dist/lines.js +1 -1
  37. package/dist/{local-cli-auth-CPS9yuTc.js → local-cli-auth-CWWDeQ7N.js} +1 -1
  38. package/dist/{mcp-local-BQMKIzSk.js → mcp-local-lPwHM1Zr.js} +4 -4
  39. package/dist/{prepared-evidence-4prvV0YK.js → prepared-evidence-COEcexVv.js} +2 -12
  40. package/dist/{prepared-process-BSpZXDDw.js → prepared-process-CS919ksO.js} +2 -14
  41. package/dist/{preview-Din4zRB-.d.ts → preview-Bdwy9Rsw.d.ts} +3 -3
  42. package/dist/{public-templates-k5rHh7Up.d.ts → public-templates-DCVYfNbP.d.ts} +2 -2
  43. package/dist/public-templates.d.ts +1 -1
  44. package/dist/{raw-evidence-archive-C5H8BaHr.js → raw-evidence-archive-Zc02SC0U.js} +2 -2
  45. package/dist/runtime.d.ts +5 -5
  46. package/dist/runtime.js +4 -4
  47. package/dist/{sandbox-BQ_u_Fjy.js → sandbox-BsAn3XVC.js} +43 -78
  48. package/dist/{secp256k1-Cbp9tbkX.js → secp256k1-CZWrpqxW.js} +1 -1
  49. package/dist/select-seat-command.d.ts +1 -1
  50. package/dist/session-gateway/index.js +3 -3
  51. package/dist/tangle/index.d.ts +1 -1
  52. package/dist/tangle/index.js +1 -1
  53. package/dist/{tangle-B-Sv_5XW.js → tangle-DyLXpfYy.js} +3 -3
  54. package/dist/{types-BVcWpKvF.d.ts → types-f5nWlpOq.d.ts} +2 -2
  55. package/package.json +6 -6
  56. package/dist/abort-signal-Cu4F2VVz.js +0 -62
  57. package/dist/api-request-wig0wgKC.js +0 -92
  58. package/dist/cli-auth-bundle-CMJWI99l.js +0 -2
  59. package/dist/response-rewrap-Cjoxh2wZ.js +0 -28
  60. /package/dist/{cli-auth-bundle-C6DtK7GX-BbbiAn-Z.js → cli-auth-bundle-C6DtK7GX-DJH6vfkJ.js} +0 -0
  61. /package/dist/{cli-auth-bundle-Wg3x2hd2.d.ts → cli-auth-bundle-COQ25k3d.d.ts} +0 -0
  62. /package/dist/{collaboration-BgSGO1KD.js → collaboration-BAx-A7gz.js} +0 -0
  63. /package/dist/{file-download-DrzpcvdM.js → file-download-BYaUfv8d.js} +0 -0
  64. /package/dist/{file-transfer-Cr9Ossea.js → file-transfer-BSe4ayU9.js} +0 -0
  65. /package/dist/{index-YbAo-so_.d.ts → index-Dqcr9p97.d.ts} +0 -0
  66. /package/dist/{index-CDtEPygc.d.ts → index-Dslyq85a.d.ts} +0 -0
  67. /package/dist/{keep-alive-fetch-C2lFwrMA.js → keep-alive-fetch-BbSFbRCd.js} +0 -0
  68. /package/dist/{lines-DHOIUO-t.js → lines-D4kRkYfv.js} +0 -0
  69. /package/dist/{preview-operations-B3TTvqlm.js → preview-operations-BvgwYaoL.js} +0 -0
  70. /package/dist/{sidecar-proxy-error-DTJbOAWL.js → sidecar-proxy-error-5DpLmHeN.js} +0 -0
  71. /package/dist/{sse-parser-DXRUx6gh.js → sse-parser-CV6Jp-Am.js} +0 -0
  72. /package/dist/{terminal-stream-types-DeH8FF0d.d.ts → terminal-stream-types-DxFpAmqp.d.ts} +0 -0
  73. /package/dist/{utils-CK-x8vXj.js → utils-vaFoyyiO.js} +0 -0
@@ -1,21 +1,21 @@
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-CGiztnGI.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-uNdUXYAZ.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";
15
- import { a as isBackendType, r as cliAuthReferenceSchema } from "./cli-auth-bundle-C6DtK7GX-BbbiAn-Z.js";
16
- import "./cli-auth-bundle-CMJWI99l.js";
17
- import { n as SandboxLines } from "./lines-DHOIUO-t.js";
18
- import { t as downloadFile } from "./file-download-DrzpcvdM.js";
7
+ import { a as isReplayableBody, o as rewrapResponse, r as abortableSleep, t as IDEMPOTENT_METHODS } from "./api-request-DJKK0J5o.js";
8
+ import { n as combineAbortSignals, t as awaitWithAbort } from "./abort-signal-C0_9B1Hm.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 { n as fetchWithKeepAlive, t as emitTiming } from "./keep-alive-fetch-BbSFbRCd.js";
11
+ import { t as SIDECAR_PROXY_ERROR_HEADER } from "./sidecar-proxy-error-5DpLmHeN.js";
12
+ import { t as parseSSEStream } from "./sse-parser-CV6Jp-Am.js";
13
+ import { s as uploadChunked } from "./chunked-upload-C_8f9f5N.js";
14
+ import { t as runPreparedProcess } from "./prepared-process-CS919ksO.js";
15
+ import { a as isBackendType, r as cliAuthReferenceSchema } from "./cli-auth-bundle-C6DtK7GX-DJH6vfkJ.js";
16
+ import "./cli-auth-bundle-jlkQA2D8.js";
17
+ import { n as SandboxLines } from "./lines-D4kRkYfv.js";
18
+ import { t as downloadFile } from "./file-download-BYaUfv8d.js";
19
19
  import { z } from "zod";
20
20
  import { createHash } from "node:crypto";
21
21
  import { constants } from "node:fs";
@@ -347,20 +347,18 @@ function generateIdempotencyKey() {
347
347
  }
348
348
  throw new Error("idempotency key generation requires global crypto");
349
349
  }
350
- const FORK_OUTAGE_CODES = new Set(["UNAVAILABLE", "STORAGE_UNAVAILABLE"]);
351
350
  /**
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.
351
+ * A fork re-POSTs the refusals a create waits out: none started a fan-out,
352
+ * and the keyed re-POST joins one that did. The transport already resends
353
+ * the keyed POST through a gateway 502, 503 or 504.
355
354
  */
356
355
  async function retryForkRefusal(post) {
357
356
  const deadline = Date.now() + DEPLOY_WINDOW_RETRY_MS;
358
357
  for (let failed = 1;; failed++) try {
359
358
  return await post();
360
359
  } 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
360
  const delayMs = Math.max(createRetryDelayMs(cause, failed), 250);
363
- if (!retryable || delayMs >= deadline - Date.now()) throw cause;
361
+ if (!isDeployWindowCreateError(cause) || delayMs >= deadline - Date.now()) throw cause;
364
362
  await abortableSleep(delayMs);
365
363
  }
366
364
  }
@@ -2789,14 +2787,6 @@ const READ_METHODS = new Set([
2789
2787
  function apiOwnedRuntimeRoute(method, path) {
2790
2788
  return !READ_METHODS.has(method) && /^(?:agents|session)(?:\/|$)/.test(path);
2791
2789
  }
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
2790
  /** POST routes that only read: the body carries the query, not a change. */
2801
2791
  const READ_ONLY_POSTS = new Set([
2802
2792
  "files/read",
@@ -2807,12 +2797,6 @@ const READ_ONLY_POSTS = new Set([
2807
2797
  function isReplaySafe(method, path) {
2808
2798
  return IDEMPOTENT_METHODS.has(method) || method === "POST" && READ_ONLY_POSTS.has(path);
2809
2799
  }
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
2800
  /**
2817
2801
  * Host-agent refusals written before it forwards anything to the sidecar
2818
2802
  * (apps/host-agent/src/routes/runtime-sidecar-proxy-request.ts): the box is
@@ -3072,7 +3056,7 @@ var DirectRuntimeHttpClient = class {
3072
3056
  };
3073
3057
  if (!route) throw new NetworkError("Direct runtime route was withdrawn");
3074
3058
  if ((route.useHost || route.useExec) && canUseNodeHttp2()) {
3075
- const { fetchDirectHttp2 } = await import("./direct-http2-Bqtn2jg3.js");
3059
+ const { fetchDirectHttp2 } = await import("./direct-http2-Bojg02xf.js");
3076
3060
  return fetchDirectHttp2(route.url, request, timing);
3077
3061
  }
3078
3062
  return fetchWithKeepAlive(route.url, request, timing);
@@ -3414,7 +3398,6 @@ const PROFILE_FILE_MOUNT_RETRY_MAX_MS = 2e3;
3414
3398
  * platform restart, which the caller is better told about.
3415
3399
  */
3416
3400
  const PROFILE_FILE_MOUNT_WRITE_RETRY_BUDGET_MS = 1e4;
3417
- const waitForProfileFileMount = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
3418
3401
  var ProfileFileMountExecTimeoutError = class extends Error {
3419
3402
  constructor(timeoutMs) {
3420
3403
  super(`exec exceeded ${timeoutMs}ms`);
@@ -3584,7 +3567,7 @@ async function writeBatchRidingOutUndecided(write, maxRetries) {
3584
3567
  if (!(retryWhen(err) && (err instanceof NetworkError || err.status >= 502 && !(err instanceof TimeoutError))) || attempt >= maxRetries) throw err;
3585
3568
  const waitMs = retryAfterMs(err) ?? Math.min(250 * 2 ** attempt, 2e3);
3586
3569
  if (Date.now() - startedAt + waitMs >= PROFILE_FILE_MOUNT_WRITE_RETRY_BUDGET_MS) throw err;
3587
- await waitForProfileFileMount(waitMs);
3570
+ await abortableSleep(waitMs);
3588
3571
  }
3589
3572
  }
3590
3573
  //#endregion
@@ -3794,7 +3777,7 @@ async function execProfileFileMount(box, mount, content, options, execState) {
3794
3777
  const homeGuard = path.startsWith("~/") ? `[ -n "$HOME" ] || { echo ${shellSingleQuote(`materializeProfileFileMounts: HOME is unset for ${path}`)} >&2; exit 1; }; ` : "";
3795
3778
  const run = async (cmd) => {
3796
3779
  for (let attempt = 0;; attempt++) {
3797
- if (execState.started && options.paceMs > 0) await waitForProfileFileMount(options.paceMs);
3780
+ if (execState.started && options.paceMs > 0) await abortableSleep(options.paceMs);
3798
3781
  execState.started = true;
3799
3782
  try {
3800
3783
  return await execWithTimeout(box, cmd, options.execTimeoutMs);
@@ -3802,7 +3785,7 @@ async function execProfileFileMount(box, mount, content, options, execState) {
3802
3785
  const { retryable, retryAfterMs: retryAfter } = transientExecError(err);
3803
3786
  if (retryable && attempt < maxRetries) {
3804
3787
  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));
3788
+ await abortableSleep(Math.min(retryAfter ?? backoff, PROFILE_FILE_MOUNT_RETRY_MAX_MS));
3806
3789
  continue;
3807
3790
  }
3808
3791
  throw new ProfileFileMaterializeError(`materializeProfileFileMounts: exec failed for ${path}`, { cause: err });
@@ -4390,7 +4373,7 @@ var SandboxOperation = class SandboxOperation {
4390
4373
  while (!info || !isTerminalOperation(info)) {
4391
4374
  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
4375
  signal?.throwIfAborted();
4393
- if (delayMs > 0) await delayUntilAborted(delayMs, signal);
4376
+ if (delayMs > 0) await abortableSleep(delayMs, signal);
4394
4377
  capMs = Math.min(Math.max(capMs * 2, FIRST_POLL_MS), MAX_POLL_MS);
4395
4378
  try {
4396
4379
  info = await this.refresh({ signal });
@@ -5202,7 +5185,7 @@ var SandboxPreviewCapabilities = class extends SandboxGpuCapabilities {
5202
5185
  endpoint
5203
5186
  });
5204
5187
  try {
5205
- await delayUntilAborted(Math.min(pollIntervalMs, remainingAfterCheckMs), options?.signal);
5188
+ await abortableSleep(Math.min(pollIntervalMs, remainingAfterCheckMs), options?.signal);
5206
5189
  } catch {
5207
5190
  throw new TimeoutError("Aborted", {
5208
5191
  timeoutMs: 0,
@@ -5388,7 +5371,7 @@ var SandboxLifecycleEventsCapabilities = class extends SandboxPreviewCapabilitie
5388
5371
  if (this.hasReachedWaitTarget(statuses)) return;
5389
5372
  if (this.status === "failed") throw new StateError(this.error ?? "Sandbox failed", { currentState: this.status });
5390
5373
  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);
5374
+ await abortableSleep(pollIntervalMs, signal).catch(rethrowWaitError);
5392
5375
  }
5393
5376
  }
5394
5377
  /**
@@ -5552,7 +5535,10 @@ var SandboxLifecycleCapabilities = class extends SandboxLifecycleEventsCapabilit
5552
5535
  response = await withLifecycleConflictRetry(() => state(this).client.fetch(path, {
5553
5536
  method: "DELETE",
5554
5537
  ...options?.signal ? { signal: options.signal } : {},
5555
- ...options?.wait === false && options.idempotencyKey ? { headers: { "Idempotency-Key": options.idempotencyKey } } : {}
5538
+ headers: {
5539
+ "x-no-retry": "1",
5540
+ ...options?.wait === false && options.idempotencyKey ? { "Idempotency-Key": options.idempotencyKey } : {}
5541
+ }
5556
5542
  }), options, (error) => {
5557
5543
  const retry = isDeleteRetry(error);
5558
5544
  retried ||= retry;
@@ -5636,7 +5622,7 @@ async function withLifecycleConflictRetry(run, options, retry = isLifecycleConfl
5636
5622
  return response;
5637
5623
  } catch (error) {
5638
5624
  if (!retry(error) || attempt >= LIFECYCLE_CONFLICT_MAX_ATTEMPTS || options?.signal?.aborted) throw error;
5639
- await delayUntilAborted(lifecycleConflictDelayMs(error, attempt), options?.signal);
5625
+ await abortableSleep(lifecycleConflictDelayMs(error, attempt), options?.signal);
5640
5626
  }
5641
5627
  }
5642
5628
  /** The largest delay `setTimeout` holds: past this it overflows its 32-bit
@@ -7132,7 +7118,7 @@ var SandboxFileWriteCapabilities = class extends SandboxFileOperations {
7132
7118
  async writeManySequential(files, paceMs, maxRetries) {
7133
7119
  let started = false;
7134
7120
  for (const file of files) for (let attempt = 0;; attempt++) {
7135
- if (started && paceMs > 0) await delay(paceMs);
7121
+ if (started && paceMs > 0) await abortableSleep(paceMs);
7136
7122
  started = true;
7137
7123
  try {
7138
7124
  await this.writeFileRequest(file.path, file.content, {
@@ -7145,7 +7131,7 @@ var SandboxFileWriteCapabilities = class extends SandboxFileOperations {
7145
7131
  } catch (err) {
7146
7132
  if (isTransientWrite(err) && attempt < maxRetries) {
7147
7133
  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);
7134
+ await abortableSleep((err instanceof SandboxError ? err.retryAfterMs : void 0) ?? backoff);
7149
7135
  continue;
7150
7136
  }
7151
7137
  throw err;
@@ -7167,7 +7153,7 @@ var SandboxFileWriteCapabilities = class extends SandboxFileOperations {
7167
7153
  }
7168
7154
  const batches = splitWriteManyBatches(files.map(toWriteManyWireFile));
7169
7155
  for (const [index, batch] of batches.entries()) {
7170
- if (index > 0 && paceMs > 0) await delay(paceMs);
7156
+ if (index > 0 && paceMs > 0) await abortableSleep(paceMs);
7171
7157
  await this.writeBatchRequest(batch.files, batch.body);
7172
7158
  }
7173
7159
  }
@@ -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({
@@ -8283,7 +8252,7 @@ var SandboxPromptTransportCapabilities = class extends SandboxSessionAdmissionCa
8283
8252
  type: "done",
8284
8253
  data: {
8285
8254
  ...state.sessionId ? { sessionId: state.sessionId } : {},
8286
- ...state.executionId ? { executionId: state.executionId } : {},
8255
+ executionId: state.executionId,
8287
8256
  status: end.status,
8288
8257
  ...end.status === "completed" ? { outcome: { type: "completed" } } : {},
8289
8258
  ...end.code ? { code: end.code } : {},
@@ -8313,10 +8282,6 @@ var SandboxPromptTransportCapabilities = class extends SandboxSessionAdmissionCa
8313
8282
  }
8314
8283
  }
8315
8284
  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
8285
  const resumeExecutionId = state.executionId;
8321
8286
  const interrupted = (reason, detail, cause) => {
8322
8287
  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 +8305,7 @@ var SandboxPromptTransportCapabilities = class extends SandboxSessionAdmissionCa
8340
8305
  const outageMs = Date.now() - outageStartedAt;
8341
8306
  if (outageMs >= state.reconnectWindowMs) throw interrupted("reconnect-window-elapsed", `unreachable for ${outageMs}ms of a ${state.reconnectWindowMs}ms reconnect window`);
8342
8307
  consecutiveFailures += 1;
8343
- await waitForReconnect(Math.min(reconnectDelayMs(consecutiveFailures), state.reconnectWindowMs - outageMs), state.streamSignal);
8308
+ await abortableSleep(Math.min(reconnectDelayMs(consecutiveFailures), state.reconnectWindowMs - outageMs), state.streamSignal).catch(() => {});
8344
8309
  state.throwIfTimedOut();
8345
8310
  if (state.options?.signal?.aborted || state.streamSignal?.aborted) return;
8346
8311
  let connectedAt;
@@ -8860,7 +8825,7 @@ var SandboxInteractiveCapabilities = class extends SandboxPromptCapabilities {
8860
8825
  var SandboxSessionEvidenceCapabilities = class extends SandboxInteractiveCapabilities {
8861
8826
  /** @internal — invoked before the sandbox is deleted. */
8862
8827
  async _sessionExportRawEvidence(id, destination, options) {
8863
- const { exportRawEvidenceDirectory } = await import("./raw-evidence-archive-C5H8BaHr.js");
8828
+ const { exportRawEvidenceDirectory } = await import("./raw-evidence-archive-Zc02SC0U.js");
8864
8829
  await this.ensureRunning();
8865
8830
  await this.refresh();
8866
8831
  return exportRawEvidenceDirectory((signal, archiveId, cancel) => this.runtimeFetch(`/agents/sessions/${encodeURIComponent(id)}/raw-evidence/archive?${new URLSearchParams([
@@ -8891,7 +8856,7 @@ var SandboxSessionEvidenceCapabilities = class extends SandboxInteractiveCapabil
8891
8856
  * and the byte and file bounds are verified before the directory appears.
8892
8857
  */
8893
8858
  async exportRawEvidence(destination, options) {
8894
- const { exportRawEvidenceDirectory } = await import("./raw-evidence-archive-C5H8BaHr.js");
8859
+ const { exportRawEvidenceDirectory } = await import("./raw-evidence-archive-Zc02SC0U.js");
8895
8860
  await this.ensureRunning();
8896
8861
  await this.refresh();
8897
8862
  return exportRawEvidenceDirectory((signal, archiveId, cancel) => this.runtimeFetch(`/agents/raw-evidence/archive?${new URLSearchParams({
@@ -11023,7 +10988,7 @@ var SandboxFilesystemOperations = class extends DeclaredFilesystemOperations {
11023
10988
  totalBytes: size,
11024
10989
  percentage: 0
11025
10990
  });
11026
- const { uploadChunkedFromFile } = await import("./chunked-upload-file-5GlXGjhY.js");
10991
+ const { uploadChunkedFromFile } = await import("./chunked-upload-file-Cpz3hZns.js");
11027
10992
  await uploadChunkedFromFile({ fetch: (path, init) => this.host.runtimeFetch(path, init) }, remotePath, localPath, {
11028
10993
  mode: options?.permissions,
11029
10994
  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-CK-x8vXj.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-vaFoyyiO.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,4 +1,4 @@
1
- import { ft as SeatOwnerTransport } from "./client-Bp3Gqf0e.js";
1
+ import { ft as SeatOwnerTransport } from "./client-x02QUDSJ.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-C0_9B1Hm.js";
2
+ import "../sidecar-proxy-error-5DpLmHeN.js";
3
+ import { t as parseSSEStream } from "../sse-parser-CV6Jp-Am.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-CfUk7Yhe.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-DyLXpfYy.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 };
@@ -1,6 +1,6 @@
1
- import { M as readFilesystemIncarnationTuple, n as createSandboxInstanceFromResponse } from "./sandbox-BQ_u_Fjy.js";
1
+ import { M as readFilesystemIncarnationTuple, n as createSandboxInstanceFromResponse } from "./sandbox-BsAn3XVC.js";
2
2
  import { a as readResponseJson } from "./errors-CNszZUZ2.js";
3
- 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-CK-x8vXj.js";
3
+ 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-vaFoyyiO.js";
4
4
  //#region ../../../packages/runtime-contracts/dist/tangle-blueprint-abi.js
5
5
  /**
6
6
  * Tangle blueprint wire contract shared by the orchestrator's Tangle driver and
@@ -2712,7 +2712,7 @@ function isAddressEqual(a, b) {
2712
2712
  //#region ../../../node_modules/.pnpm/viem@2.57.11_bufferutil@4.1.0_typescript@6.0.3_utf-8-validate@5.0.10_zod@4.6.6/node_modules/viem/_esm/utils/signature/recoverPublicKey.js
2713
2713
  async function recoverPublicKey({ hash, signature }) {
2714
2714
  const hashHex = isHex(hash) ? hash : toHex(hash);
2715
- const { secp256k1 } = await import("./secp256k1-Cbp9tbkX.js");
2715
+ const { secp256k1 } = await import("./secp256k1-CZWrpqxW.js");
2716
2716
  return `0x${(() => {
2717
2717
  if (typeof signature === "object" && "r" in signature && "s" in signature) {
2718
2718
  const { r, s, v, yParity } = signature;
@@ -1,5 +1,5 @@
1
- import { $ as ProxySecretReceipt, At as SandboxCreateReceipt, G as AgentProfileConfidential, L as AgentExactRunControlRef, Q as ReasoningEffort, U as AgentProfile, V as InteractionRequest, W as AgentProfileCapabilities, Z as AgentProfileValidationResult, a as TerminalStreamOptions, b as SandboxSizePreset, g as TerminalReadyInfo, i as TerminalStreamHandlers, s as TerminalStreamToken, t as TerminalAttachTimings, tt as PlanContinuation, x as AgentRuntimeAttachments } from "./terminal-stream-types-DeH8FF0d.js";
2
- import { t as CliAuthReference } from "./cli-auth-bundle-Wg3x2hd2.js";
1
+ import { $ as ProxySecretReceipt, At as SandboxCreateReceipt, G as AgentProfileConfidential, L as AgentExactRunControlRef, Q as ReasoningEffort, U as AgentProfile, V as InteractionRequest, W as AgentProfileCapabilities, Z as AgentProfileValidationResult, a as TerminalStreamOptions, b as SandboxSizePreset, g as TerminalReadyInfo, i as TerminalStreamHandlers, s as TerminalStreamToken, t as TerminalAttachTimings, tt as PlanContinuation, x as AgentRuntimeAttachments } from "./terminal-stream-types-DxFpAmqp.js";
2
+ import { t as CliAuthReference } from "./cli-auth-bundle-COQ25k3d.js";
3
3
  import { z } from "zod";
4
4
  //#region ../../../packages/runtime-contracts/dist/backend-types.d.ts
5
5
  /** This distribution's backend vocabulary. Gemini is only a backing transport, not a direct backend. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/sandbox",
3
- "version": "1.0.207",
3
+ "version": "1.0.209",
4
4
  "description": "Client SDK for the Tangle Sandbox platform - build AI agent applications with dev containers",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -153,15 +153,15 @@
153
153
  "vitest": "^4.1.12",
154
154
  "ws": "^8.22.0",
155
155
  "yjs": "13.6.33",
156
+ "@tangle-network/agent-profile-materialize": "0.27.1",
156
157
  "@products/sandbox-test-utils": "0.0.0",
158
+ "@tangle-network/runtime-contracts": "0.20.0",
157
159
  "@repo/shared": "0.0.0",
158
- "@tangle-network/cli-agent-registry": "0.15.0",
159
- "@tangle-network/agent-profile-materialize": "0.27.1",
160
- "@tangle-network/runtime-contracts": "0.20.0"
160
+ "@tangle-network/cli-agent-registry": "0.15.0"
161
161
  },
162
162
  "tangleRelease": {
163
- "sourceSha": "7a75479c291e178a0f41ba8a33cc2f4aa10e2bce",
164
- "mergedAt": "2026-11-03T22:09:00-08:00"
163
+ "sourceSha": "867fd00805293bc9498b822a4c32133dae1c10b2",
164
+ "mergedAt": "2026-11-03T23:55:33-08:00"
165
165
  },
166
166
  "scripts": {
167
167
  "build": "node scripts/build-dist.mjs",
@@ -1,62 +0,0 @@
1
- //#region src/lib/abort-signal.ts
2
- function combineAbortSignals(signals) {
3
- return AbortSignal.any(signals);
4
- }
5
- /** Resolve after `ms`; reject with the signal's reason the moment it aborts. */
6
- function abortableSleep(ms, signal) {
7
- if (signal?.aborted) return Promise.reject(signal.reason);
8
- if (ms <= 0) return Promise.resolve();
9
- return new Promise((resolve, reject) => {
10
- const timer = setTimeout(() => {
11
- signal?.removeEventListener("abort", onAbort);
12
- resolve();
13
- }, ms);
14
- const onAbort = () => {
15
- clearTimeout(timer);
16
- reject(signal?.reason);
17
- };
18
- signal?.addEventListener("abort", onAbort, { once: true });
19
- });
20
- }
21
- function awaitWithAbort(work, signal) {
22
- if (!signal) return work;
23
- signal.throwIfAborted();
24
- return new Promise((resolve, reject) => {
25
- let settled = false;
26
- const onAbort = () => {
27
- if (settled) return;
28
- settled = true;
29
- signal.removeEventListener("abort", onAbort);
30
- reject(signal.reason ?? new DOMException("The request was aborted", "AbortError"));
31
- };
32
- signal.addEventListener("abort", onAbort, { once: true });
33
- work.then((value) => {
34
- if (settled) return;
35
- settled = true;
36
- signal.removeEventListener("abort", onAbort);
37
- resolve(value);
38
- }, (cause) => {
39
- if (settled) return;
40
- settled = true;
41
- signal.removeEventListener("abort", onAbort);
42
- reject(cause);
43
- });
44
- });
45
- }
46
- const delayUntilAborted = (ms, signal) => new Promise((resolve, reject) => {
47
- if (signal?.aborted) {
48
- reject(signal.reason ?? /* @__PURE__ */ new Error("aborted"));
49
- return;
50
- }
51
- const timer = setTimeout(() => {
52
- signal?.removeEventListener("abort", onAbort);
53
- resolve();
54
- }, ms);
55
- function onAbort() {
56
- clearTimeout(timer);
57
- reject(signal?.reason ?? /* @__PURE__ */ new Error("aborted"));
58
- }
59
- signal?.addEventListener("abort", onAbort, { once: true });
60
- });
61
- //#endregion
62
- export { delayUntilAborted as i, awaitWithAbort as n, combineAbortSignals as r, abortableSleep as t };
@@ -1,92 +0,0 @@
1
- import { t as rewrapResponse } from "./response-rewrap-Cjoxh2wZ.js";
2
- //#region src/lib/api-request.mjs
3
- /** The package version tsdown.config.ts defines; unbuilt source reports 0.0.0. */
4
- const SDK_VERSION = "1.0.207";
5
- function withRequestContextHeaders(response, path, method, body = response.body) {
6
- const headers = new Headers(response.headers);
7
- headers.set("x-tangle-request-path", path);
8
- if (method) headers.set("x-tangle-request-method", method);
9
- return rewrapResponse(response, headers, body);
10
- }
11
- /** The SDK's authenticated raw transport, also shipped with standalone probes. */
12
- async function fetchSandboxApi({ baseUrl, apiKey, timeoutMs = 3e4, signal, fetchImpl = fetch, networkError = (error) => error, timeoutError = () => new DOMException("The operation was aborted due to timeout", "TimeoutError") }, path, options, fetchOptions) {
13
- const url = `${baseUrl.replace(/\/+$/, "")}${path}`;
14
- const requestTimeoutMs = typeof fetchOptions?.timeoutMs === "number" && fetchOptions.timeoutMs > 0 ? fetchOptions.timeoutMs : timeoutMs;
15
- const controller = new AbortController();
16
- const timeoutId = setTimeout(() => controller.abort(), requestTimeoutMs);
17
- timeoutId.unref?.();
18
- const requestSignal = AbortSignal.any([
19
- controller.signal,
20
- ...options?.signal ? [options.signal] : [],
21
- ...signal ? [signal] : []
22
- ]);
23
- let bodyOwnsTimeout = false;
24
- let reading = false;
25
- const failure = (error, network = false) => {
26
- if (!requestSignal.aborted) return network ? networkError(error) : error;
27
- return requestSignal.reason === controller.signal.reason ? timeoutError(requestTimeoutMs) : requestSignal.reason ?? error;
28
- };
29
- try {
30
- const headers = new Headers(options?.headers);
31
- headers.set("Authorization", `Bearer ${apiKey}`);
32
- headers.set("x-sdk-version", SDK_VERSION);
33
- const isFormDataBody = typeof FormData !== "undefined" && options?.body instanceof FormData;
34
- if (!headers.has("Content-Type") && !isFormDataBody) headers.set("Content-Type", "application/json");
35
- const response = await fetchImpl(url, {
36
- ...options,
37
- headers,
38
- signal: requestSignal
39
- });
40
- if (fetchOptions?.read) {
41
- reading = true;
42
- return await fetchOptions.read(withRequestContextHeaders(response, path, options?.method));
43
- }
44
- const mediaType = response.headers.get("content-type")?.split(";", 1)[0]?.trim().toLowerCase();
45
- if (fetchOptions?.bodyDeadline !== false && response.body !== null && (!response.ok || mediaType === "application/json" || mediaType?.endsWith("+json") === true)) {
46
- const reader = response.body.getReader();
47
- let settled = false;
48
- const body = new ReadableStream({
49
- type: "bytes",
50
- async pull(stream) {
51
- try {
52
- const chunk = await reader.read();
53
- if (settled) return;
54
- if (chunk.done) {
55
- settled = true;
56
- clearTimeout(timeoutId);
57
- reader.releaseLock();
58
- stream.close();
59
- stream.byobRequest?.respond(0);
60
- } else stream.enqueue(chunk.value);
61
- } catch (error) {
62
- if (settled) return;
63
- settled = true;
64
- clearTimeout(timeoutId);
65
- reader.releaseLock();
66
- stream.error(failure(error));
67
- }
68
- },
69
- async cancel(reason) {
70
- if (settled) return;
71
- settled = true;
72
- clearTimeout(timeoutId);
73
- try {
74
- await reader.cancel(reason);
75
- } finally {
76
- reader.releaseLock();
77
- }
78
- }
79
- });
80
- const wrapped = withRequestContextHeaders(response, path, options?.method, body);
81
- bodyOwnsTimeout = true;
82
- return wrapped;
83
- }
84
- return withRequestContextHeaders(response, path, options?.method);
85
- } catch (err) {
86
- throw failure(err, !reading);
87
- } finally {
88
- if (!bodyOwnsTimeout) clearTimeout(timeoutId);
89
- }
90
- }
91
- //#endregion
92
- export { fetchSandboxApi as n, SDK_VERSION as t };
@@ -1,2 +0,0 @@
1
- import "./cli-auth-bundle-C6DtK7GX-BbbiAn-Z.js";
2
- export {};
@@ -1,28 +0,0 @@
1
- //#region src/lib/response-rewrap.mjs
2
- /**
3
- * Response wrappers that must outlive the fetch Response they wrap.
4
- *
5
- * Node's fetch (undici) cancels a response body when the Response object that
6
- * fetch returned is garbage collected while its body is still unread. A
7
- * wrapper built with `new Response(original.body, …)` shares that body stream
8
- * but not that lifetime: once the original is collected, the wrapper's body is
9
- * already cancelled and every read throws `TypeError: Body is unusable: Body
10
- * has already been read`. It depends on when the collector runs, so it shows
11
- * up as a rare failure on any call whose body is read after a longer await.
12
- *
13
- * The map holds each original for as long as its wrapper is reachable, so the
14
- * body stays readable. When both are unreachable, undici's own cleanup runs.
15
- */
16
- const originals = /* @__PURE__ */ new WeakMap();
17
- /** A Response retaining `original`'s lifetime, with optional body decoration. */
18
- function rewrapResponse(original, headers, body = original.body) {
19
- const wrapper = new Response(body, {
20
- status: original.status,
21
- statusText: original.statusText,
22
- headers
23
- });
24
- originals.set(wrapper, original);
25
- return wrapper;
26
- }
27
- //#endregion
28
- export { rewrapResponse as t };
File without changes