@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.
Files changed (77) hide show
  1. package/dist/agent/index.d.ts +4 -4
  2. package/dist/agent/index.js +5 -5
  3. package/dist/agent/preview.d.ts +1 -1
  4. package/dist/agent/preview.js +3 -3
  5. package/dist/{agent-run-outcome-6RpFdvyP.d.ts → agent-run-outcome-DSW47DnU.d.ts} +2 -2
  6. package/dist/{api-request-B7cnX489.js → api-request-DNrodWdz.js} +1 -1
  7. package/dist/auth/index.d.ts +2 -2
  8. package/dist/auth/index.js +2 -2
  9. package/dist/{browser-interactive-control-controller-BRz2PPTQ.d.ts → browser-interactive-control-controller-CLxkpYNV.d.ts} +1 -1
  10. package/dist/{browser-interactive-control-controller-CI-G-lan.js → browser-interactive-control-controller-l4Yqgoug.js} +2 -2
  11. package/dist/{chunked-upload-BHRGMfDz.js → chunked-upload-CyP-FOeZ.js} +1 -1
  12. package/dist/{chunked-upload-file-BMeDaILU.js → chunked-upload-file-Dr6i6G5b.js} +2 -2
  13. package/dist/{cli-auth-bundle-BDGLGvMu-BM8TG3ms.js → cli-auth-bundle-BDGLGvMu-BXdVAPNF.js} +1 -1
  14. package/dist/cli-auth-bundle-nPm8yuKO.js +2 -0
  15. package/dist/{client-CDz5Wgc0.js → client-BSK8I_4r.js} +11 -11
  16. package/dist/{client-uV-nZY3y.d.ts → client-BdoEjuk9.d.ts} +6 -5
  17. package/dist/collaboration/index.d.ts +1 -1
  18. package/dist/collaboration/index.js +1 -1
  19. package/dist/{collaboration-C1jO3_Pp.js → collaboration-CX_XvFZZ.js} +1 -1
  20. package/dist/{core-CpQI6Yqe.js → core-DEFF0nLW.js} +6 -6
  21. package/dist/core.d.ts +6 -6
  22. package/dist/core.js +5 -5
  23. package/dist/{direct-http2-B0ztwG7m.js → direct-http2-Bojg02xf.js} +1 -1
  24. package/dist/{errors-ystNl7Ae.js → errors-BfR-fBvN.js} +1 -1
  25. package/dist/file-download-CICuFwGb.js +178 -0
  26. package/dist/harness-Cgp9jduT.js +363 -0
  27. package/dist/{index-BejHM6F8.d.ts → index-CE4JMgzA.d.ts} +6 -6
  28. package/dist/index.d.ts +11 -11
  29. package/dist/index.js +12 -11
  30. package/dist/intelligence/index.d.ts +3 -1
  31. package/dist/intelligence/index.js +25 -23
  32. package/dist/interactive-control.d.ts +1 -1
  33. package/dist/interactive-control.js +1 -1
  34. package/dist/{interactive-controller-CM1FJ0gp.d.ts → interactive-controller-B8mGHsJz.d.ts} +3 -3
  35. package/dist/{interactive-controller-BzY0se5n.js → interactive-controller-DRWdHdgK.js} +7 -7
  36. package/dist/lib/prepared-evidence.js +1 -1
  37. package/dist/lib/prepared-process.js +1 -1
  38. package/dist/{lines-Dh-39kUV.d.ts → lines-Dc42Gr39.d.ts} +1 -1
  39. package/dist/{lines-DF4g3X3I.js → lines-DlLR4pHq.js} +1 -1
  40. package/dist/lines.d.ts +1 -1
  41. package/dist/lines.js +1 -1
  42. package/dist/{local-cli-auth-D-r9JSUk.js → local-cli-auth-CI2d1Pdh.js} +1 -1
  43. package/dist/{mcp-local-B7o_k_Ll.js → mcp-local-tBlLJqTb.js} +1 -1
  44. package/dist/{prepared-evidence-DBSU--pB.js → prepared-evidence-r46MdJM9.js} +1 -1
  45. package/dist/{prepared-process-GzQXVsX8.js → prepared-process-C-rwZPIZ.js} +1 -1
  46. package/dist/{preview-BtbrzU_4.d.ts → preview-C7nHXam2.d.ts} +3 -3
  47. package/dist/{profile-schema-BD1nkqBw.js → profile-schema-nys6Qejd.js} +1 -1
  48. package/dist/{public-templates-Zec8CB3Y.d.ts → public-templates-DA4_Hn6B.d.ts} +2 -2
  49. package/dist/public-templates.d.ts +1 -1
  50. package/dist/public-templates.js +1 -1
  51. package/dist/{raw-evidence-archive-OHRixF4L.js → raw-evidence-archive-BOXTejc2.js} +11 -31
  52. package/dist/runtime.d.ts +5 -5
  53. package/dist/runtime.js +5 -5
  54. package/dist/{sandbox-NSVkjLQo.js → sandbox-CIfbsytC.js} +22 -205
  55. package/dist/{secp256k1-BGtA1PsN.js → secp256k1-CZWrpqxW.js} +1 -1
  56. package/dist/select-seat-command.d.ts +1 -1
  57. package/dist/select-seat-command.js +1 -1
  58. package/dist/session-gateway/index.js +3 -3
  59. package/dist/{harness-B63wL8RZ.js → sha2-vu4U-x2L.js} +23 -363
  60. package/dist/tangle/index.d.ts +1 -1
  61. package/dist/tangle/index.js +1 -1
  62. package/dist/{tangle-QjuaxjRc.js → tangle-bYg24n7e.js} +4 -4
  63. package/dist/{types-BA5GRheq.d.ts → types-BVyyOVyf.d.ts} +2 -2
  64. package/package.json +6 -5
  65. package/dist/cli-auth-bundle-DdAKxGZF.js +0 -2
  66. /package/dist/{abort-signal-JVaAyNMP.js → abort-signal-CDxyloxz.js} +0 -0
  67. /package/dist/{cli-auth-bundle-DMbZ1E7W.d.ts → cli-auth-bundle-COQ25k3d.d.ts} +0 -0
  68. /package/dist/{index-DnZdhFs2.d.ts → index-Dqcr9p97.d.ts} +0 -0
  69. /package/dist/{index-rbeL2Rct.d.ts → index-Dslyq85a.d.ts} +0 -0
  70. /package/dist/{keep-alive-fetch--8twRp99.js → keep-alive-fetch-BbSFbRCd.js} +0 -0
  71. /package/dist/{preview-operations-D2fXB_dc.js → preview-operations-BvgwYaoL.js} +0 -0
  72. /package/dist/{response-rewrap-B75N59JT.js → response-rewrap-CpNkboDX.js} +0 -0
  73. /package/dist/{retry-after-header-DrbSlyKY.js → retry-after-header-DUdCC0KJ.js} +0 -0
  74. /package/dist/{sidecar-proxy-error-DORW8_mD.js → sidecar-proxy-error-5DpLmHeN.js} +0 -0
  75. /package/dist/{sse-parser-BUIKfYAd.js → sse-parser-DrI47LyG.js} +0 -0
  76. /package/dist/{terminal-stream-types-CIgaXUM7.d.ts → terminal-stream-types-8-sAl2J0.d.ts} +0 -0
  77. /package/dist/{utils-CoawKwX_.js → utils-vaFoyyiO.js} +0 -0
