@tangle-network/sandbox 0.63.24 → 0.64.1

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 (32) hide show
  1. package/dist/agent/index.d.ts +4 -4
  2. package/dist/agent/index.js +3 -3
  3. package/dist/agent/preview.d.ts +1 -1
  4. package/dist/{agent-run-outcome-C-VR-L0I.d.ts → agent-run-outcome-brwJbH5S.d.ts} +1 -1
  5. package/dist/auth/index.js +1 -1
  6. package/dist/{backend-types-zuUBEJO1.js → backend-types-CLvdSX8V.js} +7 -1
  7. package/dist/{cli-auth-bundle-R0Y7rngn.js → cli-auth-bundle-BYvVrIso.js} +1 -1
  8. package/dist/{client-CqpKC6n3.d.ts → client-Dr8qasCR.d.ts} +14 -4
  9. package/dist/{client-CGcWP4FX.js → client-Dy5B2NkM.js} +22 -9
  10. package/dist/core.d.ts +5 -5
  11. package/dist/core.js +2 -2
  12. package/dist/{direct-http2-CoGVOqVR.js → direct-http2-Dar5erTH.js} +4 -2
  13. package/dist/{index-D4OBUP5M.d.ts → index-D5dVNm76.d.ts} +5 -72
  14. package/dist/index.d.ts +8 -8
  15. package/dist/index.js +6 -5
  16. package/dist/{interactive-controller-D4N4zqmu.js → interactive-controller-OAsASPd_.js} +1 -1
  17. package/dist/{interactive-controller-BBwB_5QQ.d.ts → interactive-controller-nMhGqXxq.d.ts} +1 -1
  18. package/dist/{keep-alive-fetch-CuwGi7gz.js → keep-alive-fetch-BBzJDWyt.js} +5 -2
  19. package/dist/{lines-5m11CEj-.d.ts → lines-C5CPSg8n.d.ts} +1 -1
  20. package/dist/lines.d.ts +1 -1
  21. package/dist/{local-cli-auth-DVUBOY4y.js → local-cli-auth-XgKy2zsU.js} +1 -1
  22. package/dist/{preview-CcJBQSjB.d.ts → preview-COO7TSBk.d.ts} +3 -3
  23. package/dist/{public-templates-nv4AFFVc.d.ts → public-templates-BDrchm0J.d.ts} +1 -1
  24. package/dist/public-templates.d.ts +1 -1
  25. package/dist/runtime.d.ts +3 -3
  26. package/dist/runtime.js +1 -1
  27. package/dist/{sandbox-BDgvO9Z3.js → sandbox-BPLzHOZ1.js} +67 -215
  28. package/dist/tangle/index.d.ts +1 -1
  29. package/dist/tangle/index.js +1 -1
  30. package/dist/{tangle-D-VfQGTu.js → tangle-C4Bp5krB.js} +1 -1
  31. package/dist/{types-BjyQe_CI.d.ts → types-CtH0GRql.d.ts} +71 -182
  32. package/package.json +3 -3
