@tangle-network/sandbox 0.54.0 → 0.54.1-develop.20260926104423.c9f8525

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.
package/README.md CHANGED
@@ -378,9 +378,12 @@ A turn runs in the session `<thread>-<version>`, created from that version's bac
378
378
  When you pass a new version, the sandbox and its files stay, and the next turn opens a session on the new profile.
379
379
 
380
380
  A sandbox that cannot start is replaced after `restartAfterMs` (default 60 s) of failed starts.
381
+ A failed start is a resume refused with `CONTAINER_START_FAILED`, or a sandbox the platform reports as `failed`.
381
382
  Until then `ensure()` throws `InstanceRestartingError` with `retryAfterMs`.
382
383
  A replaced sandbox is not deleted; its own retention policy deletes it.
383
- A refusal of your key, such as `SANDBOX_ATTRIBUTION_MISMATCH`, never replaces the sandbox.
384
+ Every other refusal reaches your code and never replaces the sandbox.
385
+ That covers a refusal of your key or its credentials (`SANDBOX_ATTRIBUTION_MISMATCH`, `ROUTER_KEY_REFRESH_FAILED`).
386
+ It also covers a full or unavailable host (`HOST_SLOT_UNAVAILABLE`, `HOST_UNAVAILABLE`) and a lifecycle operation still in progress.
384
387
  Use `adopt` to move a sandbox you created earlier under a key.
385
388
 
386
389
  ## Commands and files
@@ -1,7 +1,7 @@
1
- import { y as assertCurrentBackendType } from "../runtime-api-DHHveKas.js";
1
+ import { y as assertCurrentBackendType } from "../runtime-api-BARzSO0x.js";
2
2
  import { c as NotFoundError, g as ValidationError, m as StateError } from "../errors-CmYPVl-k.js";
3
- import { n as Sandbox } from "../client-oN_nODpw.js";
4
- import { t as SandboxInstance } from "../sandbox-DMrjRu5N.js";
3
+ import { n as Sandbox } from "../client-C_m-_cqr.js";
4
+ import { t as SandboxInstance } from "../sandbox-Dfc2B6qF.js";
5
5
  import { createRequire } from "node:module";
6
6
  import { z } from "zod";
7
7
  //#region src/agent/instances.ts
@@ -1,7 +1,7 @@
1
- import { E as backendTypeSchema, _ as parseSSEStream, g as encodeTextForWire, h as encodePromptForWire, p as SANDBOX_PROXY_REQUEST_MAX_BYTES, v as applyRequestedModel, x as normalizeRuntimeBackendConfig, y as assertCurrentBackendType } from "./runtime-api-DHHveKas.js";
1
+ import { E as backendTypeSchema, _ as parseSSEStream, g as encodeTextForWire, h as encodePromptForWire, p as SANDBOX_PROXY_REQUEST_MAX_BYTES, v as applyRequestedModel, x as normalizeRuntimeBackendConfig, y as assertCurrentBackendType } from "./runtime-api-BARzSO0x.js";
2
2
  import { _ as parseErrorResponse, c as NotFoundError, f as SandboxError, g as ValidationError, h as TimeoutError, l as PartialFailureError, p as ServerError, s as NetworkError, t as AuthError } from "./errors-CmYPVl-k.js";
3
3
  import { n as combineAbortSignals } from "./abort-signal-si1WMfJb.js";
4
- import { D as normalizeSandboxShape, E as normalizeConnection, N as exportTraceBundle, O as LinesClient, b as requestInteractiveSessionToken, i as normalizeStartupDiagnostics, j as rewrapResponse, n as createSandboxInstanceFromResponse, r as normalizeSandboxCreateReceipt } from "./sandbox-DMrjRu5N.js";
4
+ import { D as normalizeSandboxShape, E as normalizeConnection, N as exportTraceBundle, O as LinesClient, b as requestInteractiveSessionToken, i as normalizeStartupDiagnostics, j as rewrapResponse, n as createSandboxInstanceFromResponse, r as normalizeSandboxCreateReceipt } from "./sandbox-Dfc2B6qF.js";
5
5
  import { agentProfileSchema } from "@tangle-network/agent-interface";
6
6
  import { z } from "zod";
7
7
  //#region src/backend-registry.ts
