@tangle-network/sandbox 0.68.7 → 0.69.1

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 (68) hide show
  1. package/README.md +5 -4
  2. package/dist/abort-signal-BKVZNJul.js +46 -0
  3. package/dist/agent/index.d.ts +4 -4
  4. package/dist/agent/index.js +4 -4
  5. package/dist/agent/preview.d.ts +1 -1
  6. package/dist/agent/preview.js +2 -2
  7. package/dist/{agent-run-outcome-Cp8hzV98.d.ts → agent-run-outcome-B5CzWxw4.d.ts} +1 -1
  8. package/dist/{api-request-D8Mni27A.js → api-request-D1UVNo16.js} +1 -1
  9. package/dist/auth/index.d.ts +2 -2
  10. package/dist/auth/index.js +1 -1
  11. package/dist/{browser-interactive-control-controller-k1KkqDGF.js → browser-interactive-control-controller-CLHNi8rG.js} +2 -46
  12. package/dist/{browser-interactive-control-controller-CH7CLpmc.d.ts → browser-interactive-control-controller-SI9hV6r5.d.ts} +1 -1
  13. package/dist/{chunked-upload-file-CbbWlCFt.js → chunked-upload-file-CLwAeLrM.js} +1 -1
  14. package/dist/{cli-auth-bundle-DlQs_26j.js → cli-auth-bundle-Bq-5b0FT.js} +7 -7
  15. package/dist/{client-D5GLp93x.js → client-E6qmM8wZ.js} +9 -8
  16. package/dist/{client-aBXGR6bc.d.ts → client-XWxiuhwy.d.ts} +5 -5
  17. package/dist/collaboration/index.d.ts +1 -1
  18. package/dist/collaboration/index.js +1 -1
  19. package/dist/{core-VOzQz1mc.js → core-KP6tmonl.js} +2 -2
  20. package/dist/core.d.ts +6 -6
  21. package/dist/core.js +4 -4
  22. package/dist/{direct-http2--35cHOv5.js → direct-http2-Pyj3Rvr1.js} +1 -1
  23. package/dist/{index-EebEqYqj.d.ts → index-nXob5TkM.d.ts} +14 -14
  24. package/dist/index.d.ts +11 -11
  25. package/dist/index.js +9 -8
  26. package/dist/intelligence/index.js +1 -1
  27. package/dist/interactive-control.d.ts +1 -1
  28. package/dist/interactive-control.js +1 -1
  29. package/dist/{interactive-controller-ThIeP_oZ.js → interactive-controller-D5tWSSI1.js} +19 -237
  30. package/dist/{interactive-controller-Mh7Ud5DQ.d.ts → interactive-controller-FgmcS8_Y.d.ts} +3 -3
  31. package/dist/lib/prepared-evidence.js +1 -1
  32. package/dist/lib/prepared-process.js +1 -1
  33. package/dist/{lines-BTIFNxRO.d.ts → lines-BoVYnUCM.d.ts} +1 -1
  34. package/dist/lines.d.ts +1 -1
  35. package/dist/lines.js +1 -1
  36. package/dist/{local-cli-auth-Dxti_D10.js → local-cli-auth-BdufYsAM.js} +1 -1
  37. package/dist/{mcp-local-ClJ5TD-m.js → mcp-local-Gz1Uygqk.js} +1 -1
  38. package/dist/{preview-D6tTCcmv.d.ts → preview-BBzfwVTy.d.ts} +3 -3
  39. package/dist/{public-templates-sZe-0Qvi.d.ts → public-templates-B6_uwnRZ.d.ts} +2 -2
  40. package/dist/public-templates.d.ts +1 -1
  41. package/dist/{raw-evidence-archive-iDPF8eF_.js → raw-evidence-archive-D60Yg1-5.js} +1 -1
  42. package/dist/runtime.d.ts +5 -5
  43. package/dist/runtime.js +4 -4
  44. package/dist/{sandbox-Ksajmtq4.js → sandbox-BQhQSXF6.js} +37 -45
  45. package/dist/{secp256k1-CoRKQn1k.js → secp256k1-DxHlUI6v.js} +1 -1
  46. package/dist/select-seat-command.d.ts +1 -1
  47. package/dist/session-gateway/index.d.ts +132 -508
  48. package/dist/session-gateway/index.js +694 -946
  49. package/dist/sidecar-proxy-error-B2Hxt41g.js +24 -0
  50. package/dist/sse-parser-CUfurwcm.js +227 -0
  51. package/dist/tangle/index.d.ts +1 -1
  52. package/dist/tangle/index.js +1 -1
  53. package/dist/{tangle-Cmr8JcO3.js → tangle-DUKeaoj9.js} +3 -3
  54. package/dist/{terminal-stream-types-yAt76vk7.d.ts → terminal-stream-types-DuzvL1ge.d.ts} +13 -9
  55. package/dist/{types-DUNlmyED.d.ts → types-CkLWX7i5.d.ts} +10 -11
  56. package/package.json +6 -6
  57. /package/dist/{chunked-upload-CbtLVV6-.js → chunked-upload-l6b9AWFA.js} +0 -0
  58. /package/dist/{cli-auth-bundle-Can3oLKY.d.ts → cli-auth-bundle-CeNOYFje.d.ts} +0 -0
  59. /package/dist/{collaboration-Ox7K-TN6.js → collaboration-BwLNv6sy.js} +0 -0
  60. /package/dist/{index-B8xo7y26.d.ts → index-C0RkLba5.d.ts} +0 -0
  61. /package/dist/{index-mz8_2rr2.d.ts → index-DaIF4c9p.d.ts} +0 -0
  62. /package/dist/{keep-alive-fetch-C92u8Kce.js → keep-alive-fetch-Bi-zvHpN.js} +0 -0
  63. /package/dist/{lines-DgRXUg5y.js → lines-D_HDAcVt.js} +0 -0
  64. /package/dist/{prepared-evidence-Di89Tatw.js → prepared-evidence-DUmJSegi.js} +0 -0
  65. /package/dist/{prepared-process-DKgEUodb.js → prepared-process-Dlk_9JVJ.js} +0 -0
  66. /package/dist/{preview-operations-BL7YCkes.js → preview-operations-eTUlPen5.js} +0 -0
  67. /package/dist/{response-rewrap-Bsj87BIq.js → response-rewrap-BKkJ5hnn.js} +0 -0
  68. /package/dist/{utils-C86i6t3C.js → utils-DB8DnUCU.js} +0 -0