@@ -1,10 +1,10 @@
1
- import { i as normalizeEffectiveBackend, r as backendTypeSchema } from "./backend-types-zuUBEJO1.js";
2
- import { A as normalizeRuntimeBackendConfig, C as encodePromptForWire, D as assertCurrentBackendType, E as applyRequestedModel, F as withoutRuntimeSecrets, I as createAgentRunOutcomeTracker, L as deriveAgentResultOutcome, M as requestedSecretProfilePublicDigest, S as validateAcceptedDispatchRunRef, T as canUseNodeHttp2, _ as mintTraceId, a as assertScopedTokenActive, b as parseSSEStream, c as SandboxRuntimeApi, d as appendSessionIdQuery, f as sessionHeaders, g as isTraceId, h as TRACE_ID_HEADER, i as terminalUpgradeHeadersSupported, j as requestedPublicProfileDigest, k as mergeRuntimeBackendConfig, l as normalizeSessionInfo, m as waitForRetryAfter, n as InteractiveSessionController, p as isRetryableCredentialRefusal, r as TerminalStream, s as requestScopedToken, u as sessionMessageRequestBody, v as resolveTraceId, w as encodeTextForWire, x as resolveDispatchRunIdentity, y as traceHeaders } from "./interactive-controller-D4N4zqmu.js";
1
+ import { a as normalizeEffectiveBackend, r as backendTypeSchema } from "./backend-types-CLvdSX8V.js";
2
+ import { A as normalizeRuntimeBackendConfig, C as encodePromptForWire, D as assertCurrentBackendType, E as applyRequestedModel, F as withoutRuntimeSecrets, I as createAgentRunOutcomeTracker, L as deriveAgentResultOutcome, M as requestedSecretProfilePublicDigest, S as validateAcceptedDispatchRunRef, T as canUseNodeHttp2, _ as mintTraceId, a as assertScopedTokenActive, b as parseSSEStream, c as SandboxRuntimeApi, d as appendSessionIdQuery, f as sessionHeaders, g as isTraceId, h as TRACE_ID_HEADER, i as terminalUpgradeHeadersSupported, j as requestedPublicProfileDigest, k as mergeRuntimeBackendConfig, l as normalizeSessionInfo, m as waitForRetryAfter, n as InteractiveSessionController, p as isRetryableCredentialRefusal, r as TerminalStream, s as requestScopedToken, u as sessionMessageRequestBody, v as resolveTraceId, w as encodeTextForWire, x as resolveDispatchRunIdentity, y as traceHeaders } from "./interactive-controller-OAsASPd_.js";
3
3
  import { C as StreamInterruptedError, F as profileFileMountOutsideRootsMessage, M as SANDBOX_AGENT_HOME, N as SANDBOX_FILE_API_ABSOLUTE_ROOTS, P as isProfileFileMountOutsideRoots, S as StateError, T as ValidationError, _ as ProfileFileMountPathError, a as AuthError, b as SandboxError, c as EdgeNotReadyError, h as NotFoundError, i as readResponseJson, j as PROFILE_FILE_MOUNT_OUTSIDE_ROOTS_CODE, k as SANDBOX_PROXY_REQUEST_MAX_BYTES, m as NetworkError, n as parseErrorResponse, r as parseResponseError, s as CapabilityError, t as TerminalStreamError, v as QuotaError, w as TimeoutError, x as ServerError } from "./errors-BfbOP_rx.js";
4
4
  import { _ as interactiveSessionStatusResponseSchema, d as awaitWithAbort, f as combineAbortSignals, g as interactiveSessionControlValidationResponseSchema, h as interactiveSessionControlReleaseResponseSchema, l as createInteractiveControlHolderId, m as interactiveSessionControlClaimResponseSchema, p as delayUntilAborted } from "./browser-interactive-control-controller-DHx53yre.js";
5
- import { n as fetchWithKeepAlive, t as emitTiming } from "./keep-alive-fetch-CuwGi7gz.js";
5
+ import { n as fetchWithKeepAlive, t as emitTiming } from "./keep-alive-fetch-BBzJDWyt.js";
6
6
  import { s as uploadChunked } from "./chunked-upload-DN2twsUu.js";
7
- import { r as cliAuthReferenceSchema } from "./cli-auth-bundle-R0Y7rngn.js";
7
+ import { r as cliAuthReferenceSchema } from "./cli-auth-bundle-BYvVrIso.js";
8
8
  import { n as SandboxLines } from "./lines-C5ER4aN_.js";
9
9
  import { z } from "zod";
10
10
  import { AgentExactRunControlRefSchema, AgentInteractiveSessionAttachSchema, AgentInteractiveSessionControlClaimAcknowledgementSchema, AgentInteractiveSessionControlClaimRequestSchema, AgentInteractiveSessionControlClaimSchema, AgentInteractiveSessionPromptAcknowledgementSchema, AgentInteractiveSessionPromptCommandSchema, AgentInteractiveSessionRefSchema, AgentInteractiveSessionStartSchema, AgentInteractiveSessionStopAcknowledgementSchema, AgentInteractiveSessionStopCommandSchema, AgentRunCancellationAcknowledgementSchema, AgentRunCancellationRequestSchema, InteractionAcknowledgementSchema, InteractionBindingSchema, InteractionRequestSchema, InteractionResponseCommandSchema, InteractionResponseSchema, PlanContinuationSchema, TerminalInputSchema, TerminalOutputEventSchema, TerminalReplayWindowSchema, TerminalResizeSchema, TerminalSessionRefSchema, agentInteractiveSessionControlClaimAcknowledgementMatchesRequest, agentInteractiveSessionControlClaimIsNewer, agentInteractiveSessionControlClaimMatchesRef, agentInteractiveSessionPromptAcknowledgementMatchesCommand, agentInteractiveSessionPromptRequestDigest, agentInteractiveSessionRefMatchesStart, agentInteractiveSessionStatusMatchesRef, agentInteractiveSessionStopAcknowledgementMatchesCommand, agentProfileSchema, agentRunCancellationAcknowledgementMatchesRequest, canonicalCandidateDigest, canonicalCandidateJson, exactAgentInteractiveSessionStart, sha256DigestSchema, terminalSessionUsable } from "@tangle-network/agent-interface";
