@tangle-network/sandbox 0.60.85 → 0.60.86

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 (36) 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-t4YB-M3R.d.ts → agent-run-outcome-CIlpTZNU.d.ts} +1 -1
  5. package/dist/auth/index.d.ts +1 -1
  6. package/dist/auth/index.js +4 -4
  7. package/dist/{browser-interactive-control-controller-rpTbyvAS.d.ts → browser-interactive-control-controller-Cu6J3TUP.d.ts} +1 -1
  8. package/dist/{client-8qpE2rDI.d.ts → client-CUxfURSp.d.ts} +13 -12
  9. package/dist/{client-DM4i5RSw.js → client-D9OomGmE.js} +16 -15
  10. package/dist/collaboration/index.d.ts +1 -1
  11. package/dist/collaboration/index.js +1 -1
  12. package/dist/{collaboration-DaJU5O0E.js → collaboration-YxqL5cZY.js} +4 -4
  13. package/dist/core.d.ts +6 -6
  14. package/dist/core.js +2 -2
  15. package/dist/{errors-DtQPTnqm.d.ts → errors-B7i6lxHc.d.ts} +3 -3
  16. package/dist/{index-DZ27pdB8.d.ts → index-7_-RzCh9.d.ts} +1 -1
  17. package/dist/{index-CrOKqIcs.d.ts → index-BFW3FzJG.d.ts} +4 -5
  18. package/dist/{index-DO7GVpk_.d.ts → index-Vr-2tNP3.d.ts} +1 -1
  19. package/dist/index.d.ts +16 -15
  20. package/dist/index.js +8 -8
  21. package/dist/interactive-control.d.ts +1 -1
  22. package/dist/{interactive-controller-CJ24g8Va.js → interactive-controller-CPtHnjrz.js} +65 -21
  23. package/dist/{lines-EGmJbdDU.d.ts → lines-DosoSbnD.d.ts} +1 -1
  24. package/dist/lines.d.ts +1 -1
  25. package/dist/{managed-process-C4hYjOOD.d.ts → managed-process-CP-geV3k.d.ts} +1 -1
  26. package/dist/{preview-HePhtWQw.d.ts → preview-B-h5p2LF.d.ts} +3 -3
  27. package/dist/runtime.d.ts +6 -6
  28. package/dist/runtime.js +4 -4
  29. package/dist/{sandbox-AeLQuwb4.d.ts → sandbox-Bcs4w1RE.d.ts} +5 -8
  30. package/dist/{sandbox-BcCe13Ws.js → sandbox-DyoFguBU.js} +133 -125
  31. package/dist/tangle/index.d.ts +1 -1
  32. package/dist/tangle/index.js +1 -1
  33. package/dist/{tangle-CoNOTxcu.js → tangle-yvuD9HP_.js} +33 -32
  34. package/dist/{terminal-stream-jdYomM1m.d.ts → terminal-stream-BANlVD4Q.d.ts} +1 -2
  35. package/dist/{types-Zl7vIatu.d.ts → types-H3SX7E33.d.ts} +23 -2
  36. package/package.json +5 -5
@@ -1,5 +1,5 @@
1
1
  import { r as backendTypeSchema } from "./backend-types-D6bYbvMB.js";
2
- import { A as normalizeRuntimeBackendConfig, C as encodePromptForWire, D as assertCurrentBackendType, E as applyRequestedModel, F as createAgentRunOutcomeTracker, I as deriveAgentResultOutcome, M as requestedSecretProfilePublicDigest, P as withoutRuntimeSecrets, S as validateAcceptedDispatchRunRef, T as parseSSEStream, _ as mintTraceId, a as terminalUpgradeHeadersSupported, b as sessionHeaders, d as isRetryableCredentialRefusal, f as normalizeSessionInfo, g as isTraceId, h as TRACE_ID_HEADER, i as TerminalStreamError, j as requestedPublicProfileDigest, k as mergeRuntimeBackendConfig, l as requestScopedToken, m as waitForRetryAfter, n as InteractiveSessionController, p as sessionMessageRequestBody, r as TerminalStream, s as assertScopedTokenActive, u as SandboxRuntimeApi, v as resolveTraceId, w as encodeTextForWire, x as resolveDispatchRunIdentity, y as appendSessionIdQuery } from "./interactive-controller-CJ24g8Va.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 parseSSEStream, _ as mintTraceId, a as terminalUpgradeHeadersSupported, b as sessionHeaders, d as isRetryableCredentialRefusal, f as normalizeSessionInfo, g as isTraceId, h as TRACE_ID_HEADER, i as TerminalStreamError, j as requestedPublicProfileDigest, k as mergeRuntimeBackendConfig, l as requestScopedToken, m as waitForRetryAfter, n as InteractiveSessionController, p as sessionMessageRequestBody, r as TerminalStream, s as assertScopedTokenActive, u as SandboxRuntimeApi, v as resolveTraceId, w as encodeTextForWire, x as resolveDispatchRunIdentity, y as appendSessionIdQuery } from "./interactive-controller-CPtHnjrz.js";
3
3
  import { C as readResponseJson, S as parseResponseError, _ as StateError, b as ValidationError, d as NotFoundError, g as ServerError, h as SandboxError, i as EdgeNotReadyError, p as QuotaError, r as CapabilityError, t as AuthError, u as NetworkError, v as StreamInterruptedError, x as parseErrorResponse, y as TimeoutError } from "./errors-DSJBKmGZ.js";
4
4
  import { d as awaitWithAbort, f as combineAbortSignals, g as interactiveSessionStatusResponseSchema, h as interactiveSessionControlValidationResponseSchema, l as createInteractiveControlHolderId, m as interactiveSessionControlReleaseResponseSchema, p as interactiveSessionControlClaimResponseSchema } from "./browser-interactive-control-controller-BJf0P_J4.js";
5
5
  import { SandboxLines } from "./lines.js";
