@tangle-network/sandbox 0.60.69 → 0.60.77-develop.20261016230332.7f22d61

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 (47) hide show
  1. package/README.md +46 -0
  2. package/dist/agent/index.d.ts +4 -4
  3. package/dist/agent/index.js +4 -4
  4. package/dist/agent/preview.d.ts +1 -1
  5. package/dist/{agent-run-outcome-BBk2-5vp.d.ts → agent-run-outcome-CTEpjCEZ.d.ts} +1 -1
  6. package/dist/auth/index.d.ts +1 -1
  7. package/dist/auth/index.js +1 -1
  8. package/dist/backend-types-D6bYbvMB.js +42 -0
  9. package/dist/{browser-interactive-control-controller-JUW3gOGH.d.ts → browser-interactive-control-controller-rpTbyvAS.d.ts} +1 -1
  10. package/dist/{chunked-upload-BklCn3Li.js → chunked-upload-DtIvkKNo.js} +1 -1
  11. package/dist/{chunked-upload-file-Cp-iWsWN.js → chunked-upload-file-DnsHEjg0.js} +1 -1
  12. package/dist/{cli-auth-bundle-D61iX68d.js → cli-auth-bundle-cSJjPeFF.js} +2 -2
  13. package/dist/{client-DUDqUYDG.js → client-CRkHfByN.js} +21 -9
  14. package/dist/{client-DVouBFPR.d.ts → client-Lhxo82x1.d.ts} +10 -6
  15. package/dist/collaboration/index.d.ts +1 -1
  16. package/dist/collaboration/index.js +1 -1
  17. package/dist/{collaboration-B2g1j2ey.js → collaboration-DaJU5O0E.js} +1 -1
  18. package/dist/core.d.ts +6 -6
  19. package/dist/core.js +3 -3
  20. package/dist/{errors-iWIsey1D.js → errors-DSJBKmGZ.js} +60 -1
  21. package/dist/{errors-5j_Hlkm-.d.ts → errors-mPL-qvgF.d.ts} +79 -2
  22. package/dist/{index-DaJrtipt.d.ts → index-DRto9Ijb.d.ts} +2 -2
  23. package/dist/index.d.ts +19 -17
  24. package/dist/index.js +9 -9
  25. package/dist/intelligence/index.js +1 -1
  26. package/dist/interactive-control.d.ts +1 -1
  27. package/dist/{interactive-controller-DaYmUCO_.js → interactive-controller-CJ24g8Va.js} +237 -25
  28. package/dist/{lines-D07bn-mu.d.ts → lines-DodQslsf.d.ts} +1 -1
  29. package/dist/lines.d.ts +1 -1
  30. package/dist/lines.js +1 -1
  31. package/dist/{local-cli-auth-t8KUbrfI.js → local-cli-auth-CBV7Vjk5.js} +1 -1
  32. package/dist/{managed-process-RMyVq_du.d.ts → managed-process-B7WfqKmi.d.ts} +1 -1
  33. package/dist/{preview-dIOd13_U.d.ts → preview-wpGGk0bu.d.ts} +3 -3
  34. package/dist/runtime.d.ts +5 -6
  35. package/dist/runtime.js +3 -3
  36. package/dist/{sandbox-C7wOeFZB.d.ts → sandbox-CoIGxzm_.d.ts} +78 -24
  37. package/dist/{sandbox-Dg0WI1ZF.js → sandbox-DzSEprto.js} +732 -79
  38. package/dist/tangle/index.d.ts +1 -1
  39. package/dist/tangle/index.js +1 -1
  40. package/dist/{tangle-CaY9_VGA.js → tangle-DHFKq9sn.js} +2 -2
  41. package/dist/{terminal-stream-CV1pMSKC.d.ts → terminal-stream-jdYomM1m.d.ts} +123 -4
  42. package/dist/{types-BLCY5T4s.d.ts → types-B_QF-iHm.d.ts} +242 -28
  43. package/package.json +5 -5
  44. package/dist/backend-types-C7b_Gpa0.js +0 -59
  45. package/dist/interactive-controller-DNbLzamS.d.ts +0 -40
  46. /package/dist/{index-BgmgfYZZ.d.ts → index-DO7GVpk_.d.ts} +0 -0
  47. /package/dist/{index-DHuHjNie.d.ts → index-DZ27pdB8.d.ts} +0 -0
@@ -1,9 +1,9 @@
1
- import { r as backendTypeSchema } from "./backend-types-C7b_Gpa0.js";
2
- import { b as parseResponseError, c as NetworkError, m as ServerError, n as CapabilityError, p as SandboxError, v as ValidationError } from "./errors-iWIsey1D.js";
1
+ import { r as backendTypeSchema } from "./backend-types-D6bYbvMB.js";
2
+ import { S as parseResponseError, b as ValidationError, g as ServerError, h as SandboxError, r as CapabilityError, u as NetworkError } from "./errors-DSJBKmGZ.js";
3
3
  import { c as assertInteractiveSessionRef, d as awaitWithAbort, f as combineAbortSignals, i as createBrowserInteractiveSessionControlTransport, o as InteractiveSessionControlController, r as browserInteractiveTerminalEndpoint } from "./browser-interactive-control-controller-BJf0P_J4.js";
4
- import { s as uploadChunked } from "./chunked-upload-BklCn3Li.js";
5
- import { AgentExactRunControlRefSchema, AgentExecutionOutcomeSchema, AgentInteractiveSessionAttachSchema, AgentInteractiveSessionControlClaimSchema, AgentInteractiveSessionRefSchema, AgentRuntimeAttachmentsSchema, DurablePlanSchema, InteractionRequestSchema, agentInteractiveSessionControlClaimMatchesRef, agentProfileSchema, canonicalCandidateDigest } from "@tangle-network/agent-interface";
4
+ import { s as uploadChunked } from "./chunked-upload-DtIvkKNo.js";
6
5
  import { z } from "zod";
6
+ import { AgentExactRunControlRefSchema, AgentExecutionOutcomeSchema, AgentInteractiveSessionAttachSchema, AgentInteractiveSessionControlClaimSchema, AgentInteractiveSessionRefSchema, AgentRuntimeAttachmentsSchema, DurablePlanSchema, InteractionRequestSchema, PlanContinuationSchema, agentInteractiveSessionControlClaimMatchesRef, agentProfileSchema, canonicalCandidateDigest } from "@tangle-network/agent-interface";
7
7
  //#region src/agent-run-outcome-inspection.ts
8
8
  const HUB_APPROVAL_REQUIRED = "HUB_APPROVAL_REQUIRED";
