@tangle-network/sandbox 0.55.3 → 0.58.0

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 (44) hide show
  1. package/README.md +21 -2
  2. package/dist/agent/index.d.ts +59 -19
  3. package/dist/agent/index.js +39 -357
  4. package/dist/agent/preview.d.ts +2 -0
  5. package/dist/agent/preview.js +74 -0
  6. package/dist/{agent-run-outcome-CWo6e5lW.d.ts → agent-run-outcome-DV-9cNsk.d.ts} +1 -1
  7. package/dist/auth/index.d.ts +1 -1
  8. package/dist/auth/index.js +1 -1
  9. package/dist/{browser-interactive-control-controller-Dv0gbFMu.js → browser-interactive-control-controller-CVGqjPgs.js} +1 -1
  10. package/dist/{browser-interactive-control-controller-BELrFH4f.d.ts → browser-interactive-control-controller-knjCl8Zp.d.ts} +1 -1
  11. package/dist/{client-B-LZQQ51.d.ts → client-B1I66sl_.d.ts} +10 -4
  12. package/dist/{client-B6Jo-v5w.js → client-BMdV_CeM.js} +30 -7
  13. package/dist/collaboration/index.d.ts +1 -1
  14. package/dist/collaboration/index.js +1 -1
  15. package/dist/{collaboration-DLPFc9-W.js → collaboration-CSHswAOI.js} +1 -1
  16. package/dist/core.d.ts +5 -5
  17. package/dist/core.js +3 -3
  18. package/dist/{index-ATSSTK2A.d.ts → index-CGnI-q1g.d.ts} +2 -2
  19. package/dist/index.d.ts +11 -11
  20. package/dist/index.js +7 -7
  21. package/dist/intelligence/index.js +1 -1
  22. package/dist/interactive-control.d.ts +1 -1
  23. package/dist/interactive-control.js +1 -1
  24. package/dist/{local-cli-auth-BAJuMBZU.js → local-cli-auth-DfuFJCcs.js} +1 -1
  25. package/dist/mcp-local-DXO-9rtB.js +440 -0
  26. package/dist/preview-Bz7TXYSf.d.ts +72 -0
  27. package/dist/preview-operations-Dgbi46FH.js +212 -0
  28. package/dist/{runtime-api-DoZsOiOR.js → runtime-api-BZg34WGd.js} +10 -5
  29. package/dist/runtime.d.ts +6 -4
  30. package/dist/runtime.js +3 -3
  31. package/dist/{sandbox-C7KqjY6Y.d.ts → sandbox-BMSWYvdP.d.ts} +144 -10
  32. package/dist/{sandbox-DzSE1u7d.js → sandbox-DyrDBnjp.js} +130 -10
  33. package/dist/tangle/index.d.ts +1 -1
  34. package/dist/tangle/index.js +1 -1
  35. package/dist/{tangle-CmpR_07-.js → tangle-BtQkJqfz.js} +2 -2
  36. package/dist/{types-UOIM3RS6.d.ts → types-DRyvWIJf.d.ts} +24 -2
  37. package/package.json +11 -6
  38. /package/dist/{abort-signal-si1WMfJb.js → abort-signal-CgFhjY_v.js} +0 -0
  39. /package/dist/{cli-auth-bundle-DUsK57rK.js → cli-auth-bundle-bRJOyaJO.js} +0 -0
  40. /package/dist/{errors-CmYPVl-k.js → errors-BkhlSDW-.js} +0 -0
  41. /package/dist/{errors-Cz23YNu2.d.ts → errors-CNsmhCen.d.ts} +0 -0
  42. /package/dist/{index-BWiG3Vcw.d.ts → index-BN7zNEUB.d.ts} +0 -0
  43. /package/dist/{index-BfVsF6yU.d.ts → index-X4EEZlMi.d.ts} +0 -0
  44. /package/dist/{terminal-stream-CcaBTVg3.d.ts → terminal-stream-BW4veIsI.d.ts} +0 -0
@@ -1,8 +1,8 @@
1
- import { x as assertCurrentBackendType } from "../runtime-api-DoZsOiOR.js";
2
- import { c as NotFoundError, g as ValidationError, m as StateError } from "../errors-CmYPVl-k.js";
3
- import { n as Sandbox } from "../client-B6Jo-v5w.js";
4
- import { t as SandboxInstance } from "../sandbox-DzSE1u7d.js";
5
- import { createRequire } from "node:module";
1
+ import { a as TOOL_SPECS, i as ALL_TOOL_SPECS, o as serializeToolResult, r as bindToolSpecs, t as createMcpServer } from "../mcp-local-DXO-9rtB.js";
2
+ import { x as assertCurrentBackendType } from "../runtime-api-BZg34WGd.js";
3
+ import { c as NotFoundError, g as ValidationError, m as StateError } from "../errors-BkhlSDW-.js";
4
+ import { n as Sandbox } from "../client-BMdV_CeM.js";
5
+ import { t as SandboxInstance } from "../sandbox-DyrDBnjp.js";
6
6
  import { z } from "zod";
