@tangle-network/sandbox 1.0.189 → 1.0.191

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 (58) hide show
  1. package/README.md +7 -0
  2. package/dist/agent/index.d.ts +4 -4
  3. package/dist/agent/index.js +9 -6
  4. package/dist/agent/preview.d.ts +1 -1
  5. package/dist/agent/preview.js +1 -1
  6. package/dist/{agent-run-outcome-Cst4px_l.d.ts → agent-run-outcome-BO5paRhX.d.ts} +2 -2
  7. package/dist/{api-request-D4Ln_0F5.js → api-request-BvpTwQKs.js} +4 -1
  8. package/dist/{browser-interactive-control-controller-DHIS8edi.js → browser-interactive-control-controller-BYbNLahH.js} +1 -1
  9. package/dist/{browser-interactive-control-controller-DIvMQyer.d.ts → browser-interactive-control-controller-KOK6qn2s.d.ts} +1 -1
  10. package/dist/{chunked-upload-vAE2hVcP.js → chunked-upload-D5ytV_s6.js} +9 -13
  11. package/dist/{chunked-upload-file-HLSriv3V.js → chunked-upload-file-DL1-AqRp.js} +2 -2
  12. package/dist/{client-CwWS3a-i.js → client-XjkuWhog.js} +159 -109
  13. package/dist/{client-C4SnCCpF.d.ts → client-yWdLuj_P.d.ts} +5 -5
  14. package/dist/collaboration/index.js +1 -1
  15. package/dist/{collaboration-CmT6Ygiv.js → collaboration-Bbr45lyk.js} +3 -3
  16. package/dist/{core-BT-0QZT-.js → core-BU1I2KvV.js} +13 -7
  17. package/dist/core.d.ts +6 -6
  18. package/dist/core.js +5 -5
  19. package/dist/errors-Mzq10WZq.js +583 -0
  20. package/dist/{file-download-BXgu9BNh.js → file-download-CKOxcATB.js} +1 -1
  21. package/dist/{index-DDIymnCZ.d.ts → index-DKsOu5sq.d.ts} +5 -5
  22. package/dist/index.d.ts +9 -9
  23. package/dist/index.js +10 -10
  24. package/dist/intelligence/index.js +9 -5
  25. package/dist/interactive-control.d.ts +1 -1
  26. package/dist/interactive-control.js +1 -1
  27. package/dist/{interactive-controller-DXGWBdYK.d.ts → interactive-controller-YyZEsoB0.d.ts} +3 -3
  28. package/dist/{interactive-controller-C876Pjaj.js → interactive-controller-jr3_74Pq.js} +90 -57
  29. package/dist/lib/prepared-evidence.js +1 -1
  30. package/dist/lib/prepared-process.js +1 -1
  31. package/dist/{lines-Br3ygqhP.d.ts → lines-CCHDUfQg.d.ts} +1 -1
  32. package/dist/{lines-DxHJhxCe.js → lines-DrG0WOW6.js} +1 -1
  33. package/dist/lines.d.ts +1 -1
  34. package/dist/lines.js +1 -1
  35. package/dist/{mcp-local-Cqf4Lpp0.js → mcp-local-Dler9R_s.js} +3 -10
  36. package/dist/{prepared-evidence-CP1MmeCQ.js → prepared-evidence-4prvV0YK.js} +1 -1
  37. package/dist/{prepared-process-BWVz93cT.js → prepared-process-BSpZXDDw.js} +1 -1
  38. package/dist/{preview-DUxqnKSk.d.ts → preview-I1z42VGY.d.ts} +3 -3
  39. package/dist/{public-templates-DQiblzzK.d.ts → public-templates-Cw6gmWJD.d.ts} +2 -2
  40. package/dist/public-templates.d.ts +1 -1
  41. package/dist/public-templates.js +7 -4
  42. package/dist/{raw-evidence-archive-CgbWa4es.js → raw-evidence-archive-BD37zHN5.js} +2 -2
  43. package/dist/runtime.d.ts +5 -5
  44. package/dist/runtime.js +9 -7
  45. package/dist/{sandbox-B_Xbc9wR.js → sandbox-Dtb-_btd.js} +317 -221
  46. package/dist/select-seat-command.d.ts +1 -1
  47. package/dist/select-seat-command.js +5 -2
  48. package/dist/session-gateway/index.js +1 -1
  49. package/dist/tangle/index.d.ts +1 -1
  50. package/dist/tangle/index.js +1 -1
  51. package/dist/{tangle-Sg9ORVAA.js → tangle-fs17QlcY.js} +2 -2
  52. package/dist/{terminal-stream-types-1YKRrkZB.d.ts → terminal-stream-types-BqNv5EuG.d.ts} +280 -305
  53. package/dist/{types-B-UsXSi6.d.ts → types-CiuGb4lZ.d.ts} +4 -2
  54. package/package.json +6 -6
  55. package/dist/errors-CaX0a5Ry.js +0 -636
  56. /package/dist/{abort-signal-PgWPMn_e.js → abort-signal-Cu4F2VVz.js} +0 -0
  57. /package/dist/{file-transfer-DTHgLccV.js → file-transfer-Cr9Ossea.js} +0 -0
  58. /package/dist/{retry-after-header-Bt-XvU-x.js → retry-after-header-DUdCC0KJ.js} +0 -0