@@ -658,7 +658,7 @@ var SandboxInfoCapabilities = class {
658
658
  hasFreshStatus() {
659
659
  const statusObservedAt = sandboxStatusObservedAt.get(this) ?? 0;
660
660
  const statusAgeMs = Date.now() - statusObservedAt;
661
- return statusObservedAt > 0 && statusAgeMs >= 0 && statusAgeMs < 1e3;
661
+ return statusObservedAt > 0 && statusAgeMs >= 0 && statusAgeMs < SANDBOX_STATUS_FRESHNESS_MS;
662
662
  }
663
663
  /**
664
664
  * The check before a runtime call. A handle that has seen the sandbox
@@ -869,6 +869,7 @@ function readFilesystemIncarnationTuple(value) {
869
869
  readiness
870
870
  };
871
871
  }
872
+ const SANDBOX_STATUS_FRESHNESS_MS = 1e3;
872
873
  const sandboxStatusObservedAt = /* @__PURE__ */ new WeakMap();
873
874
  const REFRESH_REASON_HEADER = "x-tangle-refresh-reason";
874
875
  /**
@@ -1133,7 +1134,7 @@ var DirectRuntimeHttpClient = class {
1133
1134
  };
1134
1135
  if (!route) throw new NetworkError("Direct runtime route was withdrawn");
1135
1136
  if (route.useExec && canUseNodeHttp2()) {
1136
- const { fetchDirectHttp2 } = await import("./direct-http2-CoGVOqVR.js");
1137
+ const { fetchDirectHttp2 } = await import("./direct-http2-Dar5erTH.js");
1137
1138
  return fetchDirectHttp2(route.url, request, timing);
1138
1139
  }
1139
1140
  return fetchWithKeepAlive(route.url, request, timing);
@@ -2612,138 +2613,8 @@ var SandboxGitCapabilities = class extends SandboxInfoCapabilities {
2612
2613
  }
2613
2614
  };
2614
2615
  //#endregion
2615
- //#region src/sandbox-workspace-permissions.ts
2616
- var SandboxPermissionsCapabilities = class extends SandboxGitCapabilities {
2617
- /**
2618
- * Permissions manager for multi-user access control.
2619
- *
2620
- * @example List users
2621
- * ```typescript
2622
- * const users = await box.permissions.list();
2623
- * for (const user of users) {
2624
- * console.log(`${user.username}: ${user.role}`);
2625
- * }
2626
- * ```
2627
- *
2628
- * @example Add a developer
2629
- * ```typescript
2630
- * await box.permissions.add({
2631
- * userId: "user_abc",
2632
- * role: "developer",
2633
- * sshKeys: ["ssh-ed25519 AAAA..."],
2634
- * });
2635
- * ```
2636
- */
2637
- get permissions() {
2638
- return {
2639
- list: () => this.permissionsList(),
2640
- get: (userId) => this.permissionsGet(userId),
2641
- add: (options) => this.permissionsAdd(options),
2642
- update: (userId, options) => this.permissionsUpdate(userId, options),
2643
- remove: (userId, options) => this.permissionsRemove(userId, options),
2644
- setAccessPolicies: (userId, rules) => this.permissionsSetAccessPolicies(userId, rules),
2645
- getAccessPolicies: (userId) => this.permissionsGetAccessPolicies(userId),
2646
- checkAccess: (userId, path, action) => this.permissionsCheckAccess(userId, path, action)
2647
- };
2648
- }
2649
- async permissionsList() {
2650
- await this.ensureRunning();
2651
- return ((await readResponseJson(await this.runtimeFetch("/permissions/users", { method: "GET" }))).users ?? []).map((u) => ({
2652
- userId: u.userId,
2653
- username: u.username,
2654
- homeDir: u.homeDir,
2655
- role: u.role,
2656
- sshKeys: u.sshKeys ?? [],
2657
- directoryPermissions: u.directoryPermissions,
2658
- accessPolicies: u.accessPolicies,
2659
- createdAt: new Date(u.createdAt)
2660
- }));
2661
- }
2662
- async permissionsGet(userId) {
2663
- await this.ensureRunning();
2664
- const response = await this.runtimeFetch(`/permissions/users/${encodeURIComponent(userId)}`, { method: "GET" });
2665
- if (response.status === 404) return null;
2666
- const u = await readResponseJson(response);
2667
- return {
2668
- userId: u.userId,
2669
- username: u.username,
2670
- homeDir: u.homeDir,
2671
- role: u.role,
2672
- sshKeys: u.sshKeys ?? [],
2673
- directoryPermissions: u.directoryPermissions,
2674
- accessPolicies: u.accessPolicies,
2675
- createdAt: new Date(u.createdAt)
2676
- };
2677
- }
2678
- async permissionsAdd(options) {
2679
- await this.ensureRunning();
2680
- const u = await readResponseJson(await this.runtimeFetch("/permissions/users", {
2681
- method: "POST",
2682
- body: JSON.stringify(options)
2683
- }));
2684
- return {
2685
- userId: u.userId,
2686
- username: u.username,
2687
- homeDir: u.homeDir,
2688
- role: u.role,
2689
- sshKeys: u.sshKeys ?? [],
2690
- directoryPermissions: u.directoryPermissions,
2691
- accessPolicies: u.accessPolicies,
2692
- createdAt: new Date(u.createdAt)
2693
- };
2694
- }
2695
- async permissionsUpdate(userId, options) {
2696
- await this.ensureRunning();
2697
- const u = await readResponseJson(await this.runtimeFetch(`/permissions/users/${encodeURIComponent(userId)}`, {
2698
- method: "PATCH",
2699
- body: JSON.stringify(options)
2700
- }));
2701
- return {
2702
- userId: u.userId,
2703
- username: u.username,
2704
- homeDir: u.homeDir,
2705
- role: u.role,
2706
- sshKeys: u.sshKeys ?? [],
2707
- directoryPermissions: u.directoryPermissions,
2708
- accessPolicies: u.accessPolicies,
2709
- createdAt: new Date(u.createdAt)
2710
- };
2711
- }
2712
- async permissionsRemove(userId, options) {
2713
- await this.ensureRunning();
2714
- const params = new URLSearchParams();
2715
- if (options?.preserveHomeDir) params.set("preserveHomeDir", "true");
2716
- const query = params.toString();
2717
- const path = query ? `/permissions/users/${encodeURIComponent(userId)}?${query}` : `/permissions/users/${encodeURIComponent(userId)}`;
2718
- const response = await this.runtimeFetch(path, { method: "DELETE" });
2719
- if (!response.ok) throw await parseResponseError(response);
2720
- }
2721
- async permissionsSetAccessPolicies(userId, rules) {
2722
- await this.ensureRunning();
2723
- const response = await this.runtimeFetch(`/permissions/users/${encodeURIComponent(userId)}/policies`, {
2724
- method: "PUT",
2725
- body: JSON.stringify({ rules })
2726
- });
2727
- if (!response.ok) throw await parseResponseError(response);
2728
- }
2729
- async permissionsGetAccessPolicies(userId) {
2730
- await this.ensureRunning();
2731
- return (await readResponseJson(await this.runtimeFetch(`/permissions/users/${encodeURIComponent(userId)}/policies`, { method: "GET" }))).rules ?? [];
2732
- }
2733
- async permissionsCheckAccess(userId, path, action) {
2734
- await this.ensureRunning();
2735
- return (await readResponseJson(await this.runtimeFetch(`/permissions/users/${encodeURIComponent(userId)}/check`, {
2736
- method: "POST",
2737
- body: JSON.stringify({
2738
- path,
2739
- action
2740
- })
2741
- }))).allowed === true;
2742
- }
2743
- };
2744
- //#endregion
2745
2616
  //#region src/sandbox-workspace-backend.ts