7
7
  //#region src/agent/instances.ts
8
8
  const managers = /* @__PURE__ */ new WeakMap();
@@ -138,300 +138,6 @@ if (!Object.getOwnPropertyDescriptor(SandboxInstance.prototype, "agents")) Objec
138
138
  return managerFor(this);
139
139
  }
140
140
  });
141
- /**
142
- * Keyed registry. `as const` preserves per-tool TArgs/TResult through the
143
- * type system — `TOOL_SPECS.sandbox_run_code.makeHandler` returns a handler
144
- * whose args parameter is the runCodeSpec's typed `{language, source, ...}`,
145
- * not the erased `Record<string, unknown>` that an array-of-ToolSpec loses.
146
- *
147
- * Iteration order matches the order entries are declared here (V8 preserves
148
- * string-key insertion order), so the public surface is stable.
149
- */
150
- const TOOL_SPECS = {
151
- sandbox_run_code: {
152
- name: "sandbox_run_code",
153
- description: "Execute code in a persistent language kernel inside the sandbox. Variables persist across calls with the same session. Returns stdout, stderr, exit code, and a typed `results` array containing matplotlib figures (base64 PNG), pandas DataFrames, JSON via display(), or errors. Prefer this over sandbox_exec for any code that needs structured output.",
154
- inputSchema: {
155
- type: "object",
156
- properties: {
157
- language: {
158
- type: "string",
159
- enum: [
160
- "python",
161
- "node",
162
- "typescript",
163
- "bash"
164
- ],
165
- description: "Kernel language."
166
- },
167
- source: {
168
- type: "string",
169
- description: "Source code to run. Multi-line supported."
170
- },
171
- timeout_ms: {
172
- type: "number",
173
- description: "Per-call timeout. 0 disables. Default 60000."
174
- }
175
- },
176
- required: ["language", "source"],
177
- additionalProperties: false
178
- },
179
- makeHandler: ({ box, sessionId }) => async (args) => {
180
- return await box.runCode(args.language, args.source, {
181
- sessionId,
182
- timeoutMs: args.timeout_ms
183
- });
184
- }
185
- },
186
- sandbox_exec: {
187
- name: "sandbox_exec",
188
- description: "Run a shell command (no persistent state) in the sandbox. Use for one-shot tasks like 'pnpm install' or 'ls'. For code that should share state across calls, prefer sandbox_run_code with a sessionId.",
189
- inputSchema: {
190
- type: "object",
191
- properties: {
192
- command: {
193
- type: "string",
194
- description: "Shell command line."
195
- },
196
- cwd: {
197
- type: "string",
198
- description: "Working directory. Optional."
199
- },
200
- timeout_ms: {
201
- type: "number",
202
- description: "Default 60000."
203
- }
204
- },
205
- required: ["command"],
206
- additionalProperties: false
207
- },
208
- makeHandler: ({ box, sessionId }) => async (args) => {
209
- return await box.exec(args.command, {
210
- cwd: args.cwd,
211
- timeoutMs: args.timeout_ms,
212
- sessionId
213
- });
214
- }
215
- },
216
- sandbox_read: {
217
- name: "sandbox_read",
218
- description: "Read a file from the sandbox filesystem. Relative paths resolve from the workspace root; absolute paths read the container filesystem directly.",
219
- inputSchema: {
220
- type: "object",
221
- properties: { path: { type: "string" } },
222
- required: ["path"],
223
- additionalProperties: false
224
- },
225
- makeHandler: ({ box, sessionId }) => async (args) => {
226
- return { content: await box.read(args.path, { sessionId }) };
227
- }
228
- },
229
- sandbox_write: {
230
- name: "sandbox_write",
231
- description: "Write a file in the sandbox. Creates parent directories as needed. Overwrites existing files.",
232
- inputSchema: {
233
- type: "object",
234
- properties: {
235
- path: { type: "string" },
236
- content: {
237
- type: "string",
238
- description: "Full file contents."
239
- }
240
- },
241
- required: ["path", "content"],
242
- additionalProperties: false
243
- },
244
- makeHandler: ({ box }) => async (args) => {
245
- await box.write(args.path, args.content);
246
- return { ok: true };
247
- }
248
- },
249
- sandbox_list: {
250
- name: "sandbox_list",
251
- description: "List entries in a directory with size, type, and mode.",
252
- inputSchema: {
253
- type: "object",
254
- properties: { path: { type: "string" } },
255
- required: ["path"],
256
- additionalProperties: false
257
- },
258
- makeHandler: ({ box }) => async (args) => {
259
- return { entries: await box.fs.list(args.path) };
260
- }
261
- },
262
- sandbox_search: {
263
- name: "sandbox_search",
264
- description: "Ripgrep-style code search. Returns matching lines with surrounding context.",
265
- inputSchema: {
266
- type: "object",
267
- properties: {
268
- pattern: {
269
- type: "string",
270
- description: "Regex pattern."
271
- },
272
- path: {
273
- type: "string",
274
- description: "Subdirectory to search. Optional."
275
- },
276
- max_results: {
277
- type: "number",
278
- description: "Cap. Default 100."
279
- }
280
- },
281
- required: ["pattern"],
282
- additionalProperties: false
283
- },
284
- makeHandler: ({ box }) => async (args) => {
285
- const matches = [];
286
- const cap = args.max_results ?? 100;
287
- for await (const m of box.search(args.pattern, {
288
- cwd: args.path,
289
- maxResults: cap
290
- })) {
291
- matches.push(m);
292
- if (matches.length >= cap) break;
293
- }
294
- return { matches };
295
- }
296
- }
297
- };
298
- /** Canonical ordered list. Packs use this to emit tools in a stable order. */
299
- const ALL_TOOL_SPECS = Object.values(TOOL_SPECS);
300
- /** Pack-side helper: filter the registry by an optional allow-list. */
301
- function selectSpecs(allow) {
302
- if (!allow || allow.length === 0) return ALL_TOOL_SPECS;
303
- const set = new Set(allow);
304
- return Object.keys(TOOL_SPECS).filter((name) => set.has(name)).map((name) => TOOL_SPECS[name]);
305
- }
306
- /**
307
- * Best-effort serialization of a tool handler's return value into a string
308
- * tool-result payload. Each pack uses this when its target API expects a
309
- * string `content` field; packs that support structured content (Anthropic
310
- * multi-block) can opt out and serialize differently.
311
- *
312
- * `CodeExecutionResult` is serialized as JSON because the LLM benefits from
313
- * seeing the structured results array; images come through as base64 strings
314
- * which the model can read or hand back to the user.
315
- */
316
- function serializeToolResult(value) {
317
- if (typeof value === "string") return value;
318
- try {
319
- return JSON.stringify(value, null, 2);
320
- } catch {
321
- return String(value);
322
- }
323
- }
324
- //#endregion
325
- //#region src/agent/mcp-local.ts
326
- /**
327
- * Local MCP (Model Context Protocol) server bridge.
328
- *
329
- * `createMcpServer(box, { allow })` returns an MCP `Server` instance wired
330
- * with the same tool registry the framework packs use. Pair it with a
331
- * transport (most commonly stdio) and your sandbox becomes a paste-able
332
- * MCP source for Claude Desktop, Cursor, Zed, or any other MCP client.
333
- *
334
- * Complements `box.getMcpEndpoint()` — that returns a hosted HTTPS+JWT MCP
335
- * URL for users who can expose one; this gives users a fully local server
336
- * that runs inside their own process.
337
- *
338
- * `@modelcontextprotocol/sdk` is dynamically imported (optional peer dep).
339
- * Install in your app:
340
- * pnpm add @modelcontextprotocol/sdk
341
- */
342
- const SDK_VERSION = (() => {
343
- try {
344
- return createRequire(import.meta.url)("../../package.json").version ?? "0.0.0";
345
- } catch {
346
- return "0.0.0";
347
- }
348
- })();
349
- /**
350
- * Build an MCP server backed by one sandbox. The server registers
351
- * `tools/list` and `tools/call` handlers populated from the same registry
352
- * the framework packs use.
353
- *
354
- * @example
355
- * ```ts
356
- * // tangle-mcp-server.ts — used as the command in your MCP client config.
357
- * import { Sandbox } from "@tangle-network/sandbox";
358
- * import { createMcpServer } from "@tangle-network/sandbox/agent";
359
- * import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
360
- *
361
- * const client = new Sandbox({ apiKey: process.env.TANGLE_API_KEY });
362
- * const box = await client.get(process.env.SANDBOX_ID!);
363
- * const { connect } = await createMcpServer(box, { sessionId: "claude-desktop" });
364
- * await connect(new StdioServerTransport());
365
- * ```
366
- *
367
- * Claude Desktop config snippet:
368
- * ```json
369
- * {
370
- * "mcpServers": {
371
- * "tangle-sandbox": {
372
- * "command": "node",
373
- * "args": ["./tangle-mcp-server.js"],
374
- * "env": { "TANGLE_API_KEY": "...", "SANDBOX_ID": "..." }
375
- * }
376
- * }
377
- * }
378
- * ```
379
- */
380
- async function createMcpServer(box, options = {}) {
381
- let serverModule;
382
- let typesModule;
383
- try {
384
- [serverModule, typesModule] = await Promise.all([import("@modelcontextprotocol/sdk/server/index.js"), import("@modelcontextprotocol/sdk/types.js")]);
385
- } catch {
386
- throw new Error("createMcpServer(): the `@modelcontextprotocol/sdk` package is not installed. Install it via `pnpm add @modelcontextprotocol/sdk`.");
387
- }
388
- const specs = selectSpecs(options.allow);
389
- const ctx = {
390
- box,
391
- sessionId: options.sessionId
392
- };
393
- const handlers = /* @__PURE__ */ new Map();
394
- for (const spec of specs) handlers.set(spec.name, spec.makeHandler(ctx));
395
- const server = new serverModule.Server({
396
- name: options.name ?? "tangle-sandbox",
397
- version: options.version ?? SDK_VERSION
398
- }, { capabilities: { tools: {} } });
399
- server.setRequestHandler(typesModule.ListToolsRequestSchema, async () => ({ tools: specs.map((s) => ({
400
- name: s.name,
401
- description: s.description,
402
- inputSchema: s.inputSchema
403
- })) }));
404
- server.setRequestHandler(typesModule.CallToolRequestSchema, async (req) => {
405
- const r = req;
406
- const handler = handlers.get(r.params.name);
407
- if (!handler) return {
408
- isError: true,
409
- content: [{
410
- type: "text",
411
- text: `Unknown tool: ${r.params.name}`
412
- }]
413
- };
414
- try {
415
- return { content: [{
416
- type: "text",
417
- text: serializeToolResult(await handler(r.params.arguments ?? {}))
418
- }] };
419
- } catch (err) {
420
- return {
421
- isError: true,
422
- content: [{
423
- type: "text",
424
- text: err instanceof Error ? err.message : String(err)
425
- }]
426
- };
427
- }
428
- });
429
- return {
430
- server,
431
- connect: (transport) => server.connect(transport),
432
- close: () => server.close()
433
- };
434
- }
435
141
  //#endregion
