@tangle-network/sandbox 1.0.264 → 1.0.266

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 +17 -7
  2. package/dist/abi-pcDt2Adp.js +136 -0
  3. package/dist/agent/index.d.ts +4 -4
  4. package/dist/agent/index.js +5 -5
  5. package/dist/agent/preview.d.ts +1 -1
  6. package/dist/agent/preview.js +2 -2
  7. package/dist/{agent-run-outcome-DLLvOkbe.d.ts → agent-run-outcome-DThM9ULE.d.ts} +2 -2
  8. package/dist/{api-request-SBaqnuZB.js → api-request-gkPDymqn.js} +2 -2
  9. package/dist/auth/index.d.ts +2 -2
  10. package/dist/auth/index.js +2 -2
  11. package/dist/{browser-interactive-control-controller-Bg7mWDLX.d.ts → browser-interactive-control-controller-ClykJB9N.d.ts} +1 -1
  12. package/dist/{browser-interactive-control-controller-PiCGGheb.js → browser-interactive-control-controller-S_Uo-Zy7.js} +1 -1
  13. package/dist/{chunked-upload-D2S7tOJO.js → chunked-upload-ChZB-dYE.js} +1 -1
  14. package/dist/{chunked-upload-file-CfuaCSja.js → chunked-upload-file-BGaOS3iK.js} +1 -1
  15. package/dist/cli-auth-bundle-DXKH215p.js +2 -0
  16. package/dist/{cli-auth-bundle-C6DtK7GX-D8681c7j.js → cli-auth-bundle-DcxhAW23-C22MMIvx.js} +36 -36
  17. package/dist/{client-CkpH8MsM.js → client-BWD7-uaL.js} +40 -57
  18. package/dist/{client-DaZwQeOS.d.ts → client-BYGLoEiU.d.ts} +153 -198
  19. package/dist/collaboration/index.d.ts +1 -1
  20. package/dist/collaboration/index.js +1 -1
  21. package/dist/{collaboration-Corlo5N0.js → collaboration-Bqk4jYQe.js} +2 -2
  22. package/dist/core.d.ts +6 -6
  23. package/dist/core.js +5 -5
  24. package/dist/{error-catalog-CWtp7Yg1.js → error-catalog-GS97N-Cm.js} +1 -1
  25. package/dist/{errors-C0S3TzhR.js → errors-D44qyFpy.js} +1 -1
  26. package/dist/{file-download-7lcgh1LR.js → file-download-BO-Hmn3x.js} +1 -1
  27. package/dist/gpu-lease/index.d.ts +192 -184
  28. package/dist/gpu-lease/index.js +390 -281
  29. package/dist/{index-dxhLhM8L.d.ts → index-DkB8WbjK.d.ts} +43 -99
  30. package/dist/index.d.ts +13 -13
  31. package/dist/index.js +178 -61
  32. package/dist/intelligence/index.d.ts +1 -1
  33. package/dist/intelligence/index.js +4 -4
  34. package/dist/interactive-control.d.ts +1 -1
  35. package/dist/interactive-control.js +1 -1
  36. package/dist/{interactive-controller-CRp4VQKD.d.ts → interactive-controller-DSYQTRwh.d.ts} +3 -3
  37. package/dist/{interactive-controller-CqJX-LcO.js → interactive-controller-llj6EdlZ.js} +4 -4
  38. package/dist/lib/prepared-evidence.js +1 -1
  39. package/dist/{lines-BTStaSM2.d.ts → lines-D7lE49lV.d.ts} +1 -1
  40. package/dist/{lines-NECw0OhS.js → lines-DwJ7AKx7.js} +1 -1
  41. package/dist/lines.d.ts +1 -1
  42. package/dist/lines.js +1 -1
  43. package/dist/{local-cli-auth-wyO74fdb.js → local-cli-auth-C2cETxK4.js} +1 -1
  44. package/dist/{mcp-local-CpQncJsf.js → mcp-local-DVzsBlqX.js} +3 -3
  45. package/dist/{preview-D6bMarHf.d.ts → preview-DsHoo8BC.d.ts} +3 -3
  46. package/dist/{public-templates-3diq9yKD.d.ts → public-templates-DRqOkshE.d.ts} +2 -2
  47. package/dist/public-templates.d.ts +1 -1
  48. package/dist/public-templates.js +1 -1
  49. package/dist/{raw-evidence-archive-B0oCpHY3.js → raw-evidence-archive-BJ1cA-sP.js} +3 -3
  50. package/dist/runtime.d.ts +5 -5
  51. package/dist/runtime.js +5 -5
  52. package/dist/{sandbox-BVN_aNT1.js → sandbox-C3PqmwfU.js} +136 -196
  53. package/dist/{secp256k1-ZiYFbGjz.js → secp256k1-DIwypP5B.js} +1 -1
  54. package/dist/{select-seat-Cu-9jRO-.js → select-seat-Dc7cQ8To.js} +3 -3
  55. package/dist/select-seat-command.d.ts +2 -2
  56. package/dist/select-seat-command.js +2 -2
  57. package/dist/session-gateway/index.js +1 -1
  58. package/dist/tangle/index.d.ts +1 -1
  59. package/dist/tangle/index.js +2 -1
  60. package/dist/{tangle-Bpv3pIjM.js → tangle-BP8F3ZN0.js} +58 -185
  61. package/dist/{terminal-stream-types-DLaXWiSA.d.ts → terminal-stream-types-Cdz3xrux.d.ts} +1 -1
  62. package/dist/{types-COnts0u7.d.ts → types-BikjtQi3.d.ts} +202 -224
  63. package/package.json +11 -11
  64. package/dist/cli-auth-bundle-D5ZBMpZ7.js +0 -2
  65. /package/dist/{cli-auth-bundle-eUl7Sa1x.d.ts → cli-auth-bundle-CQCt2mcZ.d.ts} +0 -0
  66. /package/dist/{direct-http2-zLxsvF44.js → direct-http2-CzeIT93P.js} +0 -0
  67. /package/dist/{index-ClusTWYM.d.ts → index-B6aMEMDR.d.ts} +0 -0
  68. /package/dist/{index-BTXyTVq4.d.ts → index-BsT3M4X-.d.ts} +0 -0
  69. /package/dist/{prepared-evidence-ibAysmX8.js → prepared-evidence-DIFfn4Ki.js} +0 -0
  70. /package/dist/{preview-operations-DWL78boI.js → preview-operations-BTHZR1w2.js} +0 -0
  71. /package/dist/{raw-evidence-export-C0ieFpi2.d.ts → raw-evidence-export-C-TDdAgC.d.ts} +0 -0
  72. /package/dist/{raw-evidence-export-C6Xdl3nC.js → raw-evidence-export-Dog7W5zP.js} +0 -0
  73. /package/dist/{utils-BT2q9nkO.js → utils-BvN0Mk3j.js} +0 -0