2746
- var SandboxBackendCapabilities = class extends SandboxPermissionsCapabilities {
2617
+ var SandboxBackendCapabilities = class extends SandboxGitCapabilities {
2747
2618
  /**
2748
2619
  * Backend manager for runtime agent configuration.
2749
2620
  *
@@ -3325,77 +3196,12 @@ var SandboxPreviewCapabilities = class extends SandboxGpuCapabilities {
3325
3196
  }
3326
3197
  };
3327
3198
  //#endregion
3328
- //#region src/sandbox-workspace-tools.ts
3329
- var SandboxToolsCapabilities = class extends SandboxPreviewCapabilities {
3330
- /**
3331
- * Tools capability object for managing language runtimes.
3332
- *
3333
- * Uses mise (polyglot version manager) to install and manage tools.
3334
- *
3335
- * @example Install and use Node.js
3336
- * ```typescript
3337
- * await box.tools.install("node", "22");
3338
- * await box.tools.use("node", "22");
3339
- * const list = await box.tools.list();
3340
- * ```
3341
- */
3342
- get tools() {
3343
- return {
3344
- install: (tool, version) => this.toolsInstall(tool, version),
3345
- use: (tool, version) => this.toolsUse(tool, version),
3346
- list: () => this.toolsList(),
3347
- run: (tool, args) => this.toolsRun(tool, args)
3348
- };
3349
- }
3350
- async toolsInstall(tool, version) {
3351
- await this.ensureRunning();
3352
- const response = await this.runtimeFetch("/tools/install", {
3353
- method: "POST",
3354
- body: JSON.stringify({
3355
- tool,
3356
- version
3357
- })
3358
- });
3359
- if (!response.ok) throw await parseResponseError(response);
3360
- }
3361
- async toolsUse(tool, version) {
3362
- await this.ensureRunning();
3363
- const response = await this.runtimeFetch("/tools/use", {
3364
- method: "POST",
3365
- body: JSON.stringify({
3366
- tool,
3367
- version
3368
- })
3369
- });
3370
- if (!response.ok) throw await parseResponseError(response);
3371
- }
3372
- async toolsList() {
3373
- await this.ensureRunning();
3374
- return (await readResponseJson(await this.runtimeFetch("/tools", { method: "GET" }))).tools ?? [];
3375
- }
3376
- async toolsRun(tool, args) {
3377
- await this.ensureRunning();
3378
- const data = await readResponseJson(await this.runtimeFetch("/tools/run", {
3379
- method: "POST",
3380
- body: JSON.stringify({
3381
- tool,
3382
- args
3383
- })
3384
- }));
3385
- return {
3386
- exitCode: data.exitCode ?? 0,
3387
- stdout: data.stdout ?? "",
3388
- stderr: data.stderr ?? ""
3389
- };
3390
- }
3391
- };
3392
- //#endregion
3393
3199
  //#region src/sandbox-lifecycle-events.ts
3394
3200
  function normalizeProvisionStep(raw) {
3395
3201
  if (raw === "sidecar-ready") return "runtime-ready";
3396
3202
  return raw;
3397
3203
  }
3398
- var SandboxLifecycleEventsCapabilities = class extends SandboxToolsCapabilities {
3204
+ var SandboxLifecycleEventsCapabilities = class extends SandboxPreviewCapabilities {
3399
3205
  /**
3400
3206
  * Stream sandbox lifecycle and activity events.
3401
3207
  */
@@ -3766,13 +3572,49 @@ var SandboxLifecycleCapabilities = class extends SandboxLifecycleEventsCapabilit
3766
3572
  };
3767
3573
  }
3768
3574
  };
