@tangle-network/sandbox 0.60.88 → 0.60.90

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 (50) hide show
  1. package/dist/agent/index.d.ts +4 -4
  2. package/dist/agent/index.js +4 -4
  3. package/dist/agent/preview.d.ts +1 -1
  4. package/dist/agent/preview.js +2 -2
  5. package/dist/{agent-run-outcome-CIlpTZNU.d.ts → agent-run-outcome-KxjDXZW-.d.ts} +1 -1
  6. package/dist/auth/index.d.ts +2 -2
  7. package/dist/auth/index.js +1 -1
  8. package/dist/{browser-interactive-control-controller-Cu6J3TUP.d.ts → browser-interactive-control-controller-B6sySQFu.d.ts} +1 -1
  9. package/dist/{chunked-upload-file-DnsHEjg0.js → chunked-upload-file-RaMaNFN_.js} +1 -1
  10. package/dist/{client-D9OomGmE.js → client-BJ-xYm0s.js} +5 -4
  11. package/dist/{client-CUxfURSp.d.ts → client-BZnfyj0K.d.ts} +5 -5
  12. package/dist/collaboration/index.d.ts +1 -1
  13. package/dist/collaboration/index.js +1 -1
  14. package/dist/core.d.ts +6 -6
  15. package/dist/core.js +3 -3
  16. package/dist/direct-http2-D8mo1ePx.js +97 -0
  17. package/dist/{errors-B7i6lxHc.d.ts → errors-Fv8leP33.d.ts} +3 -3
  18. package/dist/{index-BFW3FzJG.d.ts → index-LO5315tT.d.ts} +2 -2
  19. package/dist/index.d.ts +12 -12
  20. package/dist/index.js +6 -6
  21. package/dist/interactive-control.d.ts +1 -1
  22. package/dist/{interactive-controller-CPtHnjrz.js → interactive-controller-Bize8Sca.js} +1 -1
  23. package/dist/keep-alive-fetch-qPVvvkgJ.js +239 -0
  24. package/dist/{lines-DosoSbnD.d.ts → lines-BgVaTJBw.d.ts} +1 -1
  25. package/dist/lines.d.ts +1 -1
  26. package/dist/{local-cli-auth-CBV7Vjk5.js → local-cli-auth-Do4Kc2jL.js} +1 -1
  27. package/dist/{managed-process-CP-geV3k.d.ts → managed-process-BoQAK9cz.d.ts} +1 -1
  28. package/dist/{mcp-local-DjryqUiY.js → mcp-local-BYHcA72Z.js} +1 -1
  29. package/dist/{preview-B-h5p2LF.d.ts → preview-Zqt4hIgH.d.ts} +3 -3
  30. package/dist/runtime.d.ts +5 -5
  31. package/dist/runtime.js +2 -2
  32. package/dist/{sandbox-Bcs4w1RE.d.ts → sandbox-00TWLhei.d.ts} +8 -7
  33. package/dist/{sandbox-DyoFguBU.js → sandbox-CCVZWs8k.js} +141 -273
  34. package/dist/{secp256k1-Dx2XABHz.js → secp256k1-DoWlH6ff.js} +1 -1
  35. package/dist/tangle/index.d.ts +1 -1
  36. package/dist/tangle/index.js +1 -1
  37. package/dist/{tangle-yvuD9HP_.js → tangle-DugVLl53.js} +3 -3
  38. package/dist/{types-H3SX7E33.d.ts → types-DWG-ZlvL.d.ts} +7 -2
  39. package/package.json +5 -5
  40. /package/dist/{chunked-upload-DtIvkKNo.js → chunked-upload-ClCKGr59.js} +0 -0
  41. /package/dist/{cli-auth-bundle-ODe06Ts7.d.ts → cli-auth-bundle-BKsrsbxy.d.ts} +0 -0
  42. /package/dist/{cli-auth-bundle-cSJjPeFF.js → cli-auth-bundle-CaknD92R.js} +0 -0
  43. /package/dist/{collaboration-YxqL5cZY.js → collaboration-DZCyTGdn.js} +0 -0
  44. /package/dist/{index-7_-RzCh9.d.ts → index-BxyTdtyB.d.ts} +0 -0
  45. /package/dist/{index-Vr-2tNP3.d.ts → index-ONMNeJwr.d.ts} +0 -0
  46. /package/dist/{line-application-Cq6dJLBD.js → line-application-UtPFP0o4.js} +0 -0
  47. /package/dist/{preview-operations-DqSo-IBm.js → preview-operations-Bvo5YcIq.js} +0 -0
  48. /package/dist/{raw-evidence-archive-CZdOSXOC.js → raw-evidence-archive-BjDIFiOM.js} +0 -0
  49. /package/dist/{terminal-stream-BANlVD4Q.d.ts → terminal-stream-DgD7GlFi.d.ts} +0 -0
  50. /package/dist/{utils-B7_9Hl_z.js → utils-B6gap92T.js} +0 -0
@@ -1,10 +1,11 @@
1
1
  import { r as backendTypeSchema } from "./backend-types-D6bYbvMB.js";
