@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,14 +1,14 @@
1
- import { D as assertCurrentBackendType, E as applyRequestedModel, M as withProfileHarness, N as withoutCreateOnlyModelFields, T as isBrowserRuntime, V as backendTypeSchema, k as normalizeRuntimeBackendConfig, o as requestInteractiveSessionToken, x as encodePromptForWire } from "./interactive-controller-CqJX-LcO.js";
1
+ import { D as assertCurrentBackendType, E as applyRequestedModel, M as withProfileHarness, N as withoutCreateOnlyModelFields, T as isBrowserRuntime, V as backendTypeSchema, k as normalizeRuntimeBackendConfig, o as requestInteractiveSessionToken, x as encodePromptForWire } from "./interactive-controller-llj6EdlZ.js";
2
2
  import { r as agentProfileSchema } from "./profile-schema-B11dRfGB.js";
3
- import { $ as isDeployWindowCreateError, B as parseLifecycleTimes, D as splitInlineProfileSkills, E as splitInlineProfileFileMounts, F as normalizeCaptureProof, G as CAPACITY_ETA_MARGIN_MS, H as normalizeEgressPolicyFields, I as normalizeSandboxCreateReceipt, J as awaitCreateResend, K as CAPACITY_ETA_WAIT_MAX_MS, L as normalizeStartupDiagnostics, O as validateDeferredProfileFileMounts, Q as isCapacityShortageCreateError, U as normalizeProxySecretReceipt, V as normalizeConnection, W as normalizeSandboxShape, X as extendableDeadline, Y as createRetryDelayMs, Z as generateIdempotencyKey, d as sandboxLedgerUsd, et as isRateLimitCreateError, k as isRetryableProfileFileMaterializeFailure, n as createSandboxInstanceFromResponse, o as exportTraceBundle, q as DEPLOY_WINDOW_RETRY_MS, tt as isRetryableCreateError, x as deleteSandbox, z as dateOf } from "./sandbox-BVN_aNT1.js";
4
- import { C as SandboxError, D as TimeoutError, O as ValidationError, _ as NetworkError, a as readResponseJson, c as AuthError, i as parseResponseError, r as parseErrorResponse, v as NotFoundError, w as ServerError, y as PartialFailureError } from "./errors-C0S3TzhR.js";
3
+ import { $ as isRateLimitCreateError, B as normalizeConnection, D as splitInlineProfileSkills, E as splitInlineProfileFileMounts, F as normalizeSandboxCreateReceipt, G as CAPACITY_ETA_WAIT_MAX_MS, H as normalizeProxySecretReceipt, I as normalizeStartupDiagnostics, J as createRetryDelayMs, K as DEPLOY_WINDOW_RETRY_MS, O as validateDeferredProfileFileMounts, P as normalizeCaptureProof, Q as isDeployWindowCreateError, R as dateOf, U as normalizeSandboxShape, V as normalizeEgressPolicyFields, W as CAPACITY_ETA_MARGIN_MS, X as generateIdempotencyKey, Y as extendableDeadline, Z as isCapacityShortageCreateError, d as sandboxLedgerUsd, et as isRetryableCreateError, n as createSandboxInstanceFromResponse, o as exportTraceBundle, q as awaitCreateResend, x as deleteSandbox, z as parseLifecycleTimes } from "./sandbox-C3PqmwfU.js";
4
+ import { C as SandboxError, D as TimeoutError, O as ValidationError, _ as NetworkError, a as readResponseJson, c as AuthError, i as parseResponseError, r as parseErrorResponse, v as NotFoundError, w as ServerError, y as PartialFailureError } from "./errors-D44qyFpy.js";
5
5
  import { n as combineAbortSignals } from "./abort-signal-BsriwJ8L.js";
6
6
  import { r as abortableSleep, t as RETRY_POLICY } from "./retry-policy-oW3_ljoc.js";
7
- import { i as fetchSandboxApi, n as SDK_TIMEOUTS } from "./api-request-SBaqnuZB.js";
7
+ import { i as fetchSandboxApi, n as SDK_TIMEOUTS } from "./api-request-gkPDymqn.js";
8
8
  import { l as SANDBOX_AGENT_HOME, t as isInsideReservedDir } from "./file-transfer-DOSTbUSR.js";
9
9
  import { n as fetchWithKeepAlive, t as emitTiming } from "./keep-alive-fetch-sGVP8skk.js";