3575
+ /**
3576
+ * The platform's typed refusal when one sandbox already has a lifecycle
3577
+ * operation in flight: HTTP 409 from `withSandboxLifecycleClaim`
3578
+ * (products/sandbox/api/src/routes/sandbox-lifecycle-claim.ts).
3579
+ */
3580
+ const LIFECYCLE_CONFLICT_CODE = "SANDBOX_LIFECYCLE_IN_PROGRESS";
3581
+ /**
3582
+ * How long a lifecycle call re-attempts that refusal before it surfaces.
3583
+ *
3584
+ * MEASURED MOTIVE. `resume`, `stop` and `delete` are the only three routes the
3585
+ * API guards, and they share one lease per sandbox, `lifecycle-<id>`. That
3586
+ * lease outlives the response of the call that took it: the delete handler
3587
+ * registers deferred key-revoke and meta-delete work through
3588
+ * `deferSandboxLifecycleWork`, and the release is chained after that work
3589
+ * through `executionCtx.waitUntil`. So a second lifecycle call landing inside
3590
+ * that window is refused even though nothing is wrong and the caller only has
3591
+ * to wait. The platform's own workflow smoke already hand-rolls this retry and
3592
+ * says why (scripts/platform-workflow-deploy-smoke.mjs: "the worker can still
3593
+ * hold the sandbox lifecycle claim while its final action cleanup completes,
3594
+ * so sandbox-api returns a typed 409 for a short, valid window").
3595
+ *
3596
+ * The number: 2 of 2 provider-seam runs on 2026-09-01 (tangle-network/agent-sdk#280)
3597
+ * lost a completed agent turn to this refusal. `agent-runtime`'s provider
3598
+ * executor destroys one environment twice — once when the stream settles and
3599
+ * once from `teardown()` — and the second DELETE was refused, which discarded
3600
+ * the first one's result. Nothing about the sandbox document tells a client the
3601
+ * lease is held (the response schema is `.strict()` and carries no lifecycle
3602
+ * field), so a status poll cannot replace this retry.
3603
+ *
3604
+ * The ceiling is short on purpose. The lease TTL is 360 s, but the window this
3605
+ * closes is the deferred-cleanup tail of an operation that already answered;
3606
+ * a conflict that outlives ~11 s is a genuinely concurrent operation and
3607
+ * belongs to the caller, not to a longer sleep here.
3608
+ */
3609
+ const LIFECYCLE_CONFLICT_MAX_ATTEMPTS = 6;
3610
+ const LIFECYCLE_CONFLICT_BASE_DELAY_MS = 500;
3769
3611
  const LIFECYCLE_CONFLICT_MAX_DELAY_MS = 4e3;