2
- import { A as normalizeRuntimeBackendConfig, C as encodePromptForWire, D as assertCurrentBackendType, E as applyRequestedModel, F as withoutRuntimeSecrets, I as createAgentRunOutcomeTracker, L as deriveAgentResultOutcome, M as requestedSecretProfilePublicDigest, S as validateAcceptedDispatchRunRef, T as parseSSEStream, _ as mintTraceId, a as terminalUpgradeHeadersSupported, b as sessionHeaders, d as isRetryableCredentialRefusal, f as normalizeSessionInfo, g as isTraceId, h as TRACE_ID_HEADER, i as TerminalStreamError, j as requestedPublicProfileDigest, k as mergeRuntimeBackendConfig, l as requestScopedToken, m as waitForRetryAfter, n as InteractiveSessionController, p as sessionMessageRequestBody, r as TerminalStream, s as assertScopedTokenActive, u as SandboxRuntimeApi, v as resolveTraceId, w as encodeTextForWire, x as resolveDispatchRunIdentity, y as appendSessionIdQuery } from "./interactive-controller-CPtHnjrz.js";
2
+ import { A as normalizeRuntimeBackendConfig, C as encodePromptForWire, D as assertCurrentBackendType, E as applyRequestedModel, F as withoutRuntimeSecrets, I as createAgentRunOutcomeTracker, L as deriveAgentResultOutcome, M as requestedSecretProfilePublicDigest, S as validateAcceptedDispatchRunRef, T as parseSSEStream, _ as mintTraceId, a as terminalUpgradeHeadersSupported, b as sessionHeaders, d as isRetryableCredentialRefusal, f as normalizeSessionInfo, g as isTraceId, h as TRACE_ID_HEADER, i as TerminalStreamError, j as requestedPublicProfileDigest, k as mergeRuntimeBackendConfig, l as requestScopedToken, m as waitForRetryAfter, n as InteractiveSessionController, p as sessionMessageRequestBody, r as TerminalStream, s as assertScopedTokenActive, u as SandboxRuntimeApi, v as resolveTraceId, w as encodeTextForWire, x as resolveDispatchRunIdentity, y as appendSessionIdQuery } from "./interactive-controller-Bize8Sca.js";
3
3
  import { C as readResponseJson, S as parseResponseError, _ as StateError, b as ValidationError, d as NotFoundError, g as ServerError, h as SandboxError, i as EdgeNotReadyError, p as QuotaError, r as CapabilityError, t as AuthError, u as NetworkError, v as StreamInterruptedError, x as parseErrorResponse, y as TimeoutError } from "./errors-DSJBKmGZ.js";
4
4
  import { d as awaitWithAbort, f as combineAbortSignals, g as interactiveSessionStatusResponseSchema, h as interactiveSessionControlValidationResponseSchema, l as createInteractiveControlHolderId, m as interactiveSessionControlReleaseResponseSchema, p as interactiveSessionControlClaimResponseSchema } from "./browser-interactive-control-controller-BJf0P_J4.js";
5
+ import { n as fetchWithKeepAlive, t as emitTiming } from "./keep-alive-fetch-qPVvvkgJ.js";
5
6
  import { SandboxLines } from "./lines.js";
6
- import { l as SANDBOX_PROXY_REQUEST_MAX_BYTES, s as uploadChunked } from "./chunked-upload-DtIvkKNo.js";
7
- import { r as cliAuthReferenceSchema } from "./cli-auth-bundle-cSJjPeFF.js";
7
+ import { l as SANDBOX_PROXY_REQUEST_MAX_BYTES, s as uploadChunked } from "./chunked-upload-ClCKGr59.js";
8
+ import { r as cliAuthReferenceSchema } from "./cli-auth-bundle-CaknD92R.js";
8
9
  import { z } from "zod";
9
10
  import { AgentExactRunControlRefSchema, AgentInteractiveSessionAttachSchema, AgentInteractiveSessionControlClaimAcknowledgementSchema, AgentInteractiveSessionControlClaimRequestSchema, AgentInteractiveSessionControlClaimSchema, AgentInteractiveSessionPromptAcknowledgementSchema, AgentInteractiveSessionPromptCommandSchema, AgentInteractiveSessionRefSchema, AgentInteractiveSessionStartSchema, AgentInteractiveSessionStopAcknowledgementSchema, AgentInteractiveSessionStopCommandSchema, AgentRunCancellationAcknowledgementSchema, AgentRunCancellationRequestSchema, InteractionAcknowledgementSchema, InteractionBindingSchema, InteractionRequestSchema, InteractionResponseCommandSchema, InteractionResponseSchema, PlanContinuationSchema, TerminalInputSchema, TerminalOutputEventSchema, TerminalReplayWindowSchema, TerminalResizeSchema, TerminalSessionRefSchema, agentInteractiveSessionControlClaimAcknowledgementMatchesRequest, agentInteractiveSessionControlClaimIsNewer, agentInteractiveSessionControlClaimMatchesRef, agentInteractiveSessionPromptAcknowledgementMatchesCommand, agentInteractiveSessionPromptRequestDigest, agentInteractiveSessionRefMatchesStart, agentInteractiveSessionStatusMatchesRef, agentInteractiveSessionStopAcknowledgementMatchesCommand, agentProfileSchema, agentRunCancellationAcknowledgementMatchesRequest, canonicalCandidateDigest, canonicalCandidateJson, exactAgentInteractiveSessionStart, sha256DigestSchema, terminalSessionUsable } from "@tangle-network/agent-interface";
10
11
  import { AgentInteractiveSessionControlClaimSchema as AgentInteractiveSessionControlClaimSchema$1, AgentInteractiveSessionPromptAcknowledgementSchema as AgentInteractiveSessionPromptAcknowledgementSchema$1, AgentInteractiveSessionRefSchema as AgentInteractiveSessionRefSchema$1, AgentInteractiveSessionStatusSchema, AgentInteractiveSessionStopAcknowledgementSchema as AgentInteractiveSessionStopAcknowledgementSchema$1 } from "@tangle-network/agent-interface/environment-interactive-control";
@@ -210,244 +211,6 @@ function snakeCase(value) {
210
211
  return value.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
211
212
  }
212
213
  //#endregion