@@ -1,24 +1,24 @@
1
- import { A as requestedPublicProfileDigest, C as runtimeFilesystemPath, D as assertCurrentBackendType, E as applyRequestedModel, F as createAgentRunOutcomeTracker, I as deriveAgentResultOutcome, O as mergeRuntimeBackendConfig, P as withoutRuntimeSecrets, S as encodeTextForWire, U as normalizeEffectiveBackend, _ as mintTraceId, a as assertScopedTokenActive, b as validateAcceptedDispatchRunRef, c as SandboxRuntimeApi, d as appendSessionIdQuery, f as callHeaders, g as isTraceId, h as TRACE_ID_HEADER, i as terminalUpgradeHeadersSupported, j as requestedSecretProfilePublicDigest, k as normalizeRuntimeBackendConfig, l as normalizeSessionInfo, m as assertFileWritePreconditions, n as InteractiveSessionController, p as sessionHeaders, r as TerminalStream, s as requestScopedToken, u as sessionMessageRequestBody, v as resolveTraceId, w as canUseNodeHttp2, x as encodePromptForWire, y as resolveDispatchRunIdentity } from "./interactive-controller-CqJX-LcO.js";
1
+ import { A as requestedPublicProfileDigest, C as runtimeFilesystemPath, D as assertCurrentBackendType, E as applyRequestedModel, F as createAgentRunOutcomeTracker, I as deriveAgentResultOutcome, O as mergeRuntimeBackendConfig, P as withoutRuntimeSecrets, S as encodeTextForWire, U as normalizeEffectiveBackend, _ as mintTraceId, a as assertScopedTokenActive, b as validateAcceptedDispatchRunRef, c as SandboxRuntimeApi, d as appendSessionIdQuery, f as callHeaders, g as isTraceId, h as TRACE_ID_HEADER, i as terminalUpgradeHeadersSupported, j as requestedSecretProfilePublicDigest, k as normalizeRuntimeBackendConfig, l as normalizeSessionInfo, m as assertFileWritePreconditions, n as InteractiveSessionController, p as sessionHeaders, r as TerminalStream, s as requestScopedToken, u as sessionMessageRequestBody, v as resolveTraceId, w as canUseNodeHttp2, x as encodePromptForWire, y as resolveDispatchRunIdentity } from "./interactive-controller-llj6EdlZ.js";
2
2
  import { C as boundedIdentifierSchema$1, E as boundedStringSchema$1, g as sha256DigestSchema$1, o as canonicalCandidateDigest$1, s as canonicalCandidateJson$1 } from "./harness--g8UQ5TZ.js";
3
3
  import { a as ProxySecretReceiptSchema$1, r as agentProfileSchema$1 } from "./profile-schema-B11dRfGB.js";
4
4
  import { t as sha256$1 } from "./sha2-BIoWepwn.js";
5
- 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-PiCGGheb.js";
5
+ 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-S_Uo-Zy7.js";
6
6
  import { t as canonicalAgentProfileDigest } from "./agent-execution-preparation-N1ksNIIJ.js";
7
- import { C as SandboxError, D as TimeoutError, E as StreamInterruptedError, O as ValidationError, T as StateError, _ as NetworkError, a as readResponseJson, b as ProfileFileMountPathError, c as AuthError, f as EdgeNotReadyError, i as parseResponseError, n as isTransientWrite, o as responseMetadata, r as parseErrorResponse, s as retryWhen, t as TerminalStreamError, u as CapabilityError, v as NotFoundError, w as ServerError } from "./errors-C0S3TzhR.js";
7
+ import { C as SandboxError, D as TimeoutError, E as StreamInterruptedError, O as ValidationError, T as StateError, _ as NetworkError, a as readResponseJson, b as ProfileFileMountPathError, c as AuthError, f as EdgeNotReadyError, i as parseResponseError, n as isTransientWrite, o as responseMetadata, r as parseErrorResponse, s as retryWhen, t as TerminalStreamError, u as CapabilityError, v as NotFoundError, w as ServerError, y as PartialFailureError } from "./errors-D44qyFpy.js";
8
8
  import { t as parseSandboxRetryAfterHeader } from "./retry-after-header-BZbs5rig.js";
9
9
  import { n as combineAbortSignals, t as awaitWithAbort } from "./abort-signal-BsriwJ8L.js";
10
10
  import { a as backoffDelayMs, o as isUndelivered, r as abortableSleep } from "./retry-policy-oW3_ljoc.js";
11
- import { a as isReplayableBody, i as fetchSandboxApi, n as SDK_TIMEOUTS, o as rewrapResponse, t as IDEMPOTENT_METHODS } from "./api-request-SBaqnuZB.js";
11
+ import { a as isReplayableBody, i as fetchSandboxApi, n as SDK_TIMEOUTS, o as rewrapResponse, t as IDEMPOTENT_METHODS } from "./api-request-gkPDymqn.js";
12
12
  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-DOSTbUSR.js";
13
- import { c as awaitSdkResend, l as takeSdkTurn, s as uploadChunked } from "./chunked-upload-D2S7tOJO.js";
13
+ import { c as awaitSdkResend, l as takeSdkTurn, s as uploadChunked } from "./chunked-upload-ChZB-dYE.js";
14
14
  import { n as fetchWithKeepAlive, t as emitTiming } from "./keep-alive-fetch-sGVP8skk.js";
15
15
  import { t as SIDECAR_PROXY_ERROR_HEADER } from "./sidecar-proxy-error-DTdbCbUM.js";
16
16
  import { t as parseSSEStream } from "./sse-parser-BCG3iL9j.js";
17
17
  import { t as runPreparedProcess } from "./prepared-process-DQ_68Ofg.js";
18
- import { a as isBackendType, r as cliAuthReferenceSchema } from "./cli-auth-bundle-C6DtK7GX-D8681c7j.js";
19
- import "./cli-auth-bundle-D5ZBMpZ7.js";
20
- import { n as SandboxLines } from "./lines-NECw0OhS.js";
21
- import { t as downloadFile } from "./file-download-7lcgh1LR.js";
18
+ import { a as isBackendType, r as cliAuthReferenceSchema } from "./cli-auth-bundle-DcxhAW23-C22MMIvx.js";
19
+ import "./cli-auth-bundle-DXKH215p.js";
20
+ import { n as SandboxLines } from "./lines-DwJ7AKx7.js";
21
+ import { t as downloadFile } from "./file-download-BO-Hmn3x.js";
22
22
  import { z } from "zod";
23
23
  import { createHash } from "node:crypto";
24
24
  import { constants } from "node:fs";
@@ -807,6 +807,7 @@ var SandboxInstanceState = class {
807
807
  profileReferences;
808
808
  sessionProfileReferencesSupported = false;
809
809
  profileFiles;
810
+ pendingProfile;
810
811
  profileProvenance;
811
812
  directRead;
812
813
  };
@@ -823,17 +824,12 @@ function state(instance) {
823
824
  }
824
825
  //#endregion
825
826
  //#region src/stop-phase.ts