@@ -0,0 +1,24 @@
1
+ //#region ../../../packages/runtime-contracts/dist/sidecar-proxy-error.js
2
+ /**
3
+ * Response header that the host-agent sidecar proxy puts on each error it
4
+ * writes itself. The value is the host-agent error code, for example
5
+ * `NOT_MANAGED` or `ROUTE_LOOKUP_FAILED`.
6
+ *
7
+ * The orchestrator reaches a sidecar only through the host-agent sidecar
8
+ * proxy. Thus two services write errors on that path. They use the same
9
+ * statuses (404, 502, 503, 504) and the same `{error, code}` JSON body. This
10
+ * header names the author of the response. If the header is present, the
11
+ * host-agent wrote the response. If the header is absent, the sidecar wrote
12
+ * the response.
13
+ *
14
+ * The orchestrator invalidates the endpoint and sends the request again only
15
+ * for a host-agent error. A sidecar error is an ordinary answer, and a new
16
+ * endpoint cannot change it.
17
+ *
18
+ * The host-agent deletes this header from an upstream response before it
19
+ * returns that response. A sidecar must not be able to set the header. A
20
+ * tenant preview app on an in-container port must not be able to set it.
21
+ */
22
+ const SIDECAR_PROXY_ERROR_HEADER = "X-Tangle-Sidecar-Proxy-Error";
23
+ //#endregion
24
+ export { SIDECAR_PROXY_ERROR_HEADER as t };
@@ -0,0 +1,227 @@
1
+ //#region ../../../packages/sse-core/dist/index.js
2
+ /**
3
+ * A copy of `value` that shares no memory with the string it was cut from.
4
+ *
5
+ * V8 can return a short substring of a long string as a view that keeps the
6
+ * whole string alive. Consumers keep event names and ids as long as they keep
7
+ * events, so a view would keep every chunk its frame arrived in alive.
8
+ */
9
+ function detached(value) {
10
+ return value === "" ? value : JSON.parse(JSON.stringify(value));
11
+ }
12
+ /**
13
+ * Thrown when a stream sends no bytes for longer than its `idleMs`. A
14
+ * producer that heartbeats would have written in that time, so the
15
+ * connection is dead even though it never closed: a half-open TCP connection
16
+ * or a stalled proxy hold the socket open while nothing arrives.
17
+ */
18
+ var SSEStreamSilentError = class extends Error {
19
+ name = "SSEStreamSilentError";
20
+ idleMs;
21
+ constructor(idleMs) {
22
+ super(`SSE stream sent no bytes for ${idleMs} ms`);
23
+ this.idleMs = idleMs;
24
+ }
25
+ };
26
+ /**
27
+ * Incremental SSE frame parser. Feed decoded text via `push()`; call
28
+ * `flush()` when the stream ends.
29
+ */
30
+ var SSEFrameParser = class {
31
+ buffer = "";
32
+ frameEvent = "";
33
+ frameId;
34
+ frameDataLines = null;
35
+ bomChecked = false;
36
+ /**
37
+ * Append a decoded text chunk and return every frame the chunk
38
+ * completes. Frame state survives across calls: one frame can
39
+ * straddle any number of chunks.
40
+ */
41
+ push(chunk) {
42
+ let text = chunk;
43
+ if (!this.bomChecked && text.length > 0) {
44
+ this.bomChecked = true;
45
+ if (text.charCodeAt(0) === 65279) text = text.slice(1);
46
+ }
47
+ this.buffer += text;
48
+ const lines = this.buffer.split("\n");
49
+ this.buffer = lines.pop() ?? "";
50
+ return this.processLines(lines);
51
+ }
52
+ /**
53
+ * End-of-stream: process the unterminated trailing line, then
54
+ * dispatch a dangling frame that never got its blank line.
55
+ * Well-behaved servers end frames with "\n\n", but some close early.
56
+ */
57
+ flush() {
58
+ const rest = this.buffer;
59
+ this.buffer = "";
60
+ const frames = rest.length > 0 ? this.processLines([rest]) : [];
61
+ const dangling = this.dispatch();
62
+ if (dangling) frames.push(dangling);
63
+ return frames;
64
+ }
65
+ processLines(lines) {
66
+ const frames = [];
67
+ for (const rawLine of lines) {
68
+ const line = rawLine.endsWith("\r") ? rawLine.slice(0, -1) : rawLine;
69
+ if (line === "") {
70
+ const frame = this.dispatch();
71
+ if (frame) frames.push(frame);
72
+ continue;
73
+ }
74
+ if (line.startsWith(":")) continue;
75
+ if (line.startsWith("data:")) {
76
+ let value = line.slice(5);
77
+ if (value.startsWith(" ")) value = value.slice(1);
78
+ if (this.frameDataLines === null) this.frameDataLines = [];
79
+ this.frameDataLines.push(value);
80
+ continue;
81
+ }
82
+ if (line.startsWith("event:")) {
83
+ this.frameEvent = line.slice(6).trim();
84
+ continue;
85
+ }
86
+ if (line.startsWith("id:")) this.frameId = line.slice(3).trim();
87
+ }
88
+ return frames;
89
+ }
90
+ /**
91
+ * Dispatch the accumulated frame. A frame with no `data:` field (an
92
+ * `event:`/`id:`-only frame, or a bare comment) produces nothing, and
93
+ * its field state is consumed and reset either way.
94
+ */
95
+ dispatch() {
96
+ const dataLines = this.frameDataLines;
97
+ const frame = dataLines ? {
98
+ event: detached(this.frameEvent),
99
+ data: dataLines.join("\n"),
100
+ id: this.frameId ? detached(this.frameId) : void 0
101
+ } : null;
102
+ this.frameEvent = "";
103
+ this.frameId = void 0;
104
+ this.frameDataLines = null;
105
+ return frame;
106
+ }
107
+ };
108
+ /**
109
+ * Read a streaming SSE response body into parsed frames.
110
+ *
111
+ * @throws `TypeError` when the body is missing.
112
+ * @throws `DOMException` with `name === "AbortError"` on cancellation —
113
+ * including the WHATWG-fetch variant where an aborted body resolves
114
+ * `done: true` instead of rejecting the read.
115
+ */
116
+ async function* streamSSEFrames(body, options) {
117
+ if (!body) throw new TypeError("SSE stream has no response body");
118
+ const reader = body.getReader();
119
+ const decoder = new TextDecoder();
120
+ const parser = new SSEFrameParser();
121
+ const { signal, idleMs } = options ?? {};
122
+ const read = () => {
123
+ const limit = idleMs?.();
124
+ if (limit === void 0) return reader.read();
125
+ let timer;
126
+ return Promise.race([reader.read(), new Promise((_, reject) => {
127
+ timer = setTimeout(() => reject(new SSEStreamSilentError(limit)), limit);
128
+ })]).finally(() => clearTimeout(timer));
129
+ };
130
+ let completed = false;
131
+ try {
132
+ for (;;) {
133
+ if (signal?.aborted) throw new DOMException("SSE stream aborted", "AbortError");
134
+ const { done, value } = await read();
135
+ if (done) {
136
+ if (signal?.aborted) throw new DOMException("SSE stream aborted", "AbortError");
137
+ break;
138
+ }
139
+ for (const frame of parser.push(decoder.decode(value, { stream: true }))) yield frame;
140
+ }
141
+ for (const frame of parser.push(decoder.decode())) yield frame;
142
+ for (const frame of parser.flush()) yield frame;
143
+ completed = true;
144
+ } finally {
145
+ if (!completed) await reader.cancel().catch(() => void 0);
146
+ reader.releaseLock();
147
+ }
148
+ }
149
+ //#endregion
150
+ //#region src/lib/sse-parser.ts
151
+ /**
152
+ * SSE Stream Parser
153
+ *
154
+ * EventSource stream parsing for SDK consumers. Framing — buffering
155
+ * chunk-straddling frames, LF/CRLF terminators, multi-line `data:` joins,
156
+ * comment heartbeats, BOM — lives in `@tangle-network/sse-core`, the one
157
+ * wire-format implementation shared across the repo (bundled into this
158
+ * package's dist, so the SDK stays dependency-free at runtime). This
159
+ * module owns the SDK's payload contract on top of it: JSON parsing, the
160
+ * `"message"` default event type, and the malformed-frame policy. Used by
161
+ * `Sandbox.streamBatch` and by the web dashboard's batch page; exported
162
+ * so downstream surfaces don't maintain their own copies.
163
+ *
164
+ * Guarantees:
165
+ * - Correctly buffers frames that straddle chunk boundaries.
166
+ * - Accepts LF- and CRLF-terminated streams interchangeably.
167
+ * - Joins multi-line `data:` per the spec (dispatch joins with
168
+ * "\n" before JSON parse).
169
+ * - Defaults event type to `"message"` when a frame carries
170
+ * `data:` but no `event:` field (SSE spec §9.2.6 step 3).
171
+ * - Surfaces optional `id:` so callers can implement reconnection.
172
+ * - Flushes a dangling event when the stream closes without a
173
+ * terminating blank line (well-behaved servers emit `\n\n`, but
174
+ * some close early).
175
+ * - Throws `AbortError` when the caller-supplied signal fires, so
176
+ * consumers can distinguish "ran to completion" from "cancelled"
177
+ * without peeking at signal state.
178
+ * - Rejects malformed JSON by default. Callers handling recoverable output
179
+ * streams can explicitly warn and skip one invalid frame.
180
+ *
181
+ * What it does NOT do:
182
+ * - CR-only (legacy Mac) line terminators. No known emitter uses
183
+ * them; supporting them would risk splitting payloads that
184
+ * legitimately contain CR.
185
+ * - Retry/reconnect (caller's responsibility).
186
+ * - Event-type filtering (caller's responsibility).
187
+ */
188
+ /**
189
+ * Parse a streaming SSE response body into an async iterable of
190
+ * structured events.
191
+ *
192
+ * @throws `TypeError` when the response has no body.
193
+ * @throws `DOMException` with `name === "AbortError"` on cancellation.
194
+ */
195
+ async function* parseSSEStream(body, options) {
196
+ const { signal, invalidEvent = "throw", idleMs } = options ?? {};
197
+ for await (const frame of streamSSEFrames(body, {
198
+ signal,
199
+ idleMs
200
+ })) {
201
+ const effectiveEvent = frame.event || "message";
202
+ let data;
203
+ try {
204
+ data = JSON.parse(frame.data);
205
+ } catch (error) {
206
+ if (invalidEvent === "warn-and-skip") {
207
+ console.warn(`[sandbox-sdk] Malformed SSE JSON for event "${effectiveEvent}": ${frame.data.slice(0, 200)}`);
208
+ continue;
209
+ }
210
+ throw new SyntaxError(`Malformed SSE JSON for event "${effectiveEvent}"`, { cause: error });
211
+ }
212
+ if (typeof data !== "object" || data === null || Array.isArray(data)) {
213
+ if (invalidEvent === "warn-and-skip") {
214
+ console.warn(`[sandbox-sdk] SSE event "${effectiveEvent}" data must be a JSON object`);
215
+ continue;
216
+ }
217
+ throw new TypeError(`SSE event "${effectiveEvent}" data must be a JSON object`);
218
+ }
219
+ yield {
220
+ type: effectiveEvent,
221
+ data,
222
+ id: frame.id
223
+ };
224
+ }
225
+ }
226
+ //#endregion
227
+ export { parseSSEStream as t };
@@ -1,2 +1,2 @@
1
- import { C as JsonResponseParamTypes, E as SandboxIdParamTypes, S as JOB_SANDBOX_DELETE, T as SandboxCreateResponseParamTypes, _ as TANGLE_JOBS_CONTRACT, a as fetchQuote, b as AgentSandboxBlueprintAbi, c as parseQuoteResponse, d as OperatorSession, f as OperatorSessionError, g as TANGLE_CHAIN_ID, 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 TangleSandboxClientConfig, w as SandboxCreateParamTypes, x as JOB_SANDBOX_CREATE, y as ITangleJobsAbi } from "../index-EebEqYqj.js";
1
+ import { C as JsonResponseParamTypes, E as SandboxIdParamTypes, S as JOB_SANDBOX_DELETE, T as SandboxCreateResponseParamTypes, _ as TANGLE_JOBS_CONTRACT, a as fetchQuote, b as AgentSandboxBlueprintAbi, c as parseQuoteResponse, d as OperatorSession, f as OperatorSessionError, g as TANGLE_CHAIN_ID, 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 TangleSandboxClientConfig, w as SandboxCreateParamTypes, x as JOB_SANDBOX_CREATE, y as ITangleJobsAbi } from "../index-nXob5TkM.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 TANGLE_JOBS_CONTRACT, f as ITangleJobsAbi, g as JsonResponseParamTypes, h as JOB_SANDBOX_DELETE, i as jobQuoteDigest, l as OperatorSessionError, m as JOB_SANDBOX_CREATE, n as fetchQuote, o as validateQuote, p as AgentSandboxBlueprintAbi, r as inputsHashOf, s as TangleSandboxClient, t as QuoteError, u as TANGLE_CHAIN_ID, v as SandboxCreateResponseParamTypes, y as SandboxIdParamTypes } from "../tangle-Cmr8JcO3.js";
1
+ import { _ as SandboxCreateParamTypes, a as parseQuoteResponse, c as OperatorSession, d as TANGLE_JOBS_CONTRACT, f as ITangleJobsAbi, g as JsonResponseParamTypes, h as JOB_SANDBOX_DELETE, i as jobQuoteDigest, l as OperatorSessionError, m as JOB_SANDBOX_CREATE, n as fetchQuote, o as validateQuote, p as AgentSandboxBlueprintAbi, r as inputsHashOf, s as TangleSandboxClient, t as QuoteError, u as TANGLE_CHAIN_ID, v as SandboxCreateResponseParamTypes, y as SandboxIdParamTypes } from "../tangle-DUKeaoj9.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 { i as readResponseJson } from "./errors-Bs5G7JdV.js";
2
- import { n as createSandboxInstanceFromResponse } from "./sandbox-Ksajmtq4.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-C86i6t3C.js";
2
+ import { n as createSandboxInstanceFromResponse } from "./sandbox-BQhQSXF6.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-DB8DnUCU.js";
4
4
  //#region ../../../packages/runtime-contracts/dist/tangle-blueprint-abi.js
