@tangle-network/sandbox 0.60.1 → 0.60.2
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 +6 -0
- package/dist/agent/index.d.ts +4 -4
- package/dist/agent/index.js +2 -2
- package/dist/agent/preview.d.ts +1 -1
- package/dist/{agent-run-outcome-Cs5H4B3s.d.ts → agent-run-outcome-BDxby7zK.d.ts} +1 -1
- package/dist/{client-DGwZ0Swl.d.ts → client-BFilDKO8.d.ts} +3 -3
- package/dist/{client-BRocAWYy.js → client-p2T45dAv.js} +1 -1
- package/dist/core.d.ts +4 -4
- package/dist/core.js +2 -2
- package/dist/{index-CcMKzCk4.d.ts → index-DGuTeptP.d.ts} +177 -62
- package/dist/index.d.ts +7 -7
- package/dist/index.js +3 -3
- package/dist/{lines-CHK_7gLO.d.ts → lines-T2D6xHHx.d.ts} +1 -1
- package/dist/lines.d.ts +1 -1
- package/dist/{preview-DNx_ik7Y.d.ts → preview-ZaYvOOXz.d.ts} +3 -3
- package/dist/runtime.d.ts +2 -2
- package/dist/{sandbox-BsJecVCj.js → sandbox-DeE2MDx9.js} +99 -23
- package/dist/{sandbox-BsEk7BTy.d.ts → sandbox-LRvBzGGm.d.ts} +2 -2
- package/dist/tangle/index.d.ts +2 -2
- package/dist/tangle/index.js +2 -2
- package/dist/{tangle-DKaBCad0.js → tangle-SNShua9T.js} +317 -106
- package/dist/{types-BQlqLwrK.d.ts → types-C9w6MdZB.d.ts} +37 -2
- package/package.json +4 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { r as SandboxInstance } from "./sandbox-
|
|
2
|
-
import {
|
|
3
|
-
import { i as Sandbox } from "./client-
|
|
1
|
+
import { r as SandboxInstance } from "./sandbox-LRvBzGGm.js";
|
|
2
|
+
import { Fn as PreviewLinkInfo, ht as EnsureDevServerOptions } from "./types-C9w6MdZB.js";
|
|
3
|
+
import { i as Sandbox } from "./client-BFilDKO8.js";
|
|
4
4
|
|
|
5
5
|
//#region src/agent/preview-operations.d.ts
|
|
6
6
|
type AgentPreviewOptions = Pick<EnsureDevServerOptions, "sessionId" | "cwd"> & {
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { l as ScopedToken, t as TerminalStream } from "./terminal-stream-C9jxoB07.js";
|
|
2
2
|
import { c as InteractiveSessionIdentity, l as InteractiveSessionNotRunningError, r as browserInteractiveControlHolderId } from "./browser-interactive-control-controller-C2qVGzQz.js";
|
|
3
3
|
import { t as BrowserInteractiveSessionController } from "./interactive-controller-Dghv9yMk.js";
|
|
4
|
-
import { A as CommitTaskSessionOptions, At as
|
|
4
|
+
import { A as CommitTaskSessionOptions, Aa as WriteFileOptions, At as FileUsageOptions, Bi as SessionEventStreamOptions, Ci as SandboxTerminalInfo, Cn as ListMessagesOptions, Dr as SandboxEvent, Gi as SessionInfo, H as CreateTaskSessionOptions, Hi as SessionExecutionStatus, Ii as SendSessionMessageOptions, Ji as SessionMessage, Li as SendSessionMessageRequest, Mt as FileWriteResult, Ot as FileTreeOptions, Ri as SentSessionMessage, Si as SandboxTerminalCreateOptions, St as FileReadBatchResult, T as ChunkedUploadResult, Ta as UploadProgress, Ti as SandboxTerminalRequestOptions, Tt as FileRenameResult, V as CreateSessionOptions, Vi as SessionExecutionInfo, Yi as SessionMessageAdmission, da as TaskSessionCommitResult, gi as SandboxRuntimeHealth, jt as FileUsageResult, kt as FileTreeResult, pa as TaskSessionInfo, sr as RenameOptions, ua as TaskSessionChanges, ui as SandboxPortBinding, w as ChunkedUploadOptions, wi as SandboxTerminalManager, xt as FileReadBatchOptions } from "./types-C9w6MdZB.js";
|
|
5
5
|
import { _ as TimeoutError, a as FileWriteConflictError, c as NotFoundError, f as SandboxError, g as StateError, h as ServerError, l as PartialFailureError, m as SandboxFailureDetail, n as CapabilityError, p as SandboxErrorJson, s as NetworkError, t as AuthError, u as QuotaError, v as ValidationError } from "./errors-C6dll8Qf.js";
|
|
6
|
-
import { a as deriveAgentRunOutcome, i as deriveAgentResultOutcome, n as AgentRunOutcomeTracker, r as createAgentRunOutcomeTracker, t as AgentRunOutcome } from "./agent-run-outcome-
|
|
6
|
+
import { a as deriveAgentRunOutcome, i as deriveAgentResultOutcome, n as AgentRunOutcomeTracker, r as createAgentRunOutcomeTracker, t as AgentRunOutcome } from "./agent-run-outcome-BDxby7zK.js";
|
|
7
7
|
|
|
8
8
|
//#region src/lib/chunked-upload.d.ts
|
|
9
9
|
/** The transport a caller wires this module to — {@link SandboxInstance.runtimeFetch}
|
|
@@ -302,6 +302,92 @@ function normalizeSandboxShape(raw) {
|
|
|
302
302
|
};
|
|
303
303
|
}
|
|
304
304
|
//#endregion
|
|
305
|
+
//#region src/lib/file-download.ts
|
|
306
|
+
/** Retain only complete downloads; failed streams leave the destination intact. */
|
|
307
|
+
async function downloadFile(request, localPath, options = {}) {
|
|
308
|
+
for (const [name, value] of Object.entries({
|
|
309
|
+
maxBytes: options.maxBytes,
|
|
310
|
+
expectedSize: options.expectedSize
|
|
311
|
+
})) if (value !== void 0 && (!Number.isSafeInteger(value) || value < 0)) throw new ValidationError(`${name} must be a non-negative safe integer`);
|
|
312
|
+
const expectedHash = options.expectedSha256?.replace(/^sha256:/, "");
|
|
313
|
+
if (expectedHash !== void 0 && !/^[a-f0-9]{64}$/i.test(expectedHash)) throw new ValidationError("expectedSha256 must be a SHA-256 digest");
|
|
314
|
+
const maxBytes = options.maxBytes ?? Number.MAX_SAFE_INTEGER;
|
|
315
|
+
if (options.expectedSize !== void 0 && options.expectedSize > maxBytes) throw new ValidationError("expectedSize exceeds download maxBytes");
|
|
316
|
+
options.signal?.throwIfAborted();
|
|
317
|
+
const response = await request(options.signal);
|
|
318
|
+
const reader = response.body?.getReader();
|
|
319
|
+
const abort = () => {
|
|
320
|
+
reader?.cancel(options.signal?.reason).catch(() => {});
|
|
321
|
+
};
|
|
322
|
+
options.signal?.addEventListener("abort", abort, { once: true });
|
|
323
|
+
let directory;
|
|
324
|
+
let file;
|
|
325
|
+
const fs = await import("node:fs/promises");
|
|
326
|
+
try {
|
|
327
|
+
options.signal?.throwIfAborted();
|
|
328
|
+
const length = response.headers.get("content-length");
|
|
329
|
+
const totalBytes = length === null ? void 0 : Number(length);
|
|
330
|
+
if (length !== null && (!/^\d+$/.test(length) || !Number.isSafeInteger(totalBytes))) throw new Error("Download returned an invalid content-length");
|
|
331
|
+
if (totalBytes !== void 0 && totalBytes > maxBytes) throw new Error("Download exceeds maxBytes");
|
|
332
|
+
if (options.expectedSize !== void 0 && totalBytes !== void 0 && totalBytes !== options.expectedSize) throw new Error("Download size does not match expectedSize");
|
|
333
|
+
const path = await import("node:path");
|
|
334
|
+
const { createHash } = await import("node:crypto");
|
|
335
|
+
await fs.mkdir(path.dirname(localPath), { recursive: true });
|
|
336
|
+
directory = await fs.mkdtemp(path.join(path.dirname(localPath), ".sandbox-download-"));
|
|
337
|
+
const temporaryPath = path.join(directory, "content");
|
|
338
|
+
file = await fs.open(temporaryPath, "wx", 384);
|
|
339
|
+
const hash = createHash("sha256");
|
|
340
|
+
let sizeBytes = 0;
|
|
341
|
+
if (totalBytes !== void 0 && totalBytes > 0) options.onProgress?.({
|
|
342
|
+
bytesDownloaded: 0,
|
|
343
|
+
totalBytes,
|
|
344
|
+
percentage: 0
|
|
345
|
+
});
|
|
346
|
+
for (;;) {
|
|
347
|
+
options.signal?.throwIfAborted();
|
|
348
|
+
const chunk = await reader?.read();
|
|
349
|
+
options.signal?.throwIfAborted();
|
|
350
|
+
if (!chunk || chunk.done) break;
|
|
351
|
+
sizeBytes += chunk.value.byteLength;
|
|
352
|
+
if (sizeBytes > maxBytes) throw new Error("Download exceeds maxBytes");
|
|
353
|
+
if (options.expectedSize !== void 0 && sizeBytes > options.expectedSize) throw new Error("Download size does not match expectedSize");
|
|
354
|
+
hash.update(chunk.value);
|
|
355
|
+
await file.writeFile(chunk.value);
|
|
356
|
+
if (totalBytes !== void 0 && sizeBytes < totalBytes) options.onProgress?.({
|
|
357
|
+
bytesDownloaded: sizeBytes,
|
|
358
|
+
totalBytes,
|
|
359
|
+
percentage: sizeBytes / totalBytes * 100
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
if (totalBytes !== void 0 && sizeBytes !== totalBytes || options.expectedSize !== void 0 && sizeBytes !== options.expectedSize) throw new Error("Download was truncated or its size changed");
|
|
363
|
+
const sha256 = hash.digest("hex");
|
|
364
|
+
if (expectedHash !== void 0 && sha256 !== expectedHash.toLowerCase()) throw new Error("Download SHA-256 does not match expectedSha256");
|
|
365
|
+
await file.close();
|
|
366
|
+
file = void 0;
|
|
367
|
+
options.signal?.throwIfAborted();
|
|
368
|
+
if (options.overwrite === false) await fs.link(temporaryPath, localPath);
|
|
369
|
+
else await fs.rename(temporaryPath, localPath);
|
|
370
|
+
options.onProgress?.({
|
|
371
|
+
bytesDownloaded: sizeBytes,
|
|
372
|
+
totalBytes: sizeBytes,
|
|
373
|
+
percentage: 100
|
|
374
|
+
});
|
|
375
|
+
return {
|
|
376
|
+
sizeBytes,
|
|
377
|
+
sha256
|
|
378
|
+
};
|
|
379
|
+
} finally {
|
|
380
|
+
options.signal?.removeEventListener("abort", abort);
|
|
381
|
+
await reader?.cancel().catch(() => {});
|
|
382
|
+
reader?.releaseLock();
|
|
383
|
+
await file?.close();
|
|
384
|
+
if (directory !== void 0) await fs.rm(directory, {
|
|
385
|
+
recursive: true,
|
|
386
|
+
force: true
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
//#endregion
|
|
305
391
|
//#region src/managed-process.ts
|
|
306
392
|
var ManagedProcessClient = class {
|
|
307
393
|
constructor(request, environmentId) {
|
|
@@ -4837,6 +4923,7 @@ var SandboxInstance = class SandboxInstance {
|
|
|
4837
4923
|
get fs() {
|
|
4838
4924
|
return {
|
|
4839
4925
|
supportsWriteMode: true,
|
|
4926
|
+
supportsBoundedDownload: true,
|
|
4840
4927
|
read: (path) => this.read(path),
|
|
4841
4928
|
readBatch: (paths, options) => this.fsReadBatch(paths, options),
|
|
4842
4929
|
tree: (path, options) => this.fsTree(path, options),
|
|
@@ -4895,29 +4982,18 @@ var SandboxInstance = class SandboxInstance {
|
|
|
4895
4982
|
return uploadChunked({ fetch: (path, init) => this.runtimeFetch(path, init) }, remotePath, data, options);
|
|
4896
4983
|
}
|
|
4897
4984
|
async fsDownload(remotePath, localPath, options) {
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
bytesDownloaded: 0,
|
|
4911
|
-
totalBytes,
|
|
4912
|
-
percentage: 0
|
|
4913
|
-
});
|
|
4914
|
-
const buffer = await response.arrayBuffer();
|
|
4915
|
-
await fs.writeFile(localPath, Buffer.from(buffer));
|
|
4916
|
-
if (options?.onProgress) options.onProgress({
|
|
4917
|
-
bytesDownloaded: buffer.byteLength,
|
|
4918
|
-
totalBytes: buffer.byteLength,
|
|
4919
|
-
percentage: 100
|
|
4920
|
-
});
|
|
4985
|
+
return downloadFile(async (signal) => {
|
|
4986
|
+
await this.ensureRunning();
|
|
4987
|
+
const response = await this.runtimeFetch(runtimeFilesystemPath("/fs/download", remotePath), {
|
|
4988
|
+
method: "GET",
|
|
4989
|
+
signal
|
|
4990
|
+
});
|
|
4991
|
+
if (!response.ok) {
|
|
4992
|
+
const body = await response.text();
|
|
4993
|
+
throw parseErrorResponse(response.status, body, void 0, response.headers);
|
|
4994
|
+
}
|
|
4995
|
+
return response;
|
|
4996
|
+
}, localPath, options);
|
|
4921
4997
|
}
|
|
4922
4998
|
async fsUploadDir(localDir, remoteDir) {
|
|
4923
4999
|
await this.ensureRunning();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { a as TerminalStreamReconnectAuthority, c as MintScopedTokenOptions, h as TerminalReadyInfo, l as ScopedToken, r as TerminalStreamHandlers, t as TerminalStream } from "./terminal-stream-C9jxoB07.js";
|
|
2
2
|
import { f as InteractiveAttachOptions, g as InteractiveSessionStatus, h as InteractiveRequestOptions, m as InteractiveControlClaimOptions, p as InteractiveControlClaimAcknowledgement } from "./browser-interactive-control-controller-C2qVGzQz.js";
|
|
3
3
|
import { r as InteractiveAttachRequest } from "./interactive-controller-Dghv9yMk.js";
|
|
4
|
-
import { F as SandboxLines } from "./lines-
|
|
5
|
-
import { A as CommitTaskSessionOptions, Aa as
|
|
4
|
+
import { F as SandboxLines } from "./lines-T2D6xHHx.js";
|
|
5
|
+
import { $i as SnapshotDeleteAcknowledgement, A as CommitTaskSessionOptions, Aa as WriteFileOptions, Ai as SandboxTraceOptions, Bi as SessionEventStreamOptions, C as BranchOptions, Cn as ListMessagesOptions, Cr as SandboxDeleteAcknowledgement, D as CodeExecutionResult, Da as WaitForOptions, Di as SandboxTraceBundle, Dr as SandboxEvent, E as CodeExecutionOptions, Ei as SandboxTerminals, Et as FileSystem, Gi as SessionInfo, H as CreateTaskSessionOptions, Hn as ProcessManager, Ii as SendSessionMessageOptions, In as PreviewLinkManager, Ji as SessionMessage, Jn as PromptResult, Ki as SessionInterruptOptions, Kn as PromptInputPart, Li as SendSessionMessageRequest, M as ConversationTurnOptions, Ma as WriteManyOptions, Mi as SearchMatch, Mt as FileWriteResult, N as ConversationTurnResult, Ni as SearchOptions, O as CodeLanguage, Oa as WaitForRolloutOptions, Pn as PermissionsManager, Q as DispatchedSession, Qr as SandboxFleetTraceBundle, Qt as ForkLookupOptions, Ri as SentSessionMessage, Sa as TurnDriveResult, Sn as JsonValue, Sr as SandboxCreateReceipt, V as CreateSessionOptions, Vi as SessionExecutionInfo, Wi as SessionForkOptions, Xn as ProvisionResult, Xt as ForkCounts, Yi as SessionMessageAdmission, Yn as ProvisionEvent, Z as DispatchPromptOptions, Zi as SessionResultOptions, Zt as ForkIdempotency, _a as TeeAttestationResponse, _i as SandboxShape, _n as IntelligenceReport, _r as SSHCommandDescriptor, an as GitStatus, bi as SandboxStatus, br as SandboxConnection, ci as SandboxInfo, cr as RestoreSnapshotOptions, d as BackendConfig, da as TaskSessionCommitResult, dn as GpuLeaseManager, fr as RolloutOptions, gi as SandboxRuntimeHealth, gn as InstalledTool, gt as EventStreamOptions, ha as TeeAttestationOptions, hi as SandboxRuntimeCapabilities, ia as SnapshotResult, in as GitDiff, it as DriverInfo, j as CompletedTurnResult, ja as WriteManyFile, jn as NetworkManager, ka as WorkspaceOperationLookup, lr as ResumeOptions, mr as RolloutStartResult, na as SnapshotInfo, nn as GitCommit, nt as DriveTurnOptions, oa as StartupDiagnostics, on as GpuLease, ot as DurablePlan, p as BackendManager, pa as TaskSessionInfo, pi as SandboxResourceUsage, pt as EgressManager, qi as SessionListOptions, qn as PromptOptions, ra as SnapshotOptions, st as DurablePlanDecisionResult, tn as GitBranch, ua as TaskSessionChanges, ui as SandboxPortBinding, ur as Rollout, vn as IntelligenceReportBudget, vr as SSHCredentials, vt as ExecOptions, wr as SandboxDeleteOptions, xi as SandboxTerminalAttachOptions, xn as IntelligenceReportWindow, ya as TeePublicKeyResponse, yn as IntelligenceReportCompareTo, yt as ExecResult } from "./types-C9w6MdZB.js";
|
|
6
6
|
import { AgentInteractiveSessionAttach, AgentInteractiveSessionControlClaim, AgentInteractiveSessionControlClaimAcknowledgement, AgentInteractiveSessionControlClaimRequest, AgentInteractiveSessionPromptAcknowledgement, AgentInteractiveSessionPromptCommand, AgentInteractiveSessionRef, AgentInteractiveSessionStart, AgentInteractiveSessionStopAcknowledgement, AgentInteractiveSessionStopCommand, AgentInteractiveTerminalSession, AgentInteractiveTerminalSession as AgentInteractiveTerminalSession$1, AgentRunCancellationAcknowledgement, AgentRunCancellationRequest, InteractionAcknowledgement, InteractionData, InteractionRequest, InteractionResponseCommand, TerminalOutputEvent, TerminalReplayWindow, agentInteractiveSessionPromptRequestDigest } from "@tangle-network/agent-interface";
|
|
7
7
|
import { z } from "zod";
|
|
8
8
|
|
package/dist/tangle/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { AgentSandboxBlueprintAbi, ITangleJobsAbi, JOB_SANDBOX_CREATE, JOB_SANDBOX_DELETE, JsonResponseParamTypes, SandboxCreateParamTypes, SandboxCreateResponseParamTypes, SandboxIdParamTypes, TANGLE_CHAIN_ID, TANGLE_JOBS_CONTRACT, TangleSandboxClient, TangleSandboxClientConfig };
|
|
1
|
+
import { _ as SandboxIdParamTypes, a as SignMessage, c as JOB_SANDBOX_DELETE, d as TangleSandboxClientConfig, f as AgentSandboxBlueprintAbi, g as SandboxCreateResponseParamTypes, h as SandboxCreateParamTypes, i as OperatorSessionToken, l as TANGLE_CHAIN_ID, m as JsonResponseParamTypes, n as OperatorSession, o as TangleSandboxClient, p as ITangleJobsAbi, r as OperatorSessionError, s as JOB_SANDBOX_CREATE, t as OperatorChallenge, u as TANGLE_JOBS_CONTRACT } from "../index-DGuTeptP.js";
|
|
2
|
+
export { AgentSandboxBlueprintAbi, ITangleJobsAbi, JOB_SANDBOX_CREATE, JOB_SANDBOX_DELETE, JsonResponseParamTypes, OperatorChallenge, OperatorSession, OperatorSessionError, OperatorSessionToken, SandboxCreateParamTypes, SandboxCreateResponseParamTypes, SandboxIdParamTypes, SignMessage, TANGLE_CHAIN_ID, TANGLE_JOBS_CONTRACT, TangleSandboxClient, TangleSandboxClientConfig };
|
package/dist/tangle/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { AgentSandboxBlueprintAbi, ITangleJobsAbi, JOB_SANDBOX_CREATE, JOB_SANDBOX_DELETE, JsonResponseParamTypes, SandboxCreateParamTypes, SandboxCreateResponseParamTypes, SandboxIdParamTypes, TANGLE_CHAIN_ID, TANGLE_JOBS_CONTRACT, TangleSandboxClient };
|
|
1
|
+
import { a as JOB_SANDBOX_DELETE, c as AgentSandboxBlueprintAbi, d as SandboxCreateParamTypes, f as SandboxCreateResponseParamTypes, i as JOB_SANDBOX_CREATE, l as ITangleJobsAbi, n as OperatorSession, o as TANGLE_CHAIN_ID, p as SandboxIdParamTypes, r as OperatorSessionError, s as TANGLE_JOBS_CONTRACT, t as TangleSandboxClient, u as JsonResponseParamTypes } from "../tangle-SNShua9T.js";
|
|
2
|
+
export { AgentSandboxBlueprintAbi, ITangleJobsAbi, JOB_SANDBOX_CREATE, JOB_SANDBOX_DELETE, JsonResponseParamTypes, OperatorSession, OperatorSessionError, SandboxCreateParamTypes, SandboxCreateResponseParamTypes, SandboxIdParamTypes, TANGLE_CHAIN_ID, TANGLE_JOBS_CONTRACT, TangleSandboxClient };
|