10
10
  import { t as parseSSEStream } from "./sse-parser-BCG3iL9j.js";
11
- import { t as LinesClient } from "./lines-NECw0OhS.js";
11
+ import { t as LinesClient } from "./lines-DwJ7AKx7.js";
12
12
  import { PublicTemplatesClient } from "./public-templates.js";
13
13
  import { z } from "zod";
14
14
  //#region ../../../packages/runtime-contracts/dist/git-policy.js
@@ -931,7 +931,9 @@ const backendRegistryCapabilitiesSchema = z.object({
931
931
  runtimeAttachments: z.object({ mcp: z.literal(true) }).optional(),
932
932
  sessions: z.boolean(),
933
933
  configurable: z.boolean(),
934
- interactions: z.array(z.string().min(1)).transform((values) => values.filter(isBackendRegistryInteractionKind))
934
+ interactions: z.array(z.string().min(1)).transform((values) => values.filter(isBackendRegistryInteractionKind)),
935
+ /** Model calls carry the Router execution tuple (an older API omits it). */
936
+ executionCorrelation: z.boolean().default(false)
935
937
  });
936
938
  /** One backend entry returned by the Sandbox API registry. */
937
939
  const backendRegistryEntrySchema = z.object({
@@ -1247,11 +1249,11 @@ function isLocalSandboxEndpoint(baseUrl) {
1247
1249
  }
1248
1250
  }
1249
1251
  async function resolveLocalCliAuthFiles(backendType) {
1250
- const { discoverLocalCliAuthFiles } = await import("./local-cli-auth-wyO74fdb.js");
1252
+ const { discoverLocalCliAuthFiles } = await import("./local-cli-auth-C2cETxK4.js");
1251
1253
  return discoverLocalCliAuthFiles(backendType);
1252
1254
  }
1253
1255
  async function loadLocalCliAuthExpectation(backendType) {
1254
- const { describeLocalCliAuthExpectation: describe } = await import("./local-cli-auth-wyO74fdb.js");
1256
+ const { describeLocalCliAuthExpectation: describe } = await import("./local-cli-auth-C2cETxK4.js");
1255
1257
  return describe(backendType);
1256
1258
  }
1257
1259
  /**
@@ -1694,6 +1696,8 @@ var SandboxManagement = class extends SandboxTransport {
1694
1696
  /** Create options the API takes exactly as given, in wire order. */
1695
1697
  function verbatimCreateFields(options) {
1696
1698
  return {
1699
+ driver: options?.driver,
1700
+ runtime: options?.runtime,
1697
1701
  requireNativeSessionCapture: options?.requireNativeSessionCapture,
1698
1702
  sessionCapture: options?.sessionCapture,
1699
1703
  gpuLease: options?.gpuLease,
@@ -1752,14 +1756,13 @@ var SandboxCreation = class extends SandboxManagement {
1752
1756
  const startedAt = Date.now();
1753
1757
  let deadline = startedAt + timeoutMs;
1754
1758
  let deployWindowDeadline = Math.min(deadline, startedAt + DEPLOY_WINDOW_RETRY_MS);
1755
- const git = options?.git ? {
1759
+ const git = options?.git && {
1756
1760
  url: options.git.url,
1757
1761
  ref: options.git.ref,
1758
1762
  depth: options.git.depth,
1759
1763
  sparse: options.git.sparse,
1760
1764
  auth: options.git.auth
1761
- } : void 0;
1762
- const environment = options?.environment;
1765
+ };
1763
1766
  const backend = options?.ownerContext === "isolated" ? options.backend : await hydrateLocalCliBackendAuth(options?.backend, this.baseUrl, this.trustLocalCliAuth);
1764
1767
  const derivedBackend = backend && withProfileHarness(backend);
1765
1768
  const resolvedBackend = derivedBackend ? {
@@ -1769,7 +1772,7 @@ var SandboxCreation = class extends SandboxManagement {
1769
1772
  const autoMaterializeProfileFiles = options?.autoMaterializeProfileFiles ?? true;
1770
1773
  const autoDeferProfile = options?.autoDeferProfile ?? true;
1771
1774
  let deferredProfileFiles = [];
1772
- let profileFilesFailOnError = true;
1775
+ let pendingProfile;
1773
1776
  let requestBackend = resolvedBackend;
1774
1777
  let handleBackend = resolvedBackend;
1775
1778
  let deferredProfileForPriming;
@@ -1780,10 +1783,7 @@ var SandboxCreation = class extends SandboxManagement {
1780
1783
  const split = splitInlineProfileFileMounts(profile);
1781
1784
  deferredProfileFiles = split.deferredFiles;
1782
1785
  handleProfile = split.leanProfile;
1783
- if (deferredProfileFiles.length > 0) {
1784
- profileFilesFailOnError = profile.resources?.failOnError !== false;
1785
- deferredProfileFiles = validateDeferredProfileFileMounts(deferredProfileFiles, { failOnError: profileFilesFailOnError });
1786
- }
1786
+ if (deferredProfileFiles.length > 0) deferredProfileFiles = validateDeferredProfileFileMounts(deferredProfileFiles, { failOnError: profile.resources?.failOnError !== false });
1787
1787
  }
1788
1788
  handleBackend = {
1789
1789
  ...resolvedBackend,
@@ -1800,6 +1800,7 @@ var SandboxCreation = class extends SandboxManagement {
1800
1800
  deferredProfileForPriming = handleProfile;
1801
1801
  }
1802
1802
  }
1803
+ if (deferredProfileFiles.length > 0 || deferredProfileForPriming) pendingProfile = profile;
1803
1804
  }
1804
1805
  const resources = options?.resources;
1805
1806
  const workspaceCwd = options?.cwd === void 0 ? void 0 : runtimeWorkspaceCwdSchema.parse(options.cwd);
@@ -1807,12 +1808,11 @@ var SandboxCreation = class extends SandboxManagement {
1807
1808
  const postSignal = requestOptions?.signal ? combineAbortSignals([requestOptions.signal, postDeadline.signal]) : postDeadline.signal;
1808
1809
  const createRequestBody = JSON.stringify({
1809
1810
  name: options?.name,
1810
- ...environment !== void 0 ? { environment } : {},
1811
+ environment: options?.environment,
1811
1812
  git,
1812
1813
  cwd: workspaceCwd,
1813
1814
  bare: options?.bare,
1814
1815
  agent: options?.agent,
1815
- driver: options?.driver,
1816
1816
  backend: requestBackend,
1817
1817
  env: options?.env,
1818
1818
  envRecovery: options?.envRecovery,
@@ -1928,7 +1928,7 @@ var SandboxCreation = class extends SandboxManagement {
1928
1928
  const data = await response.json();
1929
1929
  const info = this.parseInfo(data);
1930
1930
  const injectedSecrets = data.createReceipt?.injectedSecrets;
1931
- if (options?.requireNativeSessionCapture && (!info.captureProof || !info.createReceipt?.captureProof || JSON.stringify(info.captureProof) !== JSON.stringify(info.createReceipt.captureProof))) throw new PartialFailureError("The API did not confirm native session capture for the created container.", {
1931
+ if (options?.requireNativeSessionCapture && !sameCaptureProof(info.captureProof, info.createReceipt?.captureProof)) throw new PartialFailureError("The API did not confirm native session capture for the created container.", {
1932
1932
  code: "NATIVE_CAPTURE_UNVERIFIED",
1933
1933
  status: 502,
1934
1934
  origin: "sandbox-api",
@@ -1979,46 +1979,19 @@ var SandboxCreation = class extends SandboxManagement {
1979
1979
  });
1980
1980
  }
1981
1981
  }
1982
- if (deferredProfileFiles.length > 0 && resolvedBackend?.profile !== void 0) {
1983
- if (instance.status !== "running") {
1984
- const paths = deferredProfileFiles.map((file) => file.path);
1985
- const message = `Sandbox ${instance.id} reached status "${instance.status}" before its ${deferredProfileFiles.length} deferred inline profile file mount(s) [${paths.join(", ")}] could be materialized. The sandbox was NOT deleted — inspect it, or recreate with autoMaterializeProfileFiles: false.`;
1986
- if (!profileFilesFailOnError) {
1987
- console.warn(`[sandbox.create] ${message}`);
1988
- return instance;
1989
- }
1990
- throw new PartialFailureError(message, {
1991
- code: "PROFILE_FILES_MATERIALIZE_INTERRUPTED",
1992
- status: 502,
1993
- failures: paths.map((path) => ({ path }))
1994
- });
1995
- }
1996
- try {
1997
- await instance.materializeProfileFiles(resolvedBackend.profile, void 0, "replace");
1998
- } catch (err) {
1999
- const paths = deferredProfileFiles.map((file) => file.path);
2000
- const message = `Sandbox ${instance.id} is RUNNING but INCOMPLETELY PROVISIONED: materialization of its ${deferredProfileFiles.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)}`;
2001
- if (!profileFilesFailOnError) {
2002
- console.warn(`[sandbox.create] ${message}`);
2003
- return instance;
2004
- }
2005
- const retryable = isRetryableProfileFileMaterializeFailure(err);
2006
- throw new PartialFailureError(message, {
2007
- code: retryable ? "PROFILE_FILES_MATERIALIZE_INTERRUPTED" : "PROFILE_FILES_MATERIALIZE_FAILED",
2008
- status: retryable ? 502 : 422,
2009
- failures: paths.map((path) => ({ path })),
2010
- cause: err
2011
- });
2012
- }
2013
- }
2014
- if (deferredProfileForPriming !== void 0) try {
2015
- await instance.primeProfile(deferredProfileForPriming);
2016
- } catch (err) {
2017
- console.warn(`[sandbox.create] Profile priming failed for ${instance.id}; turns will send the full profile inline. Cause: ${err instanceof Error ? err.message : String(err)}`);
2018
- }
1982
+ if (pendingProfile) instance.deferProfileDelivery(pendingProfile, deferredProfileForPriming);
2019
1983
  return instance;
2020
1984
  }
2021
1985
  };
1986
+ /** The state proof carries no host id (#7599); compare everything else. */
1987
+ function sameCaptureProof(state, receipt) {
1988
+ if (!state || !receipt) return false;
1989
+ const bare = (proof) => JSON.stringify({
1990
+ ...proof,
1991
+ hostId: void 0
1992
+ });
1993
+ return bare(state) === bare(receipt);
1994
+ }
2022
1995
  //#endregion
2023
1996
  //#region src/client-batch.ts
2024
1997
  var SandboxBatch = class extends SandboxCreation {
@@ -4073,6 +4046,13 @@ var HostedInstance = class {
4073
4046
  });
4074
4047
  }
4075
4048
  };
4049
+ /** A pinned `ensure` whose sandbox moved or is gone: it never makes another. */
4050
+ function pinnedRefusal(key, current) {
4051
+ return new SandboxError(current ? `Instance ${key} now runs sandbox ${current}, not the pinned one` : `Instance ${key} has no running pinned sandbox`, {
4052
+ code: current ? "SANDBOX_CHANGED" : "SANDBOX_MISSING",
4053
+ status: 409
4054
+ });
4055
+ }
4076
4056
  /** `client.instances`: one isolated sandbox per tenant key. */
4077
4057
  var InstancesClient = class {
4078
4058
  constructor(client, now = Date.now) {
@@ -4106,6 +4086,8 @@ var InstancesClient = class {
4106
4086
  if (!KEY.test(options.key)) throw new ValidationError("An instance key is 1-200 letters, digits and . _ : @ -");
4107
4087
  for (let pass = 0; pass < MAX_PASSES; pass++) {
4108
4088
  const record = await this.get(options.key);
4089
+ const expected = options.expectSandboxId;
4090
+ if (expected !== void 0 && record?.sandboxId !== expected) throw pinnedRefusal(options.key, record?.sandboxId);
4109
4091
  if (!record?.sandboxId) {
4110
4092
  if (!record && options.adopt) {
4111
4093
  await this.write(bindingPath(options.key), "PUT", {
@@ -4149,6 +4131,7 @@ var InstancesClient = class {
4149
4131
  async start(options, record, sandboxId) {
4150
4132
  let box = await this.client.get(sandboxId);
4151
4133
  if (!box || box.status === "deleted") {
4134
+ if (options.expectSandboxId) throw pinnedRefusal(options.key, null);
4152
4135
  await this.replace(options.key, record.generation);
4153
4136
  return null;
4154
4137
  }
@@ -4194,7 +4177,7 @@ var InstancesClient = class {
4194
4177
  const marked = await this.update(options.key, record.generation, { unstartable: "mark" });
4195
4178
  if (!marked.ok) return;
4196
4179
  const since = marked.instance.unstartableSince ?? now;
4197
- if (now - since >= wait) {
4180
+ if (now - since >= wait && options.expectSandboxId === void 0) {
4198
4181
  await this.replace(options.key, record.generation);
4199
4182
  return;
4200
4183
  }