436
142
  //#region src/agent/run-code.ts
437
143
  /**
@@ -473,14 +179,8 @@ function runCode(box, language, source, options) {
473
179
  * ```
474
180
  */
475
181
  function anthropicTools(box, options = {}) {
476
- const specs = selectSpecs(options.allow);
477
- const ctx = {
478
- box,
479
- sessionId: options.sessionId
480
- };
481
- const handlers = /* @__PURE__ */ new Map();
482
- for (const spec of specs) handlers.set(spec.name, spec.makeHandler(ctx));
483
- const tools = specs.map((s) => ({
182
+ const { bindings, handlers } = bindToolSpecs(box, options);
183
+ const tools = bindings.map(({ spec: s }) => ({
484
184
  name: s.name,
485
185
  description: s.description,
486
186
  input_schema: s.inputSchema
@@ -1168,23 +868,16 @@ async function mastraTools(box, options = {}) {
1168
868
  } catch {
1169
869
  throw new Error("mastraTools(): the `@mastra/core` package is not installed. Install it via `pnpm add @mastra/core`.");
1170
870
  }
1171
- const specs = selectSpecs(options.allow);
1172
- const ctx = {
1173
- box,
1174
- sessionId: options.sessionId
1175
- };
871
+ const { bindings } = bindToolSpecs(box, options);
1176
872
  const result = {};
1177
- for (const spec of specs) {
1178
- const handler = spec.makeHandler(ctx);
1179
- result[spec.name] = mastra.createTool({
1180
- id: spec.name,
1181
- description: spec.description,
1182
- inputSchema: z.fromJSONSchema(spec.inputSchema).pipe(z.record(z.string(), z.unknown())),
1183
- execute: async (input) => {
1184
- return { result: serializeToolResult(await handler(input)) };
1185
- }
1186
- });
1187
- }
873
+ for (const { spec, handler } of bindings) result[spec.name] = mastra.createTool({
874
+ id: spec.name,
875
+ description: spec.description,
876
+ inputSchema: z.fromJSONSchema(spec.inputSchema).pipe(z.record(z.string(), z.unknown())),
877
+ execute: async (input) => {
878
+ return { result: serializeToolResult(await handler(input)) };
879
+ }
880
+ });
1188
881
  return result;
1189
882
  }
1190
883
  //#endregion
@@ -1213,14 +906,8 @@ async function mastraTools(box, options = {}) {
1213
906
  * ```
1214
907
  */
1215
908
  function openaiTools(box, options = {}) {
1216
- const specs = selectSpecs(options.allow);
1217
- const ctx = {
1218
- box,
1219
- sessionId: options.sessionId
1220
- };
1221
- const handlers = /* @__PURE__ */ new Map();
1222
- for (const spec of specs) handlers.set(spec.name, spec.makeHandler(ctx));
1223
- const tools = specs.map((s) => ({
909
+ const { bindings, handlers } = bindToolSpecs(box, options);
910
+ const tools = bindings.map(({ spec: s }) => ({
1224
911
  type: "function",
1225
912
  function: {
1226
913
  name: s.name,
@@ -1228,15 +915,6 @@ function openaiTools(box, options = {}) {
1228
915
  parameters: s.inputSchema
1229
916
  }
1230
917
  }));
1231
- function parseArgs(raw) {
1232
- if (!raw) return {};
1233
- try {
1234
- const v = JSON.parse(raw);
1235
- return typeof v === "object" && v !== null ? v : {};
1236
- } catch {
1237
- return {};
1238
- }
1239
- }
1240
918
  async function handleToolCall(call) {
1241
919
  const handler = handlers.get(call.function.name);
1242
920
  if (!handler) return {
@@ -1245,11 +923,11 @@ function openaiTools(box, options = {}) {
1245
923
  content: JSON.stringify({ error: `Unknown tool: ${call.function.name}` })
1246
924
  };
1247
925
  try {
1248
- const result = await handler(parseArgs(call.function.arguments));
926
+ const result = serializeToolResult(await handler(parseOpenAIToolArguments(call.function.arguments)));
1249
927
  return {
1250
928
  role: "tool",
1251
929
  tool_call_id: call.id,
1252
- content: serializeToolResult(result)
930
+ content: result
1253
931
  };
1254
932
  } catch (err) {
1255
933
  return {
@@ -1269,6 +947,17 @@ function openaiTools(box, options = {}) {
1269
947
  handleAssistantMessage
1270
948
  };
1271
949
  }
950
+ function parseOpenAIToolArguments(raw) {
951
+ if (typeof raw !== "string" || raw.trim() === "") throw new Error("Tool arguments must be a non-empty JSON object");
952
+ let value;
953
+ try {
954
+ value = JSON.parse(raw);
955
+ } catch {
956
+ throw new Error("Tool arguments must be valid JSON");
957
+ }
958
+ if (value === null || typeof value !== "object" || Array.isArray(value)) throw new Error("Tool arguments must be a JSON object");
959
+ return value;
960
+ }
1272
961
  //#endregion
1273
962
  //#region src/agent/tools/vercel-ai.ts
1274
963
  /**
@@ -1297,22 +986,15 @@ async function vercelAiTools(box, options = {}) {
1297
986
  } catch {
1298
987
  throw new Error("vercelAiTools(): the `ai` package is not installed. Install it via `pnpm add ai` (and pick an `@ai-sdk/*` model adapter).");
1299
988
  }
1300
- const specs = selectSpecs(options.allow);
1301
- const ctx = {
1302
- box,
1303
- sessionId: options.sessionId
1304
- };
989
+ const { bindings } = bindToolSpecs(box, options);
1305
990
  const result = {};
1306
- for (const spec of specs) {
1307
- const handler = spec.makeHandler(ctx);
1308
- result[spec.name] = ai.tool({
1309
- description: spec.description,
1310
- inputSchema: ai.jsonSchema(spec.inputSchema),
1311
- execute: async (args) => {
1312
- return serializeToolResult(await handler(args));
1313
- }
1314
- });
1315
- }
991
+ for (const { spec, handler } of bindings) result[spec.name] = ai.tool({
992
+ description: spec.description,
993
+ inputSchema: ai.jsonSchema(spec.inputSchema),
994
+ execute: async (args) => {
995
+ return serializeToolResult(await handler(args));
996
+ }
997
+ });
1316
998
  return result;
1317
999
  }
1318
1000
  //#endregion
@@ -0,0 +1,2 @@
1
+ import { a as PreviewAuthorizationRequest, c as PublishAgentPreviewOptions, d as getAgentPreview, f as listAgentPreviews, h as resolveSelfSandbox, i as AgentPreviewOptions, l as assertPreviewId, m as removeAgentPreview, n as servePreviewMcp, o as PreviewAuthorizer, p as publishAgentPreview, r as AgentPreviewError, s as PreviewExecutionContext, t as PREVIEW_TOOLS, u as ensureAgentPreview } from "../preview-Bz7TXYSf.js";
2
+ export { AgentPreviewError, AgentPreviewOptions, PREVIEW_TOOLS, PreviewAuthorizationRequest, PreviewAuthorizer, PreviewExecutionContext, PublishAgentPreviewOptions, assertPreviewId, ensureAgentPreview, getAgentPreview, listAgentPreviews, publishAgentPreview, removeAgentPreview, resolveSelfSandbox, servePreviewMcp };
@@ -0,0 +1,74 @@
1
+ import { a as listAgentPreviews, c as resolveSelfSandbox, i as getAgentPreview, n as assertPreviewId, o as publishAgentPreview, r as ensureAgentPreview, s as removeAgentPreview, t as AgentPreviewError } from "../preview-operations-Dgbi46FH.js";
2
+ //#region src/agent/preview-mcp.ts
3
+ const PREVIEW_TOOLS = [
4
+ "sandbox_preview",
5
+ "sandbox_preview_publish",
6
+ "sandbox_preview_list",
7
+ "sandbox_preview_get",
8
+ "sandbox_preview_remove"
9
+ ];
10
+ /** Host-side bridge for native agents, custom apps and isolated computers.
11
+ * Authenticate the request before calling this function. The host keeps its
12
+ * Sandbox credential; the agent receives only the host's limited capability.
13
+ * Revalidation belongs in authorize, which also runs after slow startup.
14
+ */
15
+ async function servePreviewMcp(request, config) {
16
+ if (typeof config.authorize !== "function") throw new Error("Preview MCP requires a host authorization callback");
17
+ const tools = config.tools ?? PREVIEW_TOOLS;
18
+ if (!tools.length || tools.some((tool) => !PREVIEW_TOOLS.includes(tool))) throw new Error("Preview MCP requires an explicit nonempty preview-only tool grant");
19
+ const [{ createMcpServer }, { WebStandardStreamableHTTPServerTransport }] = await Promise.all([import("../mcp-local-DXO-9rtB.js").then((n) => n.n), import("@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js")]);
20
+ const handle = await createMcpServer(config.box, {
21
+ name: "tangle-previews",
22
+ sessionId: config.sessionId,
23
+ allow: [...tools],
24
+ previewAuthorize: config.authorize,
25
+ signal: request.signal
26
+ });
27
+ const transport = new WebStandardStreamableHTTPServerTransport({ sessionIdGenerator: void 0 });
28
+ let closed = false;
29
+ const close = async () => {
30
+ if (closed) return;
31
+ closed = true;
32
+ await handle.close();
33
+ };
34
+ let response;
35
+ try {
36
+ await handle.connect(transport);
37
+ response = await transport.handleRequest(request);
38
+ } catch (error) {
39
+ await close();
40
+ throw error;
41
+ }
42
+ if (!response.body) {
43
+ await close();
44
+ return response;
45
+ }
46
+ const reader = response.body.getReader();
47
+ return new Response(new ReadableStream({
48
+ async pull(controller) {
49
+ try {
50
+ const next = await reader.read();
51
+ if (next.done) {
52
+ controller.close();
53
+ await close();
54
+ } else controller.enqueue(next.value);
55
+ } catch (error) {
56
+ controller.error(error);
57
+ await close();
58
+ }
59
+ },
60
+ async cancel(reason) {
61
+ try {
62
+ await reader.cancel(reason);
63
+ } finally {
64
+ await close();
65
+ }
66
+ }
67
+ }), {
68
+ status: response.status,
69
+ statusText: response.statusText,
70
+ headers: response.headers
71
+ });
72
+ }
73
+ //#endregion
74
+ export { AgentPreviewError, PREVIEW_TOOLS, assertPreviewId, ensureAgentPreview, getAgentPreview, listAgentPreviews, publishAgentPreview, removeAgentPreview, resolveSelfSandbox, servePreviewMcp };
@@ -1,4 +1,4 @@
1
- import { Er as SandboxEvent, a as AgentQuestionRequest, i as AgentApprovalRequirement, o as AgentRunStatus, s as AgentToolInvocation, st as DurablePlanSnapshot } from "./types-UOIM3RS6.js";
1
+ import { Er as SandboxEvent, a as AgentQuestionRequest, i as AgentApprovalRequirement, o as AgentRunStatus, s as AgentToolInvocation, st as DurablePlanSnapshot } from "./types-DRyvWIJf.js";
2
2
  import { InteractionRequest } from "@tangle-network/agent-interface";
3
3
 
4
4
  //#region src/agent-run-outcome.d.ts
@@ -1,2 +1,2 @@
1
- import { _ as ReadTokenPayload, a as issueCollaborationToken, b as materializeCliAuthBundle, c as issueSessionScopedToken, d as AnyTokenPayload, f as BatchScopedTokenPayload, g as ProjectScopedTokenPayload, h as IssueCollaborationTokenOptions, i as issueBatchScopedToken, l as unsafeDecodeToken, m as CollaborationTokenPayload, n as getTokenTTL, o as issueProjectScopedToken, p as CollaborationAccess, r as isTokenExpiringSoon, s as issueReadToken, t as ProductTokenIssuer, u as verifyToken, v as SessionScopedTokenPayload, y as TokenScope } from "../index-BfVsF6yU.js";
1
+ import { _ as ReadTokenPayload, a as issueCollaborationToken, b as materializeCliAuthBundle, c as issueSessionScopedToken, d as AnyTokenPayload, f as BatchScopedTokenPayload, g as ProjectScopedTokenPayload, h as IssueCollaborationTokenOptions, i as issueBatchScopedToken, l as unsafeDecodeToken, m as CollaborationTokenPayload, n as getTokenTTL, o as issueProjectScopedToken, p as CollaborationAccess, r as isTokenExpiringSoon, s as issueReadToken, t as ProductTokenIssuer, u as verifyToken, v as SessionScopedTokenPayload, y as TokenScope } from "../index-X4EEZlMi.js";
2
2
  export { AnyTokenPayload, BatchScopedTokenPayload, CollaborationAccess, CollaborationTokenPayload, IssueCollaborationTokenOptions, ProductTokenIssuer, ProjectScopedTokenPayload, ReadTokenPayload, SessionScopedTokenPayload, TokenScope, getTokenTTL, isTokenExpiringSoon, issueBatchScopedToken, issueCollaborationToken, issueProjectScopedToken, issueReadToken, issueSessionScopedToken, materializeCliAuthBundle, unsafeDecodeToken, verifyToken };
@@ -1,4 +1,4 @@
1
- import { n as materializeCliAuthBundle } from "../cli-auth-bundle-DUsK57rK.js";
1
+ import { n as materializeCliAuthBundle } from "../cli-auth-bundle-bRJOyaJO.js";
2
2
  //#region src/auth/tokens.ts
3
3
  const textEncoder = new TextEncoder();
4
4
  const textDecoder = new TextDecoder();
@@ -1,4 +1,4 @@
1
- import { t as awaitWithAbort } from "./abort-signal-si1WMfJb.js";
1
+ import { t as awaitWithAbort } from "./abort-signal-CgFhjY_v.js";
2
2
  import { z } from "zod";
3
3
  import { AgentInteractiveSessionControlClaimAcknowledgementSchema, AgentInteractiveSessionControlClaimRequestSchema, AgentInteractiveSessionControlClaimSchema, AgentInteractiveSessionRefSchema, AgentInteractiveSessionStatusSchema, agentInteractiveSessionControlClaimAcknowledgementMatchesRequest, agentInteractiveSessionControlClaimMatchesRef, agentInteractiveSessionControlClaimRequestDigest } from "@tangle-network/agent-interface/environment-interactive-control";
4
4
  //#region ../../../packages/runtime-contracts/dist/interactive-session-control-http.js
@@ -1,4 +1,4 @@
1
- import { r as TerminalStreamHandlers } from "./terminal-stream-CcaBTVg3.js";
1
+ import { r as TerminalStreamHandlers } from "./terminal-stream-BW4veIsI.js";
2
2
  import { AgentInteractiveSessionAttach, AgentInteractiveSessionControlClaimAcknowledgement, AgentInteractiveSessionStatus } from "@tangle-network/agent-interface";
3
3
  import { AgentInteractiveSessionControlClaim as AgentInteractiveSessionControlClaim$1, AgentInteractiveSessionControlClaimRequest as AgentInteractiveSessionControlClaimRequest$1, AgentInteractiveSessionRef as AgentInteractiveSessionRef$1 } from "@tangle-network/agent-interface/environment-interactive-control";
4
4
 
@@ -1,7 +1,7 @@
1
- import { R as LinesClient, l as TraceExportResult, n as HttpClient, r as SandboxInstance, u as TraceExportSink } from "./sandbox-C7KqjY6Y.js";
2
- import { l as ScopedToken, s as MintInteractiveSessionTokenOptions } from "./terminal-stream-CcaBTVg3.js";
3
- import { $n as PublicTemplateVersionInfo, Ar as SandboxFleetArtifactSpec, B as CreateSandboxOptions, Br as SandboxFleetMachineRecord, Bt as FleetDriveTurnOutcome, Dr as SandboxFleetAgent, F as CreateIntelligenceReportOptions, G as DeleteMatchingSandboxesFilter, Gn as PromptInputPart, Gr as SandboxFleetParent, Gt as FleetPromptDispatchOptions, Hr as SandboxFleetManifest, Ht as FleetExecDispatchOptions, I as CreateRequestOptions, Ir as SandboxFleetInfo, It as FleetDispatchCancelResult, Jt as FleetRunOptions, K as DeleteMatchingSandboxesOptions, Kn as PromptOptions, Kt as FleetPromptDispatchResult, L as CreateSandboxFleetOptions, Lt as FleetDispatchResultBuffer, M as ConversationTurnOptions, Mt as FleetAgentId, N as ConversationTurnResult, Na as BatchEvent, Nr as SandboxFleetDispatchResponse, Pi as SecretsManager, Pr as SandboxFleetDriverCapability, Pt as FleetAgentResult, Qn as PublicTemplateInfo, R as CreateSandboxFleetTokenOptions, Rt as FleetDispatchResultBufferOptions, Ta as UsageInfo, Tn as ListSandboxOptions, Tr as SandboxEnvironment, Ut as FleetExecDispatchResult, Vr as SandboxFleetMachineSpec, Vt as FleetDriveTurnRequest, Wr as SandboxFleetOperationsSummary, Wt as FleetMachineId, Xr as SandboxFleetToken, Yr as SandboxFleetSpend, Zr as SandboxFleetTraceBundle, _n as IntelligenceReportBudget, _t as ExecOptions, ai as SandboxFleetWorkspaceSnapshotResult, ar as ReconcileSandboxFleetsResult, b as BatchRunRequest, bn as IntelligenceReportWindow, ca as SubscriptionInfo, d as BackendConfig, ei as SandboxFleetTraceOptions, er as PublishPublicTemplateOptions, gn as IntelligenceReport, ia as SshKeysManager, ii as SandboxFleetWorkspaceRestoreResult, ir as ReconcileSandboxFleetsOptions, jr as SandboxFleetCostEstimate, kr as SandboxFleetArtifact, l as AttachSandboxFleetMachineOptions, nr as ReapExpiredSandboxFleetsOptions, oi as SandboxIdentity, q as DeleteMatchingSandboxesResult, qn as PromptResult, qr as SandboxFleetPolicy, qt as FleetRunEvent, ri as SandboxFleetWorkspaceReconcileResult, rr as ReapExpiredSandboxFleetsResult, si as SandboxInfo, ti as SandboxFleetUsage, tr as PublishPublicTemplateVersionOptions, v as BatchResult, vi as SandboxShapesInfo, vn as IntelligenceReportCompareTo, vr as SandboxConfig, vt as ExecResult, wn as ListSandboxFleetOptions, y as BatchRunOptions, ya as TokenRefreshHandler, z as CreateSandboxFleetWithCoordinatorOptions, zt as FleetDispatchStreamOptions } from "./types-UOIM3RS6.js";
4
- import { f as SandboxError } from "./errors-Cz23YNu2.js";
1
+ import { W as LinesClient, l as TraceExportResult, n as HttpClient, r as SandboxInstance, u as TraceExportSink } from "./sandbox-BMSWYvdP.js";
2
+ import { l as ScopedToken, s as MintInteractiveSessionTokenOptions } from "./terminal-stream-BW4veIsI.js";
3
+ import { $n as PublicTemplateVersionInfo, Ar as SandboxFleetArtifactSpec, B as CreateSandboxOptions, Br as SandboxFleetMachineRecord, Bt as FleetDriveTurnOutcome, Dr as SandboxFleetAgent, F as CreateIntelligenceReportOptions, G as DeleteMatchingSandboxesFilter, Gn as PromptInputPart, Gr as SandboxFleetParent, Gt as FleetPromptDispatchOptions, Hr as SandboxFleetManifest, Ht as FleetExecDispatchOptions, I as CreateRequestOptions, Ir as SandboxFleetInfo, It as FleetDispatchCancelResult, Jt as FleetRunOptions, K as DeleteMatchingSandboxesOptions, Kn as PromptOptions, Kt as FleetPromptDispatchResult, L as CreateSandboxFleetOptions, Lt as FleetDispatchResultBuffer, M as ConversationTurnOptions, Mt as FleetAgentId, N as ConversationTurnResult, Na as BatchEvent, Nr as SandboxFleetDispatchResponse, Pi as SecretsManager, Pr as SandboxFleetDriverCapability, Pt as FleetAgentResult, Qn as PublicTemplateInfo, R as CreateSandboxFleetTokenOptions, Rt as FleetDispatchResultBufferOptions, Ta as UsageInfo, Tn as ListSandboxOptions, Tr as SandboxEnvironment, Ut as FleetExecDispatchResult, Vr as SandboxFleetMachineSpec, Vt as FleetDriveTurnRequest, Wr as SandboxFleetOperationsSummary, Wt as FleetMachineId, Xr as SandboxFleetToken, Yr as SandboxFleetSpend, Zr as SandboxFleetTraceBundle, _n as IntelligenceReportBudget, _t as ExecOptions, ai as SandboxFleetWorkspaceSnapshotResult, ar as ReconcileSandboxFleetsResult, b as BatchRunRequest, bn as IntelligenceReportWindow, ca as SubscriptionInfo, d as BackendConfig, ei as SandboxFleetTraceOptions, er as PublishPublicTemplateOptions, gn as IntelligenceReport, ia as SshKeysManager, ii as SandboxFleetWorkspaceRestoreResult, ir as ReconcileSandboxFleetsOptions, jr as SandboxFleetCostEstimate, kr as SandboxFleetArtifact, l as AttachSandboxFleetMachineOptions, nr as ReapExpiredSandboxFleetsOptions, oi as SandboxIdentity, q as DeleteMatchingSandboxesResult, qn as PromptResult, qr as SandboxFleetPolicy, qt as FleetRunEvent, ri as SandboxFleetWorkspaceReconcileResult, rr as ReapExpiredSandboxFleetsResult, si as SandboxInfo, ti as SandboxFleetUsage, tr as PublishPublicTemplateVersionOptions, v as BatchResult, vi as SandboxShapesInfo, vn as IntelligenceReportCompareTo, vr as SandboxConfig, vt as ExecResult, wn as ListSandboxFleetOptions, y as BatchRunOptions, ya as TokenRefreshHandler, z as CreateSandboxFleetWithCoordinatorOptions, zt as FleetDispatchStreamOptions } from "./types-DRyvWIJf.js";
4
+ import { f as SandboxError } from "./errors-CNsmhCen.js";
5
5
  import { AgentInteractiveSessionRef } from "@tangle-network/agent-interface";
6
6
  import { z } from "zod";
7
7
 
@@ -575,6 +575,12 @@ declare class Sandbox implements HttpClient, ScopedTokenHttpClient {
575
575
  private _intelligence;
576
576
  private _lines;
577
577
  constructor(config: SandboxConfig);
578
+ /** Report evidence capture support before a sandbox is created. */
579
+ evidenceCapabilities(): Promise<{
580
+ workspaceCaptureV1: boolean;
581
+ nativeSessionCaptureV1: boolean;
582
+ sidecarImageDigest?: string;
583
+ }>;
578
584
  /**
579
585
  * Fleet operations for agent-managed groups of sandboxes.
580
586
  *