826
- /**
827
- * A stopped sandbox's stop phase, from the API's sandbox body. Under
828
- * `status: "stopped"`, `lifecycleState` is `suspending` while the stop's final
829
- * snapshot is still being committed and `suspended` once it is. `suspendedAt`
830
- * is when the sandbox entered this stop, before that snapshot.
831
- */
827
+ /** Stop, snapshot and deletion progress under the public stopped status. */
832
828
  function parseStopPhase(data) {
833
829
  const state = data.lifecycleState;
834
830
  const suspendedAt = typeof data.suspendedAt === "string" ? new Date(data.suspendedAt) : null;
835
831
  return {
836
- ...state === "suspending" || state === "suspended" ? { lifecycleState: state } : {},
832
+ ...state === "suspending" || state === "suspended" || state === "deleting" ? { lifecycleState: state } : {},
837
833
  ...suspendedAt && !Number.isNaN(suspendedAt.getTime()) ? { suspendedAt } : {}
838
834
  };
839
835
  }
@@ -1182,6 +1178,7 @@ var SandboxInfoCapabilities = class {
1182
1178
  resources: normalizeSandboxShape(data.resources) ?? (id === this.id ? local.info.resources : void 0),
1183
1179
  startupDiagnostics: normalizeStartupDiagnostics(data.startupDiagnostics) ?? carryCreateFacts?.startupDiagnostics,
1184
1180
  createReceipt: normalizeSandboxCreateReceipt(data.createReceipt) ?? carryCreateFacts?.createReceipt,
1181
+ backend: typeof data.backend?.status === "string" ? data.backend : carryCreateFacts?.backend,
1185
1182
  ...normalizeEgressPolicyFields(data)
1186
1183
  };
1187
1184
  }
@@ -2986,7 +2983,7 @@ var DirectRuntimeHttpClient = class {
2986
2983
  path
2987
2984
  };
2988
2985
  if (!route) throw new NetworkError("Direct runtime route was withdrawn");