@@ -2120,11 +2120,16 @@ var InstanceRestartingError = class extends SandboxError {
2120
2120
  this.name = "InstanceRestartingError";
2121
2121
  }
2122
2122
  };
2123
- /** Resume refusals that say this sandbox cannot start, as opposed to the
2124
- * account, key or platform being unavailable. An attribution refusal is not
2125
- * one: it means the caller's key cannot run the sandbox, and replacing the
2126
- * sandbox would only hide that. */
2127
- const UNSTARTABLE = new Set(["CONTAINER_START_FAILED", "SANDBOX_LIFECYCLE_IN_PROGRESS"]);
2123
+ /**
2124
+ * The one resume refusal that counts toward replacing the sandbox: its host
2125
+ * tried to start its container and the container failed. Every other refusal
2126
+ * leaves the sandbox and its files in place and reaches the caller: a key,
2127
+ * credential or attribution refusal, a platform or host that is unavailable,
2128
+ * a full host, and another lifecycle operation still holding the sandbox.
2129
+ * Replacing on those would lose the customer's files over a failure that a
2130
+ * fresh sandbox inherits or that clears on its own.
2131
+ */
2132
+ const UNSTARTABLE_CODE = "CONTAINER_START_FAILED";
2128
2133
  const DEFAULT_RESTART_AFTER_MS = 6e4;
2129
2134
  /** A failed start this much older than the wait means failures stopped in
2130
2135
  * between; the wait starts again rather than replacing at once. */