3770
3612
  function isLifecycleConflict(cause) {
3771
- return cause instanceof SandboxError && cause.status === 409 && cause.code === "SANDBOX_LIFECYCLE_IN_PROGRESS";
3613
+ return cause instanceof SandboxError && cause.status === 409 && cause.code === LIFECYCLE_CONFLICT_CODE;
3772
3614
  }
3773
3615
  function lifecycleConflictDelayMs(cause, failedAttempt) {
3774
3616
  if (cause instanceof SandboxError && cause.retryAfterMs !== void 0) return cause.retryAfterMs;
3775
- return Math.min(500 * 2 ** Math.max(0, failedAttempt - 1), LIFECYCLE_CONFLICT_MAX_DELAY_MS);
3617
+ return Math.min(LIFECYCLE_CONFLICT_BASE_DELAY_MS * 2 ** Math.max(0, failedAttempt - 1), LIFECYCLE_CONFLICT_MAX_DELAY_MS);
3776
3618
  }
3777
3619
  /**
3778
3620
  * Run one lifecycle mutation, re-attempting only the platform's typed
@@ -3785,7 +3627,7 @@ async function withLifecycleConflictRetry(run, options) {
3785
3627
  for (let attempt = 1;; attempt += 1) try {
3786
3628
  return await run();
3787
3629
  } catch (error) {
3788
- if (!isLifecycleConflict(error) || attempt >= 6 || options?.signal?.aborted) throw error;
3630
+ if (!isLifecycleConflict(error) || attempt >= LIFECYCLE_CONFLICT_MAX_ATTEMPTS || options?.signal?.aborted) throw error;
3789
3631
  await delayUntilAborted(lifecycleConflictDelayMs(error, attempt), options?.signal);
3790
3632
  }
3791
3633
  }
@@ -3829,7 +3671,7 @@ function usableExecutionTtlMs(ttlMs) {
3829
3671
  * error for the wrong reason.
3830
3672
  */
3831
3673
  function timerMsViolation(value) {
3832
- if (typeof value === "number" && Number.isInteger(value) && value > 0 && value <= 2147483647) return;
3674
+ if (typeof value === "number" && Number.isInteger(value) && value > 0 && value <= MAX_TIMER_MS) return;
3833
3675
  return typeof value === "number" ? String(value) : typeof value;
3834
3676
  }
3835
3677
  //#endregion
@@ -4988,6 +4830,10 @@ var SandboxRuntimeOperations = class extends SandboxLifecycleCapabilities {
4988
4830
  return await readResponseJson(await state(this).client.fetch(`/v1/sandboxes/${this.id}/driver`));
4989
4831
  }
4990
4832
  };
4833
+ //#endregion
4834
+ //#region src/sandbox-exec.ts
4835
+ const EXEC_DEFAULT_TIMEOUT_MS = 3e4;
4836
+ const EXEC_MIN_TIMEOUT_MS = 100;
4991
4837
  const EXEC_MAX_TIMEOUT_MS = 6e5;
4992
4838
  const EXEC_TRANSPORT_MARGIN_MS = 15e3;