5
5
  /**
6
6
  * Tangle blueprint wire contract shared by the orchestrator's Tangle driver and
@@ -2376,7 +2376,7 @@ function isAddressEqual(a, b) {
2376
2376
  //#region ../../../node_modules/.pnpm/viem@2.57.10_bufferutil@4.1.0_typescript@6.0.3_utf-8-validate@5.0.10_zod@4.6.6/node_modules/viem/_esm/utils/signature/recoverPublicKey.js
2377
2377
  async function recoverPublicKey({ hash, signature }) {
2378
2378
  const hashHex = isHex(hash) ? hash : toHex(hash);
2379
- const { secp256k1 } = await import("./secp256k1-CoRKQn1k.js");
2379
+ const { secp256k1 } = await import("./secp256k1-DxHlUI6v.js");
2380
2380
  return `0x${(() => {
2381
2381
  if (typeof signature === "object" && "r" in signature && "s" in signature) {
2382
2382
  const { r, s, v, yParity } = signature;
@@ -486,7 +486,8 @@ interface TerminalInteractiveSessionIdentity {
486
486
  /**
487
487
  * Scope of a `box.mintScopedToken()` request. `session` and `project` mint
488
488
  * SessionGateway read tokens. `session-runtime` and `read-only` mint sidecar
489
- * capability tokens for browser-safe runtime access.
489
+ * capability tokens for browser-safe runtime access; request access:"read-only"
490
+ * on session-runtime for a session event stream without write capabilities.
490
491
  */
