@tangle-network/sandbox 1.0.200 → 1.0.201

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.
@@ -1,8 +1,8 @@
1
- import { a as TOOL_SPECS, i as ALL_TOOL_SPECS, o as serializeToolResult, r as bindToolSpecs, t as createMcpServer } from "../mcp-local-CgVkpB-P.js";
1
+ import { a as TOOL_SPECS, i as ALL_TOOL_SPECS, o as serializeToolResult, r as bindToolSpecs, t as createMcpServer } from "../mcp-local-_XpeKLfZ.js";
2
2
  import { O as assertCurrentBackendType } from "../interactive-controller-CeMBZkXh.js";
3
- import { t as SandboxInstance } from "../sandbox-Bg6pjpkF.js";
3
+ import { t as SandboxInstance } from "../sandbox-I0I_UQoO.js";
4
4
  import { D as ValidationError, _ as NotFoundError, w as StateError } from "../errors-DKIV20jZ.js";
5
- import { t as Sandbox } from "../client-ByARyP60.js";
5
+ import { t as Sandbox } from "../client-BmHni-Vr.js";
6
6
  import { z } from "zod";
7
7
  //#region src/agent/instances.ts
8
8
  const managers = /* @__PURE__ */ new WeakMap();
@@ -66,7 +66,7 @@ async function servePreviewMcp(request, config) {
66
66
  if (typeof config.authorize !== "function") throw new Error("Preview MCP requires a host authorization callback");
67
67
  const tools = config.tools ?? PREVIEW_TOOLS;
68
68
  if (!tools.length || tools.some((tool) => !PREVIEW_TOOLS.includes(tool))) throw new Error("Preview MCP requires an explicit nonempty preview-only tool grant");
69
- const [{ createMcpServer }, { WebStandardStreamableHTTPServerTransport }] = await Promise.all([import("../mcp-local-CgVkpB-P.js").then((n) => n.n), import("@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js")]);
69
+ const [{ createMcpServer }, { WebStandardStreamableHTTPServerTransport }] = await Promise.all([import("../mcp-local-_XpeKLfZ.js").then((n) => n.n), import("@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js")]);
70
70
  const handle = await createMcpServer(config.box, {
71
71
  name: "tangle-previews",
72
72
  sessionId: config.sessionId,
@@ -1,7 +1,7 @@
1
1
  import { t as rewrapResponse } from "./response-rewrap-Cjoxh2wZ.js";
2
2
  //#region src/lib/api-request.mjs
3
3
  /** The package version tsdown.config.ts defines; unbuilt source reports 0.0.0. */
4
- const SDK_VERSION = "1.0.200";
4
+ const SDK_VERSION = "1.0.201";
5
5
  function withRequestContextHeaders(response, path, method, body = response.body) {
6
6
  const headers = new Headers(response.headers);
7
7
  headers.set("x-tangle-request-path", path);
@@ -1,10 +1,10 @@
1
1
  import { A as normalizeRuntimeBackendConfig, D as applyRequestedModel, E as isBrowserRuntime, H as backendTypeSchema, N as withProfileHarness, O as assertCurrentBackendType, P as withoutCreateOnlyModelFields, S as encodePromptForWire, o as requestInteractiveSessionToken } from "./interactive-controller-CeMBZkXh.js";
2
2
  import { r as agentProfileSchema } from "./profile-schema-C1KpT-wS.js";
3
- import { A as normalizeSandboxCreateReceipt, B as CAPACITY_ETA_WAIT_MAX_MS, D as validateDeferredProfileFileMounts, E as splitInlineProfileSkills, F as normalizeConnection, G as extendableDeadline, I as normalizeEgressPolicyFields, J as isDeployWindowCreateError, K as generateIdempotencyKey, L as normalizeProxySecretReceipt, N as dateOf, O as isRetryableProfileFileMaterializeFailure, P as parseLifecycleTimes, R as normalizeSandboxShape, T as splitInlineProfileFileMounts, U as DEPLOY_WINDOW_RETRY_MS, W as createRetryDelayMs, X as isRetryableCreateError, Y as isRateLimitCreateError, d as sandboxLedgerUsd, j as normalizeStartupDiagnostics, k as normalizeCaptureProof, n as createSandboxInstanceFromResponse, o as exportTraceBundle, q as isCapacityShortageCreateError, z as CAPACITY_ETA_MARGIN_MS } from "./sandbox-Bg6pjpkF.js";
3
+ import { A as normalizeSandboxCreateReceipt, B as CAPACITY_ETA_WAIT_MAX_MS, D as validateDeferredProfileFileMounts, E as splitInlineProfileSkills, F as normalizeConnection, G as extendableDeadline, I as normalizeEgressPolicyFields, J as isDeployWindowCreateError, K as generateIdempotencyKey, L as normalizeProxySecretReceipt, N as dateOf, O as isRetryableProfileFileMaterializeFailure, P as parseLifecycleTimes, R as normalizeSandboxShape, T as splitInlineProfileFileMounts, U as DEPLOY_WINDOW_RETRY_MS, W as createRetryDelayMs, X as isRetryableCreateError, Y as isRateLimitCreateError, d as sandboxLedgerUsd, j as normalizeStartupDiagnostics, k as normalizeCaptureProof, n as createSandboxInstanceFromResponse, o as exportTraceBundle, q as isCapacityShortageCreateError, z as CAPACITY_ETA_MARGIN_MS } from "./sandbox-I0I_UQoO.js";
4
4
  import { C as ServerError, D as ValidationError, E as TimeoutError, S as SandboxError, _ as NotFoundError, a as readResponseJson, g as NetworkError, i as parseResponseError, o as retryWhen, r as parseErrorResponse, s as AuthError, v as PartialFailureError } from "./errors-DKIV20jZ.js";
5
5
  import { r as combineAbortSignals, t as abortableSleep } from "./abort-signal-Cu4F2VVz.js";
6
6
  import { l as SANDBOX_AGENT_HOME, t as isInsideReservedDir } from "./file-transfer-Cr9Ossea.js";
7
- import { n as fetchSandboxApi } from "./api-request-CtiP5_m5.js";
7
+ import { n as fetchSandboxApi } from "./api-request-BrJ2JmYJ.js";
8
8
  import { n as fetchWithKeepAlive, t as emitTiming } from "./keep-alive-fetch-C2lFwrMA.js";
9
9
  import { t as parseSSEStream } from "./sse-parser-DXRUx6gh.js";
10
10
  import { t as LinesClient } from "./lines-D3CdWX7Y.js";
@@ -1,5 +1,5 @@
1
1
  import { r as agentProfileSchema } from "./profile-schema-C1KpT-wS.js";
2
- import { Z as canonicalAgentProfileDigest } from "./sandbox-Bg6pjpkF.js";
2
+ import { Z as canonicalAgentProfileDigest } from "./sandbox-I0I_UQoO.js";
3
3
  import { D as ValidationError, S as SandboxError, l as CapabilityError } from "./errors-DKIV20jZ.js";
4
4
  import { n as awaitWithAbort } from "./abort-signal-Cu4F2VVz.js";
5
5
  import { r as cliAuthReferenceSchema } from "./cli-auth-bundle-C6DtK7GX-BbbiAn-Z.js";
package/dist/core.js CHANGED
@@ -1,7 +1,7 @@
1
- import { r as WorkspaceImages, t as SandboxInstance, x as ManagedProcessClient } from "./sandbox-Bg6pjpkF.js";
1
+ import { r as WorkspaceImages, t as SandboxInstance, x as ManagedProcessClient } from "./sandbox-I0I_UQoO.js";
2
2
  import { C as ServerError, D as ValidationError, E as TimeoutError, S as SandboxError, _ as NotFoundError, b as QuotaError, g as NetworkError, l as CapabilityError, p as FileWriteConflictError, r as parseErrorResponse, s as AuthError, v as PartialFailureError, w as StateError, y as ProfileFileMountPathError } from "./errors-DKIV20jZ.js";
3
- import { a as InstancesClient, d as backendRegistryInteractionKindSchema, f as backendRegistryResponseSchema, h as parseBackendRegistryResponseBody, i as InstanceRestartingError, l as backendRegistryCapabilitiesSchema, m as parseBackendRegistryResponse, p as isBackendRegistryInteractionKind, r as HostedInstance, t as Sandbox, u as backendRegistryEntrySchema } from "./client-ByARyP60.js";
3
+ import { a as InstancesClient, d as backendRegistryInteractionKindSchema, f as backendRegistryResponseSchema, h as parseBackendRegistryResponseBody, i as InstanceRestartingError, l as backendRegistryCapabilitiesSchema, m as parseBackendRegistryResponse, p as isBackendRegistryInteractionKind, r as HostedInstance, t as Sandbox, u as backendRegistryEntrySchema } from "./client-BmHni-Vr.js";
4
4
  import { i as profileChannelReference, r as lineInstanceKey, t as LinesClient } from "./lines-D3CdWX7Y.js";
5
5
  import { PublicTemplatePublishError, PublicTemplatesClient } from "./public-templates.js";
6
- import { a as LINE_APPLICATION_REPLY_MAX_CHARS, c as parseLineApplicationResult, i as gatewaySeatTransport, l as sandboxFailureKind, n as SeatSelectionError, o as LINE_APPLICATION_REQUEST_MAX_BYTES, r as createSelectSeat, s as parseLineApplicationRequest, t as ISOLATED_CREATION_ATTESTATION_VERSION } from "./core-B9JC6IuH.js";
6
+ import { a as LINE_APPLICATION_REPLY_MAX_CHARS, c as parseLineApplicationResult, i as gatewaySeatTransport, l as sandboxFailureKind, n as SeatSelectionError, o as LINE_APPLICATION_REQUEST_MAX_BYTES, r as createSelectSeat, s as parseLineApplicationRequest, t as ISOLATED_CREATION_ATTESTATION_VERSION } from "./core-CRHdx3kD.js";
7
7
  export { AuthError, CapabilityError, FileWriteConflictError, HostedInstance, ISOLATED_CREATION_ATTESTATION_VERSION, InstanceRestartingError, InstancesClient, LINE_APPLICATION_REPLY_MAX_CHARS, LINE_APPLICATION_REQUEST_MAX_BYTES, LinesClient, ManagedProcessClient, NetworkError, NotFoundError, PartialFailureError, ProfileFileMountPathError, PublicTemplatePublishError, PublicTemplatesClient, QuotaError, Sandbox, SandboxError, SandboxInstance, SeatSelectionError, ServerError, StateError, TimeoutError, ValidationError, WorkspaceImages, backendRegistryCapabilitiesSchema, backendRegistryEntrySchema, backendRegistryInteractionKindSchema, backendRegistryResponseSchema, createSelectSeat, gatewaySeatTransport, isBackendRegistryInteractionKind, lineInstanceKey, parseBackendRegistryResponse, parseBackendRegistryResponseBody, parseErrorResponse, parseLineApplicationRequest, parseLineApplicationResult, profileChannelReference, sandboxFailureKind };
package/dist/index.js CHANGED
@@ -1,16 +1,16 @@
1
1
  import { A as normalizeRuntimeBackendConfig, B as TERMINAL_WS_ECHO_SUBPROTOCOL, G as parseBackendType, H as backendTypeSchema, I as createAgentRunOutcomeTracker, L as deriveAgentResultOutcome, R as deriveAgentRunOutcome, U as isolationPrincipalSchema, V as ALL_BACKEND_TYPES, i as terminalUpgradeHeadersSupported, j as requestedPublicProfileDigest, n as InteractiveSessionController, r as TerminalStream, t as BrowserInteractiveSessionController, z as projectAgentTerminalRecord } from "./interactive-controller-CeMBZkXh.js";
2
2
  import { a as INTERACTIVE_CONTROL_CLEANUP_TIMEOUT_MS, k as agentInteractiveSessionPromptRequestDigest, l as createInteractiveControlHolderId, n as browserInteractiveControlHolderId, o as InteractiveSessionControlController, s as InteractiveSessionNotRunningError, t as BrowserInteractiveSessionControlController, u as interactiveSessionIdentityDigest } from "./browser-interactive-control-controller-BYbNLahH.js";
3
3
  import { i as SANDBOX_SIZE_PRESET_NAMES, r as agentProfileSchema, t as agentProfileConfidentialSchema } from "./profile-schema-C1KpT-wS.js";
4
- import { C as SandboxOperationFailedError, D as validateDeferredProfileFileMounts, E as splitInlineProfileSkills, S as SandboxOperation, T as splitInlineProfileFileMounts, _ as collectAgentFinalMessageText, a as buildTraceExportPayload, b as isToolBearingEvent, c as toOtelJson, f as InteractiveSessionHandle, g as applySandboxEventText, h as createInteractiveTerminalSession, i as MAX_EGRESS_DENIALS_LIMIT, l as SandboxTaskSession, m as createInteractiveTerminalCapture, o as exportTraceBundle, p as InteractiveTerminalFrameLog, r as WorkspaceImages, s as otelTraceIdForTangleTrace, t as SandboxInstance, u as SandboxSession, v as collectAgentResponseText, w as materializeProfileFileMounts, x as ManagedProcessClient, y as getSandboxEventText } from "./sandbox-Bg6pjpkF.js";
4
+ import { C as SandboxOperationFailedError, D as validateDeferredProfileFileMounts, E as splitInlineProfileSkills, S as SandboxOperation, T as splitInlineProfileFileMounts, _ as collectAgentFinalMessageText, a as buildTraceExportPayload, b as isToolBearingEvent, c as toOtelJson, f as InteractiveSessionHandle, g as applySandboxEventText, h as createInteractiveTerminalSession, i as MAX_EGRESS_DENIALS_LIMIT, l as SandboxTaskSession, m as createInteractiveTerminalCapture, o as exportTraceBundle, p as InteractiveTerminalFrameLog, r as WorkspaceImages, s as otelTraceIdForTangleTrace, t as SandboxInstance, u as SandboxSession, v as collectAgentResponseText, w as materializeProfileFileMounts, x as ManagedProcessClient, y as getSandboxEventText } from "./sandbox-I0I_UQoO.js";
5
5
  import { C as ServerError, D as ValidationError, E as TimeoutError, S as SandboxError, T as StreamInterruptedError, _ as NotFoundError, b as QuotaError, c as BranchFanoutExceedsHostError, d as EdgeNotReadyError, f as EgressProxyRecoveryError, g as NetworkError, h as KeyBudgetExhaustedError, l as CapabilityError, m as GpuProviderNotConfiguredError, p as FileWriteConflictError, r as parseErrorResponse, s as AuthError, t as TerminalStreamError, u as CompliancePlacementError, v as PartialFailureError, w as StateError, x as ResumeEnvRequiredError, y as ProfileFileMountPathError } from "./errors-DKIV20jZ.js";
6
- import { _ as createBatchResultAccumulator, a as InstancesClient, c as runtimeWorkspaceCwdSchema, d as backendRegistryInteractionKindSchema, f as backendRegistryResponseSchema, g as IntelligenceClient, h as parseBackendRegistryResponseBody, i as InstanceRestartingError, l as backendRegistryCapabilitiesSchema, m as parseBackendRegistryResponse, n as RunsClient, o as SandboxFleetClient, p as isBackendRegistryInteractionKind, r as HostedInstance, s as SandboxFleet, t as Sandbox, u as backendRegistryEntrySchema, v as validateBatchRunRequest } from "./client-ByARyP60.js";
6
+ import { _ as createBatchResultAccumulator, a as InstancesClient, c as runtimeWorkspaceCwdSchema, d as backendRegistryInteractionKindSchema, f as backendRegistryResponseSchema, g as IntelligenceClient, h as parseBackendRegistryResponseBody, i as InstanceRestartingError, l as backendRegistryCapabilitiesSchema, m as parseBackendRegistryResponse, n as RunsClient, o as SandboxFleetClient, p as isBackendRegistryInteractionKind, r as HostedInstance, s as SandboxFleet, t as Sandbox, u as backendRegistryEntrySchema, v as validateBatchRunRequest } from "./client-BmHni-Vr.js";
7
7
  import { a as CollaborationClient, i as parseCollaborationDocumentId, n as buildCollaborationDocumentId, r as normalizeCollaborationPath, t as CollaborationFileBridge } from "./collaboration-9LAsWHvQ.js";
8
8
  import { t as parseSSEStream } from "./sse-parser-DXRUx6gh.js";
9
9
  import { i as profileChannelReference, n as SandboxLines, r as lineInstanceKey, t as LinesClient } from "./lines-D3CdWX7Y.js";
10
10
  import { t as downloadFile } from "./file-download-DnI_Z_Za.js";
11
11
  import { PublicTemplatePublishError, PublicTemplatesClient } from "./public-templates.js";
12
- import { a as LINE_APPLICATION_REPLY_MAX_CHARS, c as parseLineApplicationResult, i as gatewaySeatTransport, l as sandboxFailureKind, n as SeatSelectionError, o as LINE_APPLICATION_REQUEST_MAX_BYTES, r as createSelectSeat, s as parseLineApplicationRequest, t as ISOLATED_CREATION_ATTESTATION_VERSION } from "./core-B9JC6IuH.js";
13
- import { s as BlueprintSandboxClient } from "./tangle-KanEkVX3.js";
12
+ import { a as LINE_APPLICATION_REPLY_MAX_CHARS, c as parseLineApplicationResult, i as gatewaySeatTransport, l as sandboxFailureKind, n as SeatSelectionError, o as LINE_APPLICATION_REQUEST_MAX_BYTES, r as createSelectSeat, s as parseLineApplicationRequest, t as ISOLATED_CREATION_ATTESTATION_VERSION } from "./core-CRHdx3kD.js";
13
+ import { s as BlueprintSandboxClient } from "./tangle-C0YLjETa.js";
14
14
  import { z } from "zod";
15
15
  //#region ../../../packages/runtime-contracts/dist/model-key-proxy.js
16
16
  const MANAGED_MODEL_KEY_SENTINEL = "proxy-managed-per-request";
@@ -1,5 +1,5 @@
1
1
  import { E as TimeoutError, g as NetworkError, r as parseErrorResponse } from "../errors-DKIV20jZ.js";
2
- import { n as fetchSandboxApi } from "../api-request-CtiP5_m5.js";
2
+ import { n as fetchSandboxApi } from "../api-request-BrJ2JmYJ.js";
3
3
  import { n as verifyDownload } from "../file-download-DnI_Z_Za.js";
4
4
  //#region src/intelligence/index.ts
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { u as SANDBOX_FILE_API_ABSOLUTE_ROOTS } from "./file-transfer-Cr9Ossea.js";
2
- import "./api-request-CtiP5_m5.js";
2
+ import "./api-request-BrJ2JmYJ.js";
3
3
  import { a as listAgentPreviews, i as getAgentPreview, o as publishAgentPreview, r as ensureAgentPreview, s as removeAgentPreview, t as AgentPreviewError } from "./preview-operations-B3TTvqlm.js";
4
4
  //#region \0rolldown/runtime.js
5
5
  var __defProp = Object.defineProperty;
@@ -396,7 +396,7 @@ async function createMcpServer(box, options = {}) {
396
396
  const { bindings, handlers } = bindToolSpecs(box, options);
397
397
  const server = new serverModule.Server({
398
398
  name: options.name ?? "tangle-sandbox",
399
- version: options.version ?? "1.0.200"
399
+ version: options.version ?? "1.0.201"
400
400
  }, { capabilities: { tools: {} } });
401
401
  server.setRequestHandler(typesModule.ListToolsRequestSchema, async () => ({ tools: bindings.map(({ spec: s }) => ({
402
402
  name: s.name,
package/dist/runtime.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { I as createAgentRunOutcomeTracker, L as deriveAgentResultOutcome, R as deriveAgentRunOutcome, c as SandboxRuntimeApi, t as BrowserInteractiveSessionController, z as projectAgentTerminalRecord } from "./interactive-controller-CeMBZkXh.js";
2
2
  import { n as browserInteractiveControlHolderId, s as InteractiveSessionNotRunningError } from "./browser-interactive-control-controller-BYbNLahH.js";
3
3
  import { C as ServerError, D as ValidationError, E as TimeoutError, S as SandboxError, _ as NotFoundError, b as QuotaError, g as NetworkError, l as CapabilityError, p as FileWriteConflictError, s as AuthError, v as PartialFailureError, w as StateError, y as ProfileFileMountPathError } from "./errors-DKIV20jZ.js";
4
- import { n as fetchSandboxApi } from "./api-request-CtiP5_m5.js";
4
+ import { n as fetchSandboxApi } from "./api-request-BrJ2JmYJ.js";
5
5
  import { s as uploadChunked } from "./chunked-upload-DCdc8Nly.js";
6
6
  //#region src/runtime-client.ts
7
7
  const DEFAULT_RUNTIME_TIMEOUT_MS = 3e4;
@@ -261,34 +261,13 @@ const DEFAULT_CREATE_TIMEOUT_MS = 12e4;
261
261
  const DEFAULT_GPU_CREATE_TIMEOUT_MS = 900 * 1e3;
262
262
  const CREATE_RETRY_MAX_DELAY_MS = 4e3;
263
263
  /**
264
- * 503 classes that mean "the cell cannot place a create right now, ask
265
- * again", not "this create failed". A full fleet answers `CAPACITY_EXHAUSTED`
266
- * at once with `Retry-After` (nothing queues in the controller; the refusal
267
- * wakes the autoscaler and this re-POST meets the host it bought, its
268
- * `etaSeconds` stretching a default budget: CAPACITY_ETA_WAIT_MAX_MS), and so
269
- * does a host-agent roll that drains placement on the only host.
270
- * `HOST_PRESSURE` and `PROVISIONING_PAUSED` are the sibling placement
271
- * refusals the orchestrator maps to 503, and a keyed create cannot verify its
272
- * ref while the agent is down (`IDEMPOTENT_CREATE_PROBE_FAILED`). Re-POSTing
273
- * is safe: the placement refusals started no provision, the probe answer is
274
- * the Worker declining to act until it can prove what exists, and the
275
- * idempotency key joins whichever provision did start.
276
- *
277
- * `SANDBOX_CREATE_RECONCILING` is deliberately not in the family: it follows
278
- * only a retained real failure, whose journal the reconciler holds for at
279
- * least 5 min (products/sandbox/api/src/cf/create-reservation-reconciler.ts),
280
- * longer than any budget here, so it keeps the five-attempt budget.
281
- *
282
- * `SANDBOX_TRANSFER_PENDING` (Retry-After 1) is in the family: a keyed
283
- * create served from a ready lease answers it on a same-key retry until the
284
- * orchestrator takes the lease's ownership transfer. The sandbox already
285
- * exists and bills, and the Worker allocates nothing while it answers, so
286
- * re-POSTing on the time budget returns that sandbox once the transfer lands
287
- * instead of failing a create whose environment exists.
288
- *
289
- * `INTERNAL_CREATE_PACED` (Retry-After 5) is in the family: the Worker paces an
290
- * internal owner's creates behind customers before any D1 write or provision,
291
- * so a paced create retries to its deadline instead of failing a burst.
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.
292
271
  */
293
272
  const DEPLOY_WINDOW_RETRY_CODES = new Set([
294
273
  "INTERNAL_CREATE_PACED",
@@ -299,20 +278,15 @@ const DEPLOY_WINDOW_RETRY_CODES = new Set([
299
278
  "SANDBOX_TRANSFER_PENDING"
300
279
  ]);
301
280
  /**
302
- * Longest a create keeps re-POSTing through the deploy-window family,
303
- * counted from the start of the create. Sized to the production host-agent
304
- * roll in `scripts/release/roll-hosts.sh` (drain placement
305
- * on the host, swap the agent, restore placement): the last measured roll
306
- * kept placement drained for 124 s. The caller's create deadline binds
307
- * first when it is shorter, and the 120 s default is, so a default create
308
- * waits out its own deadline (or CAPACITY_ETA_WAIT_MAX_MS) not this ceiling.
281
+ * Longest a create keeps re-POSTing through the deploy-window family, from its
282
+ * start. Sized to the measured 124 s production host-agent roll; the caller's
283
+ * create deadline binds first when shorter.
309
284
  */
310
285
  const DEPLOY_WINDOW_RETRY_MS = 15e4;
311
286
  /**
312
- * Longest a create with no `timeoutMs` waits, from its start, for the host a
313
- * capacity refusal's `etaSeconds` says is booting. The cell sizes that wait
314
- * on its measured p95 birth (eu1 2026-10-31: 230 s; a cold start adds 15% and
315
- * a 60 s control tick, 325 s). The margin covers registration to placement.
287
+ * Longest a create with no `timeoutMs` waits for the host a capacity refusal's
288
+ * `etaSeconds` says is booting: the cell's measured p95 birth (eu1 230 s) plus
289
+ * a cold start and a control tick; the margin covers registration to placement.
316
290
  */
317
291
  const CAPACITY_ETA_WAIT_MAX_MS = 36e4;
318
292
  const CAPACITY_ETA_MARGIN_MS = 15e3;
@@ -338,14 +312,9 @@ function isDeployWindowCreateError(cause) {
338
312
  /** A no-room refusal allocated nothing, so a create giving up on one reports this typed 503. */
339
313
  const isCapacityShortageCreateError = (cause) => isDeployWindowCreateError(cause) && (cause.code === "CAPACITY_EXHAUSTED" || cause.code === "HOST_PRESSURE");
340
314
  /**
341
- * The plan rate limiter's 429 (`RATE_LIMIT_EXCEEDED`, or the platform's own
342
- * limiter); a quota 429 is final in the catalog. Every paced re-POST above is
343
- * a Worker management request that limiter counts (the free plan allows 60 a
344
- * minute, and one create retrying every 2 s is 30 of them), so in a full
345
- * fleet two concurrent creates meet it. Answered right after a capacity
346
- * refusal on the same key, it is part of that pacing, not a new failure: it
347
- * is retried on its own `Retry-After` on the time budget, and spends none of
348
- * the attempt budget.
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.
349
318
  */
350
319
  function isRateLimitCreateError(cause) {
351
320
  return retryWhen(cause) && cause.status === 429;
@@ -378,6 +347,22 @@ function generateIdempotencyKey() {
378
347
  }
379
348
  throw new Error("idempotency key generation requires global crypto");
380
349
  }
350
+ /**
351
+ * A fork re-POSTs the refusals a create waits out, plus the controller's
352
+ * `UNAVAILABLE` 503 and a gateway 502/504: none started a fan-out, and the
353
+ * keyed re-POST joins one that did.
354
+ */
355
+ async function retryForkRefusal(post) {
356
+ const deadline = Date.now() + DEPLOY_WINDOW_RETRY_MS;
357
+ for (let failed = 1;; failed++) try {
358
+ return await post();
359
+ } catch (cause) {
360
+ const retryable = isDeployWindowCreateError(cause) || cause instanceof SandboxError && (cause.status === 502 || cause.status === 504 || cause.status === 503 && cause.code === "UNAVAILABLE");
361
+ const delayMs = Math.max(createRetryDelayMs(cause, failed), 250);
362
+ if (!retryable || delayMs >= deadline - Date.now()) throw cause;
363
+ await abortableSleep(delayMs);
364
+ }
365
+ }
381
366
  //#endregion
382
367
  //#region src/normalize.ts
383
368
  /** Private client and instance normalization helpers. */
@@ -11872,15 +11857,17 @@ var SandboxInstance = class SandboxInstance extends SandboxEgressCapabilities {
11872
11857
  async fork(count, options) {
11873
11858
  const local = state(this);
11874
11859
  if (!Number.isInteger(count) || count < 1) throw new ValidationError(`branch count must be an integer >= 1 (got ${count})`);
11875
- const data = await readResponseJson(await local.client.fetch(`/v1/sandboxes/${this.id}/branch`, {
11860
+ const idempotencyKey = options?.idempotencyKey ?? generateIdempotencyKey();
11861
+ const body = JSON.stringify({
11862
+ count,
11863
+ env: options?.env,
11864
+ metadata: options?.metadata
11865
+ });
11866
+ const data = await retryForkRefusal(async () => readResponseJson(await local.client.fetch(`/v1/sandboxes/${this.id}/branch`, {
11876
11867
  method: "POST",
11877
- ...options?.idempotencyKey ? { headers: { "Idempotency-Key": options.idempotencyKey } } : {},
11878
- body: JSON.stringify({
11879
- count,
11880
- env: options?.env,
11881
- metadata: options?.metadata
11882
- })
11883
- }));
11868
+ headers: { "Idempotency-Key": idempotencyKey },
11869
+ body
11870
+ })));
11884
11871
  const children = (data.children ?? []).map((child) => createSandboxInstanceFromResponse(local.client, this.parseInfo(child), local.defaultRuntimeBackend));
11885
11872
  const materializedCount = children.length;
11886
11873
  const requestedCount = typeof data.fork?.requestedCount === "number" ? data.fork.requestedCount : count;
@@ -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-KanEkVX3.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-C0YLjETa.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,4 +1,4 @@
1
- import { M as readFilesystemIncarnationTuple, n as createSandboxInstanceFromResponse } from "./sandbox-Bg6pjpkF.js";
1
+ import { M as readFilesystemIncarnationTuple, n as createSandboxInstanceFromResponse } from "./sandbox-I0I_UQoO.js";
2
2
  import { a as readResponseJson } from "./errors-DKIV20jZ.js";
3
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";
4
4
  //#region ../../../packages/runtime-contracts/dist/tangle-blueprint-abi.js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/sandbox",
3
- "version": "1.0.200",
3
+ "version": "1.0.201",
4
4
  "description": "Client SDK for the Tangle Sandbox platform - build AI agent applications with dev containers",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -154,14 +154,14 @@
154
154
  "ws": "^8.22.0",
155
155
  "yjs": "13.6.33",
156
156
  "@products/sandbox-test-utils": "0.0.0",
157
- "@repo/shared": "0.0.0",
157
+ "@tangle-network/cli-agent-registry": "0.15.0",
158
158
  "@tangle-network/agent-profile-materialize": "0.27.1",
159
- "@tangle-network/runtime-contracts": "0.20.0",
160
- "@tangle-network/cli-agent-registry": "0.15.0"
159
+ "@repo/shared": "0.0.0",
160
+ "@tangle-network/runtime-contracts": "0.20.0"
161
161
  },
162
162
  "tangleRelease": {
163
- "sourceSha": "667bd058df8ec16f9fd7be88f512423115fa7f0c",
164
- "mergedAt": "2026-11-02T20:40:11-08:00"
163
+ "sourceSha": "d2954aefee412d25f0c519bae6e61dafa2f4bd38",
164
+ "mergedAt": "2026-11-03T09:56:48-08:00"
165
165
  },
166
166
  "scripts": {
167
167
  "build": "node scripts/build-dist.mjs",