@@ -1600,7 +1600,7 @@ function parseDirectReadGrant(value) {
1600
1600
  * this route declines.
1601
1601
  */
1602
1602
  var DirectReadRoute = class {
1603
- grant = null;
1603
+ #grant = null;
1604
1604
  cooldownUntil = 0;
1605
1605
  /**
1606
1606
  * Whether this cell ever armed the route. A latch, not the live grant:
@@ -1626,7 +1626,7 @@ var DirectReadRoute = class {
1626
1626
  adopt(payload) {
1627
1627
  const grant = parseDirectReadGrant(payload?.directRead);
1628
1628
  if (!grant) return;
1629
- this.grant = grant;
1629
+ this.#grant = grant;
1630
1630
  this.engagedOnce = true;
1631
1631
  }
1632
1632
  /**
@@ -1644,7 +1644,7 @@ var DirectReadRoute = class {
1644
1644
  armed() {
1645
1645
  const now = this.now();
1646
1646
  if (now < this.cooldownUntil) return false;
1647
- const grant = this.grant;
1647
+ const grant = this.#grant;
1648
1648
  if (!grant) return false;
1649
1649
  return grant.expiresAt - DIRECT_READ_EXPIRY_MARGIN_MS > now;
1650
1650
  }
@@ -1653,7 +1653,7 @@ var DirectReadRoute = class {
1653
1653
  this.stats.lastReason = reason;
1654
1654
  if (reason !== "expired" && reason !== "cooldown") {
1655
1655
  this.cooldownUntil = this.now() + DIRECT_READ_COOLDOWN_MS;
1656
- this.grant = null;
1656
+ this.#grant = null;
1657
1657
  }
1658
1658
  return {
1659
1659
  kind: "fallback",
@@ -1678,9 +1678,9 @@ var DirectReadRoute = class {
1678
1678
  reason: "cooldown"
1679
1679
  };
1680
1680
  }
1681
- const grant = this.grant;
1681
+ const grant = this.#grant;
1682
1682
  if (!grant || grant.expiresAt - 2e3 <= now) {
1683
- this.grant = null;
1683
+ this.#grant = null;
1684
1684
  this.stats.fallbacks += 1;
1685
1685
  this.stats.lastReason = "expired";
1686
1686
  return {
@@ -4899,10 +4899,10 @@ function timerMsViolation(value) {
4899
4899
  * A sandbox instance with methods for interaction.
4900
4900
  */
4901
4901
  var SandboxInstance = class SandboxInstance {
4902
- client;
4903
- info;
4902
+ #client;
4903
+ #info;
4904
4904
  refreshInFlight;
4905
- defaultRuntimeBackend;
4905
+ #defaultRuntimeBackend;
4906
4906
  runtime;
4907
4907
  workspaceImages;
4908
4908
  interactiveOperations;
@@ -4935,31 +4935,31 @@ var SandboxInstance = class SandboxInstance {
4935
4935
  */
4936
4936
  directRead = new DirectReadRoute();
4937
4937
  constructor(client, info, defaultRuntimeBackend) {
4938
- this.client = client;
4938
+ this.#client = client;
4939
4939
  const incarnation = readFilesystemIncarnationTuple(info);
4940
- this.info = {
4940
+ this.#info = {
4941
4941
  ...info,
4942
4942
  filesystemIncarnationId: incarnation.complete ? incarnation.id : void 0,
4943
4943
  filesystemIncarnationProvenance: incarnation.complete ? incarnation.provenance : void 0,
4944
4944
  filesystemIncarnationReadiness: incarnation.complete ? incarnation.readiness : void 0,
4945
4945
  connection: incarnation.complete && incarnation.readiness === "ready" ? info.connection : void 0
4946
4946
  };
4947
- this.defaultRuntimeBackend = defaultRuntimeBackend;
4947
+ this.#defaultRuntimeBackend = defaultRuntimeBackend;
4948
4948
  this.runtime = new SandboxRuntimeApi({
4949
4949
  ensureRunning: () => this.ensureRunning(),
4950
4950
  fetch: (path, init) => this.runtimeFetch(path, init)
4951
4951
  });
4952
- this.workspaceImages = new WorkspaceImages(this.client, this.info.id, () => this.ensureRunning(), () => this.info.filesystemIncarnationId);
4952
+ this.workspaceImages = new WorkspaceImages(this.#client, this.#info.id, () => this.ensureRunning(), () => this.#info.filesystemIncarnationId);
4953
4953
  this.interactiveOperations = new SandboxInteractiveOperations({
4954
- id: this.info.id,
4954
+ id: this.#info.id,
4955
4955
  ensureRunning: (signal) => this.ensureRunning(signal),
4956
4956
  runtimeFetch: (endpoint, request) => this.runtimeFetch(endpoint, request)
4957
4957
  });
4958
4958
  this.interactiveTerminalOperations = new SandboxInteractiveTerminalOperations({
4959
- id: this.info.id,
4959
+ id: this.#info.id,
4960
4960
  terminalApiKeyDial: () => {
4961
- const apiKey = this.client.getApiKey?.();
4962
- const baseUrl = this.client.getBaseUrl?.();
4961
+ const apiKey = this.#client.getApiKey?.();
4962
+ const baseUrl = this.#client.getBaseUrl?.();
4963
4963
  return apiKey && baseUrl ? {
4964
4964
  apiKey,
4965
4965
  baseUrl
@@ -4972,59 +4972,59 @@ var SandboxInstance = class SandboxInstance {
4972
4972
  }
4973
4973
  /** Unique sandbox identifier */
4974
4974
  get id() {
4975
- return this.info.id;
4975
+ return this.#info.id;
4976
4976
  }
4977
4977
  /** Human-readable name */
4978
4978
  get name() {
4979
- return this.info.name;
4979
+ return this.#info.name;
4980
4980
  }
4981
4981
  /** Identity of the currently published filesystem contents. */
4982
4982
  get filesystemIncarnationId() {
4983
- return this.info.filesystemIncarnationId;
4983
+ return this.#info.filesystemIncarnationId;
4984
4984
  }
4985
4985
  /** How the current filesystem contents were acquired. */
4986
4986
  get filesystemIncarnationProvenance() {
4987
- return this.info.filesystemIncarnationProvenance;
4987
+ return this.#info.filesystemIncarnationProvenance;
4988
4988
  }
4989
4989
  /** Whether the current incarnation is safe to use as authoritative state. */
4990
4990
  get filesystemIncarnationReadiness() {
4991
- return this.info.filesystemIncarnationReadiness;
4991
+ return this.#info.filesystemIncarnationReadiness;
4992
4992
  }
4993
4993
  /** Current status */
4994
4994
  get status() {
4995
- return this.info.status;
4995
+ return this.#info.status;
4996
4996
  }
4997
4997
  /** Connection information */
4998
4998
  get connection() {
4999
- return this.info.connection;
4999
+ return this.#info.connection;
5000
5000
  }
5001
5001
  /** Custom metadata */
5002
5002
  get metadata() {
5003
- return this.info.metadata;
5003
+ return this.#info.metadata;
5004
5004
  }
5005
5005
  /** When the sandbox was created */
5006
5006
  get createdAt() {
5007
- return this.info.createdAt;
5007
+ return this.#info.createdAt;
5008
5008
  }
5009
5009
  /** When the sandbox started running */
5010
5010
  get startedAt() {
5011
- return this.info.startedAt;
5011
+ return this.#info.startedAt;
5012
5012
  }
5013
5013
  /** Last activity timestamp */
5014
5014
  get lastActivityAt() {
5015
- return this.info.lastActivityAt;
5015
+ return this.#info.lastActivityAt;
5016
5016
  }
5017
5017
  /** When the sandbox will expire */
5018
5018
  get expiresAt() {
5019
- return this.info.expiresAt;
5019
+ return this.#info.expiresAt;
5020
5020
  }
5021
5021
  /** Error message if status is 'failed' */
5022
5022
  get error() {
5023
- return this.info.error;
5023
+ return this.#info.error;
5024
5024
  }
5025
5025
  /** GPU lease attached during sandbox creation, when requested. */
5026
5026
  get gpuLease() {
5027
- return this.info.gpuLease;
5027
+ return this.#info.gpuLease;
5028
5028
  }
5029
5029
  /**
5030
5030
  * The shape this sandbox was granted: the cgroup and volume limits it runs
@@ -5033,11 +5033,11 @@ var SandboxInstance = class SandboxInstance {
5033
5033
  * is refreshed, and for a sandbox created before the platform recorded it.
5034
5034
  */
5035
5035
  get resources() {
5036
- return this.info.resources;
5036
+ return this.#info.resources;
5037
5037
  }
5038
5038
  /** Web terminal URL for browser-based access */
5039
5039
  get url() {
5040
- return this.info.connection?.webTerminalUrl;
5040
+ return this.#info.connection?.webTerminalUrl;
5041
5041
  }
5042
5042
  /** Build and publish this sandbox's workspace without exposing registry credentials to it. */
5043
5043
  get images() {
@@ -5059,7 +5059,7 @@ var SandboxInstance = class SandboxInstance {
5059
5059
  * ```
5060
5060
  */
5061
5061
  startupDiagnostics() {
5062
- return this.info.startupDiagnostics ?? null;
5062
+ return this.#info.startupDiagnostics ?? null;
5063
5063
  }
5064
5064
  /**
5065
5065
  * The platform verdict for the create call that returned this sandbox: did
@@ -5078,11 +5078,11 @@ var SandboxInstance = class SandboxInstance {
5078
5078
  * ```
5079
5079
  */
5080
5080
  createReceipt() {
5081
- return this.info.createReceipt ?? null;
5081
+ return this.#info.createReceipt ?? null;
5082
5082
  }
5083
5083
  /** Verified identity of the currently running container, if available. */
5084
5084
  captureProof() {
5085
- return this.info.captureProof ?? null;
5085
+ return this.#info.captureProof ?? null;
5086
5086
  }
5087
5087
  /**
5088
5088
  * Serialize to the public sandbox shape for logs and structured
@@ -5137,10 +5137,10 @@ var SandboxInstance = class SandboxInstance {
5137
5137
  direct() {
5138
5138
  if (!this.connection?.runtimeUrl) throw new StateError("Sandbox has no direct runtime URL", this.status, "running");
5139
5139
  let directInstance;
5140
- directInstance = new SandboxInstance(new DirectRuntimeHttpClient(this.client, this.id, () => directInstance.connection, async () => {
5140
+ directInstance = new SandboxInstance(new DirectRuntimeHttpClient(this.#client, this.id, () => directInstance.connection, async () => {
5141
5141
  await directInstance.refreshFor("bearer-refused");
5142
5142
  const next = directInstance.connection?.authToken;
5143
- const client = this.client;
5143
+ const client = this.#client;
5144
5144
  if (next && typeof client._emitTokenRefresh === "function") client._emitTokenRefresh(this.id, next);
5145
5145
  }, async () => {
5146
5146
  try {
@@ -5150,7 +5150,7 @@ var SandboxInstance = class SandboxInstance {
5150
5150
  return;
5151
5151
  }
5152
5152
  directInstance.assertRunnable();
5153
- }), { ...this.info }, this.defaultRuntimeBackend);
5153
+ }), { ...this.#info }, this.#defaultRuntimeBackend);
5154
5154
  if (this.deferredProfileReference !== void 0) directInstance.deferredProfileReference = this.deferredProfileReference;
5155
5155
  const observedAt = sandboxStatusObservedAt.get(this);
5156
5156
  if (observedAt !== void 0) sandboxStatusObservedAt.set(directInstance, observedAt);
@@ -5182,7 +5182,7 @@ var SandboxInstance = class SandboxInstance {
5182
5182
  if (options?.ttlMinutes) params.set("ttlMinutes", String(options.ttlMinutes));
5183
5183
  const qs = params.toString();
5184
5184
  const path = `/v1/sandboxes/${this.id}/mcp${qs ? `?${qs}` : ""}`;
5185
- return await readResponseJson(await this.client.fetch(path));
5185
+ return await readResponseJson(await this.#client.fetch(path));
5186
5186
  }
5187
5187
  /**
5188
5188
  * Refresh sandbox information from the server.
@@ -5209,7 +5209,7 @@ var SandboxInstance = class SandboxInstance {
5209
5209
  try {
5210
5210
  await this.readStatus(reason);
5211
5211
  } finally {
5212
- emitTiming(this.client.onTiming, {
5212
+ emitTiming(this.#client.onTiming, {
5213
5213
  name: "sdk.refresh",
5214
5214
  durMs: Math.round((performance.now() - startedAt) * 10) / 10,
5215
5215
  desc: reason
@@ -5217,16 +5217,16 @@ var SandboxInstance = class SandboxInstance {
5217
5217
  }
5218
5218
  }
5219
5219
  async readStatus(reason) {
5220
- const direct = this.directRead.engaged() && DIRECT_READ_POLLABLE_STATUSES.has(this.info.status) ? await this.directRead.read() : null;
5220
+ const direct = this.directRead.engaged() && DIRECT_READ_POLLABLE_STATUSES.has(this.#info.status) ? await this.directRead.read() : null;
5221
5221
  if (direct?.kind === "unchanged") {
5222
5222
  sandboxStatusObservedAt.set(this, Date.now());
5223
5223
  return;
5224
5224
  }
5225
5225
  const headers = direct?.kind === "fallback" ? { ...this.directRead.fallbackHeaders(direct.reason) } : {};
5226
5226
  if (sendsRefreshReason()) headers[REFRESH_REASON_HEADER] = reason;
5227
- const data = await readResponseJson(await this.client.fetch(`/v1/sandboxes/${this.id}`, ...Object.keys(headers).length > 0 ? [{ headers }] : []));
5227
+ const data = await readResponseJson(await this.#client.fetch(`/v1/sandboxes/${this.id}`, ...Object.keys(headers).length > 0 ? [{ headers }] : []));
5228
5228
  this.directRead.adopt(data);
5229
- this.info = this.parseInfo(data, this.info);
5229
+ this.#info = this.parseInfo(data, this.#info);
5230
5230
  sandboxStatusObservedAt.set(this, Date.now());
5231
5231
  }
5232
5232
  /**
@@ -5260,15 +5260,15 @@ var SandboxInstance = class SandboxInstance {
5260
5260
  async getTeeAttestation(options) {
5261
5261
  await this.ensureRunning();
5262
5262
  const hasNonce = Boolean(options?.attestationNonce);
5263
- const data = await (await fetchTeeSurface(this.client, this.id, "attestation", {
5263
+ const data = await (await fetchTeeSurface(this.#client, this.id, "attestation", {
5264
5264
  method: hasNonce ? "POST" : "GET",
5265
5265
  body: hasNonce ? JSON.stringify({ attestation_nonce: options?.attestationNonce }) : void 0
5266
5266
  })).json();
5267
5267
  if (hasNonce) data.attestationNonce = options?.attestationNonce;
5268
- this.info = {
5269
- ...this.info,
5268
+ this.#info = {
5269
+ ...this.#info,
5270
5270
  metadata: {
5271
- ...this.info.metadata,
5271
+ ...this.#info.metadata,
5272
5272
  teeAttestationJson: JSON.stringify(data.attestation),
5273
5273
  ...data.attestationNonce ? { attestationNonce: data.attestationNonce } : {}
5274
5274
  }
@@ -5289,11 +5289,11 @@ var SandboxInstance = class SandboxInstance {
5289
5289
  */
5290
5290
  async getTeePublicKey() {
5291
5291
  await this.ensureRunning();
5292
- const data = await (await fetchTeeSurface(this.client, this.id, "public-key", { method: "GET" })).json();
5293
- this.info = {
5294
- ...this.info,
5292
+ const data = await (await fetchTeeSurface(this.#client, this.id, "public-key", { method: "GET" })).json();
5293
+ this.#info = {
5294
+ ...this.#info,
5295
5295
  metadata: {
5296
- ...this.info.metadata,
5296
+ ...this.#info.metadata,
5297
5297
  teePublicKeyJson: JSON.stringify(data.public_key)
5298
5298
  }
5299
5299
  };
@@ -5312,7 +5312,7 @@ var SandboxInstance = class SandboxInstance {
5312
5312
  * ```
5313
5313
  */
5314
5314
  async collaborate(path, options) {
5315
- return await readResponseJson(await this.client.fetch("/v1/collaboration/bootstrap", {
5315
+ return await readResponseJson(await this.#client.fetch("/v1/collaboration/bootstrap", {
5316
5316
  method: "POST",
5317
5317
  headers: { "Content-Type": "application/json" },
5318
5318
  body: JSON.stringify({
@@ -5330,7 +5330,7 @@ var SandboxInstance = class SandboxInstance {
5330
5330
  * token — cannot be escalated (read stays read, write stays write).
5331
5331
  */
5332
5332
  async refreshCollaborationToken(documentId, currentToken) {
5333
- return await readResponseJson(await this.client.fetch("/v1/collaboration/token", {
5333
+ return await readResponseJson(await this.#client.fetch("/v1/collaboration/token", {
5334
5334
  method: "POST",
5335
5335
  headers: { "Content-Type": "application/json" },
5336
5336
  body: JSON.stringify({
@@ -5351,7 +5351,7 @@ var SandboxInstance = class SandboxInstance {
5351
5351
  }
5352
5352
  async sshCommand() {
5353
5353
  const ssh = await this.ssh();
5354
- const authToken = this.client.getApiKey?.();
5354
+ const authToken = this.#client.getApiKey?.();
5355
5355
  if (!authToken) throw new AuthError("SSH command requires client API key access to populate proxy auth");
5356
5356
  const nullKnownHostsFile = process.platform === "win32" ? "NUL" : "/dev/null";
5357
5357
  return {
@@ -5768,7 +5768,7 @@ var SandboxInstance = class SandboxInstance {
5768
5768
  return this.profileFiles.prepare(this, profile, signal, existingFiles);
5769
5769
  }
5770
5770
  async buildRunBackendBody(overrideBackend, forceFullProfile, requestedModel, signal, preserveManagedProfile = false) {
5771
- const backend = mergeRuntimeBackendConfig(this.defaultRuntimeBackend, applyRequestedModel(overrideBackend, requestedModel));
5771
+ const backend = mergeRuntimeBackendConfig(this.#defaultRuntimeBackend, applyRequestedModel(overrideBackend, requestedModel));
5772
5772
  let normalized = normalizeRuntimeBackendConfig(backend, { allowRuntimeSecrets: true });
5773
5773
  if (!normalized) return normalized;
5774
5774
  if (backend?.profile !== void 0 && !preserveManagedProfile) try {
@@ -6257,7 +6257,7 @@ var SandboxInstance = class SandboxInstance {
6257
6257
  * Stream sandbox lifecycle and activity events.
6258
6258
  */
6259
6259
  async *events(options) {
6260
- const response = await this.client.fetch(`/v1/sandboxes/${this.id}/events`, { signal: options?.signal });
6260
+ const response = await this.#client.fetch(`/v1/sandboxes/${this.id}/events`, { signal: options?.signal });
6261
6261
  if (!response.ok) throw await parseResponseError(response);
6262
6262
  for await (const event of this.parseSSEStream(response, options?.signal)) {
6263
6263
  if (options?.eventTypes && !options.eventTypes.includes(event.type)) continue;
@@ -6267,7 +6267,7 @@ var SandboxInstance = class SandboxInstance {
6267
6267
  async trace(options = {}) {
6268
6268
  const query = new URLSearchParams();
6269
6269
  if (options.includeIntelligence === true) query.set("includeIntelligence", "true");
6270
- return await readResponseJson(await this.client.fetch(`/v1/sandboxes/${this.id}/trace${query.size ? `?${query}` : ""}`));
6270
+ return await readResponseJson(await this.#client.fetch(`/v1/sandboxes/${this.id}/trace${query.size ? `?${query}` : ""}`));
6271
6271
  }
6272
6272
  async intelligence() {
6273
6273
  const intelligence = (await this.trace({ includeIntelligence: true })).intelligence;
@@ -6276,7 +6276,7 @@ var SandboxInstance = class SandboxInstance {
6276
6276
  }
6277
6277
  async createIntelligenceReport(options = {}) {
6278
6278
  const { window, compareTo, ...rest } = options;
6279
- const response = await this.client.fetch("/v1/intelligence/reports", {
6279
+ const response = await this.#client.fetch("/v1/intelligence/reports", {
6280
6280
  method: "POST",
6281
6281
  body: JSON.stringify({
6282
6282
  subject: {
@@ -6521,7 +6521,7 @@ var SandboxInstance = class SandboxInstance {
6521
6521
  async grantNativeCredential(grant, options) {
6522
6522
  const cliAuth = cliAuthReferenceSchema.parse(grant.cliAuth);
6523
6523
  if (grant.harness === "claude-code" && cliAuth.format !== "token" || grant.harness === "codex" && cliAuth.format !== "bundle" && cliAuth.format !== "files" || grant.harness !== "claude-code" && grant.harness !== "codex") throw new ValidationError("Native credential continuation requires a supported harness and reference format");
6524
- const response = await this.client.fetch(`/v1/sandboxes/${encodeURIComponent(this.id)}/native-credentials`, {
6524
+ const response = await this.#client.fetch(`/v1/sandboxes/${encodeURIComponent(this.id)}/native-credentials`, {
6525
6525
  method: "POST",
6526
6526
  headers: { "Content-Type": "application/json" },
6527
6527
  body: JSON.stringify({
@@ -7476,19 +7476,19 @@ var SandboxInstance = class SandboxInstance {
7476
7476
  return await readResponseJson(await this.runtimeFetch("/network"));
7477
7477
  }
7478
7478
  async egressGet() {
7479
- const data = await readResponseJson(await this.client.fetch(`/v1/sandboxes/${encodeURIComponent(this.id)}`));
7479
+ const data = await readResponseJson(await this.#client.fetch(`/v1/sandboxes/${encodeURIComponent(this.id)}`));
7480
7480
  return {
7481
7481
  policy: data.egressPolicy ?? { mode: "open" },
7482
7482
  source: data.egressPolicySource ?? "platform"
7483
7483
  };
7484
7484
  }
7485
7485
  async egressUpdate(policy) {
7486
- const data = await readResponseJson(await this.client.fetch(`/v1/sandboxes/${encodeURIComponent(this.id)}/egress`, {
7486
+ const data = await readResponseJson(await this.#client.fetch(`/v1/sandboxes/${encodeURIComponent(this.id)}/egress`, {
7487
7487
  method: "PATCH",
7488
7488
  body: JSON.stringify(policy)
7489
7489
  }));
7490
- this.info = {
7491
- ...this.info,
7490
+ this.#info = {
7491
+ ...this.#info,
7492
7492
  egressPolicy: data.egressPolicy,
7493
7493
  egressPolicySource: data.source
7494
7494
  };
@@ -7504,7 +7504,7 @@ var SandboxInstance = class SandboxInstance {
7504
7504
  if (limit > 50) throw new ValidationError(`egress denials limit must be at most 50, got ${limit}`);
7505
7505
  }
7506
7506
  const query = limit === void 0 ? "" : `?limit=${encodeURIComponent(limit)}`;
7507
- const response = await this.client.fetch(`/v1/sandboxes/${encodeURIComponent(this.id)}/egress/denials${query}`);
7507
+ const response = await this.#client.fetch(`/v1/sandboxes/${encodeURIComponent(this.id)}/egress/denials${query}`);
7508
7508
  if (!response.ok) throw await parseResponseError(response);
7509
7509
  let body;
7510
7510
  try {
@@ -7544,7 +7544,7 @@ var SandboxInstance = class SandboxInstance {
7544
7544
  const month = options?.month;
7545
7545
  if (month !== void 0 && !/^\d{4}-(0[1-9]|1[0-2])$/.test(month)) throw new ValidationError(`egress usage month must be YYYY-MM, got ${month}`);
7546
7546
  const query = month === void 0 ? "" : `?month=${encodeURIComponent(month)}`;
7547
- const response = await this.client.fetch(`/v1/sandboxes/${encodeURIComponent(this.id)}/egress/usage${query}`);
7547
+ const response = await this.#client.fetch(`/v1/sandboxes/${encodeURIComponent(this.id)}/egress/usage${query}`);
7548
7548
  if (!response.ok) throw await parseResponseError(response);
7549
7549
  let body;
7550
7550
  try {
@@ -7587,7 +7587,7 @@ var SandboxInstance = class SandboxInstance {
7587
7587
  if (limit > 500) throw new ValidationError(`egress activity limit must be at most 500, got ${limit}`);
7588
7588
  }
7589
7589
  const query = limit === void 0 ? "" : `?limit=${encodeURIComponent(limit)}`;
7590
- const response = await this.client.fetch(`/v1/sandboxes/${encodeURIComponent(this.id)}/egress/activity${query}`);
7590
+ const response = await this.#client.fetch(`/v1/sandboxes/${encodeURIComponent(this.id)}/egress/activity${query}`);
7591
7591
  if (!response.ok) throw await parseResponseError(response);
7592
7592
  let body;
7593
7593
  try {
@@ -7639,29 +7639,29 @@ var SandboxInstance = class SandboxInstance {
7639
7639
  if (accelerator.memoryMB !== void 0) query.set("acceleratorMemoryMB", String(accelerator.memoryMB));
7640
7640
  }
7641
7641
  const suffix = query.size > 0 ? `?${query.toString()}` : "";
7642
- const data = await readResponseJson(await this.client.fetch(`/v1/sandboxes/${encodeURIComponent(this.id)}/gpu/providers${suffix}`));
7642
+ const data = await readResponseJson(await this.#client.fetch(`/v1/sandboxes/${encodeURIComponent(this.id)}/gpu/providers${suffix}`));
7643
7643
  return {
7644
7644
  usable: data.providers ?? [],
7645
7645
  statuses: data.statuses ?? []
7646
7646
  };
7647
7647
  }
7648
7648
  async gpuAttach(options) {
7649
- return (await readResponseJson(await this.client.fetch(`/v1/sandboxes/${encodeURIComponent(this.id)}/gpu/leases`, {
7649
+ return (await readResponseJson(await this.#client.fetch(`/v1/sandboxes/${encodeURIComponent(this.id)}/gpu/leases`, {
7650
7650
  method: "POST",
7651
7651
  body: JSON.stringify(options)
7652
7652
  }))).lease;
7653
7653
  }
7654
7654
  async gpuList() {
7655
- return (await readResponseJson(await this.client.fetch(`/v1/sandboxes/${encodeURIComponent(this.id)}/gpu/leases`))).leases ?? [];
7655
+ return (await readResponseJson(await this.#client.fetch(`/v1/sandboxes/${encodeURIComponent(this.id)}/gpu/leases`))).leases ?? [];
7656
7656
  }
7657
7657
  async gpuExec(leaseId, options) {
7658
- return await readResponseJson(await this.client.fetch(`/v1/sandboxes/${encodeURIComponent(this.id)}/gpu/leases/${encodeURIComponent(leaseId)}/exec`, {
7658
+ return await readResponseJson(await this.#client.fetch(`/v1/sandboxes/${encodeURIComponent(this.id)}/gpu/leases/${encodeURIComponent(leaseId)}/exec`, {
7659
7659
  method: "POST",
7660
7660
  body: JSON.stringify(options)
7661
7661
  }));
7662
7662
  }
7663
7663
  async gpuDetach(leaseId) {
7664
- return (await readResponseJson(await this.client.fetch(`/v1/sandboxes/${encodeURIComponent(this.id)}/gpu/leases/${encodeURIComponent(leaseId)}`, { method: "DELETE" }))).lease;
7664
+ return (await readResponseJson(await this.#client.fetch(`/v1/sandboxes/${encodeURIComponent(this.id)}/gpu/leases/${encodeURIComponent(leaseId)}`, { method: "DELETE" }))).lease;
7665
7665
  }
7666
7666
  /**
7667
7667
  * Validate CIDR notation (IPv4 and IPv6)
@@ -7801,7 +7801,7 @@ var SandboxInstance = class SandboxInstance {
7801
7801
  * ```
7802
7802
  */
7803
7803
  async getDriverInfo() {
7804
- return await readResponseJson(await this.client.fetch(`/v1/sandboxes/${this.id}/driver`));
7804
+ return await readResponseJson(await this.#client.fetch(`/v1/sandboxes/${this.id}/driver`));
7805
7805
  }
7806
7806
  async toolsInstall(tool, version) {
7807
7807
  await this.ensureRunning();
@@ -7978,7 +7978,7 @@ var SandboxInstance = class SandboxInstance {
7978
7978
  tags: data.snapshot?.tags ?? data.tags ?? []
7979
7979
  };
7980
7980
  }
7981
- const response = await this.client.fetch(`/v1/sandboxes/${this.id}/snapshots`, {
7981
+ const response = await this.#client.fetch(`/v1/sandboxes/${this.id}/snapshots`, {
7982
7982
  method: "POST",
7983
7983
  ...options?.idempotencyKey ? { headers: { "Idempotency-Key": options.idempotencyKey } } : {},
7984
7984
  body: JSON.stringify({ tags: options?.tags })
@@ -8011,13 +8011,13 @@ var SandboxInstance = class SandboxInstance {
8011
8011
  if ("paths" in options) throw new Error("Path-scoped snapshot capture is not supported; create a whole-workspace snapshot and use restorePaths()");
8012
8012
  if (options.storage) throw new Error("wait: false is not supported with customer-provided storage; the BYOS3 snapshot path keeps no operation record");
8013
8013
  await this.ensureRunning();
8014
- const response = await this.client.fetch(`/v1/sandboxes/${this.id}/snapshots?wait=false`, {
8014
+ const response = await this.#client.fetch(`/v1/sandboxes/${this.id}/snapshots?wait=false`, {
8015
8015
  method: "POST",
8016
8016
  ...options.idempotencyKey ? { headers: { "Idempotency-Key": options.idempotencyKey } } : {},
8017
8017
  body: JSON.stringify({ tags: options.tags })
8018
8018
  }, { timeoutMs: SNAPSHOT_CREATE_REQUEST_TIMEOUT_MS });
8019
8019
  const body = await readResponseJson(response);
8020
- if (response.status === 202) return new SandboxOperation(parseSandboxOperation(body.operation), this.client);
8020
+ if (response.status === 202) return new SandboxOperation(parseSandboxOperation(body.operation), this.#client);
8021
8021
  const snapshotId = body.snapshotId ?? body.id;
8022
8022
  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)}`, response.status);
8023
8023
  return SandboxOperation.completed("snapshot", this.id, { snapshot: {
@@ -8071,7 +8071,7 @@ var SandboxInstance = class SandboxInstance {
8071
8071
  sizeBytes: s.sizeBytes
8072
8072
  }));
8073
8073
  }
8074
- const data = await readResponseJson(await this.client.fetch(`/v1/sandboxes/${this.id}/snapshots`));
8074
+ const data = await readResponseJson(await this.#client.fetch(`/v1/sandboxes/${this.id}/snapshots`));
8075
8075
  return (Array.isArray(data) ? data : data.snapshots ?? []).map((s) => {
8076
8076
  const remoteSync = toSnapshotRemoteSync(s.remoteSync);
8077
8077
  return {
@@ -8086,7 +8086,7 @@ var SandboxInstance = class SandboxInstance {
8086
8086
  });
8087
8087
  }
8088
8088
  async revertToSnapshot(snapshotId) {
8089
- const response = await this.client.fetch(`/v1/sandboxes/${this.id}/snapshots/${encodeURIComponent(snapshotId)}/restore`, { method: "POST" }, { timeoutMs: SNAPSHOT_RESTORE_TIMEOUT_MS });
8089
+ const response = await this.#client.fetch(`/v1/sandboxes/${this.id}/snapshots/${encodeURIComponent(snapshotId)}/restore`, { method: "POST" }, { timeoutMs: SNAPSHOT_RESTORE_TIMEOUT_MS });
8090
8090
  const data = await readResponseJson(response);
8091
8091
  if (response.status === 202) return this.waitForSnapshotRestore(snapshotId, data);
8092
8092
  return toSnapshotResult(data, this.profileProvenance);
@@ -8096,7 +8096,7 @@ var SandboxInstance = class SandboxInstance {
8096
8096
  * Files outside the requested paths are left untouched.
8097
8097
  */
8098
8098
  async restorePaths(snapshotId, paths) {
8099
- const response = await this.client.fetch(`/v1/sandboxes/${this.id}/snapshots/${encodeURIComponent(snapshotId)}/restore`, {
8099
+ const response = await this.#client.fetch(`/v1/sandboxes/${this.id}/snapshots/${encodeURIComponent(snapshotId)}/restore`, {
8100
8100
  method: "POST",
8101
8101
  body: JSON.stringify({ paths })
8102
8102
  }, { timeoutMs: SNAPSHOT_RESTORE_TIMEOUT_MS });
@@ -8108,7 +8108,7 @@ var SandboxInstance = class SandboxInstance {
8108
8108
  const deadline = Date.now() + SNAPSHOT_RESTORE_TIMEOUT_MS;
8109
8109
  let polls = 0;
8110
8110
  while (Date.now() < deadline) {
8111
- const status = await readResponseJson(await this.client.fetch(`/v1/sandboxes/${this.id}/snapshots/jobs/${encodeURIComponent(accepted.jobId)}`));
8111
+ const status = await readResponseJson(await this.#client.fetch(`/v1/sandboxes/${this.id}/snapshots/jobs/${encodeURIComponent(accepted.jobId)}`));
8112
8112
  if (status.status === "failed" || status.result?.success === false) throw new ServerError(status.result?.error ?? `Snapshot restore job ${accepted.jobId} failed`);
8113
8113
  if (status.status === "completed") {
8114
8114
  this.applyLifecycleResponse(status.sandbox ?? null);
@@ -8160,7 +8160,7 @@ var SandboxInstance = class SandboxInstance {
8160
8160
  * 404 means this sandbox is unknown, not that the snapshot was missing.
8161
8161
  */
8162
8162
  async deleteSnapshot(snapshotId, options) {
8163
- const response = await this.client.fetch(`/v1/sandboxes/${this.id}/snapshots/${encodeURIComponent(snapshotId)}`, { method: "DELETE" }, usableTimeoutMs(options?.timeoutMs));
8163
+ const response = await this.#client.fetch(`/v1/sandboxes/${this.id}/snapshots/${encodeURIComponent(snapshotId)}`, { method: "DELETE" }, usableTimeoutMs(options?.timeoutMs));
8164
8164
  if (!response.ok) throw await parseResponseError(response);
8165
8165
  const body = await response.json().catch(() => ({}));
8166
8166
  return {
@@ -8175,7 +8175,7 @@ var SandboxInstance = class SandboxInstance {
8175
8175
  * options to read the operation bound to this owner-scoped key.
8176
8176
  */
8177
8177
  async getSnapshotOperation(idempotencyKey, options) {
8178
- const response = await this.client.fetch(`/v1/sandboxes/${this.id}/workspace-operations/lookup`, {
8178
+ const response = await this.#client.fetch(`/v1/sandboxes/${this.id}/workspace-operations/lookup`, {
8179
8179
  method: "POST",
8180
8180
  body: JSON.stringify({
8181
8181
  kind: "checkpoint",
@@ -8280,7 +8280,7 @@ var SandboxInstance = class SandboxInstance {
8280
8280
  */
8281
8281
  async fork(count, options) {
8282
8282
  if (!Number.isInteger(count) || count < 1) throw new ValidationError(`branch count must be an integer >= 1 (got ${count})`);
8283
- const data = await readResponseJson(await this.client.fetch(`/v1/sandboxes/${this.id}/branch`, {
8283
+ const data = await readResponseJson(await this.#client.fetch(`/v1/sandboxes/${this.id}/branch`, {
8284
8284
  method: "POST",
8285
8285
  ...options?.idempotencyKey ? { headers: { "Idempotency-Key": options.idempotencyKey } } : {},
8286
8286
  body: JSON.stringify({
@@ -8289,7 +8289,7 @@ var SandboxInstance = class SandboxInstance {
8289
8289
  metadata: options?.metadata
8290
8290
  })
8291
8291
  }));
8292
- const children = (data.children ?? []).map((child) => createSandboxInstanceFromResponse(this.client, this.parseInfo(child), this.defaultRuntimeBackend));
8292
+ const children = (data.children ?? []).map((child) => createSandboxInstanceFromResponse(this.#client, this.parseInfo(child), this.#defaultRuntimeBackend));
8293
8293
  const materializedCount = children.length;
8294
8294
  const requestedCount = typeof data.fork?.requestedCount === "number" ? data.fork.requestedCount : count;
8295
8295
  const reportedOutcome = data.idempotency?.outcome;
@@ -8313,7 +8313,7 @@ var SandboxInstance = class SandboxInstance {
8313
8313
  * Omit options to read the operation bound to this owner-scoped key.
8314
8314
  */
8315
8315
  async getForkOperation(idempotencyKey, options) {
8316
- const response = await this.client.fetch(`/v1/sandboxes/${this.id}/workspace-operations/lookup`, {
8316
+ const response = await this.#client.fetch(`/v1/sandboxes/${this.id}/workspace-operations/lookup`, {
8317
8317
  method: "POST",
8318
8318
  body: JSON.stringify({
8319
8319
  kind: "fork",
@@ -8361,7 +8361,7 @@ var SandboxInstance = class SandboxInstance {
8361
8361
  if (!Number.isInteger(options.n) || options.n < 1 || options.n > 8) throw new ValidationError(`rollout n must be an integer in [1, 8] (got ${options.n})`);
8362
8362
  if (!Array.isArray(options.parts) || options.parts.length === 0) throw new ValidationError("rollout parts must be a non-empty array");
8363
8363
  if (options.scorer?.type === "command" && !options.scorer.command) throw new ValidationError("scorer.command is required when scorer.type is \"command\"");
8364
- const response = await this.client.fetch(`/v1/sandboxes/${this.id}/rollouts`, {
8364
+ const response = await this.#client.fetch(`/v1/sandboxes/${this.id}/rollouts`, {
8365
8365
  method: "POST",
8366
8366
  body: JSON.stringify({
8367
8367
  n: options.n,
@@ -8383,7 +8383,7 @@ var SandboxInstance = class SandboxInstance {
8383
8383
  */
8384
8384
  async getRollout(rolloutId) {
8385
8385
  if (!rolloutId) throw new ValidationError("rolloutId is required");
8386
- return await readResponseJson(await this.client.fetch(`/v1/sandboxes/${this.id}/rollouts/${encodeURIComponent(rolloutId)}`, { method: "GET" }));
8386
+ return await readResponseJson(await this.#client.fetch(`/v1/sandboxes/${this.id}/rollouts/${encodeURIComponent(rolloutId)}`, { method: "GET" }));
8387
8387
  }
8388
8388
  /**
8389
8389
  * Poll {@link getRollout} until the rollout leaves `running`, then return
@@ -8409,7 +8409,7 @@ var SandboxInstance = class SandboxInstance {
8409
8409
  async #stop(options) {
8410
8410
  const noWait = options?.wait === false;
8411
8411
  const response = await withLifecycleConflictRetry(async () => {
8412
- const attempt = await this.client.fetch(`/v1/sandboxes/${this.id}/stop${noWait ? "?wait=false" : ""}`, {
8412
+ const attempt = await this.#client.fetch(`/v1/sandboxes/${this.id}/stop${noWait ? "?wait=false" : ""}`, {
8413
8413
  method: "POST",
8414
8414
  ...options?.idempotencyKey ? { headers: { "Idempotency-Key": options.idempotencyKey } } : {}
8415
8415
  });
@@ -8419,26 +8419,26 @@ var SandboxInstance = class SandboxInstance {
8419
8419
  }
8420
8420
  return attempt;
8421
8421
  });
8422
- if (noWait && response.status === 202) return new SandboxOperation(parseSandboxOperation((await readResponseJson(response)).operation), this.client, async (done) => {
8422
+ if (noWait && response.status === 202) return new SandboxOperation(parseSandboxOperation((await readResponseJson(response)).operation), this.#client, async (done) => {
8423
8423
  if (!this.applyLifecycleResponse(done.result?.sandbox ?? null)) await this.refresh();
8424
8424
  });
8425
8425
  const data = await this.readLifecycleResponse(response);
8426
8426
  if (!this.applyLifecycleResponse(data)) await this.refreshFor("lifecycle");
8427
8427
  const diagnostics = data ? normalizeStartupDiagnostics(data.startupDiagnostics) : null;
8428
- if (diagnostics) this.info.startupDiagnostics = diagnostics;
8428
+ if (diagnostics) this.#info.startupDiagnostics = diagnostics;
8429
8429
  return noWait ? SandboxOperation.completed("stop", this.id) : void 0;
8430
8430
  }
8431
8431
  /** Read an operation a `wait: false` stop or snapshot of this sandbox returned. */
8432
8432
  async getOperation(operationId) {
8433
- return new SandboxOperation(parseSandboxOperation(await readResponseJson(await this.client.fetch(`/v1/sandboxes/${encodeURIComponent(this.id)}/operations/${encodeURIComponent(operationId)}`))), this.client);
8433
+ return new SandboxOperation(parseSandboxOperation(await readResponseJson(await this.#client.fetch(`/v1/sandboxes/${encodeURIComponent(this.id)}/operations/${encodeURIComponent(operationId)}`))), this.#client);
8434
8434
  }
8435
8435
  /** Read credential recovery metadata without changing sandbox lifecycle. */
8436
8436
  async getEnvRecovery() {
8437
- return await readResponseJson(await this.client.fetch(`/v1/sandboxes/${encodeURIComponent(this.id)}/env-recovery`));
8437
+ return await readResponseJson(await this.#client.fetch(`/v1/sandboxes/${encodeURIComponent(this.id)}/env-recovery`));
8438
8438
  }
8439
8439
  /** Replace a stopped sandbox's policy, or inspect a proposed change with dryRun. */
8440
8440
  async setEnvRecovery(envRecovery, options = {}) {
8441
- return await readResponseJson(await this.client.fetch(`/v1/sandboxes/${encodeURIComponent(this.id)}/env-recovery`, {
8441
+ return await readResponseJson(await this.#client.fetch(`/v1/sandboxes/${encodeURIComponent(this.id)}/env-recovery`, {
8442
8442
  method: "PUT",
8443
8443
  body: JSON.stringify({
8444
8444
  envRecovery,
@@ -8464,7 +8464,7 @@ var SandboxInstance = class SandboxInstance {
8464
8464
  ...options.env ? { body: JSON.stringify({ env: options.env }) } : {},
8465
8465
  ...signal ? { signal } : {}
8466
8466
  };
8467
- const attempt = operation === "resume" ? await this.client.fetch(`/v1/sandboxes/${this.id}/resume`, requestOptions, usableTimeoutMs(options.timeoutMs)) : await this.client.fetch(`/v1/sandboxes/${this.id}/rebuild`, requestOptions, usableTimeoutMs(options.timeoutMs));
8467
+ const attempt = operation === "resume" ? await this.#client.fetch(`/v1/sandboxes/${this.id}/resume`, requestOptions, usableTimeoutMs(options.timeoutMs)) : await this.#client.fetch(`/v1/sandboxes/${this.id}/rebuild`, requestOptions, usableTimeoutMs(options.timeoutMs));
8468
8468
  if (!attempt.ok) {
8469
8469
  const body = await attempt.text();
8470
8470
  throw parseErrorResponse(attempt.status, body, void 0, attempt.headers);
@@ -8474,7 +8474,7 @@ var SandboxInstance = class SandboxInstance {
8474
8474
  const data = await this.readLifecycleResponse(response);
8475
8475
  if (!this.applyLifecycleResponse(data)) await this.refreshFor("lifecycle", signal);
8476
8476
  const diagnostics = data ? normalizeStartupDiagnostics(data.startupDiagnostics) : null;
8477
- if (diagnostics) this.info.startupDiagnostics = diagnostics;
8477
+ if (diagnostics) this.#info.startupDiagnostics = diagnostics;
8478
8478
  }
8479
8479
  /**
8480
8480
  * Delete the sandbox permanently. This is how a forked child is destroyed.
@@ -8498,7 +8498,7 @@ var SandboxInstance = class SandboxInstance {
8498
8498
  let response;
8499
8499
  try {
8500
8500
  response = await withLifecycleConflictRetry(async () => {
8501
- const attempt = await this.client.fetch(path, {
8501
+ const attempt = await this.#client.fetch(path, {
8502
8502
  method: "DELETE",
8503
8503
  ...options?.signal ? { signal: options.signal } : {}
8504
8504
  });
@@ -8521,7 +8521,7 @@ var SandboxInstance = class SandboxInstance {
8521
8521
  const data = await response.json().catch(() => null);
8522
8522
  options?.signal?.throwIfAborted();
8523
8523
  const diagnostics = data ? normalizeStartupDiagnostics(data.startupDiagnostics) : null;
8524
- if (diagnostics) this.info.startupDiagnostics = diagnostics;
8524
+ if (diagnostics) this.#info.startupDiagnostics = diagnostics;
8525
8525
  sandboxStatusObservedAt.delete(this);
8526
8526
  const outcome = data?.outcome === "destroyed" || data?.outcome === "already_absent" ? data.outcome : "unknown";
8527
8527
  const removal = data?.removal === "pending" || data?.removal === "complete" ? data.removal : void 0;
@@ -8542,7 +8542,7 @@ var SandboxInstance = class SandboxInstance {
8542
8542
  }
8543
8543
  applyLifecycleResponse(data) {
8544
8544
  if (!data || data.id !== this.id || typeof data.status !== "string" || typeof data.createdAt !== "string") return false;
8545
- this.info = this.parseInfo(data, this.info);
8545
+ this.#info = this.parseInfo(data, this.#info);
8546
8546
  sandboxStatusObservedAt.set(this, Date.now());
8547
8547
  return true;
8548
8548
  }
@@ -8790,7 +8790,7 @@ var SandboxInstance = class SandboxInstance {
8790
8790
  try {
8791
8791
  if (reason) await this.refreshFor(reason, signal);
8792
8792
  } finally {
8793
- emitTiming(this.client.onTiming, {
8793
+ emitTiming(this.#client.onTiming, {
8794
8794
  name: "sdk.ensureRunning",
8795
8795
  durMs: Math.round((performance.now() - startedAt) * 10) / 10,
8796
8796
  desc: reason ?? "cached"
@@ -8822,8 +8822,8 @@ var SandboxInstance = class SandboxInstance {
8822
8822
  const url = `/v1/sandboxes/${encodeURIComponent(this.id)}/runtime${path}`;
8823
8823
  try {
8824
8824
  let response;
8825
- if (fetchOptions) response = await this.client.fetch(url, options, fetchOptions);
8826
- else response = options ? await this.client.fetch(url, options) : await this.client.fetch(url);
8825
+ if (fetchOptions) response = await this.#client.fetch(url, options, fetchOptions);
8826
+ else response = options ? await this.#client.fetch(url, options) : await this.#client.fetch(url);
8827
8827
  if (response.ok) sandboxStatusObservedAt.set(this, Date.now());
8828
8828
  return response;
8829
8829
  } catch (err) {
@@ -8844,17 +8844,25 @@ var SandboxInstance = class SandboxInstance {
8844
8844
  */
8845
8845
  async *parseSSEStream(response, signal) {
8846
8846
  if (!response.body) throw new NetworkError("No response body");
8847
+ let silenceMs;
8847
8848
  try {
8848
8849
  for await (const event of parseSSEStream(response.body, {
8849
8850
  signal,
8850
- invalidEvent: "warn-and-skip"
8851
- })) yield {
8852
- ...event,
8853
- data: {
8854
- ...event.data,
8855
- sandboxId: this.id
8851
+ invalidEvent: "warn-and-skip",
8852
+ idleMs: () => silenceMs
8853
+ })) {
8854
+ if (event.type === "history.replay.start") {
8855
+ const heartbeatMs = event.data.heartbeatMs;
8856
+ if (typeof heartbeatMs === "number" && Number.isFinite(heartbeatMs) && heartbeatMs > 0) silenceMs = heartbeatMs * 3;
8856
8857
  }
8857
- };
8858
+ yield {
8859
+ ...event,
8860
+ data: {
8861
+ ...event.data,
8862
+ sandboxId: this.id
8863
+ }
8864
+ };
8865
+ }
8858
8866
  } catch (err) {
8859
8867
  if (err instanceof Error && err.name === "AbortError") return;
8860
8868
  throw err;
@@ -8875,7 +8883,7 @@ var SandboxInstance = class SandboxInstance {
8875
8883
  * ```
8876
8884
  */
8877
8885
  async registerSessionMapping(opts) {
8878
- const response = await this.client.fetch(`/v1/session/${encodeURIComponent(opts.sessionId)}/mapping`, {
8886
+ const response = await this.#client.fetch(`/v1/session/${encodeURIComponent(opts.sessionId)}/mapping`, {
8879
8887
  method: "PUT",
8880
8888
  body: JSON.stringify({
8881
8889
  sidecarSessionId: opts.runtimeSessionId,
@@ -8905,7 +8913,7 @@ var SandboxInstance = class SandboxInstance {
8905
8913
  * sandbox stays alive.
8906
8914
  */
8907
8915
  async unregisterSessionMapping(opts) {
8908
- const response = await this.client.fetch(`/v1/session/${encodeURIComponent(opts.sessionId)}/mapping`, { method: "DELETE" });
8916
+ const response = await this.#client.fetch(`/v1/session/${encodeURIComponent(opts.sessionId)}/mapping`, { method: "DELETE" });
8909
8917
  if (!response.ok) throw await parseResponseError(response);
8910
8918
  const data = await response.json().catch(() => ({}));
8911
8919
  return {
@@ -8928,8 +8936,8 @@ var SandboxInstance = class SandboxInstance {
8928
8936
  const id = data.id ?? this.id;
8929
8937
  const incarnation = readFilesystemIncarnationTuple(data);
8930
8938
  const incarnationComplete = incarnation.complete;
8931
- const sameReadyIncarnation = incarnationComplete && incarnation.readiness === "ready" && incarnation.id === this.info.filesystemIncarnationId;
8932
- const connection = incarnationComplete && incarnation.readiness === "ready" ? normalizeConnection(data.connection) ?? (sameReadyIncarnation ? this.info.connection : void 0) : void 0;
8939
+ const sameReadyIncarnation = incarnationComplete && incarnation.readiness === "ready" && incarnation.id === this.#info.filesystemIncarnationId;
8940
+ const connection = incarnationComplete && incarnation.readiness === "ready" ? normalizeConnection(data.connection) ?? (sameReadyIncarnation ? this.#info.connection : void 0) : void 0;
8933
8941
  return {
8934
8942
  id,
8935
8943
  name: data.name,
@@ -8940,13 +8948,13 @@ var SandboxInstance = class SandboxInstance {
8940
8948
  connection,
8941
8949
  metadata: data.metadata,
8942
8950
  captureProof: normalizeCaptureProof(data.captureProof) ?? void 0,
8943
- createdAt: data.createdAt ? new Date(data.createdAt) : this.info.createdAt,
8951
+ createdAt: data.createdAt ? new Date(data.createdAt) : this.#info.createdAt,
8944
8952
  startedAt: data.startedAt ? new Date(data.startedAt) : void 0,
8945
8953
  lastActivityAt: data.lastActivityAt ? new Date(data.lastActivityAt) : void 0,
8946
8954
  expiresAt: data.expiresAt ? new Date(data.expiresAt) : void 0,
8947
8955
  error: data.error,
8948
8956
  gpuLease: data.gpuLease ?? carryCreateFacts?.gpuLease,
8949
- resources: normalizeSandboxShape(data.resources) ?? (id === this.id ? this.info.resources : void 0),
8957
+ resources: normalizeSandboxShape(data.resources) ?? (id === this.id ? this.#info.resources : void 0),
8950
8958
  startupDiagnostics: normalizeStartupDiagnostics(data.startupDiagnostics) ?? carryCreateFacts?.startupDiagnostics,
8951
8959
  createReceipt: normalizeSandboxCreateReceipt(data.createReceipt) ?? carryCreateFacts?.createReceipt
8952
8960
  };
@@ -8967,7 +8975,7 @@ var SandboxInstance = class SandboxInstance {
8967
8975
  * member's messages here, one session per member.
8968
8976
  */
8969
8977
  get lines() {
8970
- return new SandboxLines(this.client, this.id);
8978
+ return new SandboxLines(this.#client, this.id);
8971
8979
  }
8972
8980
  /** Create an agent session and return both its handle and initial metadata. */
8973
8981
  async createSession(options) {
@@ -9245,7 +9253,7 @@ var SandboxInstance = class SandboxInstance {
9245
9253
  if (turn) return settleTurnDrive(turn.result);
9246
9254
  const info = await this._sessionStatus(opts.sessionId);
9247
9255
  const hasExplicitBackend = opts.backend !== void 0 || opts.model !== void 0;
9248
- const backend = mergeRuntimeBackendConfig(this.defaultRuntimeBackend, applyRequestedModel(opts.backend, opts.model));
9256
+ const backend = mergeRuntimeBackendConfig(this.#defaultRuntimeBackend, applyRequestedModel(opts.backend, opts.model));
9249
9257
  if (info?.status === "queued" && hasExplicitBackend) await this.createSession({
9250
9258
  sessionId: opts.sessionId,
9251
9259
  ...backend !== void 0 ? { backend: withoutRuntimeSecrets(backend) } : {}
@@ -9310,7 +9318,7 @@ var SandboxInstance = class SandboxInstance {
9310
9318
  */
9311
9319
  async preparePublicProfileRevision(opts) {
9312
9320
  await this.ensureRunning();
9313
- const backend = mergeRuntimeBackendConfig(this.defaultRuntimeBackend, applyRequestedModel(opts.backend, opts.model));
9321
+ const backend = mergeRuntimeBackendConfig(this.#defaultRuntimeBackend, applyRequestedModel(opts.backend, opts.model));
9314
9322
  if (!backend) throw new ValidationError("Public profile backend is required");
9315
9323
  const expectedPublicProfileRequestDigest = requestedPublicProfileDigest(backend);
9316
9324
  const wire = sessionMessageRequestBody({
@@ -9348,7 +9356,7 @@ var SandboxInstance = class SandboxInstance {
9348
9356
  /** Prepare a secret-bearing native revision without starting a model turn. */
9349
9357
  async prepareSecretProfileRevision(opts) {
9350
9358
  await this.ensureRunning();
9351
- const backend = mergeRuntimeBackendConfig(this.defaultRuntimeBackend, applyRequestedModel(opts.backend, opts.model));
9359
+ const backend = mergeRuntimeBackendConfig(this.#defaultRuntimeBackend, applyRequestedModel(opts.backend, opts.model));
9352
9360
  if (!backend) throw new ValidationError("Secret profile backend is required");
9353
9361
  const expectedPublicProfileRequestDigest = requestedSecretProfilePublicDigest(backend);
9354
9362
  const wire = sessionMessageRequestBody({
@@ -9391,7 +9399,7 @@ var SandboxInstance = class SandboxInstance {
9391
9399
  async driveConversationTurnPass(message, opts, traceId) {
9392
9400
  if (!opts.sessionId || !opts.turnId) throw new Error("Conversation sessionId and turnId are required");
9393
9401
  if (opts.wallCapMs !== void 0 && (!Number.isFinite(opts.wallCapMs) || opts.wallCapMs <= 0)) throw new Error("wallCapMs must be a positive finite duration");
9394
- const backend = mergeRuntimeBackendConfig(this.defaultRuntimeBackend, applyRequestedModel(opts.backend, opts.model));
9402
+ const backend = mergeRuntimeBackendConfig(this.#defaultRuntimeBackend, applyRequestedModel(opts.backend, opts.model));
9395
9403
  const request = {
9396
9404
  parts: typeof message === "string" ? [{
9397
9405
  type: "text",
@@ -9514,7 +9522,7 @@ var SandboxInstance = class SandboxInstance {
9514
9522
  * while session-runtime/read-only scopes work with SandboxRuntimeClient.
9515
9523
  */
9516
9524
  async mintScopedToken(opts) {
9517
- return requestScopedToken(this.client, this.id, opts);
9525
+ return requestScopedToken(this.#client, this.id, opts);
9518
9526
  }
9519
9527
  /** @internal — invoked by SandboxSession.status(). */
9520
9528
  async _sessionStatus(id) {
@@ -9537,7 +9545,7 @@ var SandboxInstance = class SandboxInstance {
9537
9545
  })}`, {
9538
9546
  method: "GET",
9539
9547
  signal
9540
- }), id, destination, options, this.info.captureProof);
9548
+ }), id, destination, options, this.#info.captureProof);
9541
9549
  }
9542
9550
  async _sessionRawEvidence(id) {
9543
9551
  await this.ensureRunning();
@@ -9592,7 +9600,7 @@ var SandboxInstance = class SandboxInstance {
9592
9600
  if (!source || typeof source !== "object" || Array.isArray(source) || typeof source.sourceId !== "string" || source.sourceId.length === 0) throw new ServerError("Malformed raw evidence process source ID");
9593
9601
  await verifyBytes(source, "process source");
9594
9602
  }
9595
- const expected = this.info.captureProof;
9603
+ const expected = this.#info.captureProof;
9596
9604
  if (expected && (record.proofStatus !== "verified" || record.containerId !== expected.containerId || record.sidecarImageDigest !== expected.imageId || record.sidecarBundleRevision !== expected.bundleRevision || record.sidecarBundleChecksum !== expected.bundleChecksum)) throw new ServerError("Raw evidence does not match current container capture proof");
9597
9605
  return record;
9598
9606
  }
@@ -9846,7 +9854,7 @@ var SandboxInstance = class SandboxInstance {
9846
9854
  /** @internal — invoked by SandboxSession.plan(). */
9847
9855
  async _currentPlan(sessionId) {
9848
9856
  const path = `/v1/sandboxes/${encodeURIComponent(this.id)}/agent-sessions/${encodeURIComponent(sessionId)}/plans/current`;
9849
- const response = await this.client.fetch(path);
9857
+ const response = await this.#client.fetch(path);
9850
9858
  if (response.status === 404) return null;
9851
9859
  const decoded = await readResponseJson(response);
9852
9860
  if (!decoded.plan || typeof decoded.plan.sourceTurnId !== "string" || !decoded.plan.sourceTurnId.trim()) throw new ServerError("Durable plan response is missing plan or original sourceTurnId", 502, {
@@ -9858,7 +9866,7 @@ var SandboxInstance = class SandboxInstance {
9858
9866
  /** @internal — invoked by SandboxSession.approvePlan()/rejectPlan(). */
9859
9867
  async _decidePlan(sessionId, planId, decision, options = {}) {
9860
9868
  const path = `/v1/sandboxes/${encodeURIComponent(this.id)}/agent-sessions/${encodeURIComponent(sessionId)}/plans/${encodeURIComponent(planId)}/decision`;
9861
- const decoded = await readResponseJson(await this.client.fetch(path, {
9869
+ const decoded = await readResponseJson(await this.#client.fetch(path, {
9862
9870
  method: "POST",
9863
9871
  body: JSON.stringify({
9864
9872
  ...decision,