@tangle-network/sandbox 1.0.132 → 1.0.134
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/dist/agent/index.d.ts +4 -4
- package/dist/agent/index.js +5 -5
- package/dist/agent/preview.d.ts +1 -1
- package/dist/agent/preview.js +3 -3
- package/dist/{agent-run-outcome-6RpFdvyP.d.ts → agent-run-outcome-DSW47DnU.d.ts} +2 -2
- package/dist/{api-request-B7cnX489.js → api-request-DNrodWdz.js} +1 -1
- package/dist/auth/index.d.ts +2 -2
- package/dist/auth/index.js +2 -2
- package/dist/{browser-interactive-control-controller-BRz2PPTQ.d.ts → browser-interactive-control-controller-CLxkpYNV.d.ts} +1 -1
- package/dist/{browser-interactive-control-controller-CI-G-lan.js → browser-interactive-control-controller-l4Yqgoug.js} +2 -2
- package/dist/{chunked-upload-BHRGMfDz.js → chunked-upload-CyP-FOeZ.js} +1 -1
- package/dist/{chunked-upload-file-BMeDaILU.js → chunked-upload-file-Dr6i6G5b.js} +2 -2
- package/dist/{cli-auth-bundle-BDGLGvMu-BM8TG3ms.js → cli-auth-bundle-BDGLGvMu-BXdVAPNF.js} +1 -1
- package/dist/cli-auth-bundle-nPm8yuKO.js +2 -0
- package/dist/{client-CDz5Wgc0.js → client-BSK8I_4r.js} +11 -11
- package/dist/{client-uV-nZY3y.d.ts → client-BdoEjuk9.d.ts} +6 -5
- package/dist/collaboration/index.d.ts +1 -1
- package/dist/collaboration/index.js +1 -1
- package/dist/{collaboration-C1jO3_Pp.js → collaboration-CX_XvFZZ.js} +1 -1
- package/dist/{core-CpQI6Yqe.js → core-DEFF0nLW.js} +6 -6
- package/dist/core.d.ts +6 -6
- package/dist/core.js +5 -5
- package/dist/{direct-http2-B0ztwG7m.js → direct-http2-Bojg02xf.js} +1 -1
- package/dist/{errors-ystNl7Ae.js → errors-BfR-fBvN.js} +1 -1
- package/dist/file-download-CICuFwGb.js +178 -0
- package/dist/harness-Cgp9jduT.js +363 -0
- package/dist/{index-BejHM6F8.d.ts → index-CE4JMgzA.d.ts} +6 -6
- package/dist/index.d.ts +11 -11
- package/dist/index.js +12 -11
- package/dist/intelligence/index.d.ts +3 -1
- package/dist/intelligence/index.js +25 -23
- package/dist/interactive-control.d.ts +1 -1
- package/dist/interactive-control.js +1 -1
- package/dist/{interactive-controller-CM1FJ0gp.d.ts → interactive-controller-B8mGHsJz.d.ts} +3 -3
- package/dist/{interactive-controller-BzY0se5n.js → interactive-controller-DRWdHdgK.js} +7 -7
- package/dist/lib/prepared-evidence.js +1 -1
- package/dist/lib/prepared-process.js +1 -1
- package/dist/{lines-Dh-39kUV.d.ts → lines-Dc42Gr39.d.ts} +1 -1
- package/dist/{lines-DF4g3X3I.js → lines-DlLR4pHq.js} +1 -1
- package/dist/lines.d.ts +1 -1
- package/dist/lines.js +1 -1
- package/dist/{local-cli-auth-D-r9JSUk.js → local-cli-auth-CI2d1Pdh.js} +1 -1
- package/dist/{mcp-local-B7o_k_Ll.js → mcp-local-tBlLJqTb.js} +1 -1
- package/dist/{prepared-evidence-DBSU--pB.js → prepared-evidence-r46MdJM9.js} +1 -1
- package/dist/{prepared-process-GzQXVsX8.js → prepared-process-C-rwZPIZ.js} +1 -1
- package/dist/{preview-BtbrzU_4.d.ts → preview-C7nHXam2.d.ts} +3 -3
- package/dist/{profile-schema-BD1nkqBw.js → profile-schema-nys6Qejd.js} +1 -1
- package/dist/{public-templates-Zec8CB3Y.d.ts → public-templates-DA4_Hn6B.d.ts} +2 -2
- package/dist/public-templates.d.ts +1 -1
- package/dist/public-templates.js +1 -1
- package/dist/{raw-evidence-archive-OHRixF4L.js → raw-evidence-archive-BOXTejc2.js} +11 -31
- package/dist/runtime.d.ts +5 -5
- package/dist/runtime.js +5 -5
- package/dist/{sandbox-NSVkjLQo.js → sandbox-CIfbsytC.js} +22 -205
- package/dist/{secp256k1-BGtA1PsN.js → secp256k1-CZWrpqxW.js} +1 -1
- package/dist/select-seat-command.d.ts +1 -1
- package/dist/select-seat-command.js +1 -1
- package/dist/session-gateway/index.js +3 -3
- package/dist/{harness-B63wL8RZ.js → sha2-vu4U-x2L.js} +23 -363
- package/dist/tangle/index.d.ts +1 -1
- package/dist/tangle/index.js +1 -1
- package/dist/{tangle-QjuaxjRc.js → tangle-bYg24n7e.js} +4 -4
- package/dist/{types-BA5GRheq.d.ts → types-BVyyOVyf.d.ts} +2 -2
- package/package.json +6 -5
- package/dist/cli-auth-bundle-DdAKxGZF.js +0 -2
- /package/dist/{abort-signal-JVaAyNMP.js → abort-signal-CDxyloxz.js} +0 -0
- /package/dist/{cli-auth-bundle-DMbZ1E7W.d.ts → cli-auth-bundle-COQ25k3d.d.ts} +0 -0
- /package/dist/{index-DnZdhFs2.d.ts → index-Dqcr9p97.d.ts} +0 -0
- /package/dist/{index-rbeL2Rct.d.ts → index-Dslyq85a.d.ts} +0 -0
- /package/dist/{keep-alive-fetch--8twRp99.js → keep-alive-fetch-BbSFbRCd.js} +0 -0
- /package/dist/{preview-operations-D2fXB_dc.js → preview-operations-BvgwYaoL.js} +0 -0
- /package/dist/{response-rewrap-B75N59JT.js → response-rewrap-CpNkboDX.js} +0 -0
- /package/dist/{retry-after-header-DrbSlyKY.js → retry-after-header-DUdCC0KJ.js} +0 -0
- /package/dist/{sidecar-proxy-error-DORW8_mD.js → sidecar-proxy-error-5DpLmHeN.js} +0 -0
- /package/dist/{sse-parser-BUIKfYAd.js → sse-parser-DrI47LyG.js} +0 -0
- /package/dist/{terminal-stream-types-CIgaXUM7.d.ts → terminal-stream-types-8-sAl2J0.d.ts} +0 -0
- /package/dist/{utils-CoawKwX_.js → utils-vaFoyyiO.js} +0 -0
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import { A as mergeRuntimeBackendConfig, C as encodePromptForWire, E as canUseNodeHttp2, G as normalizeEffectiveBackend, I as withoutRuntimeSecrets, L as createAgentRunOutcomeTracker, M as requestedPublicProfileDigest, N as requestedSecretProfilePublicDigest, O as applyRequestedModel, R as deriveAgentResultOutcome, S as validateAcceptedDispatchRunRef, T as runtimeFilesystemPath, _ as TRACE_ID_HEADER, a as assertScopedTokenActive, b as resolveTraceId, c as SandboxRuntimeApi, d as appendSessionIdQuery, f as callHeaders, g as waitForRetryAfter, h as isRetryableCredentialRefusal, i as terminalUpgradeHeadersSupported, j as normalizeRuntimeBackendConfig, k as assertCurrentBackendType, l as normalizeSessionInfo, m as assertFileWritePreconditions, n as InteractiveSessionController, p as sessionHeaders, r as TerminalStream, s as requestScopedToken, u as sessionMessageRequestBody, v as isTraceId, w as encodeTextForWire, x as resolveDispatchRunIdentity, y as mintTraceId } from "./interactive-controller-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { n as
|
|
7
|
-
import { t as
|
|
8
|
-
import {
|
|
9
|
-
import { t as
|
|
10
|
-
import { t as
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import "./cli-auth-bundle-
|
|
15
|
-
import
|
|
1
|
+
import { A as mergeRuntimeBackendConfig, C as encodePromptForWire, E as canUseNodeHttp2, G as normalizeEffectiveBackend, I as withoutRuntimeSecrets, L as createAgentRunOutcomeTracker, M as requestedPublicProfileDigest, N as requestedSecretProfilePublicDigest, O as applyRequestedModel, R as deriveAgentResultOutcome, S as validateAcceptedDispatchRunRef, T as runtimeFilesystemPath, _ as TRACE_ID_HEADER, a as assertScopedTokenActive, b as resolveTraceId, c as SandboxRuntimeApi, d as appendSessionIdQuery, f as callHeaders, g as waitForRetryAfter, h as isRetryableCredentialRefusal, i as terminalUpgradeHeadersSupported, j as normalizeRuntimeBackendConfig, k as assertCurrentBackendType, l as normalizeSessionInfo, m as assertFileWritePreconditions, n as InteractiveSessionController, p as sessionHeaders, r as TerminalStream, s as requestScopedToken, u as sessionMessageRequestBody, v as isTraceId, w as encodeTextForWire, x as resolveDispatchRunIdentity, y as mintTraceId } from "./interactive-controller-DRWdHdgK.js";
|
|
2
|
+
import { C as boundedIdentifierSchema, E as boundedStringSchema, g as sha256DigestSchema$1, o as canonicalCandidateDigest$1, s as canonicalCandidateJson$1, u as isCanonicalJsonValue$1 } from "./harness-Cgp9jduT.js";
|
|
3
|
+
import { t as sha256 } from "./sha2-vu4U-x2L.js";
|
|
4
|
+
import { A as agentInteractiveSessionStatusMatchesRef, B as PlanContinuationSchema, C as AgentInteractiveSessionStopAcknowledgementSchema, D as agentInteractiveSessionControlClaimMatchesRef, E as agentInteractiveSessionControlClaimIsNewer, F as AgentRunCancellationAcknowledgementSchema, G as InteractionResponseSchema, H as InteractionBindingSchema, I as AgentRunCancellationRequestSchema, L as agentRunCancellationAcknowledgementMatchesRequest, M as agentInteractiveDimensionSchema, N as sameAgentExactRun, O as agentInteractiveSessionPromptAcknowledgementMatchesCommand, P as AgentExactRunControlRefSchema, S as AgentInteractiveSessionStatusSchema, T as agentInteractiveSessionControlClaimAcknowledgementMatchesRequest, U as InteractionRequestSchema, V as InteractionAcknowledgementSchema, W as InteractionResponseCommandSchema, _ as AgentInteractiveSessionControlClaimRequestSchema, b as AgentInteractiveSessionPromptCommandSchema, d as interactiveSessionControlClaimResponseSchema, f as interactiveSessionControlReleaseResponseSchema, g as AgentInteractiveSessionControlClaimAcknowledgementSchema, h as AgentInteractiveSessionAttachSchema, j as agentInteractiveSessionStopAcknowledgementMatchesCommand, l as createInteractiveControlHolderId, m as interactiveSessionStatusResponseSchema, p as interactiveSessionControlValidationResponseSchema, v as AgentInteractiveSessionControlClaimSchema, w as AgentInteractiveSessionStopCommandSchema, x as AgentInteractiveSessionRefSchema, y as AgentInteractiveSessionPromptAcknowledgementSchema } from "./browser-interactive-control-controller-l4Yqgoug.js";
|
|
5
|
+
import { a as ProxySecretReceiptSchema, o as canonicalAgentProfileValue, r as agentProfileSchema } from "./profile-schema-nys6Qejd.js";
|
|
6
|
+
import { C as StateError, E as ValidationError, F as SANDBOX_AGENT_HOME, I as SANDBOX_FILE_API_ABSOLUTE_ROOTS, L as isProfileFileMountOutsideRoots, M as FILE_OPERATION_LIMITS, P as PROFILE_FILE_MOUNT_OUTSIDE_ROOTS_CODE, R as profileFileMountOutsideRootsMessage, S as ServerError, T as TimeoutError, a as AuthError, c as CompliancePlacementError, f as GpuProviderNotConfiguredError, g as NotFoundError, h as NetworkError, i as readResponseJson, j as SANDBOX_PROXY_REQUEST_MAX_BYTES, l as EdgeNotReadyError, m as NON_RETRYABLE_CREATE_QUOTA_REASONS, n as parseErrorResponse, r as parseResponseError, s as CapabilityError, t as TerminalStreamError, v as ProfileFileMountPathError, w as StreamInterruptedError, x as SandboxError, y as QuotaError } from "./errors-BfR-fBvN.js";
|
|
7
|
+
import { n as combineAbortSignals, r as delayUntilAborted, t as awaitWithAbort } from "./abort-signal-CDxyloxz.js";
|
|
8
|
+
import { t as rewrapResponse } from "./response-rewrap-CpNkboDX.js";
|
|
9
|
+
import { n as fetchWithKeepAlive, t as emitTiming } from "./keep-alive-fetch-BbSFbRCd.js";
|
|
10
|
+
import { t as SIDECAR_PROXY_ERROR_HEADER } from "./sidecar-proxy-error-5DpLmHeN.js";
|
|
11
|
+
import { t as parseSSEStream } from "./sse-parser-DrI47LyG.js";
|
|
12
|
+
import { s as uploadChunked } from "./chunked-upload-CyP-FOeZ.js";
|
|
13
|
+
import { t as runPreparedProcess } from "./prepared-process-C-rwZPIZ.js";
|
|
14
|
+
import { a as backendTypeSchema, r as cliAuthReferenceSchema } from "./cli-auth-bundle-BDGLGvMu-BXdVAPNF.js";
|
|
15
|
+
import "./cli-auth-bundle-nPm8yuKO.js";
|
|
16
|
+
import { n as SandboxLines } from "./lines-DlLR4pHq.js";
|
|
17
|
+
import { t as downloadFile } from "./file-download-CICuFwGb.js";
|
|
16
18
|
import { z } from "zod";
|
|
17
19
|
import { createHash } from "node:crypto";
|
|
18
20
|
import { constants } from "node:fs";
|
|
@@ -3066,7 +3068,7 @@ var DirectRuntimeHttpClient = class {
|
|
|
3066
3068
|
};
|
|
3067
3069
|
if (!route) throw new NetworkError("Direct runtime route was withdrawn");
|
|
3068
3070
|
if ((route.useHost || route.useExec) && canUseNodeHttp2()) {
|
|
3069
|
-
const { fetchDirectHttp2 } = await import("./direct-http2-
|
|
3071
|
+
const { fetchDirectHttp2 } = await import("./direct-http2-Bojg02xf.js");
|
|
3070
3072
|
return fetchDirectHttp2(route.url, request, timing);
|
|
3071
3073
|
}
|
|
3072
3074
|
return fetchWithKeepAlive(route.url, request, timing);
|
|
@@ -8783,7 +8785,7 @@ var SandboxInteractiveCapabilities = class extends SandboxPromptCapabilities {
|
|
|
8783
8785
|
var SandboxSessionEvidenceCapabilities = class extends SandboxInteractiveCapabilities {
|
|
8784
8786
|
/** @internal — invoked before the sandbox is deleted. */
|
|
8785
8787
|
async _sessionExportRawEvidence(id, destination, options) {
|
|
8786
|
-
const { exportRawEvidenceDirectory } = await import("./raw-evidence-archive-
|
|
8788
|
+
const { exportRawEvidenceDirectory } = await import("./raw-evidence-archive-BOXTejc2.js");
|
|
8787
8789
|
await this.ensureRunning();
|
|
8788
8790
|
await this.refresh();
|
|
8789
8791
|
return exportRawEvidenceDirectory((signal, archiveId, cancel) => this.runtimeFetch(`/agents/sessions/${encodeURIComponent(id)}/raw-evidence/archive?${new URLSearchParams([
|
|
@@ -8814,7 +8816,7 @@ var SandboxSessionEvidenceCapabilities = class extends SandboxInteractiveCapabil
|
|
|
8814
8816
|
* and the byte and file bounds are verified before the directory appears.
|
|
8815
8817
|
*/
|
|
8816
8818
|
async exportRawEvidence(destination, options) {
|
|
8817
|
-
const { exportRawEvidenceDirectory } = await import("./raw-evidence-archive-
|
|
8819
|
+
const { exportRawEvidenceDirectory } = await import("./raw-evidence-archive-BOXTejc2.js");
|
|
8818
8820
|
await this.ensureRunning();
|
|
8819
8821
|
await this.refresh();
|
|
8820
8822
|
return exportRawEvidenceDirectory((signal, archiveId, cancel) => this.runtimeFetch(`/agents/raw-evidence/archive?${new URLSearchParams({
|
|
@@ -10889,191 +10891,6 @@ var DeclaredFilesystemOperations = class {
|
|
|
10889
10891
|
}
|
|
10890
10892
|
};
|
|
10891
10893
|
//#endregion
|
|
10892
|
-
//#region src/lib/file-download.ts
|
|
10893
|
-
/** Retain only complete downloads; failed streams leave the destination intact. */
|
|
10894
|
-
async function downloadFile(request, localPath, options = {}) {
|
|
10895
|
-
for (const [name, value] of Object.entries({
|
|
10896
|
-
maxBytes: options.maxBytes,
|
|
10897
|
-
expectedSize: options.expectedSize
|
|
10898
|
-
})) if (value !== void 0 && (!Number.isSafeInteger(value) || value < 0)) throw new ValidationError(`${name} must be a non-negative safe integer`);
|
|
10899
|
-
const expectedHash = options.expectedSha256?.replace(/^sha256:/, "");
|
|
10900
|
-
if (expectedHash !== void 0 && !/^[a-f0-9]{64}$/i.test(expectedHash)) throw new ValidationError("expectedSha256 must be a SHA-256 digest");
|
|
10901
|
-
const maxBytes = options.maxBytes ?? Number.MAX_SAFE_INTEGER;
|
|
10902
|
-
if (options.expectedSize !== void 0 && options.expectedSize > maxBytes) throw new ValidationError("expectedSize exceeds download maxBytes");
|
|
10903
|
-
options.signal?.throwIfAborted();
|
|
10904
|
-
if (options.parallel && options.parallel > 1) {
|
|
10905
|
-
const probed = await probeRangeSupport(request, options.signal);
|
|
10906
|
-
if (probed) return await downloadParallel(request, localPath, {
|
|
10907
|
-
...options,
|
|
10908
|
-
parallel: options.parallel
|
|
10909
|
-
}, probed);
|
|
10910
|
-
}
|
|
10911
|
-
const response = await request(options.signal);
|
|
10912
|
-
const reader = response.body?.getReader();
|
|
10913
|
-
const abort = () => {
|
|
10914
|
-
reader?.cancel(options.signal?.reason).catch(() => {});
|
|
10915
|
-
};
|
|
10916
|
-
options.signal?.addEventListener("abort", abort, { once: true });
|
|
10917
|
-
let directory;
|
|
10918
|
-
let file;
|
|
10919
|
-
const fs = await import("node:fs/promises");
|
|
10920
|
-
try {
|
|
10921
|
-
options.signal?.throwIfAborted();
|
|
10922
|
-
const length = response.headers.get("content-length");
|
|
10923
|
-
const totalBytes = length === null ? void 0 : Number(length);
|
|
10924
|
-
if (length !== null && (!/^\d+$/.test(length) || !Number.isSafeInteger(totalBytes))) throw new Error("Download returned an invalid content-length");
|
|
10925
|
-
if (totalBytes !== void 0 && totalBytes > maxBytes) throw new Error("Download exceeds maxBytes");
|
|
10926
|
-
if (options.expectedSize !== void 0 && totalBytes !== void 0 && totalBytes !== options.expectedSize) throw new Error("Download size does not match expectedSize");
|
|
10927
|
-
const path = await import("node:path");
|
|
10928
|
-
const { createHash } = await import("node:crypto");
|
|
10929
|
-
await fs.mkdir(path.dirname(localPath), { recursive: true });
|
|
10930
|
-
directory = await fs.mkdtemp(path.join(path.dirname(localPath), ".sandbox-download-"));
|
|
10931
|
-
const temporaryPath = path.join(directory, "content");
|
|
10932
|
-
file = await fs.open(temporaryPath, "wx", 384);
|
|
10933
|
-
const hash = createHash("sha256");
|
|
10934
|
-
let sizeBytes = 0;
|
|
10935
|
-
if (totalBytes !== void 0 && totalBytes > 0) options.onProgress?.({
|
|
10936
|
-
bytesDownloaded: 0,
|
|
10937
|
-
totalBytes,
|
|
10938
|
-
percentage: 0
|
|
10939
|
-
});
|
|
10940
|
-
for (;;) {
|
|
10941
|
-
options.signal?.throwIfAborted();
|
|
10942
|
-
const chunk = await reader?.read();
|
|
10943
|
-
options.signal?.throwIfAborted();
|
|
10944
|
-
if (!chunk || chunk.done) break;
|
|
10945
|
-
sizeBytes += chunk.value.byteLength;
|
|
10946
|
-
if (sizeBytes > maxBytes) throw new Error("Download exceeds maxBytes");
|
|
10947
|
-
if (options.expectedSize !== void 0 && sizeBytes > options.expectedSize) throw new Error("Download size does not match expectedSize");
|
|
10948
|
-
hash.update(chunk.value);
|
|
10949
|
-
await file.writeFile(chunk.value);
|
|
10950
|
-
if (totalBytes !== void 0 && sizeBytes < totalBytes) options.onProgress?.({
|
|
10951
|
-
bytesDownloaded: sizeBytes,
|
|
10952
|
-
totalBytes,
|
|
10953
|
-
percentage: sizeBytes / totalBytes * 100
|
|
10954
|
-
});
|
|
10955
|
-
}
|
|
10956
|
-
if (totalBytes !== void 0 && sizeBytes !== totalBytes || options.expectedSize !== void 0 && sizeBytes !== options.expectedSize) throw new Error("Download was truncated or its size changed");
|
|
10957
|
-
const sha256 = hash.digest("hex");
|
|
10958
|
-
if (expectedHash !== void 0 && sha256 !== expectedHash.toLowerCase()) throw new Error("Download SHA-256 does not match expectedSha256");
|
|
10959
|
-
await file.close();
|
|
10960
|
-
file = void 0;
|
|
10961
|
-
options.signal?.throwIfAborted();
|
|
10962
|
-
if (options.overwrite === false) await fs.link(temporaryPath, localPath);
|
|
10963
|
-
else await fs.rename(temporaryPath, localPath);
|
|
10964
|
-
options.onProgress?.({
|
|
10965
|
-
bytesDownloaded: sizeBytes,
|
|
10966
|
-
totalBytes: sizeBytes,
|
|
10967
|
-
percentage: 100
|
|
10968
|
-
});
|
|
10969
|
-
return {
|
|
10970
|
-
sizeBytes,
|
|
10971
|
-
sha256
|
|
10972
|
-
};
|
|
10973
|
-
} finally {
|
|
10974
|
-
options.signal?.removeEventListener("abort", abort);
|
|
10975
|
-
await reader?.cancel().catch(() => {});
|
|
10976
|
-
reader?.releaseLock();
|
|
10977
|
-
await file?.close();
|
|
10978
|
-
if (directory !== void 0) await fs.rm(directory, {
|
|
10979
|
-
recursive: true,
|
|
10980
|
-
force: true
|
|
10981
|
-
});
|
|
10982
|
-
}
|
|
10983
|
-
}
|
|
10984
|
-
/** Probe with a one-byte range: only a 206 with a parseable Content-Range
|
|
10985
|
-
* counts as capability (200 = ignored Range, anything else = no). */
|
|
10986
|
-
async function probeRangeSupport(request, signal) {
|
|
10987
|
-
signal?.throwIfAborted();
|
|
10988
|
-
const response = await request(signal, { headers: { Range: "bytes=0-0" } });
|
|
10989
|
-
if (response.status !== 206) return void 0;
|
|
10990
|
-
const contentRange = response.headers.get("content-range");
|
|
10991
|
-
const total = contentRange ? /\/(\d+)$/.exec(contentRange)?.[1] : void 0;
|
|
10992
|
-
if (total === void 0) return void 0;
|
|
10993
|
-
await response.arrayBuffer().catch(() => void 0);
|
|
10994
|
-
const totalBytes = Number(total);
|
|
10995
|
-
return Number.isSafeInteger(totalBytes) ? { totalBytes } : void 0;
|
|
10996
|
-
}
|
|
10997
|
-
/** Parallel range download: N slices fetched concurrently, written at their
|
|
10998
|
-
* offsets into one temp file, hashed in order on a single sequential re-read,
|
|
10999
|
-
* published atomically. A failed or truncated slice fails loud — the
|
|
11000
|
-
* destination never sees a partial file. */
|
|
11001
|
-
async function downloadParallel(request, localPath, options, capable) {
|
|
11002
|
-
const { totalBytes } = capable;
|
|
11003
|
-
if (totalBytes > (options.maxBytes ?? Number.MAX_SAFE_INTEGER)) throw new Error("Download exceeds maxBytes");
|
|
11004
|
-
if (options.expectedSize !== void 0 && totalBytes !== options.expectedSize) throw new Error("Download size does not match expectedSize");
|
|
11005
|
-
const expectedHash = options.expectedSha256?.replace(/^sha256:/, "");
|
|
11006
|
-
const fs = await import("node:fs/promises");
|
|
11007
|
-
const path = await import("node:path");
|
|
11008
|
-
const { createHash } = await import("node:crypto");
|
|
11009
|
-
const directory = await fs.mkdtemp(path.join(path.dirname(localPath), ".sandbox-download-"));
|
|
11010
|
-
const temporaryPath = path.join(directory, "content");
|
|
11011
|
-
let received = 0;
|
|
11012
|
-
try {
|
|
11013
|
-
options.onProgress?.({
|
|
11014
|
-
bytesDownloaded: 0,
|
|
11015
|
-
totalBytes,
|
|
11016
|
-
percentage: 0
|
|
11017
|
-
});
|
|
11018
|
-
const file = await fs.open(temporaryPath, "wx+", 384);
|
|
11019
|
-
try {
|
|
11020
|
-
const slices = sliceRanges(totalBytes, options.parallel);
|
|
11021
|
-
await Promise.all(slices.map(async ({ start, end }) => {
|
|
11022
|
-
options.signal?.throwIfAborted();
|
|
11023
|
-
const response = await request(options.signal, { headers: { Range: `bytes=${start}-${end}` } });
|
|
11024
|
-
if (response.status !== 206) throw new Error(`Range request answered ${response.status} after a 206 probe`);
|
|
11025
|
-
const sliceBytes = end - start + 1;
|
|
11026
|
-
const buffer = Buffer.from(await response.arrayBuffer());
|
|
11027
|
-
if (buffer.byteLength !== sliceBytes) throw new Error(`Range slice ${start}-${end} returned ${buffer.byteLength} bytes (truncated)`);
|
|
11028
|
-
await file.write(buffer, 0, sliceBytes, start);
|
|
11029
|
-
received += sliceBytes;
|
|
11030
|
-
options.onProgress?.({
|
|
11031
|
-
bytesDownloaded: received,
|
|
11032
|
-
totalBytes,
|
|
11033
|
-
percentage: received / totalBytes * 100
|
|
11034
|
-
});
|
|
11035
|
-
}));
|
|
11036
|
-
const hash = createHash("sha256");
|
|
11037
|
-
const reader = file.createReadStream({ autoClose: false });
|
|
11038
|
-
for await (const chunk of reader) hash.update(chunk);
|
|
11039
|
-
const sha256 = hash.digest("hex");
|
|
11040
|
-
if (expectedHash !== void 0 && sha256 !== expectedHash.toLowerCase()) throw new Error("Download SHA-256 does not match expectedSha256");
|
|
11041
|
-
if (received !== totalBytes) throw new Error("Download was truncated or its size changed");
|
|
11042
|
-
await file.close();
|
|
11043
|
-
options.signal?.throwIfAborted();
|
|
11044
|
-
if (options.overwrite === false) await fs.link(temporaryPath, localPath);
|
|
11045
|
-
else await fs.rename(temporaryPath, localPath);
|
|
11046
|
-
options.onProgress?.({
|
|
11047
|
-
bytesDownloaded: totalBytes,
|
|
11048
|
-
totalBytes,
|
|
11049
|
-
percentage: 100
|
|
11050
|
-
});
|
|
11051
|
-
return {
|
|
11052
|
-
sizeBytes: totalBytes,
|
|
11053
|
-
sha256
|
|
11054
|
-
};
|
|
11055
|
-
} catch (error) {
|
|
11056
|
-
await file.close().catch(() => void 0);
|
|
11057
|
-
throw error;
|
|
11058
|
-
}
|
|
11059
|
-
} finally {
|
|
11060
|
-
await fs.rm(directory, {
|
|
11061
|
-
recursive: true,
|
|
11062
|
-
force: true
|
|
11063
|
-
}).catch(() => void 0);
|
|
11064
|
-
}
|
|
11065
|
-
}
|
|
11066
|
-
/** Split [0, total) into `count` contiguous inclusive ranges. */
|
|
11067
|
-
function sliceRanges(total, count) {
|
|
11068
|
-
const chunk = Math.ceil(total / count);
|
|
11069
|
-
const ranges = [];
|
|
11070
|
-
for (let start = 0; start < total; start += chunk) ranges.push({
|
|
11071
|
-
start,
|
|
11072
|
-
end: Math.min(start + chunk, total) - 1
|
|
11073
|
-
});
|
|
11074
|
-
return ranges;
|
|
11075
|
-
}
|
|
11076
|
-
//#endregion
|
|
11077
10894
|
//#region src/sandbox-filesystem-operations.ts
|
|
11078
10895
|
var SandboxFilesystemOperations = class extends DeclaredFilesystemOperations {
|
|
11079
10896
|
get fs() {
|
|
@@ -11119,7 +10936,7 @@ var SandboxFilesystemOperations = class extends DeclaredFilesystemOperations {
|
|
|
11119
10936
|
totalBytes: size,
|
|
11120
10937
|
percentage: 0
|
|
11121
10938
|
});
|
|
11122
|
-
const { uploadChunkedFromFile } = await import("./chunked-upload-file-
|
|
10939
|
+
const { uploadChunkedFromFile } = await import("./chunked-upload-file-Dr6i6G5b.js");
|
|
11123
10940
|
await uploadChunkedFromFile({ fetch: (path, init) => this.host.runtimeFetch(path, init) }, remotePath, localPath, {
|
|
11124
10941
|
mode: options?.permissions,
|
|
11125
10942
|
onProgress: options?.onProgress ? (progress) => {
|
|
@@ -12001,4 +11818,4 @@ var SandboxInstance = class SandboxInstance extends SandboxEgressCapabilities {
|
|
|
12001
11818
|
}
|
|
12002
11819
|
};
|
|
12003
11820
|
//#endregion
|
|
12004
|
-
export {
|
|
11821
|
+
export { normalizeStartupDiagnostics as A, generateIdempotencyKey as B, materializeProfileFileMounts as C, isRetryableProfileFileMaterializeFailure as D, validateDeferredProfileFileMounts as E, normalizeSandboxShape as F, canonicalAgentProfileDigest as G, isRateLimitCreateError as H, DEFAULT_CREATE_TIMEOUT_MS as I, DEFAULT_GPU_CREATE_TIMEOUT_MS as L, normalizeConnection as M, normalizeEgressPolicyFields as N, normalizeCaptureProof as O, normalizeProxySecretReceipt as P, DEPLOY_WINDOW_RETRY_MS as R, SandboxOperationFailedError as S, splitInlineProfileSkills as T, isRetryableCreateError as U, isDeployWindowCreateError as V, waitForCreateRetry as W, collectAgentResponseText as _, buildTraceExportPayload as a, ManagedProcessClient as b, toOtelJson as c, InteractiveSessionHandle as d, InteractiveTerminalFrameLog as f, collectAgentFinalMessageText as g, applySandboxEventText as h, MAX_EGRESS_DENIALS_LIMIT as i, parseStopPhase as j, normalizeSandboxCreateReceipt as k, SandboxTaskSession as l, createInteractiveTerminalSession as m, createSandboxInstanceFromResponse as n, exportTraceBundle as o, createInteractiveTerminalCapture as p, WorkspaceImages as r, otelTraceIdForTangleTrace as s, SandboxInstance as t, SandboxSession as u, getSandboxEventText as v, splitInlineProfileFileMounts as w, SandboxOperation as x, isToolBearingEvent as y, createRetryDelayMs as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as anumber, c as concatBytes$1, f as randomBytes, h as toBytes, i as ahash, l as createHasher$1, n as abytes$1, o as aoutput, p as rotr, r as aexists, s as clean, t as Hash, u as createView, x as split } from "./utils-
|
|
1
|
+
import { a as anumber, c as concatBytes$1, f as randomBytes, h as toBytes, i as ahash, l as createHasher$1, n as abytes$1, o as aoutput, p as rotr, r as aexists, s as clean, t as Hash, u as createView, x as split } from "./utils-vaFoyyiO.js";
|
|
2
2
|
//#region ../../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/_md.js
|
|
3
3
|
/**
|
|
4
4
|
* Internal Merkle-Damgard hash utils.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as combineAbortSignals } from "../abort-signal-
|
|
2
|
-
import "../sidecar-proxy-error-
|
|
3
|
-
import { t as parseSSEStream } from "../sse-parser-
|
|
1
|
+
import { n as combineAbortSignals } from "../abort-signal-CDxyloxz.js";
|
|
2
|
+
import "../sidecar-proxy-error-5DpLmHeN.js";
|
|
3
|
+
import { t as parseSSEStream } from "../sse-parser-DrI47LyG.js";
|
|
4
4
|
//#region ../../../packages/runtime-contracts/dist/session-gateway.js
|
|
5
5
|
/**
|
|
6
6
|
* Calculate connection quality from metrics.
|