213
- //#region src/lib/keep-alive-fetch.ts
214
- /** How long an idle SDK socket stays open. The servers keep theirs open for 35 s and more. */
215
- const KEEP_ALIVE_TIMEOUT_MS = 6e4;
216
- const GLOBAL_DISPATCHER = Symbol.for("undici.globalDispatcher.1");
217
- /** Report a span. A hook that throws must never fail an SDK call. */
218
- function emitTiming(hook, entry) {
219
- if (!hook) return;
220
- try {
221
- hook(entry);
222
- } catch {}
223
- }
224
- /** Milliseconds, at 0.1 ms: the resolution these spans can honestly claim. */
225
- function ms(value) {
226
- return Math.round(value * 10) / 10;
227
- }
228
- let cachedHost;
229
- let cachedAgent = null;
230
- function readGlobalDispatcher() {
231
- const read = () => globalThis[GLOBAL_DISPATCHER];
232
- const host = read();
233
- if (host) return host;
234
- globalThis.Headers;
235
- return read();
236
- }
237
- /** The options undici stored on an Agent, if this version keeps them where we look. */
238
- function agentOptions(agent) {
239
- for (const symbol of Object.getOwnPropertySymbols(agent)) {
240
- if (symbol.description !== "options") continue;
241
- const value = agent[symbol];
242
- if (value && typeof value === "object") return value;
243
- }
244
- }
245
- function buildKeepAliveAgent(host) {
246
- const AgentClass = Object.getPrototypeOf(host)?.constructor;
247
- if (typeof AgentClass !== "function" || AgentClass.name !== "Agent") return null;
248
- const options = agentOptions(host);
249
- if (!options || options.keepAliveTimeout !== void 0) return null;
250
- try {
251
- return new AgentClass({
252
- ...options,
253
- keepAliveTimeout: KEEP_ALIVE_TIMEOUT_MS
254
- });
255
- } catch {
256
- return null;
257
- }
258
- }
259
- /**
260
- * The dispatcher SDK calls pass to `fetch`, or `undefined` to keep the host's.
261
- * Rebuilt when the host replaces its global dispatcher, so a test that installs
262
- * a mock agent, or an app that reconfigures its own, is never bypassed.
263
- */
264
- function keepAliveDispatcher() {
265
- const host = readGlobalDispatcher();
266
- if (!host) return void 0;
267
- if (host !== cachedHost) {
268
- const previous = cachedAgent;
269
- cachedHost = host;
270
- cachedAgent = buildKeepAliveAgent(host);
271
- Promise.resolve(previous?.close?.()).catch(() => void 0);
272
- }
273
- return cachedAgent ?? void 0;
274
- }
275
- /**
276
- * In-flight requests by undici request. A response whose body is never read
277
- * never completes, so the map is bounded rather than trusted to drain.
278
- */
279
- const MAX_LIVE_CAPTURES = 256;
280
- const captures = /* @__PURE__ */ new Map();
281
- const socketMarks = /* @__PURE__ */ new WeakMap();
282
- let dispatching;
283
- let observing;
284
- function subscribeChannels(channels) {
285
- const now = () => performance.now();
286
- channels.subscribe("net.client.socket", (message) => {
287
- const socket = message.socket;
288
- if (!socket || captures.size === 0) return;
289
- const marks = {
290
- createdAt: now(),
291
- claimed: false
292
- };
293
- socketMarks.set(socket, marks);
294
- const once = socket.once;
295
- if (typeof once !== "function") return;
296
- once.call(socket, "lookup", () => {
297
- marks.lookupAt = now();
298
- });
299
- once.call(socket, "connect", () => {
300
- marks.connectAt = now();
301
- });
302
- once.call(socket, "secureConnect", () => {
303
- marks.secureAt = now();
304
- });
305
- });
306
- channels.subscribe("undici:request:create", (message) => {
307
- const request = message.request;
308
- if (!dispatching || !request) return;
309
- dispatching.request = request;
310
- captures.set(request, dispatching);
311
- if (captures.size > MAX_LIVE_CAPTURES) {
312
- const oldest = captures.keys().next().value;
313
- if (oldest !== void 0) captures.delete(oldest);
314
- }
315
- });
316
- channels.subscribe("undici:client:sendHeaders", (message) => {
317
- const { request, socket } = message;
318
- const capture = request ? captures.get(request) : void 0;
319
- if (!capture) return;
320
- capture.sentAt = now();
321
- const marks = socket ? socketMarks.get(socket) : void 0;
322
- if (marks && !marks.claimed) {
323
- marks.claimed = true;
324
- capture.marks = marks;
325
- }
326
- });
327
- channels.subscribe("undici:request:headers", (message) => {
328
- const request = message.request;
329
- const capture = request ? captures.get(request) : void 0;
330
- if (capture) capture.headersAt = now();
331
- });
332
- channels.subscribe("undici:request:trailers", (message) => {
333
- const request = message.request;
334
- const capture = request ? captures.get(request) : void 0;
335
- if (!capture) return;
336
- capture.doneAt = now();
337
- captures.delete(request);
338
- capture.finish();
339
- });
340
- channels.subscribe("undici:request:error", (message) => {
341
- const request = message.request;
342
- const capture = request ? captures.get(request) : void 0;
343
- if (!capture) return;
344
- capture.failed = true;
345
- capture.doneAt = now();
346
- captures.delete(request);
347
- capture.finish();
348
- });
349
- }
350
- /** Subscribe once. False where the runtime has no Node diagnostics channels. */
351
- function observeRequests() {
352
- observing ??= import("node:diagnostics_channel").then((channels) => {
353
- if (typeof channels.subscribe !== "function") return false;
354
- subscribeChannels(channels);
355
- return true;
356
- }, () => false);
357
- return observing;
358
- }
359
- /** A dispatcher that tells `capture` which undici request its dispatch created. */
360
- function tagged(base, capture) {
361
- return new Proxy(base, { get(target, property) {
362
- if (property === "dispatch") return (options, handler) => {
363
- dispatching = capture;
364
- try {
365
- return target.dispatch(options, handler);
366
- } finally {
367
- dispatching = void 0;
368
- }
369
- };
370
- const value = Reflect.get(target, property, target);
371
- return typeof value === "function" ? value.bind(target) : value;
372
- } });
373
- }
374
- function phasesOf(capture) {
375
- if (capture.sentAt === void 0 || capture.headersAt === void 0) return;
376
- const phases = { ttfbMs: ms(capture.headersAt - capture.sentAt) };
377
- const marks = capture.marks;
378
- if (marks?.connectAt !== void 0) {
379
- if (marks.lookupAt !== void 0) phases.dnsMs = ms(marks.lookupAt - marks.createdAt);
380
- phases.connectMs = ms(marks.connectAt - (marks.lookupAt ?? marks.createdAt));
381
- if (marks.secureAt !== void 0) phases.tlsMs = ms(marks.secureAt - marks.connectAt);
382
- }
383
- if (capture.doneAt !== void 0 && !capture.failed) phases.bodyMs = ms(capture.doneAt - capture.headersAt);
384
- return phases;
385
- }
386
- /**
387
- * `fetch` for an SDK call: the keep-alive dispatcher on Node, and a timing
388
- * entry per request when the client has a hook. Calls `globalThis.fetch` at
389
- * call time, so a caller's fetch override still receives the request.
390
- */
391
- async function fetchWithKeepAlive(url, init, options) {
392
- let dispatcher = keepAliveDispatcher();
393
- const hook = options.onTiming;
394
- if (!hook) return dispatcher ? globalThis.fetch(url, {
395
- ...init,
396
- dispatcher
397
- }) : globalThis.fetch(url, init);
398
- const startedAt = performance.now();
399
- const method = init.method ?? "GET";
400
- const observed = await observeRequests();
401
- const host = dispatcher ?? (observed ? readGlobalDispatcher() : void 0);
402
- let capture;
403
- let finished;
404
- if (observed && host) {
405
- let finish = () => {};
406
- finished = new Promise((resolve) => {
407
- finish = resolve;
408
- });
409
- capture = {
410
- startedAt,
411
- finish
412
- };
413
- dispatcher = tagged(host, capture);
414
- }
415
- let response;
416
- try {
417
- response = await globalThis.fetch(url, dispatcher ? {
418
- ...init,
419
- dispatcher
420
- } : init);
421
- } catch (error) {
422
- if (capture?.request) captures.delete(capture.request);
423
- emitTiming(hook, {
424
- name: "sdk.request",
425
- durMs: ms(performance.now() - startedAt),
426
- desc: "failed",
427
- method,
428
- path: options.path
429
- });
430
- throw error;
431
- }
432
- const report = () => {
433
- const phases = capture ? phasesOf(capture) : void 0;
434
- const socket = phases ? capture?.marks ? "new" : "reused" : void 0;
435
- emitTiming(hook, {
436
- name: "sdk.request",
437
- durMs: ms((capture?.doneAt ?? capture?.headersAt ?? performance.now()) - startedAt),
438
- desc: socket ? `socket=${socket}` : "",
439
- method,
440
- path: options.path,
441
- status: response.status,
442
- ...socket ? { socket } : {},
443
- ...phases ? { phases } : {}
444
- });
445
- };
446
- if (capture?.request && finished) finished.then(report);
447
- else report();
448
- return response;
449
- }
450
- //#endregion
451
214
  //#region src/lib/response-rewrap.ts