@@ -1,5 +1,6 @@
1
- import { T as TimeoutError, h as NetworkError, n as parseErrorResponse } from "../errors-ystNl7Ae.js";
2
- import { t as fetchSandboxApi } from "../api-request-B7cnX489.js";
1
+ import { T as TimeoutError, h as NetworkError, n as parseErrorResponse } from "../errors-BfR-fBvN.js";
2
+ import { t as fetchSandboxApi } from "../api-request-DNrodWdz.js";
3
+ import { n as verifyDownload } from "../file-download-CICuFwGb.js";
3
4
  //#region src/intelligence/index.ts
4
5
  /**
5
6
  * `@tangle-network/sandbox/intelligence` — browser-safe typed client for the
@@ -82,16 +83,18 @@ function createIntelligenceClient(config) {
82
83
  endpoint: path,
83
84
  origin: "sandbox-api"
84
85
  })
85
- }, path, { headers: { Accept: "application/json" } }, { read });
86
+ }, path, { headers: { Accept: "application/json" } }, { read: async (response) => {
87
+ if (!response.ok) throw parseErrorResponse(response.status, await response.text(), {
88
+ method: "GET",
89
+ path
90
+ }, response.headers);
91
+ return read(response);
92
+ } });
86
93
  }
87
94
  /** GET a JSON route, raising the SDK's typed error on a non-2xx response. */
88
95
  function getJson(path) {
89
96
  return request(path, async (response) => {
90
97
  const text = await response.text();
91
- if (!response.ok) throw parseErrorResponse(response.status, text, {
92
- method: "GET",
93
- path
94
- }, response.headers);
95
98
  return JSON.parse(text);
96
99
  });
97
100
  }