4993
4839
  /**
@@ -5014,8 +4860,8 @@ var SandboxExecCapabilities = class extends SandboxRuntimeOperations {
5014
4860
  async exec(command, options) {
5015
4861
  const headers = callHeaders(options);
5016
4862
  await this.ensureRunning(options?.signal);
5017
- const timeoutMs = options?.timeoutMs ?? 3e4;
5018
- if (!Number.isInteger(timeoutMs) || timeoutMs < 100 || timeoutMs > 6e5) throw new ValidationError(`exec timeoutMs must be an integer between 100 and ${EXEC_MAX_TIMEOUT_MS}`);
4863
+ const timeoutMs = options?.timeoutMs ?? EXEC_DEFAULT_TIMEOUT_MS;
4864
+ if (!Number.isInteger(timeoutMs) || timeoutMs < EXEC_MIN_TIMEOUT_MS || timeoutMs > EXEC_MAX_TIMEOUT_MS) throw new ValidationError(`exec timeoutMs must be an integer between ${EXEC_MIN_TIMEOUT_MS} and ${EXEC_MAX_TIMEOUT_MS}`);
5019
4865
  const result = (await readResponseJson(await this.runtimeFetch("/process/spawn", {
5020
4866
  method: "POST",
5021
4867
  headers,
@@ -5356,7 +5202,7 @@ var SandboxFileWriteCapabilities = class extends SandboxExecCapabilities {
5356
5202
  break;
5357
5203
  } catch (err) {
5358
5204
  if (isTransientWriteError(err) && attempt < maxRetries) {
5359
- const backoff = Math.min(250 * 2 ** attempt, WRITE_MANY_RETRY_MAX_MS);
5205
+ const backoff = Math.min(WRITE_MANY_RETRY_BASE_MS * 2 ** attempt, WRITE_MANY_RETRY_MAX_MS);
5360
5206
  await delay((err instanceof SandboxError ? err.retryAfterMs : void 0) ?? backoff);
5361
5207
  continue;
5362
5208
  }
@@ -5370,8 +5216,8 @@ var SandboxFileWriteCapabilities = class extends SandboxExecCapabilities {
5370
5216
  */