2989
- const { fetchDirectHttp2: transport } = (route.useHost || route.useExec) && canUseNodeHttp2() ? await import("./direct-http2-zLxsvF44.js") : { fetchDirectHttp2: fetchWithKeepAlive };
2986
+ const { fetchDirectHttp2: transport } = (route.useHost || route.useExec) && canUseNodeHttp2() ? await import("./direct-http2-CzeIT93P.js") : { fetchDirectHttp2: fetchWithKeepAlive };
2990
2987
  return fetchSandboxApi({
2991
2988
  baseUrl: route.origin,
2992
2989
  timeoutMs: this.baseClient.timeoutMs,
@@ -5100,7 +5097,7 @@ const ERROR_CATALOG = {
5100
5097
  BRANCH_UFFD_UNAVAILABLE: "503 retry | The parent host cannot fork live memory now. | Retry, or branch from a snapshot.",
5101
5098
  CAPACITY_EXHAUSTED: "503 retry | No host has room for this sandbox now. | Retry after the Retry-After interval.",
5102
5099
  COMPLIANCE_CAPACITY_UNAVAILABLE: "503 retry | No verified compliance-scope host can take this sandbox now. | Retry after the Retry-After interval.",
5103
- FIRECRACKER_IMAGE_UNAVAILABLE: "503 final | No host carries the requested Firecracker image. | Choose an image the Firecracker hosts carry, or the Docker runtime.",
5100
+ FIRECRACKER_IMAGE_UNAVAILABLE: "503 final | No host carries the requested Firecracker image. | Choose an image whose runtimes include firecracker in `environments list`, or set runtime: docker.",
5104
5101
  PLACEMENT_WARMING: "503 retry | The cell's controller has just started and has not heard a host yet. | Retry after the Retry-After interval.",
5105
5102
  HOST_UNAVAILABLE: "503 retry | The host did not answer; the sandbox and its files remain. | Retry after the Retry-After interval.",
5106
5103
  HOST_PRESSURE: "503 retry | The host was too busy to create the sandbox and created nothing. | Retry after the Retry-After interval.",
@@ -6865,12 +6862,10 @@ function validateDeferredProfileFileMounts(files, options = {}) {
6865
6862
  }
6866
6863
  /**
6867
6864
  * Split inline `resources.skills` out of a profile the way
6868
- * {@link splitInlineProfileFileMounts} splits inline files: the returned
6869
- * `leanProfile` drops them so the create POST fits its wire cap. Unlike file
6870
- * mounts, skills are NOT materialized to disk here — they are harness-specific
6871
- * (each turn's harness needs them in its own dir), so they must ride the
6872
- * per-turn profile. The full profile is delivered once (create-time priming)
6873
- * and referenced by hash thereafter.
6865
+ * {@link splitInlineProfileFileMounts} splits inline files, so the create POST
6866
+ * fits its wire cap. Skills are harness-specific (each turn's harness needs
6867
+ * them in its own dir), so they ride the per-turn profile: primed once on the
6868
+ * handle's first runtime call and referenced by hash thereafter.
6874
6869
  */
6875
6870
  function splitInlineProfileSkills(profile) {
6876
6871
  const skills = profile.resources?.skills ?? [];
@@ -7272,7 +7267,7 @@ const PROFILE_BUNDLE_PUBLISH_ENDPOINT = "/agents/profile-bundle/publish";
7272
7267
  /**
7273
7268
  * Wall-clock ceiling for one claim/publish round trip. The cache is an
7274
7269
  * optimization: a stalled box must fall back to (or skip) delivery, never
7275
- * hold create() hostage.
7270
+ * hold the handle's first runtime call hostage.
7276
7271
  */
7277
7272
  const PROFILE_BUNDLE_HTTP_TIMEOUT_MS = 1e4;
7278
7273
  function profileBundleDebug(message, data = {}) {
@@ -7426,15 +7421,7 @@ var ProfileFileDelivery = class {
7426
7421
  };
7427
7422
  //#endregion
7428
7423
  //#region src/operation.ts
7429
- /**
7430
- * A stop or snapshot the API accepted with `wait: false`.
7431
- *
7432
- * The verb answered as soon as the platform durably recorded it; the work
7433
- * finishes in the background. `wait()` polls the operation until it is
7434
- * terminal and resolves with it, or throws {@link SandboxOperationFailedError}
7435
- * carrying the failure code. A verb the API finished synchronously comes back
7436
- * as an operation that is already `succeeded`.
7437
- */
7424
+ /** Durable lifecycle operations and their client waits. */
7438
7425
  const FIRST_POLL_MS = 250;
7439
7426
  const MAX_POLL_MS = 2e3;
7440
7427
  /** An accepted operation ended in failure. `code` names why. */
@@ -7474,11 +7461,7 @@ function contractViolation(message) {
7474
7461
  status: 502
7475
7462
  });
7476
7463
  }
7477
- /**
7478
- * Parse the API's operation body; throws on a body that is not one. With
7479
- * `expected`, a well-formed body naming another operation, kind or sandbox
7480
- * throws too: tracking must never move to work this call did not ask for.
7481
- */
7464
+ /** Parse a wire operation without changing the expected identity. */
7482
7465
  function parseSandboxOperation(value, expected) {
7483
7466
  const info = parseOperationBody(value);
7484
7467
  if (expected && (expected.kind !== void 0 && info.kind !== expected.kind || info.sandboxId !== expected.sandboxId || expected.id !== void 0 && info.id !== expected.id)) throw contractViolation(`The API answered ${info.kind} operation ${info.id} on ${info.sandboxId} for ${expected.kind ?? "an"} operation ${expected.id ?? "(new)"} on ${expected.sandboxId}`);
@@ -7520,16 +7503,11 @@ var SandboxOperation = class SandboxOperation {
7520
7503
  #client;
7521
7504
  #onSettled;
7522
7505
  #settled = false;
7523
- /**
7524
- * @param client - null for a verb that already finished synchronously.
7525
- * @param onSettled - runs once when the operation is first seen succeeded.
7526
- */
7527
7506
  constructor(info, client, onSettled) {
7528
7507
  this.#info = info;
7529
7508
  this.#client = client;
7530
7509
  this.#onSettled = onSettled;
7531
7510
  }
7532
- /** A verb the API finished synchronously, as a succeeded operation. */
7533
7511
  static completed(kind, sandboxId, result) {
7534
7512
  const now = /* @__PURE__ */ new Date();
7535
7513
  return new SandboxOperation({
@@ -7554,15 +7532,15 @@ var SandboxOperation = class SandboxOperation {
7554
7532
  return this.#info;
7555
7533
  }
7556
7534
  /** Read the operation's current state. */
7557
- async refresh({ signal } = {}) {
7535
+ async refresh({ signal, waitMs = 0 } = {}) {
7558
7536
  signal?.throwIfAborted();
7559
7537
  if (!this.#client || isTerminalOperation(this.#info)) {
7560
7538
  await this.#settle();
7561
7539
  signal?.throwIfAborted();
7562
7540
  return this.#info;
7563
7541
  }
7564
- const until = this.#info.kind === "delete" && new URLSearchParams(this.#info.statusUrl.split("?")[1]).get("until") === "removed";
7565
- const response = await this.#client.fetch(`/v1/sandboxes/${encodeURIComponent(this.#info.sandboxId)}/operations/${encodeURIComponent(this.#info.id)}${until ? "?until=removed" : ""}`, { signal });
7542
+ const query = this.#info.kind === "delete" && new URLSearchParams(this.#info.statusUrl.split("?")[1]).get("until") === "removed" ? "?until=removed" : waitMs ? `?waitMs=${waitMs}` : "";
7543
+ const response = await this.#client.fetch(`/v1/sandboxes/${encodeURIComponent(this.#info.sandboxId)}/operations/${encodeURIComponent(this.#info.id)}${query}`, { signal });
7566
7544
  if (!response.ok) throw await parseResponseError(response);
7567
7545
  this.#info = parseSandboxOperation(await response.json(), {
7568
7546
  kind: this.#info.kind,
@@ -7578,14 +7556,7 @@ var SandboxOperation = class SandboxOperation {
7578
7556
  this.#settled = true;
7579
7557
  await this.#onSettled?.(this.#info);
7580
7558
  }
7581
- /**
7582
- * Poll until the operation is terminal (250 ms, doubling to 2 s). Resolves
7583
- * with a succeeded operation; throws {@link SandboxOperationFailedError} on
7584
- * a failed one and {@link TimeoutError} past `timeoutMs` (default 10 min).
7585
- * The verb was accepted, so a read that was lost, timed out or refused
7586
- * retryably says nothing about it: read again on the shared retry pacing
7587
- * (the server's Retry-After, else full jitter, and the client's retry budget).
7588
- */
7559
+ /** Wait through held snapshot reads or paced polls; retain retry budgets and identity. */
7589
7560
  async wait(options = {}) {
7590
7561
  const timeoutMs = options.timeoutMs ?? SDK_TIMEOUTS.operationWait;
7591
7562
  const startedAt = Date.now();
@@ -7605,8 +7576,13 @@ var SandboxOperation = class SandboxOperation {
7605
7576
  await abortableSleep(delayMs, signal);
7606
7577
  capMs = Math.min(Math.max(capMs * 2, FIRST_POLL_MS), MAX_POLL_MS);
7607
7578
  try {
7608
- info = await this.refresh({ signal });
7609
- [delayMs, failedReads] = [capMs, 0];
7579
+ const readStartedAt = Date.now();
7580
+ info = await this.refresh({
7581
+ signal,
7582
+ waitMs: this.#info.kind === "snapshot" ? Math.max(0, Math.min(1e4, startedAt + timeoutMs - Date.now())) : 0
7583
+ });
7584
+ delayMs = this.#info.kind === "snapshot" ? Math.max(0, capMs - (Date.now() - readStartedAt)) : capMs;
7585
+ failedReads = 0;
7610
7586
  } catch (error) {
7611
7587
  if (!retryWhen(error) || error.code === "UPSTREAM_CONTRACT_VIOLATION") throw error;
7612
7588
  const deadlineAt = startedAt + timeoutMs;
@@ -7925,6 +7901,8 @@ var SandboxBackendCapabilities = class extends SandboxGitCapabilities {
7925
7901
  };
7926
7902
  }
7927
7903
  async backendStatus() {
7904
+ const created = state(this).info.backend;
7905
+ if (created) return created;
7928
7906
  await this.ensureRunning();
7929
7907
  return await readResponseJson(await this.runtimeFetch("/backend", { method: "GET" }));
7930
7908
  }
@@ -8246,28 +8224,29 @@ var SandboxNetworkCapabilities = class extends SandboxProcessCapabilities {
8246
8224
  //#endregion
8247
8225
  //#region src/sandbox-workspace-gpu.ts
8248
8226
  var SandboxGpuCapabilities = class extends SandboxNetworkCapabilities {
8249
- /**
8250
- * On-demand GPU leases attached to this sandbox.
8251
- *
8252
- * The base sandbox stays cheap; `attach` starts a temporary external GPU
8253
- * worker with an explicit spend cap, and `detach` destroys it.
8254
- */
8255
8227
  get gpu() {
8256
8228
  return {
8257
8229
  providers: (options) => this.gpuProviders(options),
8258
- attach: (options) => this.gpuAttach(options),
8259
- list: () => this.gpuList(),
8260
- exec: (leaseId, options) => this.gpuExec(leaseId, options),
8261
- detach: (leaseId) => this.gpuDetach(leaseId)
8230
+ attach: async (options) => (await this.gpuLeaseRequest(`/v1/sandboxes/${encodeURIComponent(this.id)}/gpu/leases`, "POST", options)).lease,
8231
+ renew: async (leaseId, options) => (await this.gpuLeaseRequest(`/v1/sandboxes/${encodeURIComponent(this.id)}/gpu/leases/${encodeURIComponent(leaseId)}`, "PATCH", options)).lease,
8232
+ list: async () => (await this.gpuLeaseRequest(`/v1/sandboxes/${encodeURIComponent(this.id)}/gpu/leases`)).leases ?? [],
8233
+ exec: (leaseId, options) => this.gpuLeaseRequest(`/v1/sandboxes/${encodeURIComponent(this.id)}/gpu/leases/${encodeURIComponent(leaseId)}/exec`, "POST", options, (options.timeoutMs ?? SDK_TIMEOUTS.gpuCreate) + SDK_TIMEOUTS.margin),
8234
+ detach: async (leaseId) => (await this.gpuLeaseRequest(`/v1/sandboxes/${encodeURIComponent(this.id)}/gpu/leases/${encodeURIComponent(leaseId)}`, "DELETE")).lease
8262
8235
  };
8263
8236
  }
8237
+ async gpuLeaseRequest(path, method = "GET", body, timeoutMs) {
8238
+ return readResponseJson(await state(this).client.fetch(path, {
8239
+ method,
8240
+ ...body === void 0 ? {} : { body: JSON.stringify(body) }
8241
+ }, { timeoutMs: timeoutMs ?? (method === "POST" ? SDK_TIMEOUTS.gpuCreate : void 0) }));
8242
+ }
8264
8243
  async gpuProviders(options = {}) {
8265
8244
  const query = new URLSearchParams();
8266
8245
  const accelerator = options.accelerator;
8267
8246
  if (accelerator) {
8268
8247
  query.set("acceleratorKind", accelerator.kind);
8269
8248
  if (accelerator.count !== void 0) query.set("acceleratorCount", String(accelerator.count));
8270
- if (accelerator.memoryMB !== void 0) query.set("acceleratorMemoryMB", String(accelerator.memoryMB));
8249
+ if (accelerator.vramGb !== void 0) query.set("acceleratorVramGb", String(accelerator.vramGb));
8271
8250
  }
8272
8251
  const suffix = query.size > 0 ? `?${query.toString()}` : "";
8273
8252
  const data = await readResponseJson(await state(this).client.fetch(`/v1/sandboxes/${encodeURIComponent(this.id)}/gpu/providers${suffix}`));
@@ -8276,24 +8255,6 @@ var SandboxGpuCapabilities = class extends SandboxNetworkCapabilities {
8276
8255
  statuses: data.statuses ?? []
8277
8256
  };
8278
8257
  }
8279
- async gpuAttach(options) {
8280
- return (await readResponseJson(await state(this).client.fetch(`/v1/sandboxes/${encodeURIComponent(this.id)}/gpu/leases`, {
8281
- method: "POST",
8282
- body: JSON.stringify(options)
8283
- }))).lease;
8284
- }
8285
- async gpuList() {
8286
- return (await readResponseJson(await state(this).client.fetch(`/v1/sandboxes/${encodeURIComponent(this.id)}/gpu/leases`))).leases ?? [];
8287
- }
8288
- async gpuExec(leaseId, options) {
8289
- return await readResponseJson(await state(this).client.fetch(`/v1/sandboxes/${encodeURIComponent(this.id)}/gpu/leases/${encodeURIComponent(leaseId)}/exec`, {
8290
- method: "POST",
8291
- body: JSON.stringify(options)
8292
- }));
8293
- }
8294
- async gpuDetach(leaseId) {
8295
- return (await readResponseJson(await state(this).client.fetch(`/v1/sandboxes/${encodeURIComponent(this.id)}/gpu/leases/${encodeURIComponent(leaseId)}`, { method: "DELETE" }))).lease;
8296
- }
8297
8258
  };
8298
8259
  //#endregion
8299
8260
  //#region src/sandbox-workspace-preview.ts
@@ -10462,13 +10423,10 @@ function readPublicProfileConflicts(value) {
10462
10423
  }
10463
10424
  var SandboxProfileCapabilities = class extends SandboxFileWriteCapabilities {
10464
10425
  /**
10465
- * Record that the runtime already holds `profile` under `sha256`, so
10466
- * subsequent turns whose profile has the same canonical content send
10467
- * `backend.profileSha256` instead of the inline corpus. Use this to hydrate
10468
- * a freshly-fetched instance (`get()`/`list()`) from caller-persisted state
10469
- * — the reference otherwise lives only on the instance that primed it.
10470
- * Captures a content snapshot, so mutating the object afterwards is
10471
- * detected and that turn falls back to sending the profile inline.
10426
+ * Record that the runtime holds `profile` under `sha256`, so later turns with
10427
+ * the same content send `backend.profileSha256` instead of the corpus. Use it
10428
+ * to hydrate a fetched instance from caller-persisted state; a later mutation
10429
+ * of the object is detected and that turn sends the profile inline.
10472
10430
  */
10473
10431
  attachProfileReference(profile, sha256, name) {
10474
10432
  const data = state(this);
@@ -10478,41 +10436,30 @@ var SandboxProfileCapabilities = class extends SandboxFileWriteCapabilities {
10478
10436
  sha256,
10479
10437
  managed: false
10480
10438
  });
10481
- if (!data.profileProvenance) data.profileProvenance = {
10482
- base: {
10483
- name: name ?? null,
10484
- sha256
10485
- },
10486
- effective: {
10487
- name: name ?? null,
10488
- sha256
10489
- },
10490
- materializedAt: (/* @__PURE__ */ new Date()).toISOString()
10439
+ const effective = {
10440
+ name: name ?? null,
10441
+ sha256
10491
10442
  };
10492
- else data.profileProvenance = {
10443
+ data.profileProvenance = data.profileProvenance ? {
10493
10444
  ...data.profileProvenance,
10494
- effective: {
10495
- name: name ?? null,
10496
- sha256
10497
- }
10445
+ effective
10446
+ } : {
10447
+ base: { ...effective },
10448
+ effective,
10449
+ materializedAt: (/* @__PURE__ */ new Date()).toISOString()
10498
10450
  };
10499
10451
  }
10500
10452
  /**
10501
- * Deliver inline file mounts separately, then upload the remaining profile
10502
- * to the runtime (`POST /agents/profiles`) and record
10503
- * the returned transport-profile hash via {@link attachProfileReference}, so subsequent turns
10504
- * reference it by `profileSha256` instead of re-sending the corpus.
10505
- * Set `preserveManagedProfile` to cache the entire profile through bounded
10506
- * requests. Its managed files stay in the private native revision; this mode
10507
- * never writes them into the shared workspace. Preparation and dispatch then
10508
- * reference the same full profile. Runtime grants are never cached.
10509
- * `create()` calls this automatically for its inline profile when
10510
- * `autoDeferProfile` is on; call it directly when the profile only exists
10511
- * per-turn, or when the instance was fetched rather than created. Persist
10512
- * the returned sha256 alongside a content hash of the profile to
10513
- * re-attach on later instances without re-priming. Throws on transport/HTTP
10514
- * failure — the caller decides whether that is fatal (it is not: turns fall
10515
- * back to sending the file-free profile inline).
10453
+ * Deliver inline file mounts, then upload the remaining profile (`POST
10454
+ * /agents/profiles`) and record its hash via {@link attachProfileReference},
10455
+ * so later turns send `profileSha256` instead of the corpus. With
10456
+ * `preserveManagedProfile` the whole profile is cached through bounded
10457
+ * requests; its managed files stay in the private native revision, never the
10458
+ * shared workspace, and runtime grants are never cached. A create's inline
10459
+ * profile is primed on the handle's first runtime call when `autoDeferProfile`
10460
+ * is on; call this for a per-turn profile or a fetched instance, and persist
10461
+ * the sha256 with the profile's content hash to re-attach without re-priming.
10462
+ * Throws on transport/HTTP failure; a turn then sends the profile inline.
10516
10463
  */
10517
10464
  async primeProfile(profile, options = {}) {
10518
10465
  const parsed = agentProfileSchema$1.safeParse(profile);
@@ -10559,10 +10506,58 @@ var SandboxProfileCapabilities = class extends SandboxFileWriteCapabilities {
10559
10506
  get lastProfileFileDelivery() {
10560
10507
  return state(this).profileFiles.lastReport;
10561
10508
  }
10562
- /** @internal Shared create/turn delivery; caller policy decides how to expose failures. */
10509
+ /** @internal Create/turn delivery; skipped while this incarnation holds the bundle's receipt, even for "replace". Remount with materializeProfileFileMounts. */
10563
10510
  materializeProfileFiles(profile, signal, existingFiles = "allow-identical") {
10564
10511
  return state(this).profileFiles.prepare(this, profile, signal, existingFiles);
10565
10512
  }
10513
+ /**
10514
+ * @internal What create()'s lean POST left out. The handle's first runtime
10515
+ * call delivers it before it runs; a call started while that one is in
10516
+ * flight does not wait (a turn's own preparation is serialized regardless).
10517
+ */
10518
+ deferProfileDelivery(profile, prime) {
10519
+ state(this).pendingProfile = {
10520
+ profile,
10521
+ prime
10522
+ };
10523
+ }
10524
+ async ensureRunning(signal) {
10525
+ await super.ensureRunning(signal);
10526
+ const pending = state(this).pendingProfile;
10527
+ if (!pending) return;
10528
+ state(this).pendingProfile = void 0;
10529
+ try {
10530
+ await this.deliverCreateProfile(pending.profile, pending.prime);
10531
+ } catch (err) {
10532
+ state(this).pendingProfile ??= pending;
10533
+ throw err;
10534
+ }
10535
+ }
10536
+ async deliverCreateProfile(profile, prime) {
10537
+ try {
10538
+ await this.materializeProfileFiles(profile, void 0, "replace");
10539
+ } catch (err) {
10540
+ const paths = splitInlineProfileFileMounts(profile).deferredFiles.map((file) => file.path);
10541
+ const message = `Sandbox ${this.id} is RUNNING but INCOMPLETELY PROVISIONED: materialization of its ${paths.length} deferred inline profile file mount(s) failed partway; some or all of [${paths.join(", ")}] may be missing in the sandbox. The sandbox was NOT deleted — inspect it, retry writing the files yourself, or delete it once you've recovered what you need. Cause: ${err instanceof Error ? err.message : String(err)}`;
10542
+ if (profile.resources?.failOnError === false) {
10543
+ console.warn(`[sandbox.create] ${message}`);
10544
+ return;
10545
+ }
10546
+ const retryable = isRetryableProfileFileMaterializeFailure(err);
10547
+ throw new PartialFailureError(message, {
10548
+ code: retryable ? "PROFILE_FILES_MATERIALIZE_INTERRUPTED" : "PROFILE_FILES_MATERIALIZE_FAILED",
10549
+ status: retryable ? 502 : 422,
10550
+ failures: paths.map((path) => ({ path })),
10551
+ cause: err
10552
+ });
10553
+ }
10554
+ if (prime === void 0) return;
10555
+ try {
10556
+ await this.primeProfile(prime);
10557
+ } catch (err) {
10558
+ console.warn(`[sandbox.create] Profile priming failed for ${this.id}; turns will send the full profile inline. Cause: ${err instanceof Error ? err.message : String(err)}`);
10559
+ }
10560
+ }
10566
10561
  async buildRunBackendBody(overrideBackend, forceFullProfile, requestedModel, signal, preserveManagedProfile = false) {
10567
10562
  const backend = mergeRuntimeBackendConfig(state(this).defaultRuntimeBackend, applyRequestedModel(overrideBackend, requestedModel));
10568
10563
  let normalized = normalizeRuntimeBackendConfig(backend, { allowRuntimeSecrets: true });
@@ -10611,45 +10606,12 @@ var SandboxProfileCapabilities = class extends SandboxFileWriteCapabilities {
10611
10606
  return true;
10612
10607
  }
10613
10608
  /**
10614
- * The profile provenance receipt for this sandbox: which profile was
10615
- * materialized, its content hash, and when. Absent for a bare sandbox
10616
- * created without a profile. This is what `snapshot()` carries into the
10617
- * snapshot metadata, and what `tangle sandbox show --profile` displays.
10609
+ * Which profile was materialized, its hash and when; absent without a
10610
+ * profile. `snapshot()` carries it and `tangle sandbox show --profile` shows it.
10618
10611
  */
10619
10612
  getProfileProvenance() {
10620
10613
  return state(this).profileProvenance;
10621
10614
  }
10622
- /**
10623
- * Compute the materialization diff between the sandbox's effective profile
10624
- * and a desired profile. Returns what to add, update, and remove — the
10625
- * caller applies only the delta instead of nuking and re-materializing.
10626
- *
10627
- * Skills are diffed by name + content hash: a skill that exists in both
10628
- * with the same hash is untouched; different hash = update; only in old =
10629
- * remove; only in new = add. MCP servers diff by name. Model and prompt
10630
- * diff by value.
10631
- */
10632
- diffMaterialization(desired) {
10633
- const current = state(this).profileProvenance;
10634
- if (!current) return {
10635
- skillsToAdd: desired.resources?.skills?.map((s) => s.name) ?? [],
10636
- skillsToUpdate: [],
10637
- skillsToRemove: [],
10638
- mcpChanged: Boolean(desired.mcp),
10639
- modelChanged: Boolean(desired.model),
10640
- noChanges: false
10641
- };
10642
- const effectiveChanged = current.effective.sha256 !== current.base.sha256;
10643
- const desiredKeys = new Set(desired.resources?.skills?.map((s) => s.name) ?? []);
10644
- return {
10645
- skillsToAdd: [],
10646
- skillsToUpdate: [],
10647
- skillsToRemove: [],
10648
- mcpChanged: false,
10649
- modelChanged: false,
10650
- noChanges: !effectiveChanged && desiredKeys.size === 0
10651
- };
10652
- }
10653
10615
  /** Prime an oversized unreferenced profile, then POST a revision prepare. */
10654
10616
  async postProfileRevision(profile, endpoint, body) {
10655
10617
  if (profile && (!state(this).sessionProfileReferencesSupported || !state(this).profileReferences?.has(profileCacheSha256(profile))) && new TextEncoder().encode(body).length > 1048576) await this.primeProfile(profile, { preserveManagedProfile: true });
@@ -12030,7 +11992,7 @@ var SandboxInteractiveCapabilities = class extends SandboxPromptCapabilities {
12030
11992
  var SandboxSessionEvidenceCapabilities = class extends SandboxInteractiveCapabilities {
12031
11993
  /** @internal — invoked before the sandbox is deleted. */
12032
11994
  async _sessionExportRawEvidence(id, destination, options) {
12033
- const { exportRawEvidenceDirectory } = await import("./raw-evidence-archive-B0oCpHY3.js");
11995
+ const { exportRawEvidenceDirectory } = await import("./raw-evidence-archive-BJ1cA-sP.js");
12034
11996
  await this.ensureRunning();
12035
11997
  await this.refresh();
12036
11998
  return exportRawEvidenceDirectory((signal, archiveId, cancel) => this.runtimeFetch(`/agents/sessions/${encodeURIComponent(id)}/raw-evidence/archive?${new URLSearchParams([
@@ -12061,7 +12023,7 @@ var SandboxSessionEvidenceCapabilities = class extends SandboxInteractiveCapabil
12061
12023
  * and the byte and file bounds are verified before the directory appears.
12062
12024
  */
12063
12025
  async exportRawEvidence(destination, options) {
12064
- const { exportRawEvidenceDirectory } = await import("./raw-evidence-archive-B0oCpHY3.js");
12026
+ const { exportRawEvidenceDirectory } = await import("./raw-evidence-archive-BJ1cA-sP.js");
12065
12027
  await this.ensureRunning();
12066
12028
  await this.refresh();
12067
12029
  return exportRawEvidenceDirectory((signal, archiveId, cancel) => this.runtimeFetch(`/agents/raw-evidence/archive?${new URLSearchParams({
@@ -13084,11 +13046,11 @@ function isTransientSnapshotVisibilityError(error) {
13084
13046
  }
13085
13047
  var SandboxSnapshotCapabilities = class extends SandboxTurnCapabilities {
13086
13048
  async snapshot(options) {
13087
- if (options?.wait === false) return this.#snapshotNoWait(options);
13088
13049
  if (options && "paths" in options) throw new Error("Path-scoped snapshot capture is not supported; create a whole-workspace snapshot and use restorePaths()");
13089
13050
  if (options?.idempotencyKey && options.storage) throw new Error("idempotencyKey is not supported with customer-provided storage; the BYOS3 snapshot path keeps no operation ledger");
13090
- await this.ensureRunning();
13091
13051
  if (options?.storage) {
13052
+ if (options.wait === false) throw new Error("wait: false is not supported with customer-provided storage");
13053
+ await this.ensureRunning();
13092
13054
  const data = await readResponseJson(await this.runtimeFetch("/snapshots", {
13093
13055
  method: "POST",
13094
13056
  body: JSON.stringify({
@@ -13104,34 +13066,14 @@ var SandboxSnapshotCapabilities = class extends SandboxTurnCapabilities {
13104
13066
  tags: data.snapshot?.tags ?? data.tags ?? []
13105
13067
  };
13106
13068
  }
13107
- const response = await state(this).client.fetch(`/v1/sandboxes/${this.id}/snapshots`, {
13108
- method: "POST",
13109
- ...options?.idempotencyKey ? { headers: { "Idempotency-Key": options.idempotencyKey } } : {},
13110
- body: JSON.stringify({ tags: options?.tags })
13111
- }, { timeoutMs: SDK_TIMEOUTS.snapshot });
13112
- const data = await readResponseJson(response);
13113
- const snapshotId = data.snapshotId ?? data.id;
13114
- if (typeof snapshotId !== "string" || snapshotId.length === 0) throw new ServerError(`Snapshot create returned 200 but body had no snapshot ID: ${JSON.stringify(data).slice(0, 200)}`, { status: response.status });
13115
- const reportedOutcome = data.idempotency?.outcome;
13116
- const reportedDigest = data.idempotency?.requestDigest;
13117
- const idempotency = (reportedOutcome === "created" || reportedOutcome === "replayed") && typeof reportedDigest === "string" ? {
13118
- outcome: reportedOutcome,
13119
- requestDigest: reportedDigest
13120
- } : void 0;
13121
- const remoteSync = toSnapshotRemoteSync(data.remoteSync);
13122
- return {
13123
- snapshotId,
13124
- createdAt: new Date(data.createdAt ?? Date.now()),
13125
- sizeBytes: data.sizeBytes,
13126
- tags: data.tags ?? [],
13127
- ...remoteSync ? { remoteSync } : {},
13128
- ...idempotency ? { idempotency } : {}
13129
- };
13069
+ const operation = await this.#snapshotNoWait(options ?? {});
13070
+ if (options?.wait === false) return operation;
13071
+ const done = await operation.wait({ timeoutMs: SDK_TIMEOUTS.snapshot });
13072
+ if (!done.result?.snapshot) throw new ServerError(`Snapshot operation ${operation.id} succeeded without a snapshot`);
13073
+ return done.result.snapshot;
13130
13074
  }
13131
13075
  /** Asynchronous acceptance returns an operation; synchronous capture returns a succeeded operation. */
13132
13076
  async #snapshotNoWait(options) {
13133
- if ("paths" in options) throw new Error("Path-scoped snapshot capture is not supported; create a whole-workspace snapshot and use restorePaths()");
13134
- if (options.storage) throw new Error("wait: false is not supported with customer-provided storage; the BYOS3 snapshot path keeps no operation record");
13135
13077
  await this.ensureRunning();
13136
13078
  const response = await state(this).client.fetch(`/v1/sandboxes/${this.id}/snapshots?wait=false`, {
13137
13079
  method: "POST",
@@ -13145,12 +13087,10 @@ var SandboxSnapshotCapabilities = class extends SandboxTurnCapabilities {
13145
13087
  }), state(this).client);
13146
13088
  const snapshotId = body.snapshotId ?? body.id;
13147
13089
  if (typeof snapshotId !== "string" || snapshotId.length === 0) throw new ServerError(`Snapshot create returned ${response.status} but body had no snapshot ID: ${JSON.stringify(body).slice(0, 200)}`, { status: response.status });
13148
- return SandboxOperation.completed("snapshot", this.id, { snapshot: {
13149
- snapshotId,
13150
- createdAt: new Date(typeof body.createdAt === "string" ? body.createdAt : Date.now()),
13151
- ...typeof body.sizeBytes === "number" ? { sizeBytes: body.sizeBytes } : {},
13152
- tags: Array.isArray(body.tags) ? body.tags.filter((tag) => typeof tag === "string") : []
13153
- } });
13090
+ return SandboxOperation.completed("snapshot", this.id, { snapshot: toSnapshotResult({
13091
+ ...body,
13092
+ createdAt: body.createdAt ?? (/* @__PURE__ */ new Date()).toISOString()
13093
+ }) });
13154
13094
  }
13155
13095
  /** List snapshots; storage selects the direct customer-S3 path. */
13156
13096
  async listSnapshots(storage) {
@@ -14161,7 +14101,7 @@ var SandboxFilesystemOperations = class extends DeclaredFilesystemOperations {
14161
14101
  totalBytes: size,
14162
14102
  percentage: 0
14163
14103
  });
14164
- const { uploadChunkedFromFile } = await import("./chunked-upload-file-CfuaCSja.js");
14104
+ const { uploadChunkedFromFile } = await import("./chunked-upload-file-BGaOS3iK.js");
14165
14105
  await uploadChunkedFromFile({ fetch: (path, init) => this.host.runtimeFetch(path, init) }, remotePath, localPath, {
14166
14106
  mode: options?.permissions,
14167
14107
  onProgress: options?.onProgress ? (progress) => {
@@ -15068,4 +15008,4 @@ var SandboxInstance = class SandboxInstance extends SandboxEgressCapabilities {
15068
15008
  }
15069
15009
  };
15070
15010
  //#endregion
15071
- export { isDeployWindowCreateError as $, HARNESS_LAUNCH_MATERIALIZE_OPTIONS as A, parseLifecycleTimes as B, SandboxOperation as C, splitInlineProfileSkills as D, splitInlineProfileFileMounts as E, normalizeCaptureProof as F, CAPACITY_ETA_MARGIN_MS as G, normalizeEgressPolicyFields as H, normalizeSandboxCreateReceipt as I, awaitCreateResend as J, CAPACITY_ETA_WAIT_MAX_MS as K, normalizeStartupDiagnostics as L, enforceWorkspacePlanSupport as M, isMaterializerHarness as N, validateDeferredProfileFileMounts as O, materializeProfile as P, isCapacityShortageCreateError as Q, readFilesystemIncarnationTuple as R, ManagedProcessClient as S, materializeProfileFileMounts as T, normalizeProxySecretReceipt as U, normalizeConnection as V, normalizeSandboxShape as W, extendableDeadline as X, createRetryDelayMs as Y, generateIdempotencyKey as Z, collectAgentFinalMessageText as _, buildTraceExportPayload as a, isToolBearingEvent as b, toOtelJson as c, sandboxLedgerUsd as d, isRateLimitCreateError as et, InteractiveSessionHandle as f, applySandboxEventText as g, createInteractiveTerminalSession as h, MAX_EGRESS_DENIALS_LIMIT as i, ProfileUnsupportedError as j, isRetryableProfileFileMaterializeFailure as k, SandboxTaskSession as l, createInteractiveTerminalCapture as m, createSandboxInstanceFromResponse as n, exportTraceBundle as o, InteractiveTerminalFrameLog as p, DEPLOY_WINDOW_RETRY_MS as q, WorkspaceImages as r, otelTraceIdForTangleTrace as s, SandboxInstance as t, isRetryableCreateError as tt, SandboxSession as u, collectAgentResponseText as v, SandboxOperationFailedError as w, deleteSandbox as x, getSandboxEventText as y, dateOf as z };
15011
+ export { isRateLimitCreateError as $, ProfileUnsupportedError as A, normalizeConnection as B, SandboxOperation as C, splitInlineProfileSkills as D, splitInlineProfileFileMounts as E, normalizeSandboxCreateReceipt as F, CAPACITY_ETA_WAIT_MAX_MS as G, normalizeProxySecretReceipt as H, normalizeStartupDiagnostics as I, createRetryDelayMs as J, DEPLOY_WINDOW_RETRY_MS as K, readFilesystemIncarnationTuple as L, isMaterializerHarness as M, materializeProfile as N, validateDeferredProfileFileMounts as O, normalizeCaptureProof as P, isDeployWindowCreateError as Q, dateOf as R, ManagedProcessClient as S, materializeProfileFileMounts as T, normalizeSandboxShape as U, normalizeEgressPolicyFields as V, CAPACITY_ETA_MARGIN_MS as W, generateIdempotencyKey as X, extendableDeadline as Y, isCapacityShortageCreateError as Z, collectAgentFinalMessageText as _, buildTraceExportPayload as a, isToolBearingEvent as b, toOtelJson as c, sandboxLedgerUsd as d, isRetryableCreateError as et, InteractiveSessionHandle as f, applySandboxEventText as g, createInteractiveTerminalSession as h, MAX_EGRESS_DENIALS_LIMIT as i, enforceWorkspacePlanSupport as j, HARNESS_LAUNCH_MATERIALIZE_OPTIONS as k, SandboxTaskSession as l, createInteractiveTerminalCapture as m, createSandboxInstanceFromResponse as n, exportTraceBundle as o, InteractiveTerminalFrameLog as p, awaitCreateResend as q, WorkspaceImages as r, otelTraceIdForTangleTrace as s, SandboxInstance as t, SandboxSession as u, collectAgentResponseText as v, SandboxOperationFailedError as w, deleteSandbox as x, getSandboxEventText as y, parseLifecycleTimes as z };
@@ -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-BT2q9nkO.js";
1
+ import { a as anumber, c as concatBytes$1, f as randomBytes, h as toBytes, i as ahash, l as createHasher$1, n as abytes$1, o as aoutput, p as rotr, r as aexists, s as clean, t as Hash, u as createView, x as split } from "./utils-BvN0Mk3j.js";
2
2
  //#region ../../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/_md.js
3
3
  /**
4
4
  * Internal Merkle-Damgard hash utils.
@@ -1,9 +1,9 @@
1
1
  import { r as agentProfileSchema } from "./profile-schema-B11dRfGB.js";
2
2
  import { t as canonicalAgentProfileDigest } from "./agent-execution-preparation-N1ksNIIJ.js";
3
- import { C as SandboxError, O as ValidationError, u as CapabilityError } from "./errors-C0S3TzhR.js";
3
+ import { C as SandboxError, O as ValidationError, u as CapabilityError } from "./errors-D44qyFpy.js";
4
4
  import { n as combineAbortSignals, t as awaitWithAbort } from "./abort-signal-BsriwJ8L.js";
5
- import { r as cliAuthReferenceSchema } from "./cli-auth-bundle-C6DtK7GX-D8681c7j.js";
6
- import "./cli-auth-bundle-D5ZBMpZ7.js";
5
+ import { r as cliAuthReferenceSchema } from "./cli-auth-bundle-DcxhAW23-C22MMIvx.js";
6
+ import "./cli-auth-bundle-DXKH215p.js";
7
7
  import { z } from "zod";
8
8
  //#region ../../../packages/runtime-contracts/dist/seat-selection.js
9
9
  /**
@@ -1,5 +1,5 @@
1
- import { R as SandboxError } from "./terminal-stream-types-DLaXWiSA.js";
2
- import { _t as SeatOwnerTransport, bt as SeatSelectionRequest, ft as SEAT_COMMAND_TIMEOUT_MS } from "./client-DaZwQeOS.js";
1
+ import { R as SandboxError } from "./terminal-stream-types-Cdz3xrux.js";
2
+ import { _t as SeatOwnerTransport, bt as SeatSelectionRequest, ft as SEAT_COMMAND_TIMEOUT_MS } from "./client-BYGLoEiU.js";
3
3
 
4
4
  //#region src/select-seat-command.d.ts
5
5
  /** Public reply bound; the owner prints one metadata object. */
@@ -1,5 +1,5 @@
1
- import { C as SandboxError, O as ValidationError } from "./errors-C0S3TzhR.js";
2
- import { r as SEAT_OWNER_MAX_RESPONSE_BYTES, s as seatOwnerTimeoutMs, t as SEAT_COMMAND_TIMEOUT_MS } from "./select-seat-Cu-9jRO-.js";
1
+ import { C as SandboxError, O as ValidationError } from "./errors-D44qyFpy.js";
2
+ import { r as SEAT_OWNER_MAX_RESPONSE_BYTES, s as seatOwnerTimeoutMs, t as SEAT_COMMAND_TIMEOUT_MS } from "./select-seat-Dc7cQ8To.js";
3
3
  import { spawn } from "node:child_process";
4
4
  //#region src/select-seat-command.ts
5
5
  /**