9
9
  const MAX_SERIALIZED_TOOL_VALUE_BYTES = 4 * 1024 * 1024;
@@ -678,6 +678,9 @@ function withoutRuntimeSecrets(backend) {
678
678
  function normalizeRuntimeBackendConfig(backendInput, options = {}) {
679
679
  const backend = foldModelRoutingFields(backendInput);
680
680
  if (!backend) return void 0;
681
+ const continuation = backendInput?.planContinuation;
682
+ if (continuation !== void 0 && !options.allowPlanContinuation) throw new ValidationError("backend.planContinuation is turn-only; session creation and persistence cannot carry it");
683
+ if (continuation !== void 0 && !PlanContinuationSchema.safeParse(continuation).success) throw new ValidationError("backend.planContinuation is invalid");
681
684
  if (backend.runtimeSecrets !== void 0) {
682
685
  if (!options.allowRuntimeSecrets) throw new ValidationError("[sandbox-sdk] backend.runtimeSecrets is turn-scoped credential delivery: send it on a turn request (streamPrompt / driveConversationTurn / sendMessage), not on sandbox or session creation");
683
686
  assertRuntimeSecrets(backend.runtimeSecrets);
@@ -694,6 +697,7 @@ function normalizeRuntimeBackendConfig(backendInput, options = {}) {
694
697
  if (backend.type !== void 0) assertCurrentBackendType(backend.type);
695
698
  if (backend.profile !== void 0 && !agentProfileSchema.safeParse(backend.profile).success) throw new Error("[sandbox-sdk] backend.profile must be an AgentProfile object");
696
699
  return {
700
+ ...continuation !== void 0 ? { planContinuation: structuredClone(continuation) } : {},
697
701
  ...backend?.type ? { type: backend.type } : {},
698
702
  ...backend?.profile !== void 0 ? { profile: backend.profile } : {},
699
703
  ...backend.runtimeAttachments !== void 0 ? { runtimeAttachments: structuredClone(backend.runtimeAttachments) } : {},
@@ -706,11 +710,17 @@ function normalizeRuntimeBackendConfig(backendInput, options = {}) {
706
710
  }
707
711
  /** Digest the exact public backend payload the SDK sends for a profile turn. */
708
712
  function requestedPublicProfileDigest(backend) {
709
- return publicProfileRequestDigest(normalizeRuntimeBackendConfig(backend, { allowRuntimeSecrets: true }) ?? {});
713
+ return publicProfileRequestDigest(normalizeRuntimeBackendConfig(backend, {
714
+ allowRuntimeSecrets: true,
715
+ allowPlanContinuation: true
716
+ }) ?? {});
710
717
  }
711
718
  /** Digest public profile controls while private turn fields remain on wire. */
712
719
  function requestedSecretProfilePublicDigest(backend) {
713
- return secretProfilePublicRequestDigest(normalizeRuntimeBackendConfig(backend, { allowRuntimeSecrets: true }) ?? {});
720
+ return secretProfilePublicRequestDigest(normalizeRuntimeBackendConfig(backend, {
721
+ allowRuntimeSecrets: true,
722
+ allowPlanContinuation: true
723
+ }) ?? {});
714
724
  }
715
725
  //#endregion
716
726
  //#region ../../../packages/sse-core/dist/index.js
@@ -1397,6 +1407,11 @@ var SandboxRuntimeApi = class {
1397
1407
  "content-type": "application/json",
1398
1408
  "x-no-retry": "true"
1399
1409
  });
1410
+ if (options.planFollowUp) {
1411
+ if (!request.backend?.planContinuation || !request.expectedPublicProfileRequestDigest || !request.expectedSecretProfileReceipt || !Number.isFinite(Date.parse(options.planFollowUp.expiresAt)) || Date.parse(options.planFollowUp.expiresAt) <= Date.now()) throw new ValidationError("Caller plan follow-up requires current admission and both fresh profile pins");
1412
+ headers.set("x-tangle-plan-followup-credential", options.planFollowUp.credential);
1413
+ headers.set("x-tangle-plan-followup-callback", options.planFollowUp.callbackUrl);
1414
+ }
1400
1415
  if (options.credentials?.apiKey) headers.set("X-Backend-Api-Key", options.credentials.apiKey);
1401
1416
  if (options.credentials?.baseUrl) headers.set("X-Backend-Base-Url", options.credentials.baseUrl);
1402
1417
  if (options.traceId !== void 0) headers.set(TRACE_ID_HEADER, resolveTraceId(options.traceId));
@@ -1413,7 +1428,7 @@ var SandboxRuntimeApi = class {
1413
1428
  try {
1414
1429
  receipt = await this.json(path, init);
1415
1430
  } catch (error) {
1416
- if (!isRetryableCredentialRefusal(error)) throw error;
1431
+ if (options.planFollowUp || !isRetryableCredentialRefusal(error)) throw error;
1417
1432
  await waitForRetryAfter(error.retryAfterMs ?? 1e3, signal);
1418
1433
  receipt = await this.json(path, init);
1419
1434
  }
@@ -1589,6 +1604,7 @@ function normalizeSessionInfo(raw) {
1589
1604
  }
1590
1605
  /** The admission check must hash the same wire request as dispatch. */
1591
1606
  function sessionMessageRequestBody(request) {
1607
+ if (request.ttlMs !== void 0 && (!Number.isInteger(request.ttlMs) || request.ttlMs <= 0)) throw new ValidationError("ttlMs must be a positive integer of milliseconds");
1592
1608
  if (request.admissionDeadline !== void 0) {
1593
1609
  if (!request.turnId) throw new ValidationError("admissionDeadline requires turnId");
1594
1610
  const deadline = request.admissionDeadline;
@@ -1603,13 +1619,17 @@ function sessionMessageRequestBody(request) {
1603
1619
  if (request.expectedPublicProfileRevision !== void 0 && request.expectedPublicProfileRequestDigest === void 0) throw new ValidationError("Native public profile plan pin requires a public request pin");
1604
1620
  if (request.expectedSecretProfileReceipt !== void 0 && (request.expectedPublicProfileRequestDigest === void 0 || request.expectedPublicProfileRevision !== void 0 || !/^hmac-sha256:[a-f0-9]{64}$/.test(request.expectedSecretProfileReceipt))) throw new ValidationError("Secret native profile receipt requires a public request pin and no public native receipt");
1605
1621
  return {
1606
- ...request.backend !== void 0 ? { backend: normalizeRuntimeBackendConfig(request.backend, { allowRuntimeSecrets: true }) } : {},
1622
+ ...request.backend !== void 0 ? { backend: normalizeRuntimeBackendConfig(request.backend, {
1623
+ allowRuntimeSecrets: true,
1624
+ allowPlanContinuation: true
1625
+ }) } : {},
1607
1626
  ...request.managedQuoteVersion !== void 0 ? { managedQuoteVersion: request.managedQuoteVersion } : {},
1608
1627
  ...request.expectedPublicProfileRequestDigest !== void 0 ? { expectedPublicProfileRequestDigest: request.expectedPublicProfileRequestDigest } : {},
1609
1628
  ...request.expectedPublicProfileRevision !== void 0 ? { expectedPublicProfileRevision: request.expectedPublicProfileRevision } : {},
1610
1629
  ...request.expectedSecretProfileReceipt !== void 0 ? { expectedSecretProfileReceipt: request.expectedSecretProfileReceipt } : {},
1611
1630
  ...request.managedModelCredential === true ? { managedModelCredential: true } : {},
1612
1631
  ...request.runControlRef !== void 0 ? { runControlRef: AgentExactRunControlRefSchema.parse(request.runControlRef) } : {},
1632
+ ...request.ttlMs !== void 0 ? { ttlMs: request.ttlMs } : {},
1613
1633
  ...request.admissionDeadline !== void 0 ? { admissionDeadline: request.admissionDeadline } : {},
1614
1634
  ...request.messageId !== void 0 ? { messageID: request.messageId } : {},
1615
1635
  parts: request.parts.map((part) => part.type === "text" ? {
@@ -1718,6 +1738,21 @@ const TERMINAL_WS_EDGE_BEARER_SUBPROTOCOL_PREFIX = "bearer.";
1718
1738
  const TERMINAL_WS_SIDECAR_BEARER_SUBPROTOCOL_PREFIX = "tangle.bearer.";
1719
1739
  /** Non-credential protocol selected during a successful terminal handshake. */
1720
1740
  const TERMINAL_WS_ECHO_SUBPROTOCOL = "tangle.terminal.v1";
1741
+ /**
1742
+ * Encode the upgrade URL's query (no leading `?`): the size of a
1743
+ * default-shell attach with its flag, and the trace id. Nothing else rides the
1744
+ * URL.
1745
+ */
1746
+ function encodeTerminalUpgradeQuery(input) {
1747
+ const params = new URLSearchParams();
1748
+ if (input.defaultShell !== void 0) {
1749
+ params.set("cols", String(input.defaultShell.cols));
1750
+ params.set("rows", String(input.defaultShell.rows));
1751
+ params.set("defaultShell", "1");
1752
+ }
1753
+ if (input.traceId !== void 0) params.set("traceId", input.traceId);
1754
+ return params.toString();
1755
+ }
1721
1756
  const terminalGeometry = {
1722
1757
  cols: z.number().int().min(1).max(TERMINAL_WS_MAX_DIMENSION),
1723
1758
  rows: z.number().int().min(1).max(TERMINAL_WS_MAX_DIMENSION)
@@ -1733,7 +1768,12 @@ const terminalInitMessageSchema = z.object({
1733
1768
  env: z.record(z.string(), z.string()).optional(),
1734
1769
  sessionId: z.string().min(1).optional(),
1735
1770
  /** Canonical control claim for an interactive-agent PTY. */
1736
- control: AgentInteractiveSessionControlClaimSchema.optional()
1771
+ control: AgentInteractiveSessionControlClaimSchema.optional(),
1772
+ /**
1773
+ * Caller trace id for a browser, which cannot set `x-tangle-trace-id` on
1774
+ * the upgrade. The server adopts it only when it is a well-formed id.
1775
+ */
1776
+ traceId: z.string().max(200).optional()
1737
1777
  }).superRefine((message, refinement) => {
1738
1778
  if (message.incarnationId !== void 0 && message.control === void 0) refinement.addIssue({
1739
1779
  code: "custom",
@@ -1763,6 +1803,39 @@ z.union([
1763
1803
  terminalRenewMessageSchema,
1764
1804
  terminalCloseMessageSchema
1765
1805
  ]);
1806
+ /**
1807
+ * Server stamps for one attach, in epoch milliseconds on the sidecar's clock.
1808
+ * They are absolute so a caller can lay them against its own marks and read
1809
+ * each leg (client clock skew is the only error). `spawn*` and `initPersistAt`
1810
+ * are absent when the attach adopted a PTY that already existed.
1811
+ */
1812
+ const terminalReadyTimingsSchema = z.object({
1813
+ /** The upgrade request reached the sidecar's upgrade handler. */
1814
+ upgradeAt: z.number(),
1815
+ /** The bearer was verified (`ws.auth` ends). */
1816
+ authAt: z.number(),
1817
+ /** The init parameters were in hand: at the upgrade for `via: "upgrade"`, on the init frame otherwise. */
1818
+ initAt: z.number(),
1819
+ /** `loadOrCreateConnection` started. */
1820
+ loadAt: z.number(),
1821
+ /** The PTY process was spawned (`pty.spawn` ends). */
1822
+ spawnAt: z.number().optional(),
1823
+ /** The `session.init` event was persisted (`session.init.persist` ends). */
1824
+ initPersistAt: z.number().optional(),
1825
+ /** `loadOrCreateConnection` returned. */
1826
+ loadedAt: z.number(),
1827
+ /** The retained history was read (`history.read` ends). */
1828
+ historyAt: z.number(),
1829
+ /** Retained events and bytes the replay will carry. */
1830
+ historyEvents: z.number().int().nonnegative(),
1831
+ historyBytes: z.number().int().nonnegative(),
1832
+ /** The `ready` frame was sent. */
1833
+ readyAt: z.number(),
1834
+ /** How the init parameters reached the server. */
1835
+ via: z.enum(["upgrade", "frame"]),
1836
+ /** Correlation id of this attach (`terminal_attach` spans share it). */
1837
+ ptid: z.string().optional()
1838
+ });
1766
1839
  const terminalReadyMessageSchema = z.object({
1767
1840
  type: z.literal("ready"),
1768
1841
  connectionId: z.string(),
@@ -1775,7 +1848,9 @@ const terminalReadyMessageSchema = z.object({
1775
1848
  cursors: z.object({
1776
1849
  earliest: z.number().int().nonnegative(),
1777
1850
  latest: z.number().int().nonnegative()
1778
- }).optional()
1851
+ }).optional(),
1852
+ /** Server stamps for this attach; absent from a sidecar that predates them. */
1853
+ timings: terminalReadyTimingsSchema.optional()
1779
1854
  });
1780
1855
  /** One sequenced output frame for an exact interactive terminal. */
1781
1856
  const terminalOutputMessageSchema = z.object({
@@ -1835,6 +1910,14 @@ const terminalServerMessageSchema = z.union([
1835
1910
  * capture consumer; not part of the client surface
1836
1911
  * server → client (BINARY): raw PTY output bytes
1837
1912
  *
1913
+ * A default-shell attach (no `command`, `cwd`, `env` or interactive identity)
1914
+ * also puts `cols`, `rows` and `defaultShell=1` on the upgrade URL. A server
1915
+ * that reads them starts the PTY when it accepts the upgrade and sends `ready`
1916
+ * without waiting for `init`; the `init` frame is still sent, first, and that
1917
+ * server ignores it. A server that does not read them waits for `init` exactly
1918
+ * as before. `command` and `cwd` travel only in the `init` frame, inside the
1919
+ * WebSocket: the URL and the request headers reach access logs.
1920
+ *
1838
1921
  * Detach/reconnect: the server keeps the PTY alive for `detachTimeoutMs`
1839
1922
  * (5 minutes today) after the socket closes; re-dialing with the SAME
1840
1923
  * connectionId reattaches and replays the buffered output history, so a
@@ -1848,10 +1931,18 @@ const terminalServerMessageSchema = z.union([
1848
1931
  var TerminalStreamError = class extends Error {
1849
1932
  /** Protocol error code (e.g. `INIT_FAILED`) or `TRANSPORT` for socket faults. */
1850
1933
  code;
1851
- constructor(message, code) {
1934
+ /**
1935
+ * True when the socket never reached OPEN: the upgrade was refused (a
1936
+ * WebSocket client cannot read the HTTP status, so a 401 and a network drop
1937
+ * look alike) or the runtime rejected the dial's options. No PTY work had
1938
+ * started on the client's side of that dial.
1939
+ */
1940
+ beforeOpen;
1941
+ constructor(message, code, options = {}) {
1852
1942
  super(message);
1853
1943
  this.name = "TerminalStreamError";
1854
1944
  this.code = code;
1945
+ this.beforeOpen = options.beforeOpen === true;
1855
1946
  }
1856
1947
  };
1857
1948
  /**
@@ -1900,6 +1991,77 @@ async function resolveTerminalToken(token, signal) {
1900
1991
  if (typeof value !== "string" || !value.trim()) throw new TerminalStreamError(typeof token === "function" ? "Terminal stream token provider returned an empty token" : "Terminal stream token must not be empty", "INVALID_TOKEN");
1901
1992
  return value;
1902
1993
  }
1994
+ function isApiKeyToken(token) {
1995
+ return typeof token === "object" && token !== null && "apiKey" in token && typeof token.apiKey === "string";
1996
+ }
1997
+ async function resolveDialCredential(token, authFormat, signal) {
1998
+ if (!isApiKeyToken(token)) return {
1999
+ kind: "subprotocol",
2000
+ token: await resolveTerminalToken(token, signal)
2001
+ };
2002
+ if (!token.apiKey.trim()) throw new TerminalStreamError("Terminal stream API key must not be empty", "INVALID_TOKEN");
2003
+ if (authFormat === "sidecar-direct") throw new TerminalStreamError("An API key authenticates the public API proxy, not a direct sidecar dial", "INVALID_TOKEN");
2004
+ if (!terminalUpgradeHeadersSupported()) throw new TerminalStreamError("This runtime cannot set headers on a WebSocket upgrade; dial with a scoped token", "ENVIRONMENT", { beforeOpen: true });
2005
+ return {
2006
+ kind: "apiKey",
2007
+ apiKey: token.apiKey
2008
+ };
2009
+ }
2010
+ /**
2011
+ * Whether this runtime's global `WebSocket` accepts request headers on the
2012
+ * upgrade (Node >= 22 through undici, and Bun): the condition for dialing with
2013
+ * the API key and for sending `x-tangle-trace-id` as a header. Browsers and
2014
+ * Workers cannot. A runtime that is judged able but ignores the headers is
2015
+ * still safe: the upgrade is refused, and the caller dials with a scoped token.
2016
+ */
2017
+ function terminalUpgradeHeadersSupported() {
2018
+ const runtime = globalThis;
2019
+ if (typeof runtime.process?.versions?.node !== "string") return false;
2020
+ if (runtime.navigator?.userAgent?.startsWith("Cloudflare-Workers")) return false;
2021
+ return typeof globalThis.WebSocket === "function";
2022
+ }
2023
+ function buildUpgradeRequest(options, credential, identity, traceId) {
2024
+ const canSetHeaders = terminalUpgradeHeadersSupported();
2025
+ const initOnUpgrade = identity === void 0 && options.env === void 0 && options.command === void 0 && options.cwd === void 0;
2026
+ const query = encodeTerminalUpgradeQuery({
2027
+ ...initOnUpgrade ? { defaultShell: {
2028
+ cols: options.cols ?? DEFAULT_COLS,
2029
+ rows: options.rows ?? DEFAULT_ROWS
2030
+ } } : {},
2031
+ traceId
2032
+ });
2033
+ const url = new URL(toWebSocketUrl(options.url));
2034
+ for (const [key, value] of new URLSearchParams(query)) url.searchParams.set(key, value);
2035
+ return {
2036
+ url: url.toString(),
2037
+ protocols: credential.kind === "apiKey" ? [TERMINAL_WS_ECHO_SUBPROTOCOL] : buildAuthSubprotocols(options.authFormat ?? "edge", credential.token),
2038
+ headers: {
2039
+ ...canSetHeaders ? { [TRACE_ID_HEADER]: traceId } : {},
2040
+ ...credential.kind === "apiKey" ? { Authorization: `Bearer ${credential.apiKey}` } : {}
2041
+ },
2042
+ initOnUpgrade
2043
+ };
2044
+ }
2045
+ function openWebSocket(request, credential) {
2046
+ const WebSocketCtor = globalThis.WebSocket;
2047
+ if (typeof WebSocketCtor !== "function") throw new TerminalStreamError("global WebSocket is unavailable in this environment (Node >= 22 or a browser is required)", "ENVIRONMENT");
2048
+ if (Object.keys(request.headers).length === 0) return new WebSocketCtor(request.url, request.protocols);
2049
+ const WebSocketWithHeaders = WebSocketCtor;
2050
+ try {
2051
+ return new WebSocketWithHeaders(request.url, {
2052
+ protocols: request.protocols,
2053
+ headers: request.headers
2054
+ });
2055
+ } catch (cause) {
2056
+ if (credential.kind === "apiKey") throw new TerminalStreamError(`This runtime rejected WebSocket upgrade headers: ${cause instanceof Error ? cause.message : String(cause)}`, "ENVIRONMENT", { beforeOpen: true });
2057
+ return new WebSocketCtor(request.url, request.protocols);
2058
+ }
2059
+ }
2060
+ function resolveStreamTraceId(requested) {
2061
+ if (requested === void 0) return mintTraceId();
2062
+ if (!isTraceId(requested)) throw new TerminalStreamError("Terminal stream traceId must be 8-200 characters of letters, digits, '_' or '-'", "INVALID_TRACE_ID");
2063
+ return requested;
2064
+ }
1903
2065
  function terminalAbortReason(signal) {
1904
2066
  return signal.reason instanceof Error ? signal.reason : new DOMException("Terminal attach was aborted", "AbortError");
1905
2067
  }
@@ -1977,7 +2139,7 @@ function interactiveInitFields(identity) {
1977
2139
  control: identity.control
1978
2140
  };
1979
2141
  }
1980
- function buildTerminalInitMessage(options, identity) {
2142
+ function buildTerminalInitMessage(options, identity, traceId) {
1981
2143
  if (typeof options.connectionId !== "string" || !options.connectionId.trim()) throw new TerminalStreamError("Terminal stream connectionId must not be empty", "INVALID_CONNECTION_ID");
1982
2144
  if (options.cols !== void 0) assertDimension("cols", options.cols);
1983
2145
  if (options.rows !== void 0) assertDimension("rows", options.rows);
@@ -1989,7 +2151,8 @@ function buildTerminalInitMessage(options, identity) {
1989
2151
  ...options.command !== void 0 ? { command: options.command } : {},
1990
2152
  ...options.cwd !== void 0 ? { cwd: options.cwd } : {},
1991
2153
  ...options.env !== void 0 ? { env: options.env } : {},
1992
- ...interactiveInitFields(identity)
2154
+ ...interactiveInitFields(identity),
2155
+ ...terminalUpgradeHeadersSupported() ? {} : { traceId }
1993
2156
  });
1994
2157
  if (!parsed.success) throw new TerminalStreamError("Terminal stream init does not match the shared terminal protocol", "INVALID_INIT");
1995
2158
  return parsed.data;
@@ -2031,6 +2194,14 @@ var TerminalStream = class TerminalStream {
2031
2194
  interactiveIdentity;
2032
2195
  initMessage;
2033
2196
  handlers;
2197
+ attachTraceId;
2198
+ initOnUpgrade;
2199
+ dialStartedAt = performance.now();
2200
+ openedAt;
2201
+ readyAt;
2202
+ firstByteAt;
2203
+ firstWriteAt;
2204
+ echoRttMs;
2034
2205
  readyInfo = null;
2035
2206
  closed = false;
2036
2207
  closeWaiters = [];
@@ -2047,19 +2218,18 @@ var TerminalStream = class TerminalStream {
2047
2218
  static async connect(options) {
2048
2219
  const interactiveIdentity = normalizeInteractiveSessionIdentity(options.incarnationId, options.control);
2049
2220
  options.signal?.throwIfAborted();
2050
- const initMessage = buildTerminalInitMessage(options, interactiveIdentity);
2051
- const token = await awaitTerminalOperation(resolveTerminalToken(options.token, options.signal), options.signal);
2221
+ const traceId = resolveStreamTraceId(options.traceId);
2222
+ const initMessage = buildTerminalInitMessage(options, interactiveIdentity, traceId);
2223
+ const credential = await awaitTerminalOperation(resolveDialCredential(options.token, options.authFormat ?? "edge", options.signal), options.signal);
2052
2224
  options.signal?.throwIfAborted();
2053
- return new TerminalStream(options, token, interactiveIdentity, initMessage).establish(options.signal);
2225
+ return new TerminalStream(options, credential, interactiveIdentity, initMessage, traceId).establish(options.signal);
2054
2226
  }
2055
- constructor(options, resolvedToken, interactiveIdentity, initMessage) {
2227
+ constructor(options, credential, interactiveIdentity, initMessage, traceId) {
2056
2228
  const exactOptions = interactiveIdentity === void 0 ? options : {
2057
2229
  ...options,
2058
2230
  incarnationId: interactiveIdentity.incarnationId,
2059
2231
  control: interactiveIdentity.control
2060
2232
  };
2061
- const WebSocketCtor = globalThis.WebSocket;
2062
- if (typeof WebSocketCtor !== "function") throw new TerminalStreamError("global WebSocket is unavailable in this environment (Node >= 22 or a browser is required)", "ENVIRONMENT");
2063
2233
  this.options = {
2064
2234
  ...exactOptions,
2065
2235
  signal: void 0
@@ -2067,12 +2237,16 @@ var TerminalStream = class TerminalStream {
2067
2237
  this.interactiveIdentity = interactiveIdentity;
2068
2238
  this.initMessage = initMessage;
2069
2239
  this.handlers = exactOptions.handlers ?? {};
2070
- this.ws = new WebSocketCtor(toWebSocketUrl(exactOptions.url), buildAuthSubprotocols(exactOptions.authFormat ?? "edge", resolvedToken));
2240
+ this.attachTraceId = traceId;
2241
+ const request = buildUpgradeRequest(exactOptions, credential, interactiveIdentity, traceId);
2242
+ this.initOnUpgrade = request.initOnUpgrade;
2243
+ this.ws = openWebSocket(request, credential);
2071
2244
  this.ws.binaryType = "arraybuffer";
2072
2245
  }
2073
2246
  establish(signal) {
2074
2247
  return new Promise((resolve, reject) => {
2075
2248
  let settled = false;
2249
+ let opened = false;
2076
2250
  const timeoutMs = this.options.connectTimeoutMs ?? DEFAULT_CONNECT_TIMEOUT_MS;
2077
2251
  const timer = setTimeout(() => {
2078
2252
  fail(new TerminalStreamError(`Terminal attach timed out after ${timeoutMs}ms waiting for ready`, "CONNECT_TIMEOUT"));
@@ -2105,6 +2279,8 @@ var TerminalStream = class TerminalStream {
2105
2279
  return;
2106
2280
  }
2107
2281
  this.ws.addEventListener("open", () => {
2282
+ opened = true;
2283
+ this.openedAt = performance.now();
2108
2284
  if (settled) return;
2109
2285
  try {
2110
2286
  assertInteractiveControlActive(this.interactiveIdentity);
@@ -2122,11 +2298,11 @@ var TerminalStream = class TerminalStream {
2122
2298
  });
2123
2299
  });
2124
2300
  this.ws.addEventListener("error", () => {
2125
- fail(new TerminalStreamError("Terminal WebSocket transport failed before ready", "TRANSPORT"));
2301
+ fail(new TerminalStreamError("Terminal WebSocket transport failed before ready", "TRANSPORT", { beforeOpen: !opened }));
2126
2302
  });
2127
2303
  this.ws.addEventListener("close", (event) => {
2128
2304
  this.closed = true;
2129
- fail(new TerminalStreamError(`Terminal WebSocket closed before ready (code ${event.code}${event.reason ? `: ${event.reason}` : ""})`, "CLOSED_BEFORE_READY"));
2305
+ fail(new TerminalStreamError(`Terminal WebSocket closed before ready (code ${event.code}${event.reason ? `: ${event.reason}` : ""})`, "CLOSED_BEFORE_READY", { beforeOpen: !opened }));
2130
2306
  for (const waiter of this.closeWaiters) waiter();
2131
2307
  this.closeWaiters = [];
2132
2308
  this.handlers.onClose?.(event.code, event.reason);
@@ -2135,7 +2311,10 @@ var TerminalStream = class TerminalStream {
2135
2311
  }
2136
2312
  handleMessage(raw, connectPhase) {
2137
2313
  if (typeof raw !== "string") {
2138
- if (raw instanceof ArrayBuffer) this.handlers.onData?.(new Uint8Array(raw));
2314
+ if (raw instanceof ArrayBuffer) {
2315
+ this.noteOutput();
2316
+ this.handlers.onData?.(new Uint8Array(raw));
2317
+ }
2139
2318
  return;
2140
2319
  }
2141
2320
  const failProtocolFrame = () => {
@@ -2172,9 +2351,11 @@ var TerminalStream = class TerminalStream {
2172
2351
  restored: parsed.data.restored,
2173
2352
  detachTimeoutMs: parsed.data.detachTimeoutMs,
2174
2353
  ...parsed.data.attachCount === void 0 ? {} : { attachCount: parsed.data.attachCount },
2175
- ...parsed.data.cursors === void 0 ? {} : { cursors: parsed.data.cursors }
2354
+ ...parsed.data.cursors === void 0 ? {} : { cursors: parsed.data.cursors },
2355
+ ...parsed.data.timings === void 0 ? {} : { timings: parsed.data.timings }
2176
2356
  };
2177
2357
  this.readyInfo = info;
2358
+ this.readyAt ??= performance.now();
2178
2359
  connectPhase.succeed();
2179
2360
  this.handlers.onReady?.(info);
2180
2361
  return;
@@ -2182,6 +2363,7 @@ var TerminalStream = class TerminalStream {
2182
2363
  case "output":
2183
2364
  try {
2184
2365
  const bytes = decodeBase64(parsed.data.data);
2366
+ this.noteOutput();
2185
2367
  this.handlers.onOutput?.(parsed.data.seq, bytes);
2186
2368
  if (this.handlers.onOutput === void 0) this.handlers.onData?.(bytes);
2187
2369
  } catch (error) {
@@ -2218,6 +2400,34 @@ var TerminalStream = class TerminalStream {
2218
2400
  if (!this.readyInfo) throw new TerminalStreamError("Terminal stream is not ready yet", "NOT_READY");
2219
2401
  return this.readyInfo;
2220
2402
  }
2403
+ /** Correlation id of this attach (`x-tangle-trace-id` / `traceId`). */
2404
+ get traceId() {
2405
+ return this.attachTraceId;
2406
+ }
2407
+ /**
2408
+ * Timings of this attach. `firstByteMs` and `echoRttMs` appear once the
2409
+ * stream has produced the output they measure.
2410
+ */
2411
+ get timings() {
2412
+ const opened = this.openedAt ?? this.dialStartedAt;
2413
+ const ready = this.readyAt ?? opened;
2414
+ return {
2415
+ ...this.options.mintMs === void 0 ? {} : { mintMs: this.options.mintMs },
2416
+ wsOpenMs: opened - this.dialStartedAt,
2417
+ initToReadyMs: ready - opened,
2418
+ ...this.firstByteAt === void 0 ? {} : { firstByteMs: this.firstByteAt - ready },
2419
+ ...this.echoRttMs === void 0 ? {} : { echoRttMs: this.echoRttMs },
2420
+ init: this.initOnUpgrade ? "upgrade" : "frame",
2421
+ ...this.readyInfo?.timings === void 0 ? {} : { server: this.readyInfo.timings }
2422
+ };
2423
+ }
2424
+ /** Stamp the first output byte after `ready`, and the first one after the first write. */
2425
+ noteOutput() {
2426
+ if (this.readyAt === void 0) return;
2427
+ const now = performance.now();
2428
+ this.firstByteAt ??= now;
2429
+ if (this.firstWriteAt !== void 0 && this.echoRttMs === void 0) this.echoRttMs = now - this.firstWriteAt;
2430
+ }
2221
2431
  /** True while the socket is open. */
2222
2432
  get isOpen() {
2223
2433
  return !this.closed && this.ws.readyState === WebSocket.OPEN;
@@ -2232,6 +2442,7 @@ var TerminalStream = class TerminalStream {
2232
2442
  this.assertOpen("write");
2233
2443
  assertInteractiveControlActive(this.interactiveIdentity);
2234
2444
  const text = typeof data === "string" ? data : this.textDecoder.decode(data);
2445
+ if (this.readyAt !== void 0) this.firstWriteAt ??= performance.now();
2235
2446
  for (const chunk of chunkInput(text)) this.ws.send(JSON.stringify({
2236
2447
  type: "input",
2237
2448
  data: chunk
@@ -2292,6 +2503,7 @@ var TerminalStream = class TerminalStream {
2292
2503
  control: binding.control
2293
2504
  },
2294
2505
  token: overrides?.token ?? this.options.token,
2506
+ mintMs: void 0,
2295
2507
  handlers: this.handlersForReconnect(overrides?.handlers),
2296
2508
  cols: overrides?.cols ?? this.options.cols,
2297
2509
  rows: overrides?.rows ?? this.options.rows,
@@ -2457,4 +2669,4 @@ var BrowserInteractiveSessionController = class extends InteractiveSessionContro
2457
2669
  }
2458
2670
  };
2459
2671
  //#endregion
2460
- export { requestedPublicProfileDigest as A, encodeTextForWire as C, foldModelRoutingFields as D, assertCurrentBackendType as E, deriveAgentResultOutcome as F, deriveAgentRunOutcome as I, projectAgentTerminalRecord as L, withProfileHarness as M, withoutRuntimeSecrets as N, mergeRuntimeBackendConfig as O, createAgentRunOutcomeTracker as P, encodePromptForWire as S, applyRequestedModel as T, resolveTraceId as _, TERMINAL_WS_ECHO_SUBPROTOCOL as a, resolveDispatchRunIdentity as b, requestScopedToken as c, normalizeSessionInfo as d, sessionMessageRequestBody as f, mintTraceId as g, isTraceId as h, TerminalStreamError as i, requestedSecretProfilePublicDigest as j, normalizeRuntimeBackendConfig as k, SandboxRuntimeApi as l, TRACE_ID_HEADER as m, InteractiveSessionController as n, assertScopedTokenActive as o, waitForRetryAfter as p, TerminalStream as r, requestInteractiveSessionToken as s, BrowserInteractiveSessionController as t, isRetryableCredentialRefusal as u, appendSessionIdQuery as v, parseSSEStream as w, validateAcceptedDispatchRunRef as x, sessionHeaders as y };
2672
+ export { normalizeRuntimeBackendConfig as A, encodePromptForWire as C, assertCurrentBackendType as D, applyRequestedModel as E, createAgentRunOutcomeTracker as F, deriveAgentResultOutcome as I, deriveAgentRunOutcome as L, requestedSecretProfilePublicDigest as M, withProfileHarness as N, foldModelRoutingFields as O, withoutRuntimeSecrets as P, projectAgentTerminalRecord as R, validateAcceptedDispatchRunRef as S, parseSSEStream as T, mintTraceId as _, terminalUpgradeHeadersSupported as a, sessionHeaders as b, requestInteractiveSessionToken as c, isRetryableCredentialRefusal as d, normalizeSessionInfo as f, isTraceId as g, TRACE_ID_HEADER as h, TerminalStreamError as i, requestedPublicProfileDigest as j, mergeRuntimeBackendConfig as k, requestScopedToken as l, waitForRetryAfter as m, InteractiveSessionController as n, TERMINAL_WS_ECHO_SUBPROTOCOL as o, sessionMessageRequestBody as p, TerminalStream as r, assertScopedTokenActive as s, BrowserInteractiveSessionController as t, SandboxRuntimeApi as u, resolveTraceId as v, encodeTextForWire as w, resolveDispatchRunIdentity as x, appendSessionIdQuery as y };
@@ -1,4 +1,4 @@
1
- import { B as CreateSandboxOptions, d as BackendConfig } from "./types-BLCY5T4s.js";
1
+ import { B as CreateSandboxOptions, d as BackendConfig } from "./types-B_QF-iHm.js";
2
2
 
3
3
  //#region src/line-application.d.ts
4
4
  /** Bounded callback request bytes after canonicalization, including JSON framing. */
package/dist/lines.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { A as LineSendReceipt, B as lineInstanceKey, C as LineReplyCode, D as LineRespondView, E as LineRespondAgent, F as LineVoice, I as LineVoiceOptions, L as LinesClient, M as LineSenderVerificationStart, N as LineThread, O as LineRole, P as LineTransport, R as LinesHttpClient, S as LineReminderPreferences, T as LineReplyGate, V as profileChannelReference, _ as LineMemberPatch, a as LineApplicationAttachOptions, b as LineNumberInventory, c as LineAttachmentReauthorization, d as LineImage, f as LineInstanceAttachOptions, g as LineMemberInstance, h as LineMember, i as LineAllowanceSubject, j as LineSenderVerification, k as LineSendInput, l as LineExecutionKey, m as LineLimits, n as LineAgentRolePolicy, o as LineAttachOptions, p as LineInstanceCreate, r as LineAllowance, s as LineAttachment, t as Line, u as LineFromConnectionInput, v as LineMemberSpec, w as LineReplyCodeInput, x as LineProvider, y as LineMessage, z as SandboxLines } from "./lines-D07bn-mu.js";
1
+ import { A as LineSendReceipt, B as lineInstanceKey, C as LineReplyCode, D as LineRespondView, E as LineRespondAgent, F as LineVoice, I as LineVoiceOptions, L as LinesClient, M as LineSenderVerificationStart, N as LineThread, O as LineRole, P as LineTransport, R as LinesHttpClient, S as LineReminderPreferences, T as LineReplyGate, V as profileChannelReference, _ as LineMemberPatch, a as LineApplicationAttachOptions, b as LineNumberInventory, c as LineAttachmentReauthorization, d as LineImage, f as LineInstanceAttachOptions, g as LineMemberInstance, h as LineMember, i as LineAllowanceSubject, j as LineSenderVerification, k as LineSendInput, l as LineExecutionKey, m as LineLimits, n as LineAgentRolePolicy, o as LineAttachOptions, p as LineInstanceCreate, r as LineAllowance, s as LineAttachment, t as Line, u as LineFromConnectionInput, v as LineMemberSpec, w as LineReplyCodeInput, x as LineProvider, y as LineMessage, z as SandboxLines } from "./lines-DodQslsf.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,4 +1,4 @@
1
- import { v as ValidationError, y as parseErrorResponse } from "./errors-iWIsey1D.js";
1
+ import { b as ValidationError, x as parseErrorResponse } from "./errors-DSJBKmGZ.js";
2
2
  //#region src/lines.ts
3
3
  /**
4
4
  * Lines: give a sandbox a phone number or messaging address.
@@ -1,4 +1,4 @@
1
- import { t as AUTH_BUNDLE_PATHS } from "./cli-auth-bundle-D61iX68d.js";
1
+ import { t as AUTH_BUNDLE_PATHS } from "./cli-auth-bundle-cSJjPeFF.js";
2
2
  import { existsSync, readFileSync } from "node:fs";
3
3
  import { join } from "node:path";
4
4
  import { homedir } from "node:os";
@@ -1,4 +1,4 @@
1
- import { An as ManagedProcessRecord, Mn as ManagedProcessSpec, On as ManagedProcessJobs, jn as ManagedProcessResumeOptions, kn as ManagedProcessOptions } from "./types-BLCY5T4s.js";
1
+ import { Fn as ManagedProcessJobs, In as ManagedProcessOptions, Ln as ManagedProcessRecord, Rn as ManagedProcessResumeOptions, zn as ManagedProcessSpec } from "./types-B_QF-iHm.js";
2
2
 
3
3
  //#region src/managed-process.d.ts
4
4
  declare class ManagedProcessClient implements ManagedProcessJobs {
@@ -1,6 +1,6 @@
1
- import { r as SandboxInstance } from "./sandbox-C7wOeFZB.js";
2
- import { Vn as PreviewLinkInfo, ht as EnsureDevServerOptions } from "./types-BLCY5T4s.js";
3
- import { i as Sandbox } from "./client-DVouBFPR.js";
1
+ import { n as SandboxInstance } from "./sandbox-CoIGxzm_.js";
2
+ import { Jn as PreviewLinkInfo, _t as EnsureDevServerOptions } from "./types-B_QF-iHm.js";
3
+ import { i as Sandbox } from "./client-Lhxo82x1.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,8 @@
1
- import { A as CommitTaskSessionOptions, Ai as SandboxTerminalInfo, At as FileUsageOptions, Ci as SandboxRuntimeHealth, Cn as ListMessagesOptions, Gi as SentSessionMessage, H as CreateTaskSessionOptions, Ji as SessionExecutionInfo, Mi as SandboxTerminalRequestOptions, Mt as FileWriteResult, Nr as SandboxEvent, Ot as FileTreeOptions, Pa as UploadProgress, Qi as SessionInfo, Sa as TaskSessionInfo, St as FileReadBatchResult, T as ChunkedUploadResult, Tt as FileRenameResult, Ui as SendSessionMessageOptions, V as CreateSessionOptions, Wi as SendSessionMessageRequest, Yi as SessionExecutionStatus, ba as TaskSessionCommitResult, gi as SandboxPortBinding, ji as SandboxTerminalManager, jt as FileUsageResult, ki as SandboxTerminalCreateOptions, kt as FileTreeResult, mr as RenameOptions, na as SessionMessageAdmission, qi as SessionEventStreamOptions, ta as SessionMessage, w as ChunkedUploadOptions, xt as FileReadBatchOptions, ya as TaskSessionChanges, za as WriteFileOptions } from "./types-BLCY5T4s.js";
2
- import { l as ScopedToken, t as TerminalStream } from "./terminal-stream-CV1pMSKC.js";
3
- import { c as InteractiveSessionIdentity, l as InteractiveSessionNotRunningError, r as browserInteractiveControlHolderId } from "./browser-interactive-control-controller-JUW3gOGH.js";
4
- import { t as BrowserInteractiveSessionController } from "./interactive-controller-DNbLzamS.js";
5
- import { a as FileWriteConflictError, b as ValidationError, 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, y as TimeoutError } from "./errors-5j_Hlkm-.js";
6
- import { a as deriveAgentRunOutcome, i as deriveAgentResultOutcome, n as AgentRunOutcomeTracker, o as projectAgentTerminalRecord, r as createAgentRunOutcomeTracker, t as AgentRunOutcome } from "./agent-run-outcome-BBk2-5vp.js";
1
+ import { $i as SendSessionMessageOptions, A as CommitTaskSessionOptions, Aa as TaskSessionChanges, An as ListMessagesOptions, At as FileTreeOptions, Bi as SandboxTerminalInfo, Br as SandboxEvent, Ct as FileReadBatchOptions, Dt as FileRenameResult, Ei as SandboxPortBinding, H as CreateTaskSessionOptions, Hi as SandboxTerminalRequestOptions, Ka as UploadProgress, Mt as FileUsageOptions, Na as TaskSessionInfo, Ni as SandboxRuntimeHealth, Nt as FileUsageResult, Pt as FileWriteResult, T as ChunkedUploadResult, V as CreateSessionOptions, Vi as SandboxTerminalManager, Za as WriteFileOptions, aa as SessionExecutionStatus, ca as SessionInfo, da as SessionMessage, ea as SendSessionMessageRequest, fa as SessionMessageAdmission, ia as SessionExecutionInfo, ja as TaskSessionCommitResult, jt as FileTreeResult, ra as SessionEventStreamOptions, ta as SentSessionMessage, w as ChunkedUploadOptions, wt as FileReadBatchResult, xr as RenameOptions, zi as SandboxTerminalCreateOptions } from "./types-B_QF-iHm.js";
2
+ import { n as TerminalStream, p as ScopedToken } from "./terminal-stream-jdYomM1m.js";
3
+ import { c as InteractiveSessionIdentity, l as InteractiveSessionNotRunningError, r as browserInteractiveControlHolderId } from "./browser-interactive-control-controller-rpTbyvAS.js";
4
+ import { C as ValidationError, S as TimeoutError, _ as SandboxFailureDetail, d as NotFoundError, f as PartialFailureError, g as SandboxErrorJson, h as SandboxError, o as FileWriteConflictError, p as QuotaError, r as CapabilityError, t as AuthError, u as NetworkError, v as ServerError, w as BrowserInteractiveSessionController, y as StateError } from "./errors-mPL-qvgF.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-CTEpjCEZ.js";
7
6
 
8
7
  //#region src/lib/chunked-upload.d.ts
9
8
  /** The transport a caller wires this module to — {@link SandboxInstance.runtimeFetch}
package/dist/runtime.js CHANGED
@@ -1,7 +1,7 @@
1
- import { F as deriveAgentResultOutcome, I as deriveAgentRunOutcome, L as projectAgentTerminalRecord, P as createAgentRunOutcomeTracker, l as SandboxRuntimeApi, t as BrowserInteractiveSessionController } from "./interactive-controller-DaYmUCO_.js";
2
- import { _ as TimeoutError, a as FileWriteConflictError, c as NetworkError, d as QuotaError, h as StateError, l as NotFoundError, m as ServerError, n as CapabilityError, p as SandboxError, t as AuthError, u as PartialFailureError, v as ValidationError } from "./errors-iWIsey1D.js";
1
+ import { F as createAgentRunOutcomeTracker, I as deriveAgentResultOutcome, L as deriveAgentRunOutcome, R as projectAgentTerminalRecord, t as BrowserInteractiveSessionController, u as SandboxRuntimeApi } from "./interactive-controller-CJ24g8Va.js";
2
+ import { _ as StateError, b as ValidationError, d as NotFoundError, f as PartialFailureError, g as ServerError, h as SandboxError, o as FileWriteConflictError, p as QuotaError, r as CapabilityError, t as AuthError, u as NetworkError, y as TimeoutError } from "./errors-DSJBKmGZ.js";
3
3
  import { f as combineAbortSignals, n as browserInteractiveControlHolderId, s as InteractiveSessionNotRunningError } from "./browser-interactive-control-controller-BJf0P_J4.js";
4
- import { s as uploadChunked } from "./chunked-upload-BklCn3Li.js";
4
+ import { s as uploadChunked } from "./chunked-upload-DtIvkKNo.js";
5
5
  //#region src/runtime-client.ts
6
6
  const DEFAULT_RUNTIME_TIMEOUT_MS = 3e4;
7
7
  function requireToken(token) {