5371
5217
  async writeMany(files, options = {}) {
5372
5218
  if (files.length === 0) return;
5373
- const paceMs = options.paceMs ?? 0;
5374
- const maxRetries = options.maxRetries ?? 4;
5219
+ const paceMs = options.paceMs ?? WRITE_MANY_DEFAULT_PACE_MS;
5220
+ const maxRetries = options.maxRetries ?? WRITE_MANY_DEFAULT_MAX_RETRIES;
5375
5221
  await this.ensureRunning();
5376
5222
  if (hasDuplicateWriteManyPaths(files)) {
5377
5223
  await this.writeManySequential(files, paceMs, maxRetries);
@@ -5420,7 +5266,11 @@ var SandboxFileWriteCapabilities = class extends SandboxExecCapabilities {
5420
5266
  return state(this).filesystemOperations.fs;
5421
5267
  }
5422
5268
  };
5269
+ const WRITE_MANY_DEFAULT_PACE_MS = 0;
5270
+ const WRITE_MANY_DEFAULT_MAX_RETRIES = 4;
5271
+ const WRITE_MANY_RETRY_BASE_MS = 250;
5423
5272
  const WRITE_MANY_RETRY_MAX_MS = 2e3;
5273
+ const WRITE_MANY_BATCH_MAX_FILES = 100;
5424
5274
  const WRITE_MANY_BATCH_WIRE_BUDGET_BYTES = SANDBOX_PROXY_REQUEST_MAX_BYTES - 8 * 1024;
5425
5275
  function toWriteManyWireFile(file) {
5426
5276
  return {
@@ -5441,7 +5291,7 @@ function splitWriteManyBatches(files) {
5441
5291
  for (const file of files) {
5442
5292
  const candidate = [...current, file];
5443
5293
  const candidateBody = serializeWriteManyBatch(candidate);
5444
- const exceedsCount = candidate.length > 100;
5294
+ const exceedsCount = candidate.length > WRITE_MANY_BATCH_MAX_FILES;
5445
5295
  const exceedsWireBudget = new TextEncoder().encode(candidateBody).byteLength > WRITE_MANY_BATCH_WIRE_BUDGET_BYTES;
5446
5296
  if (current.length > 0 && (exceedsCount || exceedsWireBudget)) {
5447
5297
  batches.push({
@@ -6509,7 +6359,7 @@ var SandboxPromptTransportCapabilities = class extends SandboxSessionAdmissionCa
6509
6359
  };
6510
6360
  if (typeof request.body === "string" && new TextEncoder().encode(request.body).byteLength > 1048576) throw new ValidationError("Agent run request exceeds the gateway request bound; place large content in resources.files");
6511
6361
  response = await this.runtimeFetch(requestEndpoint, request);
6512
- for (let attempt = 1; !explicitReplay && response.status === 503 && attempt <= 3; attempt += 1) {
6362
+ for (let attempt = 1; !explicitReplay && response.status === 503 && attempt <= MAX_CREDENTIAL_REFUSAL_RETRIES; attempt += 1) {
6513
6363
  const body = await response.clone().text();
6514
6364
  const refusal = parseErrorResponse(response.status, body, {
6515
6365
  method: request.method,
@@ -6823,6 +6673,7 @@ function toStreamErrorEvent(err) {
6823
6673
  }
6824
6674
  };
6825
6675
  }
6676
+ const MAX_CREDENTIAL_REFUSAL_RETRIES = 3;
6826
6677
  //#endregion
6827
6678
  //#region src/sandbox-prompt.ts
6828
6679
  var SandboxPromptCapabilities = class extends SandboxPromptTransportCapabilities {
@@ -8215,6 +8066,7 @@ function interpretWorkspaceOperationLookup(body, kind, keyOnly) {
8215
8066
  };
8216
8067
  }
8217
8068
  const SNAPSHOT_RESTORE_POLL_INTERVAL_MS = 1e3;
8069
+ const SNAPSHOT_RESTORE_FIRST_POLL_INTERVAL_MS = 200;
8218
8070
  const SNAPSHOT_RESTORE_POLL_GROWTH = 1.6;
8219
8071
  const SNAPSHOT_RESTORE_TIMEOUT_MS = 600 * 1e3;
8220
8072
  /**
@@ -8229,7 +8081,7 @@ const SNAPSHOT_RESTORE_TIMEOUT_MS = 600 * 1e3;
8229
8081
  * poll rate is bounded by the ceiling, not by the starting interval.
8230
8082
  */
8231
8083
  function nextRestorePollDelayMs(pollsTaken) {
8232
- const delay = 200 * SNAPSHOT_RESTORE_POLL_GROWTH ** pollsTaken;
8084
+ const delay = SNAPSHOT_RESTORE_FIRST_POLL_INTERVAL_MS * SNAPSHOT_RESTORE_POLL_GROWTH ** pollsTaken;
8233
8085
  return Math.min(Math.round(delay), SNAPSHOT_RESTORE_POLL_INTERVAL_MS);
8234
8086
  }
8235
8087
  const SNAPSHOT_VISIBILITY_POLL_INTERVAL_MS = 1e3;
@@ -1,2 +1,2 @@
1
- import { C as JsonResponseParamTypes, E as SandboxIdParamTypes, S as JOB_SANDBOX_DELETE, T as SandboxCreateResponseParamTypes, _ as TANGLE_JOBS_CONTRACT, a as fetchQuote, b as AgentSandboxBlueprintAbi, c as parseQuoteResponse, d as OperatorSession, f as OperatorSessionError, g as TANGLE_CHAIN_ID, h as TangleSandboxClient, 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 TangleSandboxClientConfig, w as SandboxCreateParamTypes, x as JOB_SANDBOX_CREATE, y as ITangleJobsAbi } from "../index-D4OBUP5M.js";
1
+ import { C as JsonResponseParamTypes, E as SandboxIdParamTypes, S as JOB_SANDBOX_DELETE, T as SandboxCreateResponseParamTypes, _ as TANGLE_JOBS_CONTRACT, a as fetchQuote, b as AgentSandboxBlueprintAbi, c as parseQuoteResponse, d as OperatorSession, f as OperatorSessionError, g as TANGLE_CHAIN_ID, h as TangleSandboxClient, 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 TangleSandboxClientConfig, w as SandboxCreateParamTypes, x as JOB_SANDBOX_CREATE, y as ITangleJobsAbi } from "../index-D5dVNm76.js";
2
2
  export { AgentSandboxBlueprintAbi, 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, TangleSandboxClient, TangleSandboxClientConfig, 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 TangleSandboxClient, t as QuoteError, u as TANGLE_CHAIN_ID, v as SandboxCreateResponseParamTypes, y as SandboxIdParamTypes } from "../tangle-D-VfQGTu.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 TangleSandboxClient, t as QuoteError, u as TANGLE_CHAIN_ID, v as SandboxCreateResponseParamTypes, y as SandboxIdParamTypes } from "../tangle-C4Bp5krB.js";
2
2
  export { AgentSandboxBlueprintAbi, ITangleJobsAbi, JOB_SANDBOX_CREATE, JOB_SANDBOX_DELETE, JsonResponseParamTypes, OperatorSession, OperatorSessionError, QuoteError, SandboxCreateParamTypes, SandboxCreateResponseParamTypes, SandboxIdParamTypes, TANGLE_CHAIN_ID, TANGLE_JOBS_CONTRACT, TangleSandboxClient, fetchQuote, inputsHashOf, jobQuoteDigest, parseQuoteResponse, validateQuote };
@@ -1,5 +1,5 @@
1
1
  import { i as readResponseJson } from "./errors-BfbOP_rx.js";
2
- import { n as createSandboxInstanceFromResponse } from "./sandbox-BDgvO9Z3.js";
2
+ import { n as createSandboxInstanceFromResponse } from "./sandbox-BPLzHOZ1.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-BGvM02yJ.js";
4
4
  //#region ../../../packages/runtime-contracts/dist/tangle-blueprint-abi.js
5
5
  /**