452
215
  /**
453
216
  * Response wrappers that must outlive the fetch Response they wrap.
@@ -493,12 +256,16 @@ function normalizeConnection(raw) {
493
256
  if (!raw || typeof raw !== "object") return void 0;
494
257
  const c = raw;
495
258
  const runtimeUrl = c.runtimeUrl;
259
+ const execHost = typeof c.execHost === "string" ? c.execHost : void 0;
496
260
  const edgeStatus = normalizeEdgeStatus(c.edgeStatus);
497
261
  const ssh = normalizeSshCredentials(c.ssh);
498
262
  const webTerminalUrl = c.webTerminalUrl;
499
- if (!runtimeUrl && !edgeStatus && !ssh && !webTerminalUrl) return void 0;
263
+ if (!runtimeUrl && !execHost && !edgeStatus && !ssh && !webTerminalUrl) return void 0;
500
264
  return {
501
265
  runtimeUrl,
266
+ execHost,
267
+ execToken: c.execToken,
268
+ execTokenExpiresAt: c.execTokenExpiresAt,
502
269
  authToken: c.authToken,
503
270
  authTokenExpiresAt: c.authTokenExpiresAt,
504
271
  edgeStatus,
@@ -1108,6 +875,79 @@ async function materializeAbsentProfileFiles(box, files, options) {
1108
875
  };
1109
876
  }
1110
877
  //#endregion
878
+ //#region ../../../packages/runtime-contracts/dist/sidecar-request.js
879
+ /**
880
+ * One normalizer for every edge route and host proxy, including preview ports.
881
+ * Decode URL data once, reject path syntax, then encode segment data for the
882
+ * next hop. A bounded safety probe rejects hidden traversal syntax without
883
+ * applying another decoding layer to filenames that are actually forwarded.
884
+ */
885
+ function normalizeSidecarPathname(input) {
886
+ if (/[?#]/.test(input)) return null;
887
+ let decoded;
888
+ try {
889
+ decoded = decodeURIComponent(input);
890
+ } catch {
891
+ return null;
892
+ }
893
+ let probe = decoded;
894
+ for (let layer = 0; layer <= 8; layer++) {
895
+ if (probe.includes("\\") || [...probe].some((character) => character.charCodeAt(0) < 32 || character.charCodeAt(0) === 127) || probe.split("/").some((segment) => segment === "." || segment === "..")) return null;
896
+ const next = probe.replace(/%(25|2e|2f|5c)/gi, (_, hex) => String.fromCharCode(Number.parseInt(hex, 16)));
897
+ if (next === probe) {
898
+ const pathname = decoded.split("/").map((segment) => encodeURIComponent(segment).replace(/%(3a|40|24|26|2b|2c|3b|3d)/gi, (escaped) => String.fromCharCode(Number.parseInt(escaped.slice(1), 16)))).join("/");
899
+ return {
900
+ path: decoded.replace(/^\/+|\/+$/g, ""),
901
+ pathname: `/${pathname.replace(/^\/+/, "")}`
902
+ };
903
+ }
904
+ if (layer === 8) return null;
905
+ probe = next;
906
+ }
907
+ return null;
908
+ }
909
+ const EXEC_ROUTES = [
910
+ {
911
+ path: "exec",
912
+ rateFamily: "process"
913
+ },
914
+ {
915
+ path: "code/exec",
916
+ rateFamily: "process"
917
+ },
918
+ {
919
+ path: "process/spawn",
920
+ rateFamily: "process"
921
+ },
922
+ {
923
+ path: "process/ensure-dev-server",
924
+ rateFamily: "process"
925
+ },
926
+ {
927
+ path: "terminals/commands",
928
+ rateFamily: "terminal"
929
+ }
930
+ ];
931
+ /** Classify once, before constructing a URL that could erase dot segments. */
932
+ function classifySidecarRequest(input, method, upgrade = false) {
933
+ const normalized = normalizeSidecarPathname(input);
934
+ if (!normalized) return null;
935
+ const { path, pathname } = normalized;
936
+ const exec = method === "POST" && !upgrade ? EXEC_ROUTES.find((route) => route.path === path) : void 0;
937
+ let auditAction = exec ? "sandbox.exec" : null;
938
+ if (upgrade && /^terminals\/[^/]+\/ws$/.test(path)) auditAction = "sandbox.terminal.attach";
939
+ else if (upgrade && path === "ssh") auditAction = "sandbox.ssh.open";
940
+ else if (!upgrade && method === "POST" && path === "terminals") auditAction = "sandbox.terminal.attach";
941
+ const rateFamily = exec?.rateFamily ?? (auditAction ? "terminal-open" : null) ?? (path === "process" || path.startsWith("process/") ? "process" : null);
942
+ return {
943
+ path,
944
+ pathname,
945
+ auditAction,
946
+ rateFamily,
947
+ shortTokenRequired: !!exec
948
+ };
949
+ }
950
+ //#endregion
1111
951
  //#region src/lib/file-download.ts
1112
952
  /** Retain only complete downloads; failed streams leave the destination intact. */
1113
953
  async function downloadFile(request, localPath, options = {}) {
@@ -4497,10 +4337,11 @@ function normalizeSandboxCreateReceipt(raw) {
4497
4337
  */
4498
4338
  function redactConnectionSecrets(connection) {
4499
4339
  if (!connection) return connection;
4500
- if (connection.authToken === void 0) return connection;
4340
+ if (connection.authToken === void 0 && connection.execToken === void 0) return connection;
4501
4341
  return {
4502
4342
  ...connection,
4503
- authToken: "[REDACTED]"
4343
+ ...connection.authToken ? { authToken: "[REDACTED]" } : {},
4344
+ ...connection.execToken ? { execToken: "[REDACTED]" } : {}
4504
4345
  };
4505
4346
  }
4506
4347
  function normalizePreviewLink(raw) {
@@ -5131,11 +4972,12 @@ var SandboxInstance = class SandboxInstance {
5131
4972
  * Create an advanced direct-runtime view of this sandbox.
5132
4973
  *
5133
4974
  * Runtime methods on the returned instance talk to the sandbox runtime
5134
- * directly using `connection.runtimeUrl` and `connection.authToken`.
4975
+ * directly using `connection.execHost` when supplied, otherwise
4976
+ * `connection.runtimeUrl`, and the scoped `connection.authToken`.
5135
4977
  * Lifecycle methods still go through the parent SDK client.
5136
4978
  */
5137
4979
  direct() {
5138
- if (!this.connection?.runtimeUrl) throw new StateError("Sandbox has no direct runtime URL", this.status, "running");
4980
+ if (!this.connection?.execHost && !this.connection?.runtimeUrl) throw new StateError("Sandbox has no direct runtime URL", this.status, "running");
5139
4981
  let directInstance;
5140
4982
  directInstance = new SandboxInstance(new DirectRuntimeHttpClient(this.#client, this.id, () => directInstance.connection, async () => {
5141
4983
  await directInstance.refreshFor("bearer-refused");
@@ -6761,7 +6603,7 @@ var SandboxInstance = class SandboxInstance {
6761
6603
  totalBytes: size,
6762
6604
  percentage: 0
6763
6605
  });
6764
- const { uploadChunkedFromFile } = await import("./chunked-upload-file-DnsHEjg0.js");
6606
+ const { uploadChunkedFromFile } = await import("./chunked-upload-file-RaMaNFN_.js");
6765
6607
  await uploadChunkedFromFile({ fetch: (path, init) => this.runtimeFetch(path, init) }, remotePath, localPath, {
6766
6608
  mode: options?.permissions,
6767
6609
  onProgress: options?.onProgress ? (progress) => {
@@ -8766,7 +8608,7 @@ var SandboxInstance = class SandboxInstance {
8766
8608
  origin: "sandbox-api",
8767
8609
  endpoint: `/v1/sandboxes/${this.id}`
8768
8610
  });
8769
- return connection?.edgeStatus !== "pending" && Boolean(connection?.runtimeUrl);
8611
+ return connection?.edgeStatus !== "pending" && Boolean(connection?.execHost || connection?.runtimeUrl);
8770
8612
  }
8771
8613
  hasFreshStatus() {
8772
8614
  const statusObservedAt = sandboxStatusObservedAt.get(this) ?? 0;
@@ -9533,7 +9375,7 @@ var SandboxInstance = class SandboxInstance {
9533
9375
  }
9534
9376
  /** @internal — invoked before the sandbox is deleted. */
9535
9377
  async _sessionExportRawEvidence(id, destination, options) {
9536
- const { exportRawEvidenceDirectory } = await import("./raw-evidence-archive-CZdOSXOC.js");
9378
+ const { exportRawEvidenceDirectory } = await import("./raw-evidence-archive-BjDIFiOM.js");
9537
9379
  await this.ensureRunning();
9538
9380
  await this.refresh();
9539
9381
  return exportRawEvidenceDirectory((signal) => this.runtimeFetch(`/agents/sessions/${encodeURIComponent(id)}/raw-evidence/archive?${new URLSearchParams({
@@ -10006,12 +9848,30 @@ var DirectRuntimeHttpClient = class {
10006
9848
  if (!path.startsWith(runtimePrefix)) return this.baseClient.fetch(path, options, fetchOptions);
10007
9849
  const runtimePath = path.slice(runtimePrefix.length);
10008
9850
  if (runtimePath === "/network" || runtimePath.startsWith("/network/") || runtimePath === "/preview-links" || runtimePath.startsWith("/preview-links/")) return this.baseClient.fetch(path, options, fetchOptions);
10009
- const connection = this.getConnection();
10010
- const runtimeUrl = connection?.runtimeUrl;
10011
- if (!runtimeUrl) throw new NetworkError("Sandbox has no direct runtime URL");
10012
- const targetUrl = `${runtimeUrl.replace(/\/$/, "")}${runtimePath}`;
9851
+ const command = classifySidecarRequest(runtimePath.split("?")[0], options?.method ?? "GET");
9852
+ if (!command) throw new NetworkError("Invalid direct runtime path");
9853
+ const selectRoute = () => {
9854
+ const connection = this.getConnection();
9855
+ const useExec = command.shortTokenRequired && !!connection?.execHost && !!connection.execToken;
9856
+ if (command.shortTokenRequired && !useExec) return void 0;
9857
+ const origin = useExec ? connection?.execHost : connection?.runtimeUrl;
9858
+ if (!origin) return void 0;
9859
+ return {
9860
+ useExec,
9861
+ url: `${origin.replace(/\/$/, "")}${runtimePath}`,
9862
+ bearer: useExec ? connection?.execToken : connection?.authToken
9863
+ };
9864
+ };
9865
+ let route = selectRoute();
9866
+ if (!route) return this.baseClient.fetch(path, options, fetchOptions);
10013
9867
  const headers = new Headers(options?.headers);
10014
- if (connection?.authToken) headers.set("Authorization", `Bearer ${connection.authToken}`);
9868
+ const authenticate = () => {
9869
+ headers.delete("Authorization");
9870
+ headers.delete("X-Tangle-Sandbox-Ref");
9871
+ if (route?.useExec) headers.set("X-Tangle-Sandbox-Ref", this.sandboxId);
9872
+ if (route?.bearer) headers.set("Authorization", `Bearer ${route.bearer}`);
9873
+ };
9874
+ authenticate();
10015
9875
  const isFormDataBody = typeof FormData !== "undefined" && options?.body instanceof FormData;
10016
9876
  if (!headers.has("Content-Type") && !isFormDataBody) headers.set("Content-Type", "application/json");
10017
9877
  const init = {
@@ -10021,30 +9881,38 @@ var DirectRuntimeHttpClient = class {
10021
9881
  if (options?.body && typeof options.body === "object" && !isFormDataBody) init.duplex = "half";
10022
9882
  const directTimeoutMs = fetchOptions?.timeoutMs;
10023
9883
  if (!init.signal && typeof directTimeoutMs === "number" && directTimeoutMs > 0) init.signal = AbortSignal.timeout(directTimeoutMs);
10024
- const send = (request) => fetchWithKeepAlive(targetUrl, request, {
10025
- onTiming: this.onTiming,
10026
- path
10027
- });
9884
+ const send = async (request) => {
9885
+ const timing = {
9886
+ onTiming: this.onTiming,
9887
+ path
9888
+ };
9889
+ if (!route) throw new NetworkError("Direct runtime route was withdrawn");
9890
+ if (route.useExec && typeof process !== "undefined" && process.versions?.node) {
9891
+ const { fetchDirectHttp2 } = await import("./direct-http2-D8mo1ePx.js");
9892
+ return fetchDirectHttp2(route.url, request, timing);
9893
+ }
9894
+ return fetchWithKeepAlive(route.url, request, timing);
9895
+ };
10028
9896
  let response = await send(init);
10029
9897
  if ((response.status === 401 || response.status === 403 && await isRefusedBearer(response)) && this.onUnauthorized && !headers.has("x-no-retry")) {
10030
- const refusedStatus = response.status;
10031
- await response.arrayBuffer().catch(() => void 0);
9898
+ const refusal = {
9899
+ status: response.status,
9900
+ statusText: response.statusText,
9901
+ headers: new Headers(response.headers)
9902
+ };
9903
+ const refusedBody = await response.arrayBuffer().catch(() => null);
10032
9904
  try {
10033
9905
  await this.onUnauthorized();
10034
9906
  } catch {
10035
- return new Response("", {
10036
- status: refusedStatus,
10037
- statusText: response.statusText
10038
- });
10039
- }
10040
- const refreshedConnection = this.getConnection();
10041
- if (refreshedConnection?.authToken) {
10042
- headers.set("Authorization", `Bearer ${refreshedConnection.authToken}`);
10043
- response = await send({
10044
- ...init,
10045
- headers
10046
- });
9907
+ return new Response(refusedBody, refusal);
10047
9908
  }
9909
+ route = selectRoute();
9910
+ if (!route) return this.baseClient.fetch(path, options, fetchOptions);
9911
+ authenticate();
9912
+ response = await send({
9913
+ ...init,
9914
+ headers
9915
+ });
10048
9916
  }
10049
9917
  if (this.onUnreachable && await isRuntimeUnreachable(response)) await this.onUnreachable();
10050
9918
  const responseHeaders = new Headers(response.headers);
@@ -10070,4 +9938,4 @@ function quoteForShell(value) {
10070
9938
  return `'${value.replace(/'/g, "'\\''")}'`;
10071
9939
  }
10072
9940
  //#endregion
10073
- export { rewrapResponse as A, ManagedProcessClient as C, validateDeferredProfileFileMounts as D, splitInlineProfileSkills as E, toOtelJson as F, buildTraceExportPayload as M, exportTraceBundle as N, normalizeConnection as O, otelTraceIdForTangleTrace as P, isToolBearingEvent as S, splitInlineProfileFileMounts as T, SandboxOperationFailedError as _, normalizeStartupDiagnostics as a, collectAgentResponseText as b, MAX_EGRESS_DENIALS_LIMIT as c, InteractiveSessionHandle as d, agentInteractiveSessionPromptRequestDigest as f, SandboxOperation as g, createInteractiveTerminalSession as h, normalizeSandboxCreateReceipt as i, fetchWithKeepAlive as j, normalizeSandboxShape as k, SandboxTaskSession as l, createInteractiveTerminalCapture as m, createSandboxInstanceFromResponse as n, WorkspaceImages as o, InteractiveTerminalFrameLog as p, normalizeCaptureProof as r, GPU_LEASE_PROVIDER_NAMES as s, SandboxInstance as t, SandboxSession as u, applySandboxEventText as v, materializeProfileFileMounts as w, getSandboxEventText as x, collectAgentFinalMessageText as y };
9941
+ export { rewrapResponse as A, ManagedProcessClient as C, validateDeferredProfileFileMounts as D, splitInlineProfileSkills as E, exportTraceBundle as M, otelTraceIdForTangleTrace as N, normalizeConnection as O, toOtelJson as P, isToolBearingEvent as S, splitInlineProfileFileMounts as T, SandboxOperationFailedError as _, normalizeStartupDiagnostics as a, collectAgentResponseText as b, MAX_EGRESS_DENIALS_LIMIT as c, InteractiveSessionHandle as d, agentInteractiveSessionPromptRequestDigest as f, SandboxOperation as g, createInteractiveTerminalSession as h, normalizeSandboxCreateReceipt as i, buildTraceExportPayload as j, normalizeSandboxShape as k, SandboxTaskSession as l, createInteractiveTerminalCapture as m, createSandboxInstanceFromResponse as n, WorkspaceImages as o, InteractiveTerminalFrameLog as p, normalizeCaptureProof as r, GPU_LEASE_PROVIDER_NAMES as s, SandboxInstance as t, SandboxSession as u, applySandboxEventText as v, materializeProfileFileMounts as w, getSandboxEventText as x, collectAgentFinalMessageText as y };
@@ -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-B7_9Hl_z.js";
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-B6gap92T.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,2 +1,2 @@
1
- import { C as JsonResponseParamTypes, E as SandboxIdParamTypes, S as ITangleJobsAbi, T as SandboxCreateResponseParamTypes, _ as JOB_SANDBOX_DELETE, a as fetchQuote, b as TangleSandboxClientConfig, c as parseQuoteResponse, d as OperatorSession, f as OperatorSessionError, g as JOB_SANDBOX_CREATE, h as TangleSandboxClient, i as SignedQuote, l as validateQuote, m as SignMessage, n as QuoteDomain, o as inputsHashOf, p as OperatorSessionToken, r as QuoteError, s as jobQuoteDigest, t as JobQuoteDetails, u as OperatorChallenge, v as TANGLE_CHAIN_ID, w as SandboxCreateParamTypes, x as AgentSandboxBlueprintAbi, y as TANGLE_JOBS_CONTRACT } from "../index-BFW3FzJG.js";
1
+ import { C as JsonResponseParamTypes, E as SandboxIdParamTypes, S as ITangleJobsAbi, T as SandboxCreateResponseParamTypes, _ as JOB_SANDBOX_DELETE, a as fetchQuote, b as TangleSandboxClientConfig, c as parseQuoteResponse, d as OperatorSession, f as OperatorSessionError, g as JOB_SANDBOX_CREATE, h as TangleSandboxClient, i as SignedQuote, l as validateQuote, m as SignMessage, n as QuoteDomain, o as inputsHashOf, p as OperatorSessionToken, r as QuoteError, s as jobQuoteDigest, t as JobQuoteDetails, u as OperatorChallenge, v as TANGLE_CHAIN_ID, w as SandboxCreateParamTypes, x as AgentSandboxBlueprintAbi, y as TANGLE_JOBS_CONTRACT } from "../index-LO5315tT.js";
2
2
  export { AgentSandboxBlueprintAbi, ITangleJobsAbi, JOB_SANDBOX_CREATE, JOB_SANDBOX_DELETE, JobQuoteDetails, JsonResponseParamTypes, OperatorChallenge, OperatorSession, OperatorSessionError, OperatorSessionToken, QuoteDomain, QuoteError, SandboxCreateParamTypes, SandboxCreateResponseParamTypes, SandboxIdParamTypes, SignMessage, SignedQuote, TANGLE_CHAIN_ID, TANGLE_JOBS_CONTRACT, TangleSandboxClient, TangleSandboxClientConfig, fetchQuote, inputsHashOf, jobQuoteDigest, parseQuoteResponse, validateQuote };
@@ -1,2 +1,2 @@
1
- import { _ as SandboxCreateParamTypes, a as parseQuoteResponse, c as OperatorSession, d as JOB_SANDBOX_DELETE, f as TANGLE_CHAIN_ID, g as JsonResponseParamTypes, h as ITangleJobsAbi, i as jobQuoteDigest, l as OperatorSessionError, m as AgentSandboxBlueprintAbi, n as fetchQuote, o as validateQuote, p as TANGLE_JOBS_CONTRACT, r as inputsHashOf, s as TangleSandboxClient, t as QuoteError, u as JOB_SANDBOX_CREATE, v as SandboxCreateResponseParamTypes, y as SandboxIdParamTypes } from "../tangle-yvuD9HP_.js";
1
+ import { _ as SandboxCreateParamTypes, a as parseQuoteResponse, c as OperatorSession, d as JOB_SANDBOX_DELETE, f as TANGLE_CHAIN_ID, g as JsonResponseParamTypes, h as ITangleJobsAbi, i as jobQuoteDigest, l as OperatorSessionError, m as AgentSandboxBlueprintAbi, n as fetchQuote, o as validateQuote, p as TANGLE_JOBS_CONTRACT, r as inputsHashOf, s as TangleSandboxClient, t as QuoteError, u as JOB_SANDBOX_CREATE, v as SandboxCreateResponseParamTypes, y as SandboxIdParamTypes } from "../tangle-DugVLl53.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,6 +1,6 @@
1
1
  import { C as readResponseJson } from "./errors-DSJBKmGZ.js";
2
- import { n as createSandboxInstanceFromResponse } from "./sandbox-DyoFguBU.js";
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-B7_9Hl_z.js";
2
+ import { n as createSandboxInstanceFromResponse } from "./sandbox-CCVZWs8k.js";
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-B6gap92T.js";
4
4
  //#region src/tangle/abi.ts
5
5
  /**
6
6
  * Tangle Contract ABI Definitions
@@ -2370,7 +2370,7 @@ function isAddressEqual(a, b) {
2370
2370
  //#region ../../../node_modules/.pnpm/viem@2.55.4_bufferutil@4.1.0_typescript@6.0.3_utf-8-validate@5.0.10_zod@4.6.5/node_modules/viem/_esm/utils/signature/recoverPublicKey.js
2371
2371
  async function recoverPublicKey({ hash, signature }) {
2372
2372
  const hashHex = isHex(hash) ? hash : toHex(hash);
2373
- const { secp256k1 } = await import("./secp256k1-Dx2XABHz.js");
2373
+ const { secp256k1 } = await import("./secp256k1-DoWlH6ff.js");
2374
2374
  return `0x${(() => {
2375
2375
  if (typeof signature === "object" && "r" in signature && "s" in signature) {
2376
2376
  const { r, s, v, yParity } = signature;
@@ -1,5 +1,5 @@
1
- import { t as CliAuthReference } from "./cli-auth-bundle-ODe06Ts7.js";
2
- import { n as TerminalStream, o as TerminalStreamHandlers } from "./terminal-stream-BANlVD4Q.js";
1
+ import { t as CliAuthReference } from "./cli-auth-bundle-BKsrsbxy.js";
2
+ import { n as TerminalStream, o as TerminalStreamHandlers } from "./terminal-stream-DgD7GlFi.js";
3
3
  import { z } from "zod";
4
4
  import * as _$_tangle_network_agent_interface0 from "@tangle-network/agent-interface";
5
5
  import { AgentExactRunControlRef, AgentProfile, AgentProfileCapabilities, AgentProfileConfidential, AgentProfileValidationResult, AgentRuntimeAttachments, PlanContinuation, ReasoningEffort, SandboxSizePreset } from "@tangle-network/agent-interface";
@@ -2405,6 +2405,11 @@ interface SSHCommandDescriptor {
2405
2405
  interface SandboxConnection {
2406
2406
  /** Sandbox runtime API URL for programmatic access */
2407
2407
  runtimeUrl?: string;
2408
+ /** Cell exec origin. Direct requests select this sandbox by header. */
2409
+ execHost?: string;
2410
+ /** Short command-only credential; refreshed through the Sandbox API. */
2411
+ execToken?: string;
2412
+ execTokenExpiresAt?: string;
2408
2413
  /** Access token for authenticating directly with the runtime (Bearer token) */
2409
2414
  authToken?: string;
2410
2415
  /** Token expiration timestamp (ISO 8601). Refresh before this time. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/sandbox",
3
- "version": "0.60.88",
3
+ "version": "0.60.90",
4
4
  "description": "Client SDK for the Tangle Sandbox platform - build AI agent applications with dev containers",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -154,17 +154,17 @@
154
154
  "vitest": "^4.1.11",
155
155
  "ws": "^8.20.0",
156
156
  "yjs": "13.6.30",
157
- "@repo/shared": "0.0.0",
158
157
  "@products/sandbox-test-utils": "0.0.0",
158
+ "@repo/shared": "0.0.0",
159
+ "@tangle-network/agent-profile-materialize": "0.26.0",
159
160
  "@tangle-network/cli-agent-registry": "0.10.2",
160
161
  "@tangle-network/runtime-contracts": "0.19.0",
161
162
  "@tangle-network/sdk": "4.0.16",
162
- "@tangle-network/agent-profile-materialize": "0.26.0",
163
163
  "@tangle-network/sse-core": "0.0.0"
164
164
  },
165
165
  "tangleRelease": {
166
- "sourceSha": "5f9a7c1d27c98600bf10f0468794ad1ca1efe920",
167
- "mergedAt": "2026-10-18T16:20:07-06:00"
166
+ "sourceSha": "db5e69e455ad2566d89a7a8000252f9c27dc4e27",
167
+ "mergedAt": "2026-10-18T17:58:21-06:00"
168
168
  },
169
169
  "scripts": {
170
170
  "build": "node scripts/build-dist.mjs",
File without changes