@@ -117,13 +120,6 @@ function createIntelligenceClient(config) {
117
120
  async function exportTraceSpansNdjson(traceId) {
118
121
  const path = `/v1/traces/${encodeURIComponent(traceId)}/spans.ndjson`;
119
122
  const response = await request(path, async (served) => served);
120
- if (!response.ok) {
121
- const body = await response.text();
122
- throw parseErrorResponse(response.status, body, {
123
- method: "GET",
124
- path
125
- }, response.headers);
126
- }
127
123
  if (!response.body) throw new NetworkError("Intelligence API returned an NDJSON export with no body stream", {
128
124
  endpoint: path,
129
125
  origin: "sandbox-api"
@@ -168,22 +164,28 @@ function createIntelligenceClient(config) {
168
164
  }
169
165
  }
170
166
  async function downloadRunSessionFile(runId, file, options) {
167
+ const { storedSha256, storedBytes, etag } = file;
168
+ if (file.runId !== void 0 && file.runId !== runId) throw new Error("Run-session descriptor belongs to another run");
171
169
  const search = new URLSearchParams({
172
170
  sandboxId: file.sandboxId,
173
171
  sessionId: file.sessionId,
174
172
  path: file.path
175
173
  });
176
- const path = `/v1/run-sessions/${encodeURIComponent(runId)}/content?${search}`;
177
- return request(path, async (response) => {
178
- if (!response.ok) throw parseErrorResponse(response.status, await response.text(), {
179
- method: "GET",
180
- path
181
- }, response.headers);
182
- if (options?.stream) {
174
+ return request(`/v1/run-sessions/${encodeURIComponent(runId)}/content?${search}`, async (response) => {
175
+ try {
176
+ const digest = response.headers.get("x-stored-sha256");
177
+ if (!digest || !/^sha256:[a-f0-9]{64}$/.test(digest) || storedSha256 !== void 0 && storedSha256 !== digest || etag !== void 0 && etag !== response.headers.get("etag") || storedBytes === null) throw new Error("Run-session download does not match its selected revision");
183
178
  if (!response.body) throw new NetworkError("Run-session download returned no source body");
184
- return response.body;
179
+ const stream = verifyDownload(response, {
180
+ expectedSha256: digest,
181
+ expectedSize: storedBytes,
182
+ signal: transport.signal
183
+ });
184
+ return options?.stream ? stream : new Uint8Array(await new Response(stream).arrayBuffer());
185
+ } catch (error) {
186
+ if (!response.body?.locked) await response.body?.cancel(error).catch(() => {});
187
+ throw error;
185
188
  }
186
- return new Uint8Array(await response.arrayBuffer());
187
189
  });
188
190
  }
189
191
  async function listSessions(params = {}) {
@@ -1,2 +1,2 @@
1
- import { c as InteractiveSessionIdentity, l as InteractiveSessionNotRunningError, n as BrowserInteractiveSessionControlControllerOptions, r as browserInteractiveControlHolderId, t as BrowserInteractiveSessionControlController } from "./browser-interactive-control-controller-BRz2PPTQ.js";
1
+ import { c as InteractiveSessionIdentity, l as InteractiveSessionNotRunningError, n as BrowserInteractiveSessionControlControllerOptions, r as browserInteractiveControlHolderId, t as BrowserInteractiveSessionControlController } from "./browser-interactive-control-controller-CLxkpYNV.js";
2
2
  export { BrowserInteractiveSessionControlController, type BrowserInteractiveSessionControlControllerOptions, type InteractiveSessionIdentity, InteractiveSessionNotRunningError, browserInteractiveControlHolderId };
@@ -1,2 +1,2 @@
1
- import { n as browserInteractiveControlHolderId, s as InteractiveSessionNotRunningError, t as BrowserInteractiveSessionControlController } from "./browser-interactive-control-controller-CI-G-lan.js";
1
+ import { n as browserInteractiveControlHolderId, s as InteractiveSessionNotRunningError, t as BrowserInteractiveSessionControlController } from "./browser-interactive-control-controller-l4Yqgoug.js";
2
2
  export { BrowserInteractiveSessionControlController, InteractiveSessionNotRunningError, browserInteractiveControlHolderId };
@@ -1,6 +1,6 @@
1
- import { k as AgentInteractiveSessionRef, o as TerminalStreamReconnectAuthority, u as ScopedToken } from "./terminal-stream-types-CIgaXUM7.js";
2
- import { Cn as TerminalStream } from "./types-BA5GRheq.js";
3
- import { a as InteractiveSessionControlController, c as InteractiveSessionIdentity, f as InteractiveAttachOptions, g as InteractiveRequestOptions, n as BrowserInteractiveSessionControlControllerOptions, o as InteractiveSessionControlControllerOptions, s as InteractiveSessionControlTransport } from "./browser-interactive-control-controller-BRz2PPTQ.js";
1
+ import { k as AgentInteractiveSessionRef, o as TerminalStreamReconnectAuthority, u as ScopedToken } from "./terminal-stream-types-8-sAl2J0.js";
2
+ import { Cn as TerminalStream } from "./types-BVyyOVyf.js";
3
+ import { a as InteractiveSessionControlController, c as InteractiveSessionIdentity, f as InteractiveAttachOptions, g as InteractiveRequestOptions, n as BrowserInteractiveSessionControlControllerOptions, o as InteractiveSessionControlControllerOptions, s as InteractiveSessionControlTransport } from "./browser-interactive-control-controller-CLxkpYNV.js";
4
4
 
5
5
  //#region src/interactive-controller.d.ts
6
6
  /** The request fields supplied by an attach caller before control is claimed. */
@@ -1,10 +1,10 @@
1
- import { E as boundedJsonSchema, o as canonicalCandidateDigest, w as boundedIdentifierSchema } from "./harness-B63wL8RZ.js";
2
- import { B as PlanContinuationSchema, D as agentInteractiveSessionControlClaimMatchesRef, P as AgentExactRunControlRefSchema, R as AgentExecutionOutcomeSchema, U as InteractionRequestSchema, c as assertInteractiveSessionRef, h as AgentInteractiveSessionAttachSchema, i as createBrowserInteractiveSessionControlTransport, o as InteractiveSessionControlController, r as browserInteractiveTerminalEndpoint, v as AgentInteractiveSessionControlClaimSchema, x as AgentInteractiveSessionRefSchema, z as DurablePlanSchema } from "./browser-interactive-control-controller-CI-G-lan.js";
3
- import { r as agentProfileSchema } from "./profile-schema-BD1nkqBw.js";
4
- import { E as ValidationError, S as ServerError, h as NetworkError, r as parseResponseError, s as CapabilityError, t as TerminalStreamError, x as SandboxError } from "./errors-ystNl7Ae.js";
5
- import { n as combineAbortSignals, t as awaitWithAbort } from "./abort-signal-JVaAyNMP.js";
6
- import { t as parseSSEStream } from "./sse-parser-BUIKfYAd.js";
7
- import { s as uploadChunked } from "./chunked-upload-BHRGMfDz.js";
1
+ import { C as boundedIdentifierSchema, T as boundedJsonSchema, o as canonicalCandidateDigest } from "./harness-Cgp9jduT.js";
2
+ import { B as PlanContinuationSchema, D as agentInteractiveSessionControlClaimMatchesRef, P as AgentExactRunControlRefSchema, R as AgentExecutionOutcomeSchema, U as InteractionRequestSchema, c as assertInteractiveSessionRef, h as AgentInteractiveSessionAttachSchema, i as createBrowserInteractiveSessionControlTransport, o as InteractiveSessionControlController, r as browserInteractiveTerminalEndpoint, v as AgentInteractiveSessionControlClaimSchema, x as AgentInteractiveSessionRefSchema, z as DurablePlanSchema } from "./browser-interactive-control-controller-l4Yqgoug.js";
3
+ import { r as agentProfileSchema } from "./profile-schema-nys6Qejd.js";
4
+ import { E as ValidationError, S as ServerError, h as NetworkError, r as parseResponseError, s as CapabilityError, t as TerminalStreamError, x as SandboxError } from "./errors-BfR-fBvN.js";
5
+ import { n as combineAbortSignals, t as awaitWithAbort } from "./abort-signal-CDxyloxz.js";
6
+ import { t as parseSSEStream } from "./sse-parser-DrI47LyG.js";
7
+ import { s as uploadChunked } from "./chunked-upload-CyP-FOeZ.js";
8
8
  import { z } from "zod";
9
9
  /** Stable declaration order; registry tests check the shipped spec composition. */
10
10
  const ALL_BACKEND_TYPES = Object.values({
@@ -1,2 +1,2 @@
1
- import { t as runPreparedEvidence } from "../prepared-evidence-DBSU--pB.js";
1
+ import { t as runPreparedEvidence } from "../prepared-evidence-r46MdJM9.js";
2
2
  export { runPreparedEvidence };
@@ -1,2 +1,2 @@
1
- import { n as withPreparedProcessCalls, t as runPreparedProcess } from "../prepared-process-GzQXVsX8.js";
1
+ import { n as withPreparedProcessCalls, t as runPreparedProcess } from "../prepared-process-C-rwZPIZ.js";
2
2
  export { runPreparedProcess, withPreparedProcessCalls };
@@ -1,4 +1,4 @@
1
- import { Tn as CreateSandboxOptions, ga as BackendConfig } from "./types-BA5GRheq.js";
1
+ import { Tn as CreateSandboxOptions, ga as BackendConfig } from "./types-BVyyOVyf.js";
2
2
 
3
3
  //#region src/line-application.d.ts
4
4
  /** Bounded callback request bytes after canonicalization, including JSON framing. */
@@ -1,4 +1,4 @@
1
- import { E as ValidationError, n as parseErrorResponse } from "./errors-ystNl7Ae.js";
1
+ import { E as ValidationError, n as parseErrorResponse } from "./errors-BfR-fBvN.js";
2
2
  //#region src/line-identity.ts
3
3
  /**
4
4
  * The instance key that serves one member: `keyPrefix` plus the first 32 hex
package/dist/lines.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { A as LineRespondAgent, B as LineVoiceOptions, C as LineMessage, D as LineReplyCode, E as LineReminderPreferences, F as LineSenderVerification, I as LineSenderVerificationStart, L as LineThread, M as LineRole, N as LineSendInput, O as LineReplyCodeInput, P as LineSendReceipt, R as LineTransport, S as LineMemberSpec, T as LineProvider, V as LinesHttpClient, _ as LineInstanceCreate, a as Line, b as LineMemberInstance, c as LineAllowanceSubject, d as LineAttachment, f as LineAttachmentReauthorization, g as LineInstanceAttachOptions, h as LineImage, i as profileChannelReference, j as LineRespondView, k as LineReplyGate, l as LineApplicationAttachOptions, m as LineFromConnectionInput, n as SandboxLines, o as LineAgentRolePolicy, p as LineExecutionKey, r as lineInstanceKey, s as LineAllowance, t as LinesClient, u as LineAttachOptions, v as LineLimits, w as LineNumberInventory, x as LineMemberPatch, y as LineMember, z as LineVoice } from "./lines-Dh-39kUV.js";
1
+ import { A as LineRespondAgent, B as LineVoiceOptions, C as LineMessage, D as LineReplyCode, E as LineReminderPreferences, F as LineSenderVerification, I as LineSenderVerificationStart, L as LineThread, M as LineRole, N as LineSendInput, O as LineReplyCodeInput, P as LineSendReceipt, R as LineTransport, S as LineMemberSpec, T as LineProvider, V as LinesHttpClient, _ as LineInstanceCreate, a as Line, b as LineMemberInstance, c as LineAllowanceSubject, d as LineAttachment, f as LineAttachmentReauthorization, g as LineInstanceAttachOptions, h as LineImage, i as profileChannelReference, j as LineRespondView, k as LineReplyGate, l as LineApplicationAttachOptions, m as LineFromConnectionInput, n as SandboxLines, o as LineAgentRolePolicy, p as LineExecutionKey, r as lineInstanceKey, s as LineAllowance, t as LinesClient, u as LineAttachOptions, v as LineLimits, w as LineNumberInventory, x as LineMemberPatch, y as LineMember, z as LineVoice } from "./lines-Dc42Gr39.js";
2
2
  export { Line, LineAgentRolePolicy, LineAllowance, LineAllowanceSubject, LineApplicationAttachOptions, LineAttachOptions, LineAttachment, LineAttachmentReauthorization, LineExecutionKey, LineFromConnectionInput, LineImage, LineInstanceAttachOptions, LineInstanceCreate, LineLimits, LineMember, LineMemberInstance, LineMemberPatch, LineMemberSpec, LineMessage, LineNumberInventory, LineProvider, LineReminderPreferences, LineReplyCode, LineReplyCodeInput, LineReplyGate, LineRespondAgent, LineRespondView, LineRole, LineSendInput, LineSendReceipt, LineSenderVerification, LineSenderVerificationStart, LineThread, LineTransport, LineVoice, LineVoiceOptions, LinesClient, LinesHttpClient, SandboxLines, lineInstanceKey, profileChannelReference };
package/dist/lines.js CHANGED
@@ -1,2 +1,2 @@
1
- import { i as profileChannelReference, n as SandboxLines, r as lineInstanceKey, t as LinesClient } from "./lines-DF4g3X3I.js";
1
+ import { i as profileChannelReference, n as SandboxLines, r as lineInstanceKey, t as LinesClient } from "./lines-DlLR4pHq.js";
2
2
  export { LinesClient, SandboxLines, lineInstanceKey, profileChannelReference };
@@ -1,4 +1,4 @@
1
- import { t as AUTH_BUNDLE_PATHS } from "./cli-auth-bundle-BDGLGvMu-BM8TG3ms.js";
1
+ import { t as AUTH_BUNDLE_PATHS } from "./cli-auth-bundle-BDGLGvMu-BXdVAPNF.js";
2
2
  import { existsSync, readFileSync } from "node:fs";
3
3
  import { basename, dirname, join } from "node:path";
4
4
  import { homedir } from "node:os";
@@ -1,4 +1,4 @@
1
- import { a as listAgentPreviews, i as getAgentPreview, o as publishAgentPreview, r as ensureAgentPreview, s as removeAgentPreview, t as AgentPreviewError } from "./preview-operations-D2fXB_dc.js";
1
+ import { a as listAgentPreviews, i as getAgentPreview, o as publishAgentPreview, r as ensureAgentPreview, s as removeAgentPreview, t as AgentPreviewError } from "./preview-operations-BvgwYaoL.js";
2
2
  import { createRequire } from "node:module";
3
3
  //#region \0rolldown/runtime.js
4
4
  var __defProp = Object.defineProperty;
@@ -1,4 +1,4 @@
1
- import { t as parseSandboxRetryAfterHeader } from "./retry-after-header-DrbSlyKY.js";
1
+ import { t as parseSandboxRetryAfterHeader } from "./retry-after-header-DUdCC0KJ.js";
2
2
  //#region src/lib/prepared-evidence.mjs
3
3
  async function receipt(response, idField) {
4
4
  const reader = response.body?.getReader();
@@ -1,4 +1,4 @@
1
- import { t as parseSandboxRetryAfterHeader } from "./retry-after-header-DrbSlyKY.js";
1
+ import { t as parseSandboxRetryAfterHeader } from "./retry-after-header-DUdCC0KJ.js";
2
2
  //#region src/lib/prepared-process.mjs
3
3
  /** Request and pause share one deadline, including independent cancellation cleanup. */
4
4
  function processRequests(request, deadline, signal) {
@@ -1,6 +1,6 @@
1
- import { O as SandboxInstance } from "./index-BejHM6F8.js";
2
- import { F as EnsureDevServerOptions, H as PreviewLinkInfo } from "./types-BA5GRheq.js";
3
- import { t as Sandbox } from "./client-uV-nZY3y.js";
1
+ import { O as SandboxInstance } from "./index-CE4JMgzA.js";
2
+ import { F as EnsureDevServerOptions, H as PreviewLinkInfo } from "./types-BVyyOVyf.js";
3
+ import { t as Sandbox } from "./client-BdoEjuk9.js";
4
4
 
5
5
  //#region src/agent/preview-operations.d.ts
6
6
  type AgentPreviewOptions = Pick<EnsureDevServerOptions, "sessionId" | "cwd"> & {
@@ -1,4 +1,4 @@
1
- import { a as agentCandidateSecretRefSchema, c as environmentNameSchema, d as isSafeExecutable, f as isSafeRelativePath, g as sha256DigestSchema, i as trainedModelIdForArtifact, k as isBoundedJsonMaterial, l as headerNameSchema, m as looksLikeCredential, n as REASONING_EFFORTS, o as canonicalCandidateDigest, p as isWellFormedUnicode, s as canonicalCandidateJson, t as harnessTypeSchema, v as CONTRACT_MAX_ARRAY_LENGTH, w as boundedIdentifierSchema, y as CONTRACT_MAX_JSON_NODES } from "./harness-B63wL8RZ.js";
1
+ import { C as boundedIdentifierSchema, O as isBoundedJsonMaterial, _ as CONTRACT_MAX_ARRAY_LENGTH, a as agentCandidateSecretRefSchema, c as environmentNameSchema, d as isSafeExecutable, f as isSafeRelativePath, g as sha256DigestSchema, i as trainedModelIdForArtifact, l as headerNameSchema, m as looksLikeCredential, n as REASONING_EFFORTS, o as canonicalCandidateDigest, p as isWellFormedUnicode, s as canonicalCandidateJson, t as harnessTypeSchema, v as CONTRACT_MAX_JSON_NODES } from "./harness-Cgp9jduT.js";
2
2
  import { z } from "zod";
3
3
  //#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.10.9/node_modules/@tangle-network/agent-interface/dist/profile-knowledge.js
4
4
  /** Immutable Hub generation identities, never aliases such as latest or a caller's scope. */
@@ -1,5 +1,5 @@
1
- import { bt as SandboxError } from "./terminal-stream-types-CIgaXUM7.js";
2
- import { Cr as PublishPublicTemplateVersionOptions, Sr as PublishPublicTemplateOptions, Xr as HttpClient, br as PublicTemplateInfo, xr as PublicTemplateVersionInfo } from "./types-BA5GRheq.js";
1
+ import { bt as SandboxError } from "./terminal-stream-types-8-sAl2J0.js";
2
+ import { Cr as PublishPublicTemplateVersionOptions, Sr as PublishPublicTemplateOptions, Xr as HttpClient, br as PublicTemplateInfo, xr as PublicTemplateVersionInfo } from "./types-BVyyOVyf.js";
3
3
  import { z } from "zod";
4
4
 
5
5
  //#region src/public-templates.d.ts
@@ -1,2 +1,2 @@
1
- import { a as PublicTemplatesClient, i as PublicTemplatePublishRequestOptions, n as PublicTemplatePublishError, r as PublicTemplatePublishJob, t as PublicTemplatePublishArtifact } from "./public-templates-Zec8CB3Y.js";
1
+ import { a as PublicTemplatesClient, i as PublicTemplatePublishRequestOptions, n as PublicTemplatePublishError, r as PublicTemplatePublishJob, t as PublicTemplatePublishArtifact } from "./public-templates-DA4_Hn6B.js";
2
2
  export { PublicTemplatePublishArtifact, PublicTemplatePublishError, PublicTemplatePublishJob, PublicTemplatePublishRequestOptions, PublicTemplatesClient };
@@ -1,4 +1,4 @@
1
- import { i as readResponseJson, x as SandboxError } from "./errors-ystNl7Ae.js";
1
+ import { i as readResponseJson, x as SandboxError } from "./errors-BfR-fBvN.js";
2
2
  import { z } from "zod";
3
3
  //#region src/public-templates.ts
4
4
  const publicationStatus = z.enum([
@@ -1,4 +1,5 @@
1
- import { t as runPreparedEvidence } from "./prepared-evidence-DBSU--pB.js";
1
+ import { n as verifyDownload } from "./file-download-CICuFwGb.js";
2
+ import { t as runPreparedEvidence } from "./prepared-evidence-r46MdJM9.js";
2
3
  import { z } from "zod";
3
4
  //#region src/lib/raw-evidence-archive.ts
4
5
  const digest = z.string().regex(/^sha256:[a-f0-9]{64}$/).transform((value) => `sha256:${value.slice(7)}`);
@@ -467,40 +468,19 @@ async function exportRawEvidenceDirectory(request, subject, targetDirectory, opt
467
468
  }
468
469
  /** Acquire bounded compressed bytes and verify the complete transfer before extraction. */
469
470
  async function downloadEvidenceArchive(response, archive, options) {
470
- const fs = await import("node:fs/promises");
471
- const { createHash } = await import("node:crypto");
472
- const file = await fs.open(archive, "wx", 384);
473
- const hash = createHash("sha256");
474
- let sizeBytes = 0;
475
- const reader = response.body?.getReader();
476
- const abort = () => {
477
- reader?.cancel(options.signal?.reason).catch(() => {});
478
- };
479
- options.signal?.addEventListener("abort", abort, { once: true });
480
- const maxArchiveBytes = options.maxArchiveBytes ?? Math.min(Number.MAX_SAFE_INTEGER, options.maxBytes + options.maxFiles * 2048 + 1024 * 1024);
471
+ const file = await (await import("node:fs/promises")).open(archive, "wx", 384);
472
+ let result;
481
473
  try {
482
- for (;;) {
483
- options.signal?.throwIfAborted();
484
- const chunk = await reader?.read();
485
- options.signal?.throwIfAborted();
486
- if (!chunk || chunk.done) break;
487
- sizeBytes += chunk.value.byteLength;
488
- if (sizeBytes > maxArchiveBytes) throw new Error("Evidence archive exceeds compressed byte limit");
489
- hash.update(chunk.value);
490
- await file.writeFile(chunk.value);
491
- }
474
+ await verifyDownload(response, {
475
+ signal: options.signal,
476
+ maxBytes: options.maxArchiveBytes ?? Math.min(Number.MAX_SAFE_INTEGER, options.maxBytes + options.maxFiles * 2048 + 1024 * 1024)
477
+ }, (value) => {
478
+ result = value;
479
+ }).pipeTo(new WritableStream({ write: (chunk) => file.writeFile(chunk) }));
480
+ return result;
492
481
  } finally {
493
- options.signal?.removeEventListener("abort", abort);
494
482
  await file.close();
495
- await reader?.cancel().catch(() => {});
496
- reader?.releaseLock();
497
483
  }
498
- const length = response.headers.get("content-length");
499
- if (length !== null && (!/^\d+$/.test(length) || Number(length) !== sizeBytes)) throw new Error("Evidence archive transfer was truncated");
500
- return {
501
- sizeBytes,
502
- sha256: hash.digest("hex")
503
- };
504
484
  }
505
485
  async function readBoundedResponse(response, max, signal) {
506
486
  const reader = response.body?.getReader();
package/dist/runtime.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { Ct as ServerError, Dt as TimeoutError, Ot as ValidationError, St as SandboxFailureDetail, _t as ProfileFileMountPathError, bt as SandboxError, gt as PartialFailureError, ht as NotFoundError, it as AuthError, mt as NetworkError, ot as CapabilityError, u as ScopedToken, ut as FileWriteConflictError, vt as QuotaError, wt as StateError, xt as SandboxErrorJson } from "./terminal-stream-types-CIgaXUM7.js";
2
- import { $i as SessionExecutionStatus, Bi as CreateSessionOptions, Cn as TerminalStream, Di as SandboxEvent, Fi as CommitTaskSessionOptions, Gi as ListMessagesOptions, Gn as ChunkedUploadResult, Ji as SendSessionMessageRequest, Qi as SessionExecutionInfo, Qn as FileReadBatchResult, Vi as CreateTaskSessionOptions, Wn as ChunkedUploadOptions, Yi as SentSessionMessage, Zi as SessionEventStreamOptions, Zn as FileReadBatchOptions, aa as SessionMessage, ar as FileTreeResult, cr as FileWriteResult, dn as SandboxTerminalCreateOptions, dr as RenameOptions, fa as TaskSessionInfo, fn as SandboxTerminalInfo, ir as FileTreeOptions, la as TaskSessionChanges, ln as SandboxRuntimeHealth, mn as SandboxTerminalRequestOptions, mr as WriteFileOptions, na as SessionInfo, oa as SessionMessageAdmission, on as SandboxPortBinding, or as FileUsageOptions, pn as SandboxTerminalManager, pr as UploadProgress, qi as SendSessionMessageOptions, sr as FileUsageResult, tr as FileRenameResult, ua as TaskSessionCommitResult } from "./types-BA5GRheq.js";
3
- import { c as InteractiveSessionIdentity, l as InteractiveSessionNotRunningError, r as browserInteractiveControlHolderId } from "./browser-interactive-control-controller-BRz2PPTQ.js";
4
- import { t as BrowserInteractiveSessionController } from "./interactive-controller-CM1FJ0gp.js";
5
- import { a as deriveAgentRunOutcome, i as deriveAgentResultOutcome, n as AgentRunOutcomeTracker, o as projectAgentTerminalRecord, r as createAgentRunOutcomeTracker, t as AgentRunOutcome } from "./agent-run-outcome-6RpFdvyP.js";
1
+ import { Ct as ServerError, Dt as TimeoutError, Ot as ValidationError, St as SandboxFailureDetail, _t as ProfileFileMountPathError, bt as SandboxError, gt as PartialFailureError, ht as NotFoundError, it as AuthError, mt as NetworkError, ot as CapabilityError, u as ScopedToken, ut as FileWriteConflictError, vt as QuotaError, wt as StateError, xt as SandboxErrorJson } from "./terminal-stream-types-8-sAl2J0.js";
2
+ import { $i as SessionExecutionStatus, Bi as CreateSessionOptions, Cn as TerminalStream, Di as SandboxEvent, Fi as CommitTaskSessionOptions, Gi as ListMessagesOptions, Gn as ChunkedUploadResult, Ji as SendSessionMessageRequest, Qi as SessionExecutionInfo, Qn as FileReadBatchResult, Vi as CreateTaskSessionOptions, Wn as ChunkedUploadOptions, Yi as SentSessionMessage, Zi as SessionEventStreamOptions, Zn as FileReadBatchOptions, aa as SessionMessage, ar as FileTreeResult, cr as FileWriteResult, dn as SandboxTerminalCreateOptions, dr as RenameOptions, fa as TaskSessionInfo, fn as SandboxTerminalInfo, ir as FileTreeOptions, la as TaskSessionChanges, ln as SandboxRuntimeHealth, mn as SandboxTerminalRequestOptions, mr as WriteFileOptions, na as SessionInfo, oa as SessionMessageAdmission, on as SandboxPortBinding, or as FileUsageOptions, pn as SandboxTerminalManager, pr as UploadProgress, qi as SendSessionMessageOptions, sr as FileUsageResult, tr as FileRenameResult, ua as TaskSessionCommitResult } from "./types-BVyyOVyf.js";
3
+ import { c as InteractiveSessionIdentity, l as InteractiveSessionNotRunningError, r as browserInteractiveControlHolderId } from "./browser-interactive-control-controller-CLxkpYNV.js";
4
+ import { t as BrowserInteractiveSessionController } from "./interactive-controller-B8mGHsJz.js";
5
+ import { a as deriveAgentRunOutcome, i as deriveAgentResultOutcome, n as AgentRunOutcomeTracker, o as projectAgentTerminalRecord, r as createAgentRunOutcomeTracker, t as AgentRunOutcome } from "./agent-run-outcome-DSW47DnU.js";
6
6
 
7
7
  //#region src/lib/chunked-upload.d.ts
8
8
  /** The transport a caller wires this module to — {@link SandboxInstance.runtimeFetch}
package/dist/runtime.js CHANGED
@@ -1,8 +1,8 @@
1
- import { B as projectAgentTerminalRecord, L as createAgentRunOutcomeTracker, R as deriveAgentResultOutcome, c as SandboxRuntimeApi, t as BrowserInteractiveSessionController, z as deriveAgentRunOutcome } from "./interactive-controller-BzY0se5n.js";
2
- import { n as browserInteractiveControlHolderId, s as InteractiveSessionNotRunningError } from "./browser-interactive-control-controller-CI-G-lan.js";
3
- import { C as StateError, E as ValidationError, S as ServerError, T as TimeoutError, _ as PartialFailureError, a as AuthError, d as FileWriteConflictError, g as NotFoundError, h as NetworkError, s as CapabilityError, v as ProfileFileMountPathError, x as SandboxError, y as QuotaError } from "./errors-ystNl7Ae.js";
4
- import { t as fetchSandboxApi } from "./api-request-B7cnX489.js";
5
- import { s as uploadChunked } from "./chunked-upload-BHRGMfDz.js";
1
+ import { B as projectAgentTerminalRecord, L as createAgentRunOutcomeTracker, R as deriveAgentResultOutcome, c as SandboxRuntimeApi, t as BrowserInteractiveSessionController, z as deriveAgentRunOutcome } from "./interactive-controller-DRWdHdgK.js";
2
+ import { n as browserInteractiveControlHolderId, s as InteractiveSessionNotRunningError } from "./browser-interactive-control-controller-l4Yqgoug.js";
3
+ import { C as StateError, E as ValidationError, S as ServerError, T as TimeoutError, _ as PartialFailureError, a as AuthError, d as FileWriteConflictError, g as NotFoundError, h as NetworkError, s as CapabilityError, v as ProfileFileMountPathError, x as SandboxError, y as QuotaError } from "./errors-BfR-fBvN.js";
4
+ import { t as fetchSandboxApi } from "./api-request-DNrodWdz.js";
5
+ import { s as uploadChunked } from "./chunked-upload-CyP-FOeZ.js";
6
6
  //#region src/runtime-client.ts
7
7
  const DEFAULT_RUNTIME_TIMEOUT_MS = 3e4;
8
8
  function requireToken(token) {