package/README.md CHANGED
@@ -15,6 +15,13 @@ export TANGLE_API_KEY=sk-tan-...
15
15
  export SANDBOX_BASE_URL=https://sandbox.tangle.tools
16
16
  ```
17
17
 
18
+ ## Supported versions
19
+
20
+ The oldest supported SDK is `@tangle-network/sandbox@1.0.151`, the first version that accepts a capability or enum value it does not know instead of refusing the whole response.
21
+ Older versions fail when the Sandbox API advertises a new value; upgrade to this version or later.
22
+ This line is the one place the floor is stated: the production journey (`scripts/production-journey.sh`) reads it and runs every cell's journey on it.
23
+ Every request from the [shared raw transport](src/lib/api-request.mjs) and the Python SDK sends `x-sdk-version: <package version>`, and the Sandbox Worker's invocation log records it as `$workers.event.request.headers.x-sdk-version`, so the versions customers run can be counted.
24
+
18
25
  ## Choose an entrypoint
19
26
 
20
27
  | Need | Import |
@@ -1,7 +1,7 @@
1
- import { I as SandboxTaskSession, O as SandboxInstance, R as SandboxSession } from "../index-DDIymnCZ.js";
2
- import { Bt as SandboxFleetParent, Ha as CodeExecutionResult, Ua as CodeLanguage, Ur as CodeExecutionOptions, Wa as CodeResultPart, ga as BackendConfig, ia as SessionListOptions, na as SessionInfo, wo as BackendType } from "../types-B-UsXSi6.js";
3
- import { t as Sandbox } from "../client-C4SnCCpF.js";
4
- import { u as PreviewAuthorizer } from "../preview-DUxqnKSk.js";
1
+ import { I as SandboxTaskSession, O as SandboxInstance, R as SandboxSession } from "../index-DKsOu5sq.js";
2
+ import { Bt as SandboxFleetParent, Ha as CodeExecutionResult, Ua as CodeLanguage, Ur as CodeExecutionOptions, Wa as CodeResultPart, ga as BackendConfig, ia as SessionListOptions, na as SessionInfo, wo as BackendType } from "../types-CiuGb4lZ.js";
3
+ import { t as Sandbox } from "../client-yWdLuj_P.js";
4
+ import { u as PreviewAuthorizer } from "../preview-I1z42VGY.js";
5
5
  import * as _$_modelcontextprotocol_sdk_server_index_js0 from "@modelcontextprotocol/sdk/server/index.js";
6
6
  import { JSONSchema } from "zod/v4/core";
7
7
  import { ToolSet } from "ai";
@@ -1,8 +1,8 @@
1
- import { a as TOOL_SPECS, i as ALL_TOOL_SPECS, o as serializeToolResult, r as bindToolSpecs, t as createMcpServer } from "../mcp-local-Cqf4Lpp0.js";
2
- import { O as assertCurrentBackendType } from "../interactive-controller-C876Pjaj.js";
3
- import { t as SandboxInstance } from "../sandbox-B_Xbc9wR.js";
4
- import { C as StateError, E as ValidationError, g as NotFoundError } from "../errors-CaX0a5Ry.js";
5
- import { t as Sandbox } from "../client-CwWS3a-i.js";
1
+ import { a as TOOL_SPECS, i as ALL_TOOL_SPECS, o as serializeToolResult, r as bindToolSpecs, t as createMcpServer } from "../mcp-local-Dler9R_s.js";
2
+ import { O as assertCurrentBackendType } from "../interactive-controller-jr3_74Pq.js";
3
+ import { t as SandboxInstance } from "../sandbox-Dtb-_btd.js";
4
+ import { D as ValidationError, _ as NotFoundError, w as StateError } from "../errors-Mzq10WZq.js";
5
+ import { t as Sandbox } from "../client-XjkuWhog.js";
6
6
  import { z } from "zod";
7
7
  //#region src/agent/instances.ts
8
8
  const managers = /* @__PURE__ */ new WeakMap();
@@ -107,7 +107,10 @@ var SandboxAgentManager = class {
107
107
  }
108
108
  async startPrepared(spec) {
109
109
  if (spec.callerSelectedId) {
110
- if (await this.sandbox.session(spec.id).status()) throw new StateError(`Agent ${spec.id} already exists; use box.agents.get("${spec.id}") to reattach or choose a new id`, "existing-agent", "new-agent-id");
110
+ if (await this.sandbox.session(spec.id).status()) throw new StateError(`Agent ${spec.id} already exists; use box.agents.get("${spec.id}") to reattach or choose a new id`, {
111
+ currentState: "existing-agent",
112
+ requiredState: "new-agent-id"
113
+ });
111
114
  }
112
115
  if (spec.workspace.mode === "isolated") return (await this.sandbox.createTaskSession({
113
116
  sessionId: spec.id,
@@ -1,2 +1,2 @@
1
- import { _ as publishAgentPreview, a as previewOperationTool, c as AgentPreviewOptions, d as PreviewExecutionContext, f as PublishAgentPreviewOptions, g as listAgentPreviews, h as getAgentPreview, i as PreviewTool, l as PreviewAuthorizationRequest, m as ensureAgentPreview, n as PREVIEW_MCP_ALIAS, o as previewToolsForProfile, p as assertPreviewId, r as PREVIEW_TOOLS, s as AgentPreviewError, t as servePreviewMcp, u as PreviewAuthorizer, v as removeAgentPreview, y as resolveSelfSandbox } from "../preview-DUxqnKSk.js";
1
+ import { _ as publishAgentPreview, a as previewOperationTool, c as AgentPreviewOptions, d as PreviewExecutionContext, f as PublishAgentPreviewOptions, g as listAgentPreviews, h as getAgentPreview, i as PreviewTool, l as PreviewAuthorizationRequest, m as ensureAgentPreview, n as PREVIEW_MCP_ALIAS, o as previewToolsForProfile, p as assertPreviewId, r as PREVIEW_TOOLS, s as AgentPreviewError, t as servePreviewMcp, u as PreviewAuthorizer, v as removeAgentPreview, y as resolveSelfSandbox } from "../preview-I1z42VGY.js";
2
2
  export { AgentPreviewError, AgentPreviewOptions, PREVIEW_MCP_ALIAS, PREVIEW_TOOLS, PreviewAuthorizationRequest, PreviewAuthorizer, PreviewExecutionContext, PreviewTool, PublishAgentPreviewOptions, assertPreviewId, ensureAgentPreview, getAgentPreview, listAgentPreviews, previewOperationTool, previewToolsForProfile, publishAgentPreview, removeAgentPreview, resolveSelfSandbox, servePreviewMcp };
@@ -66,7 +66,7 @@ async function servePreviewMcp(request, config) {
66
66
  if (typeof config.authorize !== "function") throw new Error("Preview MCP requires a host authorization callback");
67
67
  const tools = config.tools ?? PREVIEW_TOOLS;
68
68
  if (!tools.length || tools.some((tool) => !PREVIEW_TOOLS.includes(tool))) throw new Error("Preview MCP requires an explicit nonempty preview-only tool grant");
69
- const [{ createMcpServer }, { WebStandardStreamableHTTPServerTransport }] = await Promise.all([import("../mcp-local-Cqf4Lpp0.js").then((n) => n.n), import("@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js")]);
69
+ const [{ createMcpServer }, { WebStandardStreamableHTTPServerTransport }] = await Promise.all([import("../mcp-local-Dler9R_s.js").then((n) => n.n), import("@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js")]);
70
70
  const handle = await createMcpServer(config.box, {
71
71
  name: "tangle-previews",
72
72
  sessionId: config.sessionId,
@@ -1,5 +1,5 @@
1
- import { V as InteractionRequest } from "./terminal-stream-types-1YKRrkZB.js";
2
- import { Di as SandboxEvent, _i as DurablePlanSnapshot, ci as AgentApprovalRequirement, di as AgentToolInvocation, li as AgentQuestionRequest, ui as AgentRunStatus } from "./types-B-UsXSi6.js";
1
+ import { V as InteractionRequest } from "./terminal-stream-types-BqNv5EuG.js";
2
+ import { Di as SandboxEvent, _i as DurablePlanSnapshot, ci as AgentApprovalRequirement, di as AgentToolInvocation, li as AgentQuestionRequest, ui as AgentRunStatus } from "./types-CiuGb4lZ.js";
3
3
 
4
4
  //#region src/agent-run-outcome.d.ts
5
5
  interface AgentRunOutcome {
@@ -1,5 +1,7 @@
1
1
  import { t as rewrapResponse } from "./response-rewrap-Cjoxh2wZ.js";
2
2
  //#region src/lib/api-request.mjs
3
+ /** The package version tsdown.config.ts defines; unbuilt source reports 0.0.0. */
4
+ const SDK_VERSION = "1.0.191";
3
5
  function withRequestContextHeaders(response, path, method, body = response.body) {
4
6
  const headers = new Headers(response.headers);
5
7
  headers.set("x-tangle-request-path", path);
@@ -27,6 +29,7 @@ async function fetchSandboxApi({ baseUrl, apiKey, timeoutMs = 3e4, signal, fetch
27
29
  try {
28
30
  const headers = new Headers(options?.headers);
29
31
  headers.set("Authorization", `Bearer ${apiKey}`);
32
+ headers.set("x-sdk-version", SDK_VERSION);
30
33
  const isFormDataBody = typeof FormData !== "undefined" && options?.body instanceof FormData;
31
34
  if (!headers.has("Content-Type") && !isFormDataBody) headers.set("Content-Type", "application/json");
32
35
  const response = await fetchImpl(url, {
@@ -86,4 +89,4 @@ async function fetchSandboxApi({ baseUrl, apiKey, timeoutMs = 3e4, signal, fetch
86
89
  }
87
90
  }
88
91
  //#endregion
89
- export { fetchSandboxApi as t };
92
+ export { fetchSandboxApi as n, SDK_VERSION as t };
@@ -1,5 +1,5 @@
1
1
  import { C as boundedIdentifierSchema, D as isBoundedEventContentJson, E as boundedStringSchema, S as boundedEventContentStringSchema, T as boundedJsonSchema, _ as CONTRACT_MAX_ARRAY_LENGTH, b as boundedEventContentJsonSchema, g as sha256DigestSchema, h as omitTopLevelDigest, m as looksLikeCredential, n as REASONING_EFFORTS, o as canonicalCandidateDigest, p as isWellFormedUnicode, s as canonicalCandidateJson, t as harnessTypeSchema, u as isCanonicalJsonValue, w as boundedJsonRecordSchema, x as boundedEventContentRecordSchema, y as CONTRACT_MAX_STRING_LENGTH } from "./harness-DMaNgn0S.js";
2
- import { n as awaitWithAbort } from "./abort-signal-PgWPMn_e.js";
2
+ import { n as awaitWithAbort } from "./abort-signal-Cu4F2VVz.js";
3
3
  import { z } from "zod";
4
4
  //#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.10.13/node_modules/@tangle-network/agent-interface/dist/native-session-event.js
5
5
  /**
@@ -1,4 +1,4 @@
1
- import { A as AgentInteractiveSessionStatus, C as AgentInteractiveSessionAttach, E as AgentInteractiveSessionControlClaimRequest, T as AgentInteractiveSessionControlClaimAcknowledgement, i as TerminalStreamHandlers, k as AgentInteractiveSessionRef, w as AgentInteractiveSessionControlClaim } from "./terminal-stream-types-1YKRrkZB.js";
1
+ import { A as AgentInteractiveSessionStatus, C as AgentInteractiveSessionAttach, E as AgentInteractiveSessionControlClaimRequest, T as AgentInteractiveSessionControlClaimAcknowledgement, i as TerminalStreamHandlers, k as AgentInteractiveSessionRef, w as AgentInteractiveSessionControlClaim } from "./terminal-stream-types-BqNv5EuG.js";
2
2
 
3
3
  //#region src/interactive-types.d.ts
4
4
  /** Cancellation for an interactive SDK request. */
@@ -1,6 +1,6 @@
1
- import { i as FILE_UPLOAD_SESSION_MAX_BYTES, n as isFileTooLargeErrorBody, r as isPayloadTooLargeErrorBody } from "./file-transfer-DTHgLccV.js";
2
- import { S as ServerError, T as TimeoutError, h as NetworkError, n as parseErrorResponse, x as SandboxError, y as QuotaError } from "./errors-CaX0a5Ry.js";
3
- import { t as abortableSleep } from "./abort-signal-PgWPMn_e.js";
1
+ import { S as SandboxError, n as isTransientWrite, r as parseErrorResponse } from "./errors-Mzq10WZq.js";
2
+ import { t as abortableSleep } from "./abort-signal-Cu4F2VVz.js";
3
+ import { i as FILE_UPLOAD_SESSION_MAX_BYTES, n as isFileTooLargeErrorBody, r as isPayloadTooLargeErrorBody } from "./file-transfer-Cr9Ossea.js";
4
4
  //#region src/generated/sandbox-upload-operations.ts
5
5
  function uploadSessionInit(transport, input, init = {}) {
6
6
  return transport.fetch(`/fs/upload-session`, {
@@ -50,15 +50,8 @@ const RETRY_MAX_MS = 2e3;
50
50
  * staging budget. */
51
51
  const DEFAULT_UPLOAD_CONCURRENCY = 4;
52
52
  const MAX_UPLOAD_CONCURRENCY = 8;
53
- /** Transient part-upload failures worth retrying: rate-limit/budget (429),
54
- * 5xx, transport (network), and request timeouts — mirrors
55
- * `isTransientWriteError` in `sandbox.ts`. A non-transient error (bad path,
56
- * auth, checksum, containment) fails loud immediately. */
57
- function isTransientUploadError(rejection) {
58
- return rejection instanceof QuotaError || rejection instanceof ServerError || rejection instanceof NetworkError || rejection instanceof TimeoutError;
59
- }
60
53
  function isChecksumMismatch(rejection) {
61
- return rejection instanceof SandboxError && rejection.code === "CHECKSUM_MISMATCH";
54
+ return rejection instanceof SandboxError && rejection.wireCode === "CHECKSUM_MISMATCH";
62
55
  }
63
56
  /** Cheap size probe used for the pre-flight cap check, read directly off
64
57
  * the input shape (`Blob.size` / `ArrayBuffer.byteLength` / view
@@ -223,7 +216,7 @@ async function putPart(transport, uploadId, index, options, wire) {
223
216
  if (!response.ok) throw await parseUploadError(response);
224
217
  return;
225
218
  } catch (err) {
226
- if (isTransientUploadError(err) && attempt < maxRetries) {
219
+ if (isTransientWrite(err) && attempt < maxRetries) {
227
220
  const retryAfterMs = err instanceof SandboxError ? err.retryAfterMs : void 0;
228
221
  const backoff = Math.min(RETRY_BASE_MS * 2 ** attempt, RETRY_MAX_MS);
229
222
  await abortableSleep(retryAfterMs ?? backoff, options.signal);
@@ -339,7 +332,10 @@ async function abortSession(transport, uploadId) {
339
332
  */
340
333
  async function uploadChunked(transport, remotePath, data, options = {}) {
341
334
  const estimatedSize = sizeOfInput(data);
342
- if (estimatedSize > 67108864) throw new SandboxError(`Payload for ${remotePath} is ${estimatedSize} bytes, over the ${FILE_UPLOAD_SESSION_MAX_BYTES} byte chunked-upload session cap`, "PAYLOAD_TOO_LARGE", 413);
335
+ if (estimatedSize > 67108864) throw new SandboxError(`Payload for ${remotePath} is ${estimatedSize} bytes, over the ${FILE_UPLOAD_SESSION_MAX_BYTES} byte chunked-upload session cap`, {
336
+ code: "PAYLOAD_TOO_LARGE",
337
+ status: 413
338
+ });
343
339
  options.signal?.throwIfAborted();
344
340
  const bytes = await normalizeToBytes(data);
345
341
  options.signal?.throwIfAborted();
@@ -1,5 +1,5 @@
1
- import { i as FILE_UPLOAD_SESSION_MAX_BYTES } from "./file-transfer-DTHgLccV.js";
2
- import { a as planCompression, i as partCount, n as commitSession, o as putPart, r as initUploadSession, t as abortSession } from "./chunked-upload-vAE2hVcP.js";
1
+ import { i as FILE_UPLOAD_SESSION_MAX_BYTES } from "./file-transfer-Cr9Ossea.js";
2
+ import { a as planCompression, i as partCount, n as commitSession, o as putPart, r as initUploadSession, t as abortSession } from "./chunked-upload-D5ytV_s6.js";
3
3
  import { createHash } from "node:crypto";
4
4
  import { open } from "node:fs/promises";
5
5
  //#region src/lib/chunked-upload-file.ts