491
492
  type ScopedTokenScope = "session" | "session-runtime" | "project" | "read-only";
492
493
  interface MintScopedTokenBase {
@@ -502,7 +503,8 @@ type MintScopedTokenOptions = (MintScopedTokenBase & {
502
503
  runtimeSessionId: string;
503
504
  }) | (MintScopedTokenBase & {
504
505
  scope: "session-runtime";
505
- sessionId: string;
506
+ sessionId: string; /** Restrict this session's bearer to reads; omission also grants workspace/terminal. */
507
+ access?: "read-only";
506
508
  runtimeSessionId?: never;
507
509
  }) | (MintScopedTokenBase & {
508
510
  scope: "project" | "read-only";
@@ -512,9 +514,8 @@ type MintScopedTokenOptions = (MintScopedTokenBase & {
512
514
  /** Options for the server-side exact interactive-session token request. */
513
515
  type MintInteractiveSessionTokenOptions = Pick<MintScopedTokenBase, "ttlMinutes" | "signal">;
514
516
  /**
515
- * Returned by `box.mintScopedToken()`. Use session/project tokens with
516
- * `SessionGatewayClient`; use session-runtime/read-only tokens with
517
- * `SandboxRuntimeClient`.
517
+ * Returned by `box.mintScopedToken()`. Native session streams use a read-only
518
+ * session-runtime token. Session/project tokens retain legacy gateway semantics.
518
519
  */
519
520
  interface ScopedToken {
520
521
  /** Bearer token (JWT) for the consumer selected by `scope`. */
@@ -528,6 +529,8 @@ interface ScopedToken {
528
529
  sidecarProxyUrl: string;
529
530
  /** Echo of the requested scope. */
530
531
  scope: ScopedTokenScope;
532
+ /** Acknowledged session-runtime restriction; absent for unrestricted requests. */
533
+ access?: "read-only";
531
534
  }
532
535
  //#endregion
533
536
  //#region src/terminal-stream-types.d.ts
@@ -555,10 +558,11 @@ interface TerminalStreamHandlers {
555
558
  * `Sec-WebSocket-Protocol` offer — and the two dialable endpoints expect
556
559
  * DIFFERENT envelopes:
557
560
  *
558
- * - `"edge"` (default): the public API proxy
559
- * (`wss://<api>/v1/sidecar-proxy/{sidecarId}/terminals/{id}/ws`) expects
560
- * `bearer.<base64url(token)>` — see `parseTerminalWsSubprotocolToken` in
561
- * `products/sandbox/api/src/lib/terminal-websocket.ts`. The fixed
561
+ * - `"edge"` (default): the public API runtime proxy
562
+ * (`wss://<api>/v1/sandboxes/{id}/runtime/terminals/{id}/ws`, or its older
563
+ * spelling `/v1/sidecar-proxy/{id}/...`) expects
564
+ * `bearer.<base64url(token)>` — see `bearerFromSubprotocolOffer` in the
565
+ * platform's runtime contracts. The fixed
562
566
  * `tangle.terminal.v1` marker is offered alongside the credential (see
563
567
  * {@link TERMINAL_WS_ECHO_SUBPROTOCOL}).
564
568
  * - `"sidecar-direct"`: the sidecar's own `/terminals/{id}/ws` route expects
@@ -1,5 +1,5 @@
1
- import { K as SandboxCreateReceipt, a as TerminalStreamOptions, g as TerminalReadyInfo, i as TerminalStreamHandlers, s as TerminalStreamToken, t as TerminalAttachTimings } from "./terminal-stream-types-yAt76vk7.js";
2
- import { t as CliAuthReference } from "./cli-auth-bundle-Can3oLKY.js";
1
+ import { K as SandboxCreateReceipt, a as TerminalStreamOptions, g as TerminalReadyInfo, i as TerminalStreamHandlers, s as TerminalStreamToken, t as TerminalAttachTimings } from "./terminal-stream-types-DuzvL1ge.js";
2
+ import { t as CliAuthReference } from "./cli-auth-bundle-CeNOYFje.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";
@@ -7065,16 +7065,15 @@ interface SessionForkOptions {
7065
7065
  }
7066
7066
  /**
7067
7067
  * One message on a session — user, assistant, or system. The metadata
7068
- * field carries the durability marker set by the sidecar:
7069
- * - `status: "streaming"` and no `completed`/`interrupted` flag → turn
7070
- * is in flight, OR the sidecar died before stamping a marker
7071
- * (SIGKILL, OOM). The partial parts are the partial assistant
7072
- * content the recorder flushed before death.
7068
+ * field of a run's assistant message carries its turn state:
7069
+ * - `status: "streaming"` → the turn is in flight; the parts are what it
7070
+ * has streamed so far.
7073
7071
  * - `completed: true` + `completedAt` → turn finished normally. If a
7074
7072
  * `turnId` was supplied, its result is cached for idempotent retry.
7075
- * - `interrupted: true` + `interruptedAt` + `interruptReason` → graceful
7076
- * abort, timeout, or upstream error. Partial content is preserved
7077
- * but not billable as a completion.
7073
+ * - `interrupted: true` + `interruptedAt` + `interruptReason` → the run
7074
+ * failed or was cancelled, or the sidecar died (SIGKILL, OOM) and its
7075
+ * restart closed the run (`interruptReason: "runtime_restart"`).
7076
+ * Partial content is preserved but not billable as a completion.
7078
7077
  */
7079
7078
  interface SessionMessage {
7080
7079
  id: string;
@@ -7091,7 +7090,7 @@ interface SessionMessage {
7091
7090
  completedAt?: string;
7092
7091
  interrupted?: boolean;
7093
7092
  interruptedAt?: string;
7094
- interruptReason?: string;
7093
+ interruptReason?: string; /** @deprecated The runtime no longer sets it; look a turn up with `findCompletedTurn`. */
7095
7094
  turnId?: string;
7096
7095
  startedAt?: string;
7097
7096
  [extra: string]: unknown;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/sandbox",
3
- "version": "0.68.7",
3
+ "version": "0.69.1",
4
4
  "description": "Client SDK for the Tangle Sandbox platform - build AI agent applications with dev containers",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -152,16 +152,16 @@
152
152
  "vitest": "^4.1.12",
153
153
  "ws": "^8.22.0",
154
154
  "yjs": "13.6.30",
155
- "@repo/shared": "0.0.0",
156
- "@tangle-network/cli-agent-registry": "0.10.2",
157
155
  "@tangle-network/agent-profile-materialize": "0.26.0",
158
156
  "@tangle-network/sse-core": "0.0.0",
157
+ "@tangle-network/cli-agent-registry": "0.10.2",
159
158
  "@tangle-network/runtime-contracts": "0.19.0",
160
- "@products/sandbox-test-utils": "0.0.0"
159
+ "@products/sandbox-test-utils": "0.0.0",
160
+ "@repo/shared": "0.0.0"
161
161
  },
162
162
  "tangleRelease": {
163
- "sourceSha": "8d71e957df3d41bb0586f2bb0acd5b26c550cd17",
164
- "mergedAt": "2026-10-26T04:37:12-06:00"
163
+ "sourceSha": "9b4bfec466d5b9fc3f320f4383cb0103f0e18bfb",
164
+ "mergedAt": "2026-10-26T07:43:24-06:00"
165
165
  },
166
166
  "scripts": {
167
167
  "build": "node scripts/build-dist.mjs",
File without changes
File without changes