@@ -2264,8 +2269,7 @@ var InstancesClient = class {
2264
2269
  try {
2265
2270
  await box.resume();
2266
2271
  } catch (error) {
2267
- const code = error?.code;
2268
- if (typeof code !== "string" || !UNSTARTABLE.has(code)) throw error;
2272
+ if (error?.code !== UNSTARTABLE_CODE) throw error;
2269
2273
  await this.failedStart(options, record, error instanceof Error ? error : new Error(String(error)));
2270
2274
  return null;
2271
2275
  }
package/dist/core.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { a as FileWriteConflictError, c as NotFoundError, f as SandboxError, g as ValidationError, h as TimeoutError, l as PartialFailureError, m as StateError, n as CapabilityError, p as ServerError, s as NetworkError, t as AuthError, u as QuotaError } from "./errors-CmYPVl-k.js";
2
- import { _ as backendRegistryInteractionKindSchema, b as parseBackendRegistryResponse, c as InstanceRestartingError, g as backendRegistryEntrySchema, h as backendRegistryCapabilitiesSchema, l as InstancesClient, n as Sandbox, s as HostedInstance, v as backendRegistryResponseSchema, x as parseBackendRegistryResponseBody, y as isBackendRegistryInteractionKind } from "./client-oN_nODpw.js";
3
- import { A as lineInstanceKey, O as LinesClient, a as WorkspaceImages, t as SandboxInstance } from "./sandbox-DMrjRu5N.js";
2
+ import { _ as backendRegistryInteractionKindSchema, b as parseBackendRegistryResponse, c as InstanceRestartingError, g as backendRegistryEntrySchema, h as backendRegistryCapabilitiesSchema, l as InstancesClient, n as Sandbox, s as HostedInstance, v as backendRegistryResponseSchema, x as parseBackendRegistryResponseBody, y as isBackendRegistryInteractionKind } from "./client-C_m-_cqr.js";
3
+ import { A as lineInstanceKey, O as LinesClient, a as WorkspaceImages, t as SandboxInstance } from "./sandbox-Dfc2B6qF.js";
4
4
  //#region src/core.ts
5
5
  /** Local SDK protocol support only, not a deployed-host readiness assertion.
6
6
  * Version 1 refuses unconfirmed isolated receipts before materializing any
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
- import { C as deriveAgentResultOutcome, D as parseBackendType, E as backendTypeSchema, S as createAgentRunOutcomeTracker, T as ALL_BACKEND_TYPES, _ as parseSSEStream, w as deriveAgentRunOutcome, x as normalizeRuntimeBackendConfig } from "./runtime-api-DHHveKas.js";
1
+ import { C as deriveAgentResultOutcome, D as parseBackendType, E as backendTypeSchema, S as createAgentRunOutcomeTracker, T as ALL_BACKEND_TYPES, _ as parseSSEStream, w as deriveAgentRunOutcome, x as normalizeRuntimeBackendConfig } from "./runtime-api-BARzSO0x.js";
2
2
  import { a as FileWriteConflictError, c as NotFoundError, d as ResumeEnvRequiredError, f as SandboxError, g as ValidationError, h as TimeoutError, i as EgressProxyRecoveryError, l as PartialFailureError, m as StateError, n as CapabilityError, o as KeyBudgetExhaustedError, p as ServerError, r as EdgeNotReadyError, s as NetworkError, t as AuthError, u as QuotaError } from "./errors-CmYPVl-k.js";
3
- import { _ as backendRegistryInteractionKindSchema, a as splitInlineProfileSkills, b as parseBackendRegistryResponse, c as InstanceRestartingError, d as SandboxFleetClient, f as runtimeWorkspaceCwdSchema, g as backendRegistryEntrySchema, h as backendRegistryCapabilitiesSchema, i as splitInlineProfileFileMounts, l as InstancesClient, m as validateBatchRunRequest, n as Sandbox, o as validateDeferredProfileFileMounts, p as createBatchResultAccumulator, r as materializeProfileFileMounts, s as HostedInstance, t as IntelligenceClient, u as SandboxFleet, v as backendRegistryResponseSchema, x as parseBackendRegistryResponseBody, y as isBackendRegistryInteractionKind } from "./client-oN_nODpw.js";
3
+ import { _ as backendRegistryInteractionKindSchema, a as splitInlineProfileSkills, b as parseBackendRegistryResponse, c as InstanceRestartingError, d as SandboxFleetClient, f as runtimeWorkspaceCwdSchema, g as backendRegistryEntrySchema, h as backendRegistryCapabilitiesSchema, i as splitInlineProfileFileMounts, l as InstancesClient, m as validateBatchRunRequest, n as Sandbox, o as validateDeferredProfileFileMounts, p as createBatchResultAccumulator, r as materializeProfileFileMounts, s as HostedInstance, t as IntelligenceClient, u as SandboxFleet, v as backendRegistryResponseSchema, x as parseBackendRegistryResponseBody, y as isBackendRegistryInteractionKind } from "./client-C_m-_cqr.js";
4
4
  import { a as INTERACTIVE_CONTROL_CLEANUP_TIMEOUT_MS, c as createInteractiveControlHolderId, l as interactiveSessionIdentityDigest, n as browserInteractiveControlHolderId, o as InteractiveSessionControlController, t as BrowserInteractiveSessionControlController } from "./browser-interactive-control-controller-Dv0gbFMu.js";
5
- import { A as lineInstanceKey, C as collectAgentResponseText, F as toOtelJson, M as buildTraceExportPayload, N as exportTraceBundle, O as LinesClient, P as otelTraceIdForTangleTrace, S as collectAgentFinalMessageText, T as isToolBearingEvent, _ as TerminalStream, a as WorkspaceImages, c as SandboxTaskSession, d as agentInteractiveSessionPromptRequestDigest, f as InteractiveTerminalFrameLog, g as InteractiveSessionController, h as BrowserInteractiveSessionController, k as SandboxLines, l as SandboxSession, m as createInteractiveTerminalSession, o as GPU_LEASE_PROVIDER_NAMES, p as createInteractiveTerminalCapture, s as MAX_EGRESS_DENIALS_LIMIT, t as SandboxInstance, u as InteractiveSessionHandle, v as TerminalStreamError, w as getSandboxEventText, x as applySandboxEventText, y as TERMINAL_WS_ECHO_SUBPROTOCOL } from "./sandbox-DMrjRu5N.js";
5
+ import { A as lineInstanceKey, C as collectAgentResponseText, F as toOtelJson, M as buildTraceExportPayload, N as exportTraceBundle, O as LinesClient, P as otelTraceIdForTangleTrace, S as collectAgentFinalMessageText, T as isToolBearingEvent, _ as TerminalStream, a as WorkspaceImages, c as SandboxTaskSession, d as agentInteractiveSessionPromptRequestDigest, f as InteractiveTerminalFrameLog, g as InteractiveSessionController, h as BrowserInteractiveSessionController, k as SandboxLines, l as SandboxSession, m as createInteractiveTerminalSession, o as GPU_LEASE_PROVIDER_NAMES, p as createInteractiveTerminalCapture, s as MAX_EGRESS_DENIALS_LIMIT, t as SandboxInstance, u as InteractiveSessionHandle, v as TerminalStreamError, w as getSandboxEventText, x as applySandboxEventText, y as TERMINAL_WS_ECHO_SUBPROTOCOL } from "./sandbox-Dfc2B6qF.js";
6
6
  import { a as CollaborationClient, i as parseCollaborationDocumentId, n as buildCollaborationDocumentId, r as normalizeCollaborationPath, t as CollaborationFileBridge } from "./collaboration-DLPFc9-W.js";
7
- import { t as TangleSandboxClient } from "./tangle-HORVNS5w.js";
7
+ import { t as TangleSandboxClient } from "./tangle-nXQHWlwx.js";
8
8
  import { SANDBOX_SIZE_PRESET_NAMES, agentProfileConfidentialSchema, agentProfileSchema } from "@tangle-network/agent-interface";
9
9
  import { z } from "zod";
10
10
  //#region src/confidential.ts
@@ -521,6 +521,16 @@ function normalizeRuntimeBackendConfig(backend) {
521
521
  //#endregion
522
522
  //#region ../../../packages/sse-core/dist/index.js
523
523
  /**
524
+ * A copy of `value` that shares no memory with the string it was cut from.
525
+ *
526
+ * V8 can return a short substring of a long string as a view that keeps the
527
+ * whole string alive. Consumers keep event names and ids as long as they keep
528
+ * events, so a view would keep every chunk its frame arrived in alive.
529
+ */
530
+ function detached(value) {
531
+ return value === "" ? value : JSON.parse(JSON.stringify(value));
532
+ }
533
+ /**
524
534
  * Incremental SSE frame parser. Feed decoded text via `push()`; call
525
535
  * `flush()` when the stream ends.
526
536
  */
@@ -592,9 +602,9 @@ var SSEFrameParser = class {
592
602
  dispatch() {
593
603
  const dataLines = this.frameDataLines;
594
604
  const frame = dataLines ? {
595
- event: this.frameEvent,
605
+ event: detached(this.frameEvent),
596
606
  data: dataLines.join("\n"),
597
- id: this.frameId || void 0
607
+ id: this.frameId ? detached(this.frameId) : void 0
598
608
  } : null;
599
609
  this.frameEvent = "";
600
610
  this.frameId = void 0;
package/dist/runtime.js CHANGED
@@ -1,4 +1,4 @@
1
- import { C as deriveAgentResultOutcome, S as createAgentRunOutcomeTracker, t as SandboxRuntimeApi, u as uploadChunked, w as deriveAgentRunOutcome } from "./runtime-api-DHHveKas.js";
1
+ import { C as deriveAgentResultOutcome, S as createAgentRunOutcomeTracker, t as SandboxRuntimeApi, u as uploadChunked, w as deriveAgentRunOutcome } from "./runtime-api-BARzSO0x.js";
2
2
  import { a as FileWriteConflictError, c as NotFoundError, f as SandboxError, g as ValidationError, h as TimeoutError, l as PartialFailureError, m as StateError, n as CapabilityError, p as ServerError, s as NetworkError, t as AuthError, u as QuotaError } from "./errors-CmYPVl-k.js";
3
3
  import { n as combineAbortSignals } from "./abort-signal-si1WMfJb.js";
4
4
  //#region src/runtime-client.ts
@@ -1,4 +1,4 @@
1
- import { C as deriveAgentResultOutcome, S as createAgentRunOutcomeTracker, _ as parseSSEStream, a as isTraceId, b as mergeRuntimeBackendConfig, c as appendSessionIdQuery, d as resolveDispatchRunIdentity, f as validateAcceptedDispatchRunRef, h as encodePromptForWire, i as TRACE_ID_HEADER, l as sessionHeaders, n as normalizeSessionInfo, o as mintTraceId, p as SANDBOX_PROXY_REQUEST_MAX_BYTES, r as sessionMessageRequestBody, s as resolveTraceId, t as SandboxRuntimeApi, u as uploadChunked, v as applyRequestedModel, x as normalizeRuntimeBackendConfig, y as assertCurrentBackendType } from "./runtime-api-DHHveKas.js";
1
+ import { C as deriveAgentResultOutcome, S as createAgentRunOutcomeTracker, _ as parseSSEStream, a as isTraceId, b as mergeRuntimeBackendConfig, c as appendSessionIdQuery, d as resolveDispatchRunIdentity, f as validateAcceptedDispatchRunRef, h as encodePromptForWire, i as TRACE_ID_HEADER, l as sessionHeaders, n as normalizeSessionInfo, o as mintTraceId, p as SANDBOX_PROXY_REQUEST_MAX_BYTES, r as sessionMessageRequestBody, s as resolveTraceId, t as SandboxRuntimeApi, u as uploadChunked, v as applyRequestedModel, x as normalizeRuntimeBackendConfig, y as assertCurrentBackendType } from "./runtime-api-BARzSO0x.js";
2
2
  import { _ as parseErrorResponse, c as NotFoundError, f as SandboxError, g as ValidationError, h as TimeoutError, m as StateError, n as CapabilityError, p as ServerError, r as EdgeNotReadyError, s as NetworkError, t as AuthError, u as QuotaError } from "./errors-CmYPVl-k.js";
3
3
  import { c as createInteractiveControlHolderId, d as interactiveSessionControlReleaseResponseSchema, f as interactiveSessionControlValidationResponseSchema, i as createBrowserInteractiveSessionControlTransport, o as InteractiveSessionControlController, p as interactiveSessionStatusResponseSchema, r as browserInteractiveTerminalEndpoint, s as assertInteractiveSessionRef, u as interactiveSessionControlClaimResponseSchema } from "./browser-interactive-control-controller-Dv0gbFMu.js";
4
4
  import { n as combineAbortSignals, t as awaitWithAbort } from "./abort-signal-si1WMfJb.js";
@@ -1,2 +1,2 @@
1
- import { a as TANGLE_JOBS_CONTRACT, c as JsonResponseParamTypes, d as SandboxIdParamTypes, i as TANGLE_CHAIN_ID, l as SandboxCreateParamTypes, n as JOB_SANDBOX_CREATE, o as AgentSandboxBlueprintAbi, r as JOB_SANDBOX_DELETE, s as ITangleJobsAbi, t as TangleSandboxClient, u as SandboxCreateResponseParamTypes } from "../tangle-HORVNS5w.js";
1
+ import { a as TANGLE_JOBS_CONTRACT, c as JsonResponseParamTypes, d as SandboxIdParamTypes, i as TANGLE_CHAIN_ID, l as SandboxCreateParamTypes, n as JOB_SANDBOX_CREATE, o as AgentSandboxBlueprintAbi, r as JOB_SANDBOX_DELETE, s as ITangleJobsAbi, t as TangleSandboxClient, u as SandboxCreateResponseParamTypes } from "../tangle-nXQHWlwx.js";
2
2
  export { AgentSandboxBlueprintAbi, ITangleJobsAbi, JOB_SANDBOX_CREATE, JOB_SANDBOX_DELETE, JsonResponseParamTypes, SandboxCreateParamTypes, SandboxCreateResponseParamTypes, SandboxIdParamTypes, TANGLE_CHAIN_ID, TANGLE_JOBS_CONTRACT, TangleSandboxClient };
@@ -1,5 +1,5 @@
1
1
  import { _ as parseErrorResponse } from "./errors-CmYPVl-k.js";
2
- import { n as createSandboxInstanceFromResponse } from "./sandbox-DMrjRu5N.js";
2
+ import { n as createSandboxInstanceFromResponse } from "./sandbox-Dfc2B6qF.js";
3
3
  //#region src/tangle/abi.ts
4
4
  /**
5
5
  * Tangle Contract ABI Definitions
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/sandbox",
3
- "version": "0.54.0",
3
+ "version": "0.54.1-develop.20260926104423.c9f8525",
4
4
  "description": "Client SDK for the Tangle Sandbox platform - build AI agent applications with dev containers",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -139,8 +139,8 @@
139
139
  "yjs": "13.6.30",
140
140
  "@repo/shared": "0.0.0",
141
141
  "@tangle-network/agent-profile-materialize": "0.20.2",
142
- "@tangle-network/runtime-contracts": "0.8.0",
143
142
  "@tangle-network/cli-agent-registry": "0.4.8",
143
+ "@tangle-network/runtime-contracts": "0.8.0",
144
144
  "@tangle-network/sse-core": "0.0.0"
145
145
  },
146
146
  "scripts": {