@tangle-network/sandbox 0.60.78-develop.20261023061855.4e0fe75 → 0.60.78-develop.20261023063254.e61b3b8

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
@@ -461,6 +461,8 @@ Use `adopt` to move a sandbox you created earlier under a key.
461
461
 
462
462
  `exec()` returns the exit code, standard output, standard error, and timing data.
463
463
 
464
+ After an admitted blocking command is aborted or times out, the shared process transport sends a tree kill and follows the authenticated PID result until it settles, within a separate five-second cleanup budget. A kill acknowledgement alone does not prove exit. Missing results, authentication failures, transport failures, and cleanup expiry leave termination unknown; the caller still receives its original abort or timeout error. Cleanup does not download the completed command's output.
465
+
464
466
  ```typescript
465
467
  const test = await box.exec("pnpm test", {
466
468
  cwd: "/workspace/service",
@@ -1,8 +1,8 @@
1
1
  import { a as TOOL_SPECS, i as ALL_TOOL_SPECS, o as serializeToolResult, r as bindToolSpecs, t as createMcpServer } from "../mcp-local-BaQdgLvZ.js";
2
2
  import { D as assertCurrentBackendType } from "../interactive-controller-D_YmzZMA.js";
3
3
  import { S as StateError, T as ValidationError, h as NotFoundError } from "../errors-BfbOP_rx.js";
4
- import { t as Sandbox } from "../client-Bd1sDC0e.js";
5
- import { t as SandboxInstance } from "../sandbox-CfIa-5qJ.js";
4
+ import { t as Sandbox } from "../client-DkwgGHA6.js";
5
+ import { t as SandboxInstance } from "../sandbox-JRl9l7pE.js";
6
6
  import { z } from "zod";
7
7
  //#region src/agent/instances.ts
8
8
  const managers = /* @__PURE__ */ new WeakMap();
@@ -3,7 +3,7 @@ import { A as normalizeRuntimeBackendConfig, C as encodePromptForWire, D as asse
3
3
  import { T as ValidationError, a as AuthError, b as SandboxError, d as GpuProviderNotConfiguredError, g as PartialFailureError, h as NotFoundError, i as readResponseJson, m as NetworkError, n as parseErrorResponse, p as NON_RETRYABLE_CREATE_QUOTA_REASONS, r as parseResponseError, v as QuotaError, w as TimeoutError, x as ServerError } from "./errors-BfbOP_rx.js";
4
4
  import { f as combineAbortSignals } from "./browser-interactive-control-controller-DHx53yre.js";
5
5
  import { n as fetchWithKeepAlive } from "./keep-alive-fetch-BBzJDWyt.js";
6
- import { A as normalizeSandboxCreateReceipt, D as validateDeferredProfileFileMounts, E as splitInlineProfileSkills, F as normalizeSandboxShape, I as rewrapResponse, M as parseStopPhase, N as normalizeConnection, O as isRetryableProfileFileMaterializeFailure, P as normalizeEgressPolicyFields, T as splitInlineProfileFileMounts, j as normalizeStartupDiagnostics, k as normalizeCaptureProof, n as createSandboxInstanceFromResponse, o as exportTraceBundle } from "./sandbox-CfIa-5qJ.js";
6
+ import { A as normalizeSandboxCreateReceipt, D as validateDeferredProfileFileMounts, E as splitInlineProfileSkills, F as normalizeSandboxShape, I as rewrapResponse, M as parseStopPhase, N as normalizeConnection, O as isRetryableProfileFileMaterializeFailure, P as normalizeEgressPolicyFields, T as splitInlineProfileFileMounts, j as normalizeStartupDiagnostics, k as normalizeCaptureProof, n as createSandboxInstanceFromResponse, o as exportTraceBundle } from "./sandbox-JRl9l7pE.js";
7
7
  import { t as LinesClient } from "./lines-CXkOvy_9.js";
8
8
  import { PublicTemplatesClient } from "./public-templates.js";
9
9
  import { z } from "zod";
package/dist/core.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { S as StateError, T as ValidationError, _ as ProfileFileMountPathError, a as AuthError, b as SandboxError, g as PartialFailureError, h as NotFoundError, m as NetworkError, s as CapabilityError, u as FileWriteConflictError, v as QuotaError, w as TimeoutError, x as ServerError } from "./errors-BfbOP_rx.js";
2
- import { _ as parseBackendRegistryResponse, a as InstancesClient, f as backendRegistryCapabilitiesSchema, g as isBackendRegistryInteractionKind, h as backendRegistryResponseSchema, i as InstanceRestartingError, m as backendRegistryInteractionKindSchema, p as backendRegistryEntrySchema, r as HostedInstance, t as Sandbox, v as parseBackendRegistryResponseBody } from "./client-Bd1sDC0e.js";
3
- import { r as WorkspaceImages, t as SandboxInstance, x as ManagedProcessClient } from "./sandbox-CfIa-5qJ.js";
2
+ import { _ as parseBackendRegistryResponse, a as InstancesClient, f as backendRegistryCapabilitiesSchema, g as isBackendRegistryInteractionKind, h as backendRegistryResponseSchema, i as InstanceRestartingError, m as backendRegistryInteractionKindSchema, p as backendRegistryEntrySchema, r as HostedInstance, t as Sandbox, v as parseBackendRegistryResponseBody } from "./client-DkwgGHA6.js";
3
+ import { r as WorkspaceImages, t as SandboxInstance, x as ManagedProcessClient } from "./sandbox-JRl9l7pE.js";
4
4
  import { i as profileChannelReference, r as lineInstanceKey, t as LinesClient } from "./lines-CXkOvy_9.js";
5
5
  import { PublicTemplatePublishError, PublicTemplatesClient } from "./public-templates.js";
6
6
  import { i as parseLineApplicationResult, n as LINE_APPLICATION_REQUEST_MAX_BYTES, r as parseLineApplicationRequest, t as LINE_APPLICATION_REPLY_MAX_CHARS } from "./line-application-CvOBTLei.js";
package/dist/index.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import { i as isolationPrincipalSchema, o as parseBackendType, r as backendTypeSchema, t as ALL_BACKEND_TYPES } from "./backend-types-CLvdSX8V.js";
2
2
  import { A as normalizeRuntimeBackendConfig, B as TERMINAL_WS_ECHO_SUBPROTOCOL, I as createAgentRunOutcomeTracker, L as deriveAgentResultOutcome, R as deriveAgentRunOutcome, b as parseSSEStream, i as terminalUpgradeHeadersSupported, j as requestedPublicProfileDigest, n as InteractiveSessionController, r as TerminalStream, t as BrowserInteractiveSessionController, z as projectAgentTerminalRecord } from "./interactive-controller-D_YmzZMA.js";
3
3
  import { C as StreamInterruptedError, S as StateError, T as ValidationError, _ as ProfileFileMountPathError, a as AuthError, b as SandboxError, c as EdgeNotReadyError, d as GpuProviderNotConfiguredError, f as KeyBudgetExhaustedError, g as PartialFailureError, h as NotFoundError, l as EgressProxyRecoveryError, m as NetworkError, o as BranchFanoutExceedsHostError, s as CapabilityError, t as TerminalStreamError, u as FileWriteConflictError, v as QuotaError, w as TimeoutError, x as ServerError, y as ResumeEnvRequiredError } from "./errors-BfbOP_rx.js";
4
- import { _ as parseBackendRegistryResponse, a as InstancesClient, c as IntelligenceClient, d as validateBatchRunRequest, f as backendRegistryCapabilitiesSchema, g as isBackendRegistryInteractionKind, h as backendRegistryResponseSchema, i as InstanceRestartingError, l as runtimeWorkspaceCwdSchema, m as backendRegistryInteractionKindSchema, n as RunsClient, o as SandboxFleetClient, p as backendRegistryEntrySchema, r as HostedInstance, s as SandboxFleet, t as Sandbox, u as createBatchResultAccumulator, v as parseBackendRegistryResponseBody } from "./client-Bd1sDC0e.js";
4
+ import { _ as parseBackendRegistryResponse, a as InstancesClient, c as IntelligenceClient, d as validateBatchRunRequest, f as backendRegistryCapabilitiesSchema, g as isBackendRegistryInteractionKind, h as backendRegistryResponseSchema, i as InstanceRestartingError, l as runtimeWorkspaceCwdSchema, m as backendRegistryInteractionKindSchema, n as RunsClient, o as SandboxFleetClient, p as backendRegistryEntrySchema, r as HostedInstance, s as SandboxFleet, t as Sandbox, u as createBatchResultAccumulator, v as parseBackendRegistryResponseBody } from "./client-DkwgGHA6.js";
5
5
  import { a as INTERACTIVE_CONTROL_CLEANUP_TIMEOUT_MS, l as createInteractiveControlHolderId, n as browserInteractiveControlHolderId, o as InteractiveSessionControlController, s as InteractiveSessionNotRunningError, t as BrowserInteractiveSessionControlController, u as interactiveSessionIdentityDigest } from "./browser-interactive-control-controller-DHx53yre.js";
6
- import { C as SandboxOperationFailedError, D as validateDeferredProfileFileMounts, E as splitInlineProfileSkills, S as SandboxOperation, T as splitInlineProfileFileMounts, _ as collectAgentFinalMessageText, a as buildTraceExportPayload, b as isToolBearingEvent, c as toOtelJson, d as InteractiveSessionHandle, f as agentInteractiveSessionPromptRequestDigest, g as applySandboxEventText, h as createInteractiveTerminalSession, i as MAX_EGRESS_DENIALS_LIMIT, l as SandboxTaskSession, m as createInteractiveTerminalCapture, o as exportTraceBundle, p as InteractiveTerminalFrameLog, r as WorkspaceImages, s as otelTraceIdForTangleTrace, t as SandboxInstance, u as SandboxSession, v as collectAgentResponseText, w as materializeProfileFileMounts, x as ManagedProcessClient, y as getSandboxEventText } from "./sandbox-CfIa-5qJ.js";
6
+ import { C as SandboxOperationFailedError, D as validateDeferredProfileFileMounts, E as splitInlineProfileSkills, S as SandboxOperation, T as splitInlineProfileFileMounts, _ as collectAgentFinalMessageText, a as buildTraceExportPayload, b as isToolBearingEvent, c as toOtelJson, d as InteractiveSessionHandle, f as agentInteractiveSessionPromptRequestDigest, g as applySandboxEventText, h as createInteractiveTerminalSession, i as MAX_EGRESS_DENIALS_LIMIT, l as SandboxTaskSession, m as createInteractiveTerminalCapture, o as exportTraceBundle, p as InteractiveTerminalFrameLog, r as WorkspaceImages, s as otelTraceIdForTangleTrace, t as SandboxInstance, u as SandboxSession, v as collectAgentResponseText, w as materializeProfileFileMounts, x as ManagedProcessClient, y as getSandboxEventText } from "./sandbox-JRl9l7pE.js";
7
7
  import { i as profileChannelReference, n as SandboxLines, r as lineInstanceKey, t as LinesClient } from "./lines-CXkOvy_9.js";
8
8
  import { PublicTemplatePublishError, PublicTemplatesClient } from "./public-templates.js";
9
9
  import { a as CollaborationClient, i as parseCollaborationDocumentId, n as buildCollaborationDocumentId, r as normalizeCollaborationPath, t as CollaborationFileBridge } from "./collaboration-Dgyl7F33.js";
10
10
  import { i as parseLineApplicationResult, n as LINE_APPLICATION_REQUEST_MAX_BYTES, r as parseLineApplicationRequest, t as LINE_APPLICATION_REPLY_MAX_CHARS } from "./line-application-CvOBTLei.js";
11
- import { s as TangleSandboxClient } from "./tangle-CwQP4t9_.js";
11
+ import { s as TangleSandboxClient } from "./tangle-CIhQrQxx.js";
12
12
  import { z } from "zod";
13
13
  import { SANDBOX_SIZE_PRESET_NAMES, agentProfileConfidentialSchema, agentProfileSchema } from "@tangle-network/agent-interface";
14
14
  //#region src/confidential.ts
@@ -1,2 +1,2 @@
1
- import { n as withPreparedProcessCalls, t as runPreparedProcess } from "../prepared-process-D2pf4i13.js";
1
+ import { n as withPreparedProcessCalls, t as runPreparedProcess } from "../prepared-process-Bf-WBVNx.js";
2
2
  export { runPreparedProcess, withPreparedProcessCalls };
@@ -1,8 +1,6 @@
1
1
  //#region src/lib/prepared-process.mjs
2
- /** One prepare/PID/result transport for SDK, Worker adapters and Node probes. */
3
- async function runPreparedProcess(request, path, init, timeoutMs = 75e3, read = (response) => response.clone().json()) {
4
- const deadline = timeoutMs === 0 ? Number.POSITIVE_INFINITY : Date.now() + timeoutMs;
5
- const signal = init.signal;
2
+ /** Request and pause share one deadline, including independent cancellation cleanup. */
3
+ function processRequests(request, deadline, signal) {
6
4
  const remaining = (ceiling = 3e4) => {
7
5
  signal?.throwIfAborted();
8
6
  const left = deadline - Date.now();
@@ -18,48 +16,70 @@ async function runPreparedProcess(request, path, init, timeoutMs = 75e3, read =
18
16
  ...requestSignal ? { signal: requestSignal } : {}
19
17
  }, Number.isFinite(left) ? left : 0);
20
18
  };
19
+ const pause = () => {
20
+ return new Promise((resolve, reject) => {
21
+ const abort = () => {
22
+ clearTimeout(timer);
23
+ reject(signal.reason);
24
+ };
25
+ const timer = setTimeout(() => {
26
+ signal?.removeEventListener("abort", abort);
27
+ resolve();
28
+ }, Math.min(250, remaining()));
29
+ signal?.addEventListener("abort", abort, { once: true });
30
+ if (signal?.aborted) abort();
31
+ });
32
+ };
33
+ return {
34
+ ask,
35
+ pause
36
+ };
37
+ }
38
+ /** Only the small pending receipt is parsed; terminal output stays streamed. */
39
+ async function pollPreparedProcess(transport, target, pid, headers, read) {
40
+ while (true) {
41
+ const response = await transport.ask(target, {
42
+ method: "GET",
43
+ headers
44
+ });
45
+ if (response.status !== 202) return response;
46
+ const pending = await read(response);
47
+ if (pending.state !== "running" || pending.pid !== pid) throw new Error("Malformed process result receipt");
48
+ await transport.pause();
49
+ }
50
+ }
51
+ /** One prepare/PID/result transport for SDK, Worker adapters and Node probes. */
52
+ async function runPreparedProcess(request, path, init, timeoutMs = 75e3, read = (response) => response.clone().json()) {
53
+ const transport = processRequests(request, timeoutMs === 0 ? Number.POSITIVE_INFINITY : Date.now() + timeoutMs, init.signal);
21
54
  const resultBase = path.split("?")[0].replace(/\/spawn$/, "");
22
55
  let pid;
23
56
  try {
24
- let response = await ask(`${path}${path.includes("?") ? "&" : "?"}async=1`, init, Number.POSITIVE_INFINITY);
57
+ const response = await transport.ask(`${path}${path.includes("?") ? "&" : "?"}async=1`, init, Number.POSITIVE_INFINITY);
25
58
  if (response.status < 200 || response.status >= 300) return response;
26
59
  const admitted = await read(response);
27
60
  if (typeof admitted.data?.exitCode === "number") return response;
28
61
  pid = admitted.data?.pid;
29
62
  if (!Number.isSafeInteger(pid) || pid <= 0) throw new Error("Malformed process admission");
30
- while (true) {
31
- response = await ask(`${resultBase}/${pid}?result=1`, {
32
- method: "GET",
33
- headers: init.headers
34
- });
35
- if (response.status !== 202) return response;
36
- const pending = await read(response);
37
- if (pending.state !== "running" || pending.pid !== pid) throw new Error("Malformed process result receipt");
38
- await new Promise((resolve, reject) => {
39
- const abort = () => {
40
- clearTimeout(timer);
41
- reject(signal.reason);
42
- };
43
- const timer = setTimeout(() => {
44
- signal?.removeEventListener("abort", abort);
45
- resolve();
46
- }, Math.min(250, remaining()));
47
- signal?.addEventListener("abort", abort, { once: true });
48
- if (signal?.aborted) abort();
49
- });
50
- }
63
+ return await pollPreparedProcess(transport, `${resultBase}/${pid}?result=1`, pid, init.headers, read);
51
64
  } catch (error) {
52
65
  const cancelHeaders = new Headers(init.headers);
53
66
  cancelHeaders.set("Content-Type", "application/json");
54
- if (pid) await request(`${resultBase}/${pid}`, {
55
- method: "DELETE",
56
- headers: cancelHeaders,
57
- signal: AbortSignal.timeout(5e3),
58
- body: JSON.stringify({
59
- signal: "SIGKILL",
60
- tree: true
61
- })
62
- }, 5e3).then((response) => response.body?.cancel?.()).catch(() => void 0);
67
+ if (pid) {
68
+ const cleanup = processRequests(request, Date.now() + 5e3);
69
+ try {
70
+ await (await cleanup.ask(`${resultBase}/${pid}`, {
71
+ method: "DELETE",
72
+ headers: cancelHeaders,
73
+ body: JSON.stringify({
74
+ signal: "SIGKILL",
75
+ tree: true
76
+ })
77
+ })).body?.cancel?.();
78
+ const settled = await pollPreparedProcess(cleanup, `${resultBase}/${pid}?result=1`, pid, init.headers, read);
79
+ if (settled.status !== 200 && settled.status !== 408) throw new Error("Process cancellation settlement unknown");
80
+ await settled.body?.cancel?.();
81
+ } catch {}
82
+ }
63
83
  throw error;
64
84
  }
65
85
  }
@@ -4,7 +4,7 @@ import { C as StreamInterruptedError, F as profileFileMountOutsideRootsMessage,
4
4
  import { _ as interactiveSessionStatusResponseSchema, d as awaitWithAbort, f as combineAbortSignals, g as interactiveSessionControlValidationResponseSchema, h as interactiveSessionControlReleaseResponseSchema, l as createInteractiveControlHolderId, m as interactiveSessionControlClaimResponseSchema, p as delayUntilAborted } from "./browser-interactive-control-controller-DHx53yre.js";
5
5
  import { n as fetchWithKeepAlive, t as emitTiming } from "./keep-alive-fetch-BBzJDWyt.js";
6
6
  import { s as uploadChunked } from "./chunked-upload-DN2twsUu.js";
7
- import { t as runPreparedProcess } from "./prepared-process-D2pf4i13.js";
7
+ import { t as runPreparedProcess } from "./prepared-process-Bf-WBVNx.js";
8
8
  import { r as cliAuthReferenceSchema } from "./cli-auth-bundle-DyiAdzXr.js";
9
9
  import { n as SandboxLines } from "./lines-CXkOvy_9.js";
10
10
  import { z } from "zod";
@@ -1,2 +1,2 @@
1
- import { _ as SandboxCreateParamTypes, a as parseQuoteResponse, c as OperatorSession, d as TANGLE_JOBS_CONTRACT, f as ITangleJobsAbi, g as JsonResponseParamTypes, h as JOB_SANDBOX_DELETE, i as jobQuoteDigest, l as OperatorSessionError, m as JOB_SANDBOX_CREATE, n as fetchQuote, o as validateQuote, p as AgentSandboxBlueprintAbi, r as inputsHashOf, s as TangleSandboxClient, t as QuoteError, u as TANGLE_CHAIN_ID, v as SandboxCreateResponseParamTypes, y as SandboxIdParamTypes } from "../tangle-CwQP4t9_.js";
1
+ import { _ as SandboxCreateParamTypes, a as parseQuoteResponse, c as OperatorSession, d as TANGLE_JOBS_CONTRACT, f as ITangleJobsAbi, g as JsonResponseParamTypes, h as JOB_SANDBOX_DELETE, i as jobQuoteDigest, l as OperatorSessionError, m as JOB_SANDBOX_CREATE, n as fetchQuote, o as validateQuote, p as AgentSandboxBlueprintAbi, r as inputsHashOf, s as TangleSandboxClient, t as QuoteError, u as TANGLE_CHAIN_ID, v as SandboxCreateResponseParamTypes, y as SandboxIdParamTypes } from "../tangle-CIhQrQxx.js";
2
2
  export { AgentSandboxBlueprintAbi, ITangleJobsAbi, JOB_SANDBOX_CREATE, JOB_SANDBOX_DELETE, JsonResponseParamTypes, OperatorSession, OperatorSessionError, QuoteError, SandboxCreateParamTypes, SandboxCreateResponseParamTypes, SandboxIdParamTypes, TANGLE_CHAIN_ID, TANGLE_JOBS_CONTRACT, TangleSandboxClient, fetchQuote, inputsHashOf, jobQuoteDigest, parseQuoteResponse, validateQuote };
@@ -1,5 +1,5 @@
1
1
  import { i as readResponseJson } from "./errors-BfbOP_rx.js";
2
- import { n as createSandboxInstanceFromResponse } from "./sandbox-CfIa-5qJ.js";
2
+ import { n as createSandboxInstanceFromResponse } from "./sandbox-JRl9l7pE.js";
3
3
  import { _ as rotlBH, a as anumber, b as rotlSL, d as createXOFer, g as u32, h as toBytes$1, l as createHasher, m as swap32IfBE, n as abytes, o as aoutput, r as aexists, s as clean, t as Hash, v as rotlBL, x as split, y as rotlSH } from "./utils-CLVp0apb.js";
4
4
  //#region ../../../packages/runtime-contracts/dist/tangle-blueprint-abi.js
5
5
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/sandbox",
3
- "version": "0.60.78-develop.20261023061855.4e0fe75",
3
+ "version": "0.60.78-develop.20261023063254.e61b3b8",
4
4
  "description": "Client SDK for the Tangle Sandbox platform - build AI agent applications with dev containers",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -159,11 +159,11 @@
159
159
  "vitest": "^4.1.11",
160
160
  "ws": "^8.20.0",
161
161
  "yjs": "13.6.30",
162
- "@repo/shared": "0.0.0",
163
162
  "@products/sandbox-test-utils": "0.0.0",
164
163
  "@tangle-network/agent-profile-materialize": "0.26.0",
165
164
  "@tangle-network/cli-agent-registry": "0.10.2",
166
165
  "@tangle-network/runtime-contracts": "0.19.0",
166
+ "@repo/shared": "0.0.0",
167
167
  "@tangle-network/sdk": "4.0.16",
168
168
  "@tangle-network/sse-core": "0.0.0"
169
169
  },